There are LCD displays (1602, 2004) that can be purchased with a small board that connects to the displays pins and allows for communication using I2C.
Looking through the online help, and searching this forum I couldn't find any examples of using these with GCB. Has anyone had any success with these modules? These would be great for low pin count pics using I2C only.
Any help or steering in the right direction would be greatly appreciated!!!!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Anobium, I have a couple of these, and would be happy to send to you. Can you get me your address and I will ship them today! Thanks for your help on this!!!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I wrote some code for a Midas COG display (from rapid electronics).
The main thing is you have to look at the datasheet as displays will have different codes to go into command and data modes and they should all have different id codes (so you can have more than one device on the same pins). You also need pull-ups on the clock and data pins (10k).
~~~~~~~~~
chip 12F683,1
config OSC=INTosc, MCLRE=Off, WDT=on, boren=off
'I2C settings
define I2C_MODE Master
define I2C_DATA GPIO.2
define I2C_CLOCK GPIO.1
wait 200 ms
SL=0x7C 'DISPLAY ID
COMSEND=0x00 'display COMMAND send
DS=0X40 'display DATA send
Can let me know the part number of the display. Midas will send me a part but I need to know the part number - this looks like a cool addition to the LCD driver set.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have the same display and want to get it running on an Arduino. Wasted a lot of time and no luck. I took the sample code, changed the config. Had CLK DATA GND and VCC. Nothing
So I would like to see what Anobium comes up with too.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
@lhatch. Should not be to hard. If you have one and are willing to send to me I can integrate in the existing LCD routines. I will also contact the UK supplier and see if they will let me have a sample. If you send me a personal message then we can exchange details etc.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I see no reason that the SainSmart display will not work with the current GCB/LCD.H driver. The I2C adapter uses the PCF8574 I/O expander which is supported by LCD.H.The LCD module seems to be a generic parallel type.
SainSmart publishes the I2C Address as 0x3F. This is the 7-bit address. The 8-bit address will therefore be 0x7E. This is the address to use in GCB. This address is only possible with the PCF8574A. Look at the chip on the expander board is it a PCF8574T or PCF8574AT? Only the AT Version should support an address of 0x7E. However, if the chip is a knockoff or counterfeit of a real NXP PCF8574AT, then the marking may not matter.
One thing about these White-on-Blue displays is that the back light must be on and the contrast must be correctly adjusted before you can see any characters. Since SainSmart does not seem to believe in datasheets there is no way to tell if the transistor that drives the back light is an NPN or PNP except by visual inspection or testing. This means you may have to reverse the back light ON/OFF bits.
When asking for help it is generally a good idea to post your non-working code, so that others might be better able to help.
I have a similar display but with a different address. It works fine on an UNO R3 with GCB. Here is some working test code but with a different address. Change the address to 0x7E for the SainSmart.
#chip mega328p, 16
#config mclr_on
HI2CMode Master
#define HI2C_DATA
#define LCD_IO 10
#define LCD_I2C_Address 0x4E '// Change to 0xFE for SainSmart
#define LCD_Backlight_On_State 1 '// These may need to be reversed
#define LCD_Backlight_Off_State 0
do
CLS
wait 1 s
Locate 0,0
PRINT "Great Cow Basic .94"
Locate 1,0
Print "Arduino UNO ": Print chipnamestr
Locate 2,0
PRINT "I2C LCD Driver"
wait 1 s
loop
Last edit: William Roth 2015-05-22
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I assume the other fellow did not send one. Might be easier if I send a link to the actual part and paypal (if you have paypal) the cash and you pick one up other there. The International shipping might cost more than the part lol.
How do I PM here, I clicked your name but did not see a PM button.
Thanks again.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
No I have the same one sainsmart is, and figured is should work. But I just ran William's program and it works fine. So all is good. To simple to be wiring, so I must have missed something when I ran the sample code.
Thanks again guys. And speacial thanks to William, I am off and running. I have a starting point now. I think I can change a mode number at get the display without the 1C2/twi module (I loose more I/O pins though) and it will work as well. Is that correct?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
#chip 16f88,8 'mega328p, 16
#define I2C_DATA PORTB.1 'SDA
#define I2C_CLOCK PORTB.4 'SCL
and <wink> LCD_10 twice in comments to LCD_IO
Beforehand i2csoftwarediscovery_to_terminal_16f88.gcb (attached) derived from i2csoftwarediscovery_to_terminal_16f1938.gcb was used to discover the 1602 LCD I2C address. Happily the address found was already setup for LCD_I2C_Address_1.
There are LCD displays (1602, 2004) that can be purchased with a small board that connects to the displays pins and allows for communication using I2C.
http://www.sainsmart.com/sainsmart-iic-i2c-twi-serial-2004-20x4-lcd-module-shield-for-arduino-uno-mega-r3.html
Looking through the online help, and searching this forum I couldn't find any examples of using these with GCB. Has anyone had any success with these modules? These would be great for low pin count pics using I2C only.
Any help or steering in the right direction would be greatly appreciated!!!!
I have seen a few questions on this but no code.
A few thoughts.
Some thoughts.
Hi Anobium, I have a couple of these, and would be happy to send to you. Can you get me your address and I will ship them today! Thanks for your help on this!!!
I wrote some code for a Midas COG display (from rapid electronics).
The main thing is you have to look at the datasheet as displays will have different codes to go into command and data modes and they should all have different id codes (so you can have more than one device on the same pins). You also need pull-ups on the clock and data pins (10k).
~~~~~~~~~
chip 12F683,1
config OSC=INTosc, MCLRE=Off, WDT=on, boren=off
'I2C settings
define I2C_MODE Master
define I2C_DATA GPIO.2
define I2C_CLOCK GPIO.1
wait 200 ms
SL=0x7C 'DISPLAY ID
COMSEND=0x00 'display COMMAND send
DS=0X40 'display DATA send
'LCD INITIALIZATION
I2CStart
I2CSEND(Sl)
I2CSEND(Comsend)
I2CSEND(0x34) 'initialize 16x2
'i2csend(0x38) '16x1
I2CSEND(COMSEND)
I2CSEND(0x35)
'i2csend(0x39)
I2CSEND(0x14) 'osc
I2CSEND(0x74) 'contrast
I2CSEND(0x54) 'pwr
I2CSEND(0x6F) 'follower
'WAIT 30 US
I2CSEND(0x0C) 'on/off
I2CSEND(0x01) 'clear
I2Cstop
'initialization end
do
z1=1:z2=2:z3=3:z4=4:z5=5:z6=6
'send some output to lcd
I2CStart
I2CSEND(Sl) 'device id
I2CSEND(Comsend) 'command mode
i2csend(0x01) 'clear screen
i2cstop
I2CStart
I2Csend(Sl) 'device id
I2Csend(DS) 'data mode
i2csend(32)
i2csend(80)
i2csend(97)
i2cstop
sleep
sleep
loop
~~~~~~~~~~~~~~
Can let me know the part number of the display. Midas will send me a part but I need to know the part number - this looks like a cool addition to the LCD driver set.
I have the same display and want to get it running on an Arduino. Wasted a lot of time and no luck. I took the sample code, changed the config. Had CLK DATA GND and VCC. Nothing
So I would like to see what Anobium comes up with too.
@lhatch. Should not be to hard. If you have one and are willing to send to me I can integrate in the existing LCD routines. I will also contact the UK supplier and see if they will let me have a sample. If you send me a personal message then we can exchange details etc.
I see no reason that the SainSmart display will not work with the current GCB/LCD.H driver. The I2C adapter uses the PCF8574 I/O expander which is supported by LCD.H.The LCD module seems to be a generic parallel type.
SainSmart publishes the I2C Address as 0x3F. This is the 7-bit address. The 8-bit address will therefore be 0x7E. This is the address to use in GCB. This address is only possible with the PCF8574A. Look at the chip on the expander board is it a PCF8574T or PCF8574AT? Only the AT Version should support an address of 0x7E. However, if the chip is a knockoff or counterfeit of a real NXP PCF8574AT, then the marking may not matter.
One thing about these White-on-Blue displays is that the back light must be on and the contrast must be correctly adjusted before you can see any characters. Since SainSmart does not seem to believe in datasheets there is no way to tell if the transistor that drives the back light is an NPN or PNP except by visual inspection or testing. This means you may have to reverse the back light ON/OFF bits.
When asking for help it is generally a good idea to post your non-working code, so that others might be better able to help.
I have a similar display but with a different address. It works fine on an UNO R3 with GCB. Here is some working test code but with a different address. Change the address to 0x7E for the SainSmart.
Last edit: William Roth 2015-05-22
Hey Evan,
I assume the other fellow did not send one. Might be easier if I send a link to the actual part and paypal (if you have paypal) the cash and you pick one up other there. The International shipping might cost more than the part lol.
How do I PM here, I clicked your name but did not see a PM button.
Thanks again.
I did get the i2c lcd for http://www.sainsmart.com/sainsmart-iic-i2c-twi-serial-2004-20x4-lcd-module-shield-for-arduino-uno-mega-r3.html
I thought you were referring to the Midas COG display. y/n?
:-)
No I have the same one sainsmart is, and figured is should work. But I just ran William's program and it works fine. So all is good. To simple to be wiring, so I must have missed something when I ran the sample code.
Thanks again guys. And speacial thanks to William, I am off and running. I have a starting point now. I think I can change a mode number at get the display without the 1C2/twi module (I loose more I/O pins though) and it will work as well. Is that correct?
Have a look at the demos. You can address up to four devices on one bus.
See https://sourceforge.net/projects/gcbasic/files/Demonstration%20Files/LCD%20%20Solutions/I2C%20Solutions/Multiple_Devices_Setup_IC2_adapter_Test_HardwareI2C_mega328p.gcb
Sadly "The "/Demonstration Files..wareI2C_mega328p.gcb" file could not be found or is not available. Please select another file" :-(
Very old thread, very old URL. The file will be in your locally installed demos.
or, in the GitHub rep @ https://github.com/GreatCowBASIC/Demonstration_Sources/tree/main/LCD_Solutions/I2C_Solutions There are lot more there - a lot more.
https://github.com/GreatCowBASIC/Demonstration_Sources/blob/main/LCD_Solutions/I2C_Solutions/Multiple_Devices_Setup_IC2_adapter_Test_HardwareI2C_mega328p.gcb
https://github.com/GreatCowBASIC/Demonstration_Sources/blob/main/LCD_Solutions/I2C_Solutions/Multiple_Devices_Setup_IC2_adapter_Test_SoftwareI2C_mega328p.gcb
Last edit: Anobium 2022-06-06
Magic, thank you Anobium. https://github.com/GreatCowBASIC/Demonstration_Sources/blob/main/LCD_Solutions/I2C_Solutions/Multiple_Devices_Setup_IC2_adapter_Test_SoftwareI2C_mega328p.gcb works with minor changes despite being 'very old'!
Setup was a 'very new' LCD 1602 Display, with PCF8574/PCF8574A I2C converter factory-attached, driven from a PIC16F88
The following were changed:
Beforehand i2csoftwarediscovery_to_terminal_16f88.gcb (attached) derived from i2csoftwarediscovery_to_terminal_16f1938.gcb was used to discover the 1602 LCD I2C address. Happily the address found was already setup for LCD_I2C_Address_1.
Good to hear of success.
Evan