Batron I2C display

Thread Starter

geoffers

Joined Oct 25, 2010
487
Hi all,
Have a problem thats vexing me a bit, I've got a Batron I2C display I'm having trouble getting to work. Has anyone else used one of these ? I've been through the data sheet and the sheet for the driver chip it uses. I'm not having much joy. It could be somthing as basic as me having the pinout the wrong way round? The data sheet isn't clear if its top elevation or bottom:p. The segments dont go dark when its powerd up? Could that be a sign I have it wrong way round? If I havn't I dont want to swap it and cook it!
Any advise welcome, thanks Geoff
 

ErnieM

Joined Apr 24, 2011
8,377
Exactly what is a Batron I2C display? Do you have a link to the data sheet?

Do you have a schematic of your system? Have you ever used I2C before?

How do you make VLCD (if your part uses such)?
 

Thread Starter

geoffers

Joined Oct 25, 2010
487
Hi Ernie,
Thanks for the reply, The display is a 16x2 alphanumeric with a I2C interface, I got it from RS http://uk.rs-online.com/web/p/lcd-monochrome-displays/7436134/, I've attached the data sheet but I know folks are cautious about opening random pdfs! The other imformation needed is the data sheet for the driver chip www.nxp.com/documents/data_sheet/PCF2119X.pdf . I've used I2C before and have a 24lc512 eeprom and a mcp(cant remeber the numbers!) real time clock chip on the bus which I'm trying to get the display to work with.

The logic for the LCD runs at 3.3v and VLCD is 5V, my exsiting board is running 5v so I've put a 3,3v ldo regulator on some vero board along with some decoupling capacitors, I have 3.3v and 5v in the right place if the pin out is as I think?

I've followed the routine on page 65 of the philips data sheet, even when I power it up you cant see any sign of the display doing anything? I would have thought if it was connected up the wrong way round VLCD and Vlogic would be attached to the I2c bus and stop it working but my clock keeps going! All other displays I've used at least do somthing when they are powered up, I wonder if its dodgey!

I've ordered another one to see if thats any good? I've also checked all my connections, as I just added it to the bus it was only the two bus lines and a power on reset to my pic I thought it should be straight forward!
Thanks for looking, Geoff
Thanks for looking
 

Attachments

Thread Starter

geoffers

Joined Oct 25, 2010
487
Hi all,
Thanks for the replies, I think I may have identified my problem?! In the batron data sheet, the scl clock frequency only has a maximum of 400khz quoted, no minimum or typical value? I'm assuming this means it MUST run a clock frequency of 400khz? At the moment my I2C is running at 100kHZ and my xtall is 4mhz, if I want to run the I2C at 400khz I'm going to need to run my 18f2523 at 16Mhz, is the internal osc running a 4Mhz with a 4x PLL to get the internal clock up to 16Mhz accurate enough for the I2C bus or am I going to need a 16Mhz crystall?
Cheers Geoff
 

ErnieM

Joined Apr 24, 2011
8,377
In fact, running I2C at 400KHz can be a problem all on it's own: the slower you clock the I2C the easier it is to use. 400KHz is the max, you probably want to run slower.

As I read Fig 1&2 of the Baltron spec the pins run 1 to 6 left to right looking down at the display. With 3.3V power the I2C resistors should also go to 3.3V but the spec allows connections to 5.0V. There is a note in the Baltron spec that VLCD may need to be adjusted anywhere between 5.0 and 5.6V, and that is the production spread so any given unit may need a voltage in that range.

LCD displays are notorious for doing absolutely nothing until they are properly set up and written to, but at least you shouldn't have a set-up to contend with.

The first thing to check with I2C is if your device is acknowledging (ACK) it's given address. This is given by the slave in response to the master's 9th clock pulse. Look on a scope, or pause the clock there and use a DVM: if the data line is not pulled low then the display is not being addressed and isn't listening to any of the data you are sending.
 

Thread Starter

geoffers

Joined Oct 25, 2010
487
Hi all,
Thanks for the response! I've only got a cheap vellman scope but can see the data line being pulled low, I wrote a loop that keeps addressing the the display, I cant see much detail but think thats the displays response to the master? I guess this means the logics working so I must have somthing wrong in what I'm telling it? I've put the new display on and thats no different! At least I know I've got either two good displays (or not),
here is my code;
CALL BSTART ;GENERATE START CONDITION

MOVLW LCD ;SLAVE ADDRESS OF DISPLAY
MOVWF datao
CALL TX_BYTE

MOVLW 0X00 ;CONTROL BYTE FUNCTION SET
MOVWF datao
CALL TX_BYTE

MOVLW B'00100101' ;FUNCTION SET 2X16 DISPLAY
MOVWF datao
CALL TX_BYTE

MOVLW B'00001110' ;DISPLAY CONTROL SET
MOVWF datao
CALL TX_BYTE

MOVLW B'00000110' ;ENTRY MODE INC CURSOR
MOVWF datao
CALL TX_BYTE

CALL BSTART ;START CON
MOVLW LCD
MOVWF datao
CALL TX_BYTE

MOVLW B'01000000' ;CONTROL BYTE WRITE DATA
MOVWF datao
CALL TX_BYTE

MOVLW 0X48
MOVWF datao
CALL TX_BYTE

MOVLW 0X49
MOVWF datao
CALL TX_BYTE

CALL BSTOP

This is following the philips data sheet apart from using a 2x16 display.
Cheers Geoff
 

ErnieM

Joined Apr 24, 2011
8,377
Hi all,
Thanks for the response! I've only got a cheap vellman scope but can see the data line being pulled low, I wrote a loop that keeps addressing the the display, I cant see much detail but think thats the displays response to the master? I guess this means the logics working so I must have somthing wrong in what I'm telling it? I've put the new display on and thats no different! At least I know I've got either two good displays (or not),
Are you sure there is an ACK back from the Batron? Slow things down until your scope can show you things clearly and see SDA is low for the 9th clock for the initial address.

Your code looks fine, excepting the data for the 4th element FUNCTION SET does not match the data sheet. I read it as:
00100001 and you have
00100101
 

Thread Starter

geoffers

Joined Oct 25, 2010
487
Hi Ernie,
Thanks for the advise, I think what I thought as the display holding sda low is acctualy the PIC creating a start condition? Will keep poking it and see what happens?
Cheers Geoff
 

Thread Starter

geoffers

Joined Oct 25, 2010
487
Hi All,

I've finaly got it talking, after yet another google search for 'batron problems lcd i2c' I eventualy found a few words on one page which reads 'On a side note the batron display can have two i2c addresses, one which is in the data sheet and one that appears no where!' The magic address is =01110110 for a write, and 01110111 for a read. Thanks to Ernie and Mr Chips for looking at this, I will post full code for this when I've got it properly sorted.
Cheers Geoff:)
 

ErnieM

Joined Apr 24, 2011
8,377
Hi All,

I've finaly got it talking, after yet another google search for 'batron problems lcd i2c' I eventualy found a few words on one page which reads 'On a side note the batron display can have two i2c addresses, one which is in the data sheet and one that appears no where!' The magic address is =01110110 for a write, and 01110111 for a read. Thanks to Ernie and Mr Chips for looking at this, I will post full code for this when I've got it properly sorted.
Cheers Geoff:)
If you look at these two numbers:
01110110
01110111

You will note they only differ in the last digit. This is due to I2C only using a 7 bit address, and the last bit is for read (1) or write (0). The Phillips spec actually does say this (look at Fig 33 for example). It's just a basic part of the I2C method, which as you see in practice can be really tricky to get correct.

The "SA0" they refer to is a pin brought out on the Phillips chip in case you wish to use two of these devices in your system: it lets you give them each a different address. I don't see how the Baltron handles this but it must be pulling it high for that address to work.

Congratulations on getting this to work!
 

Thread Starter

geoffers

Joined Oct 25, 2010
487
Hi Ernie,
Thanks for that, I've done a tiny bit with I2C before, it was bit 1 that threw me! The Batron data sheet is pretty poor, you would have thought they would have put the I2C address on it?! I reckon several have gone in the bin because of that! For some reason they use a funny Character set too, not the 'standard' one. Which also means if you want to clear the display you have to write blank characters to all the DDRAM addresses, what fun!
Thanks again Geoff
 

ErnieM

Joined Apr 24, 2011
8,377
My only complaint with the character set is the omission of a forward slash \, which is something I like to use in a "I'm still alive" animation in a single cell. When I do that I have to load that as a custom character. Grrr...

To clear the entire screen try sending the command 0b00000001.
 

Thread Starter

geoffers

Joined Oct 25, 2010
487
Hi Ernie,
The Batron display uses character set 'R' so if you use the B'00000001' comand you end up with a screen full of little arrows!:eek: Might be helpfull for anyone else using the display? This is how I did it;

CLEARSCRN CALL BSTART ;START CONDITION ON BUS

MOVLW LCD ;WAKE UP LCD
MOVWF datao
CALL TX_BYTE

MOVLW 0X00 ;CONTROL BYTE FOR INSTRUCTIONS
MOVWF datao
CALL TX_BYTE

MOVLW 0X02 ;RETURN CURSOR, SETS DRAM 0
MOVWF datao
CALL TX_BYTE

MOVLW B'00001000' ;TURN DISPLAY OFF
MOVWF datao
CALL TX_BYTE

CALL BSTART

MOVLW LCD
MOVWF datao
CALL TX_BYTE

MOVLW B'01000000' ;CONTROL BYTE WRITE DATA
MOVWF datao
CALL TX_BYTE

MOVLW 0X50
MOVWF COUNT

CLEAR1 MOVLW B'10100000' ;BLANK CHARACTER
MOVWF datao
CALL TX_BYTE

DECFSZ COUNT ;WRITE TO ALL 16X2 SCREEN
GOTO CLEAR1

CALL BSTART
MOVLW LCD
MOVWF datao
CALL TX_BYTE

MOVLW 0X00 ;CONTROL BYTE FOR INSTRUCTION
MOVWF datao
CALL TX_BYTE

MOVLW B'00001100'
MOVWF datao
CALL TX_BYTE

MOVLW 0X02
MOVWF datao
CALL TX_BYTE

CALL BSTOP
RETLW 0

There might be a better way but this works! Just one more question (for now anyway!). Now I have my bus running and working is there any reason not to speed it up? I see from the data sheet with 4Mhz clock I can run the I2C bus at up to 333kHz, are there any problems I might run into or is it a case of if it works now it always will?
Cheers Geoff
 

ErnieM

Joined Apr 24, 2011
8,377
The speed you can actually run the I2C is pretty much dependent on how good your layout is. Usually you can run it up to the max, once I had an 11-board system (1 master 10 slaves) daisy chained together. So it was over several PCBs, not just one. It worked poorly at 400KHz but just fine at 100KHz, so I just used the slower frequency. No one ever noticed any delay as it was just grabbing several bytes from each slave.

I don't know why the clear screen works so weird, but I've never used the Phillips chip.
 

Thread Starter

geoffers

Joined Oct 25, 2010
487
It is a bit weird, never mind even at 100kHz its still faster than a 4 bit display.

I knew there would be another question! How long a distance will the I2C bus work over? I guess it very much depends on the speed its run at?

Thanks again Geoff
 

ErnieM

Joined Apr 24, 2011
8,377
I2C stands for Inter Integrated Circuit and was always intended to just run a few inches on one board. I think it's first use was inside TV receivers.

All you have to drive the line is the pull-up resistor, so a lower resistor will help drive a longer line, which is going to have more stray capacitance to drive.

According to Wikipedia "The maximum number of nodes is limited by the address space, and also by the total bus capacitance of 400 pF, which restricts practical communication distances to a few meters."
 
Top