Funduino I2C LCD Display

hamtech

Member
I have bought a Funduino 16x2 I2C LCD display thinking it would work with a PicAxe 20X2. The limited info that comes with it suggests that the I2C address is 0x27.


In trying a simple "Hello World" program using the address 0x27 I do not get anything on the LCD. The LCD is powered and I have a line of blocks which tells me the LCD is not fully initialised. The simple code is pasted below. Can anyone offer some guidance, surely I should be able to use this !!!


Is there any way to do a sweep of I2C addresses in case the supplied info is wrong. Thanks in anticipation

Code:
init: Pause 500; wait for initialisation

hi2csetup i2cmaster, 0x27, i2cslow, i2cbyte
pause 500

hi2cout 0,(254,1,255)  ' clear display

Pause 50
hi2cout 0,(254,14,255)   ' cursor on

pause  50

main: writei2c 0,(254,128,255)   ;  move cursor to start of first line

pause 10

writei2c 0, ("Hello World",255)   ; output text

end
 

inglewoodpete

Senior Member
The PICAXE adopts the addressing used by the i2c standard where some other systems modify the address. The address byte in i2c has the slave address in the upper 7 bits, bit 0 is the read/write flag. The read/write flag is under the control of the PICAXE chip, so it can be ignored in your code. That means the apparent address of the slave must be shifted left by one bit.

For the address 0x27 (%00100111), shift it left by one bit: %01001110 or 0x4E. Bit 0 is usually left as a zero.

Also, rather than use writei2c, try using hi2cout as suggested in the manual.
 

hamtech

Member
Hi InglewoodPete,

Thanks for the reply. No joy I am afraid, the display did flicker but that was it. I have changed my commands to Hi2cout as suggested, the code was written some time ago to test i2c devices but that was a rev ed supplied device. Unlike this one which is not.

However I guess it is possible I have the wrong address still.

I tried putting in a for next loop and counting from 1 - 255 in the hope that I would hit the correct address but no good. I have changed 20x2 for an another one again no joy.


Is it possible to sweep I2C addresses and look for a response. I was expecting that I would see Hello World for one i2c address and at least prove all was working even if wrongly addressed.

The 20x2 runs my temp and humidity program taken from the forum ok but that does not use I2C. ( sertxd output). Any other thoughts??
 

techElder

Well-known member
For the address 0x27 (%00100111), shift it left by one bit: %01001110 or 0x4E. Bit 0 is usually left as a zero.

Perhaps use "%00100110" ??? (That is 0x27 with the LSB changed to zero.)

Also, don't forget to wait after initialization codes are sent. The display may take some time to get initialized.
 

hippy

Technical Support
Staff member
hi2cout 0,(254,1,255) ' clear display
That and similar HI2COUT commands will send four bytes out to the display after the device address; $00, $FE, $01, $FF.

Is that what the LCD is expecting ?

A link to the LCD's datasheet would probably help answer that.
 

hamtech

Member
Hi Rick,


Again I am in your debt..... Your code drives my Funduino LCD and also another one I bought ex China. Hooray!

Now I know my board actually works ...


The project I am building is a clock which has a DS1307 and has also got a temperature and humidity sensor. I have some programs that work from the forum but output serial mode data. What I want to do is use I2c for all comms from PICAXE 20X2 to the DS1307 and the I2C LCD.

Your code has perplexed me a little as I am not clear how it works. I will have a read through it and see what you have done..


Edited to add ic2 interface does use an 8574 expander.... As it works with your code rick I assume wired as you suggest.

But basically is there a simple routine that I can write variable values to the LCD screen from my programs, time and Temp/Humidity???
 
Last edited:

Rick100

Senior Member
But basically is there a simple routine that I can write variable values to the LCD screen from my programs, time and Temp/Humidity???
Glad to hear you got your display working. Unfortunately these displays are not as simple as the serial driven ones. You are basically driving the display in 4 bit parallel mode with the added complexity of driving the I2C expander chip.

The InitLcd is used to initialize the display.The SendCmdByte subroutine is used to send command bytes to do things like clear the screen or position the cursor. The SendDataByte subroutine puts characters on the screen. The code between main: and end are examples of printing a string and variables. You have to convert your variables to a series of ASCII characters and use SendDataByte to print each character. The program uses the Picaxe bintoascii command to do the conversion. To use this display you will probably want to look at the Hitachi HD44780 commands.
https://en.wikipedia.org/wiki/Hitachi_HD44780_LCD_controller
Also remember the execution times on the commands are very important. Especially the clear display and home cursor commands.

Good luck,
Rick
 

hamtech

Member
Glad to hear you got your display working. Unfortunately these displays are not as simple as the serial driven ones. You are basically driving the display in 4 bit parallel mode with the added complexity of driving the I2C expander chip.

The InitLcd is used to initialize the display.The SendCmdByte subroutine is used to send command bytes to do things like clear the screen or position the cursor. The SendDataByte subroutine puts characters on the screen. The code between main: and end are examples of printing a string and variables. You have to convert your variables to a series of ASCII characters and use SendDataByte to print each character. The program uses the Picaxe bintoascii command to do the conversion. To use this display you will probably want to look at the Hitachi HD44780 commands.
https://en.wikipedia.org/wiki/Hitachi_HD44780_LCD_controller
Also remember the execution times on the commands are very important. Especially the clear display and home cursor commands.

Good luck,
Rick


Rick many thanks.
I will have a go at using your code with my program. If i had realised that this lcd i2c was different to the rev ed version, i probably would not have bought them! Of course i will have a go with them as i have paid the cash, but the lesson is that Arduino hardware may well differ from picaxe hardware.



thanks again!
 
Top