I2c GLCD help

Captain Haddock

Senior Member
Can anyone tell me how to operate one of these glcd's with a picaxe please.
GLCD-FLEXEL.pdf
It gives some ardweeny info but not sure of the i2c setup from picaxe, I can see the default address is 70 ($46) and I'm guessing at i2cslow and i2cbyte but can't get it to show anything (I'm assuming it will default to regular text till given other commands), once I can communicate with it I can work the rest out.
 

Captain Haddock

Senior Member
Doesn't seem to make any difference, can't get anything to display at all, backlight comes on ok.
This is the test code I'm trying.
Code:
#Picaxe 40X2
#no_data

init: pause 500 ‘ wait for display to initialise

hi2csetup i2cmaster,$46,i2cslow,i2cbyte; set up i2c master for LCD

main:
 
pause 10 
hi2cout ("hello")


goto main
 

nick12ab

Senior Member
The datasheet does say that it shows regular text unless it is given a command by sending 254 (like on AXE033)

If you use hi2cout ($FE,$34,$00), does the backlight turn off?
 

Captain Haddock

Senior Member
Just found another datasheet for an 12c/serial lcd controller they do and it seems they do give the 7 bit address so new using $8c, still no go, also have ds1307 and eeprom on i2c line, they are fine, have tried with them disconnected with no difference.:(
 

Captain Haddock

Senior Member
The datasheet does say that it shows regular text unless it is given a command by sending 254 (like on AXE033)

If you use hi2cout ($FE,$34,$00), does the backlight turn off?
No, backlight stays on so I would guess it's a communication issue.
The pullup resistors are in place, RTC and eeprom still work ok.
 

nick12ab

Senior Member
No, backlight stays on so I would guess it's a communication issue.
The pullup resistors are in place, RTC and eeprom still work ok.
The datasheet says that the pull-up resistors are built into the module. Try removing your additional ones.

Don't forget to try both slave addresses.
 

Captain Haddock

Senior Member
I disconnected the other i2c devices completely as resistors are on rtc end of wires, no joy with either address.
I'm sure this is something stupid I'm doing but don't know what.
 

westaust55

Moderator
The datasheet indicates the initialisation time is approx 0.5 seconds.

Try using PAUSE 1000

You may also need to send commands to:
1. Clear the screen,
2. set the x,y position
3. set the colour (otherwise text may be same as background)

or alternatively send the Init Graph command.
see command summary on page 5 of datasheet.

From section 3.1
issues the Init Graph command by sending two bytes 0xFE 0x02. This command makes the LCD hardware reset and
initialization, fills LCD screen with BLACK color, sets a cursor position to upper left corner
and sets the current color to WHITE.

Have you tired to read the firmware version?

command data 0xFE 0x30
then read back a byte with hi2cin (Module returns data byte with firmware version number.)

That would at least prove the i2c comms and slave address is right.

Keep in mind that this is a graphic LCD module, not a simple character based LCD module. You need to send a lot more command data to set up and put text where you want it to be displayed.
 

Captain Haddock

Senior Member
Tried the init graph and firmware to no avail, all I got back for firmware was 255 which I doubt is the real version number somehow, glcd is powered before picaxe is programed so would have though it would be ready to go.
 

westaust55

Moderator
Have you tried with the slave address as both $46 and $8C.


EDIT:
assuming the wiring to the gLCD is correct the $FF (255 dec) is usually an indication that there is no communication as if the slave address is wrong.

If neither slave address works then it is time to recheck the wiring.

EDIT2:
had a look at the ardweeny C code on the website for the gLCD and see:
char i2cAddress = 0x46; // LCD module I2C address

so I believe you should go with the $46 version
 
Last edited:

Captain Haddock

Senior Member
WooHoo!!:)
It works, thanks for all the help guys, it seems $8c is the address for this module, I have a feeling it needs position/colour setting every time, when I set the colour to red and sent a clear screen command the whole thing went red whereas I expected black.
This is working, I'm going to try it in one hi2cout command and see what I can get away with.
Code:
#Picaxe 40X2
#no_data

init: pause 600 ‘ wait for display to initialise

hi2csetup i2cmaster,$8c,i2cslow,i2cbyte; set up i2c master for LCD
;pause 200 
main:
 
;pause 200 
hi2cout ($fe,$02)'init graph
;pause 600
hi2cout ($fe,$08,$f8,$00)'set colour to red
;pause 600 
hi2cout ($fe,$13,$45,$07,$20)'draw a circle
;pause 500
hi2cout ($fe,$08,$ff,$ff,"Hello")'change to white and write text

pause 500
 

westaust55

Moderator
Good to read that you have got something happening.
You may find that the "pen" colour for text or line work is retained and does not need to be given for each new item unless you wish to change colour.
 

Captain Haddock

Senior Member
First dabble with one of these so lots to learn, thanks again for all assistance, at least now I have a starting point for trial and error learning.
 

Captain Haddock

Senior Member
Ok so I can get things displayed on the glcd but when I try to get data back (firmware version/cursor position) all I get is 141 in the variable returned, if 255 I would put it down to comms failiure but it's always 141, I have sent different cursor commands before interrogating but still the same figure comes back.
Any ideas? Is 141 significant?
 

nick12ab

Senior Member
Ok so I can get things displayed on the glcd but when I try to get data back (firmware version/cursor position) all I get is 141 in the variable returned, if 255 I would put it down to comms failiure but it's always 141, I have sent different cursor commands before interrogating but still the same figure comes back.
Any ideas? Is 141 significant?
What code are you using?
 

Captain Haddock

Senior Member
Code:
#Picaxe 40X2
#no_data
Symbol clr = $03;clear screen
Symbol init = $02;initialise screen
Symbol colour = $08;send 2 bytes
Symbol cursor = $04;send 2 bytes
Symbol cmd = 254;command mode
Symbol circle = $13;send 3 bytes
Symbol home = $05;cursor to 0,0 position
initglcd: 
pause 600 ; wait for display to initialise

hi2csetup i2cmaster,$8c,i2cslow,i2cword; set up i2c master for LCD
hi2cout (cmd,init)'init graph
pause 500
hi2cout (cmd,clr) 
hi2cout (cmd,$34,155) 
main:
 
;pause 200 


hi2cout (cmd,colour,$f8,$00)'set colour to red

hi2cout (cmd,circle,89,50,40)'draw a circle
;pause 500
hi2cout (cmd,colour,$ff,$ff,cmd,home,"Hello")'change to white and write text
pause 260
hi2cout (cmd,colour,$00,$1f)

hi2cout (cmd,colour,$00,$1f)
hi2cout (cmd,circle,89,50,35)
hi2cout (cmd,colour,$ff,$e0)
hi2cout (cmd,circle,89,50,30)
hi2cout (cmd,colour,$f8,$1f)
hi2cout (cmd,circle,89,50,25)
hi2cout (cmd,colour,$07,$e0)
hi2cout (cmd,circle,89,50,20)

hi2cout (cmd,$32)
;pause 10
hi2cin 0,(b0)
debug
pause 500


;goto main
 

Captain Haddock

Senior Member
This seems to work for keypad functions.
Code:
hi2cout ($fe)
hi2cin $32,(b0)
So should work for the other functions too, I guess the command parameter for reading data is just the register address.
 

westaust55

Moderator
If you are getting a consistent non $FF value it is likely correct

I have a look through the manual and other info I coul find about your module and unlike some other parts there is no reference to what constitutes a firmware number.
141 could just equate to V1.4.1 (all a guess in the absence of guidelines)
 

westaust55

Moderator
Try hi2cin $32,(b0). If hi2cin 0,(b0) is used, 0 is sent to the GLCD first then a byte is requested.
Captain Haddock was not putting a zero (0) as a location at the start of the i2c comms comemnds
If you look at the slightly blurry scope images in PICAXE manual 2 under the hi2cin and hi2cout commands, when no location is specificed then no byte is sent.
 

nick12ab

Senior Member
Captain Haddock was not putting a zero (0) as a location at the start of the i2c comms comemnds
If you look at the slightly blurry scope images in PICAXE manual 2 under the hi2cin and hi2cout commands, when no location is specificed then no byte is sent.
He did specify a zero address.
That is a technical nickpick.
Code:
hi2cout (cmd,$32)
;pause 10
[B]hi2cin 0,(b0)[/B]
debug
pause 500


;goto main
 

westaust55

Moderator
Ah yes, noted that Captain Haddock did have a location specified on one hi2c... command of many tucked in near the bottom of his listing on second look.

That acknowledged, deletion of the 0 for the location in the hi2cin command is sufficient.
While the sugegstion will work, there is no specific need to bring part of the command sequence from the hi2cout over to the hi2cin as a "location" parameter which might confuse folks as to the purpose.
As mentioned, the hi2cin command will work without a location parameter.
 
Last edited:

alhoop

Member
Very useful thread! My unit works with Captain Haddock's code. On my unit sda and scl are not pulled up to vdd(reads meg ohms).
They read 10k to ground. Address $46 and $8c work on my unit. Thanks Captain.
Al
 
Last edited:

westaust55

Moderator
Can anyone please share the GLCD-FLEXEL.pdf document and the C library of this board. I can't find it !+

Thank you.
As this forum is for the PICAXE microcontrollers which have an inbuilt BASIC interpreter (not "C" language) it is less likely that folks here with have the C library you seek available.
A quick search seems that the original web page linked to on this thread and on other forums has gone.

Forum member Captain Haddock still frequents the forum (last active: 07-10-2014 19:32 ) so he may see your post and respond.
 
Last edited:

MohamedAbid

New Member
As this forum is for the PICAXE microcontrollers which have an inbuilt BASIC interpreter (not "C" language) it is less likely that folks here with have the C library you seek available.
A quick search seems that the original web page linked to on this thread and on other forums has gone.

Forum member Captain Haddock still frequents the forum (last active: 07-10-2014 19:32 ) so he may see your post and respond.

Thank you very much, I am waiting for any help.
 
Top