Bookmaker
USA
Asked
— Edited
DJ, I am out of Digital Ports and I want to use a LCD Display. Can I use a 12C port and if so do I need to purchase a special interface and how would I input the text since the only control available under 12C is blinkin and nothing that I can see in Script? I await your input.
You sure can use the I2C ... The script command SendI2C will allow you to output to a I2C display.
There are problems i've found with I2C displays though. They are usually poorly documented or have strange initialization commands. If you find a nice easy one, I'd love for you to share it.
Thanks DJ, I will start the hunt.
I think I found a good one. I will let you know when it gets here. I do not see 12C marked on the EZ-B. Where do you plug into the board for 12C?
Bookmaker, which version of the EZ-B do you have? v2, v2.1 or v3?
The I2C ports on the V3 are located under the Analog ADC inputs
DJ, I am running V3 and it is just amazing what you can find if one just looks. Yup, sure enough, there it is as big as life, 12C.
cool
DJ, I received my 12C LCD and tried the script command and I keep getting a syntex error. Can you give me an example?
You'll have to check your datasheet for the specific commands that it will accept. You can post a link to the datasheet and i can take a look for you.
This is how you send an I2C command:
Keep in mind, that it is I (as in the vowel). it is not a number one.. It's EYE TWO SEE
DJ, You were absolutly correct "There are problems i've found with I2C displays though. They are usually poorly documented or have strange initialization commands." I ran the code you wrote above and nothing happened. I have found the documentation but it reads like Greek to me. Any advise?
The code I pasted was an example of how I assumed it would work, but there are two things that are missing...
You'll need to know the address. the 0x0a was just a sample
It might not accept merely a string of text. You might have to send it an initialization string first
Thanks for the input DJ, I found the address. It is 0x27. I tried that and all that happened was the screen turned from a lit blue (on power up) to a blank (no power). Any idea how to find out what the initialization string might be?
DJ, This is what I found. Makes no sense to me but it may to you. Can you translate?
///Arduino Sample Code ///www.DFRobot.com ///Last modified on 17th September 2010
#include #include
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
void setup() { lcd.init(); // initialize the lcd
// Print a message to the LCD. lcd.backlight(); //lcd.setCursor(0, 1); lcd.print("Hello, world!"); }
void loop() { // when characters arrive over the serial port... if (Serial.available()) { // wait a bit for the entire message to arrive delay(100); // clear the screen lcd.clear(); // read all the available characters while (Serial.available() > 0) { // display each character to the LCD lcd.write(Serial.read()); }
You know, i'm entirely unsure what that mess is. I'll have to probe the Arduino library to see what they're doing. Does your LCD have a serial interface also? You can use that instead maybe.... Now that ARC supports more than one EZ-B Board You have lots of free I/O!
I2C is great if your hardware is documented. Doesn't look like that I2C LCD is documented very well
DJ, I found an add that has alot of documentation. Can you please take a look and see if maybe there is a solution at hand?
E Bay add
Many thanks in advance.
try
also, make sure the interface is indeed I2C and not SPI. The pins should be marked as:
Ah after fustrating searches... Look at this link: Proper Datasheet
Your device address is 0x27 it seems. Now I still don't know what command is sent to write a string.. you can try this first
I also just read that the default address could be 0x4C ... Geez this LCD is not documented well
so maybe this will work..
PS.. I'd cycle the LCD power before trying different commands. Each command might get to the LCD but do something that makes the next command not work.
Thanks a bunch DJ, I am at work now but I will try it when I get home. It is definitely i2C. I did try the sendI2C(0x27, "Hello World") but all that happened was the screen went dead. Thanks for all your time!
Wait!!! It responded with 0x27? That might be it!! See if it goes dead with 0x4C also...
Does it normally go dead? Or only that time?
Chinese stuff like this is never documented well
Actually that is the one and only responce I have gotten.
Okay then we're on the right track for address ID i think
Hello, I just got home and tried everything you mentioned. The only one that did anything was the sendI2C(0x27, "Hello world") which blanked the screen.
Okay, that's a start. Now we need to find out how to send commands.
How about
For reference:
So looks like you can do this for initialization....
I'm not sure, but looks like you need to put it in some Enable mode to begin writing after you initialize
Ah, ha I will give it a try as soon as I get home. Are you sure that last line of code (0xEF) is correct? All the others are numbers???
All numbers that have a 0x in front of them are called Hexidecimal
0xEF is a number. It is hexidecimal. It is another way to count, but it is base 16. Normal counting is Base 10 and it is called Decimal (for 10)
Hexidecimal counts like this: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 2A 2B 2C 2D 2E 2F ....
So the least significant digit (the digit on the right) increases from 0 to F before the next digit increases. You can count to 255 with Hex by having only two digits. Decimal 255 is FF Hex
Hex 0xEF is 239 in decimal
You could write that same peice of code without the 0x and specify decimal instead...
Look at this link: http://www.cdrummond.qc.ca/cegep/informat/Professeurs/Alain/files/ascii.htm
Thanks for the ASCII lesson. I tried the code above and the screen blinked. Without the last line of code the screen went blank. What now?
Keep trying
Ill post something soon as I can think of anything else... hmm
Hello DJ, Love V13. Does the read I2C help any to find out how to print with my LCD?
Having no datasheet on that lcd isn't making this easy. Have you tried anything since then? Just keep poking at it. We know that the screen clears when we send any data to 0x27 .. So we have to assume the LCD address is 0x27.
Try sending more data to 0x27 and see what you get. Try different things like
and other things like..
and try incrementing 0x01 by 1 .. try 0x02, 0x03, 0x04... etc
Thanks DJ, I will give that a try.
Let's hope v13 makes it a bit easier for you by using the script console.
PS, i ordered one. So i'll be able to help you when i get it
As usual you always go above and beyond. WAY ABOVE AND BEYOND. It is more of a chalange now than a practacality since I have an additonal 20 digital ports to work with I could simply order a serial LCD but like I said it is more of a chalange at this point.
LOL, we'll figure it out
Well, I tried a bunch to noavail.
Does the screen still go blank with the anything send to the address 0x27?
DJ, sendI2C(0x27, "Hello World") Blanks the screen.
I get a lit screen with the curser flashing in position one when I send: sendI2C(0x27, 0x20, 0x10) # put in 8 bit mode sendI2C(0x27, 0x20, 0x08) # configure for 2 line display sendI2C(0x27, 0x01) # clear display
Well that's good news!
After those commands, try sending something like
sendI2C(0x27, 0x80, "Hello World")
No such luck. May be we should wait until you get yours. Don't need taking everyones time up.
DJ, I downloaded the new version and firmware. Tried sending I2Cwrite(0x27,"test") and it blacked out the EZ-B. NEXT?
You need to i2cStart() first. The i2c command structure has changed to support more devices, including debugging your device.
In order to "talk" to a slave from the master (Ez-b), a Ttart sequences is one of two special sequences defined by the i2c bus. The other sequences is the Stop sequence. So a master must send a Start or a Stop. The master in our case is the EZ-B. The EZ-B plays the roll of a master on the i2c network. Your LCD device would be the slave.
So in your case, you would now need to do this...
But that's not going to do much. I doubt it would even blank the screen. This is because the first bit (also called the least significant bit or LSB) is set to a 1. What? Ha, let me tell you...
So how I originally implemented the i2c was for simple devices like stepper motor controls, blinkm and one of the lcd's i have. Lately there have been people using different i2c devices that require special care. That means I had to dramatically change the i2c command structure. We have an ez-robot member, for example that is building a flying drone and needs to talk to a specific g sensor.
What's this about bits? It's an i2c thing... Here's how it works. So the address of i2c devices or functions are really 7 bit, and the 8th bit is used for the direction (kinda). So let's say your LCD address is 0x27. Well that's 00100111 in binary IF it was an 8 bit number. But because the address is 7 bit and we use the 8th bit to determine the communication direction (Read/Write), we need to shift the bits over by 1.
So you always need your first bit to be a 0 when writing. That means your address is actually 0x4E and not 0x27. Because you have to shift the bits over of 0x27. When you shift bits from left to the right, you multiple the number by 2.
0x27 = 0010 0111 0x4E = 0100 1110
See how the last bit is now a 0 with the 0x4E? That means "write to the device".
Read more here www.robot-electronics.co.uk/acatalog/I2C_Tutorial.html
Well, it made the screen go blank. Guess I have some studying to do!!!
DJ, Did you receive your LCD yet? If so any progress on getting something to print? Buster wants to know. Gosh, it has only been a week. It seemed like alot longer. Anyway, after our Etiquette lesson I am feeling realy stupid. Please disregard my impatients. I will just wait.
No, sadly i have not received it yet
I was tinkering with the blinkM I just got and wanted to try things out. I noticed when making a script that the 'auto complete' doesnt have "sendI2C". Theres the I2CWrite and SendSerial. There are a few references to SendI2C as examples under the script help on the right side. Im new to this so am I missing something?
DJ, Did you ever figure out how to get the LCD to work? Mine is still blank.