Academic Hardware Products (myDAQ, myRIO)

cancel
Showing results for 
Search instead for 
Did you mean: 

Stainsmart I2C LCD communication with myRIO

I have a stainsmart 2004 I2C LCD and am trying to interface it with a myRIO (http://www.sainsmart.com/sainsmart-iic-i2c-twi-serial-2004-20x4-lcd-module-shield-for-arduino-uno-me...)

 

I was hoping the communication protocal would be as simple as the myRIO project essential I2C LCD example but it seem to be much more involved. I have been going through as much arduino code as possible but still not luck.

 

Can someone please get me going in the right direction to programing this LCD screen. Thank you.

0 Kudos
Message 1 of 15
(13,246 Views)

Hi cyotani,

 

I personally have not used that particular LCD but what kind of issues are you running into? Are you seeing specific errors or just unexpected behavior with the LCD? Were you able to look through the example code the manufacturer posted?

 

Here are some links to other examples that might prove useful also:

 

myRIO LCD Demo (youtube)

myRIO LCD Display (youtube)

myRIO I2C (youtube)

I2C Bus Specifications

myRIO LCD Example (in LabVIEW and in C)

myRIO LCD Example (SparkFun LCD)

Snake for myRIO

 

David C
0 Kudos
Message 2 of 15
(13,205 Views)

Thanks for the reply.

 

The myRIO LCD examples found in the project essentials use a very different LCD that conatins its own processor that takes care of all of the LCD comands. You simply send ith ASCII bytes to the LCD and it handles all the low level LCD comands.

 

Most of the LCDs on the market with an I2C or serial "back pack" (like the one I posted) do not have this function. You need to understand communication with the LCD and do initialization and all the lower level communication such as clear screen, shift cursor, etc. in the myRIO code.

 

Knowing this now I just need to read a bunch of data sheets and arduino or C code to figure out the comunication and replicate it on the myRIO. If I can produce a clean and bug free version I will be sure to post it in the community section. There are a few fpga based code using the LCD parallel interface that I can build off of which helps too.

 

I will post back if I get stuck or make progress.

0 Kudos
Message 3 of 15
(13,158 Views)

I am on the same path as you.

Have you done any progress on being able to communicate with this backpack through MyRIO's IIC?

0 Kudos
Message 4 of 15
(13,020 Views)

Yup, I got it to work. I will post some VIs when I get home.

Message 5 of 15
(12,994 Views)
I would be grateful man. Thanks.
0 Kudos
Message 6 of 15
(12,990 Views)

Here you go sir!

 

It should be pretty straight forward. Open the project and run the example VI. This VI takes the accelerometer data and outputs the x, y, and z values to the first three lines of the LCD. The 4th line is controlled by the myRIO button which also turns on LED0.

 

To use this always start with the Init VI and end with the close VI. In the loop, use the write VI and input the text in an array of 4 strings with the 0 index array being the 1st LCD line and the 3 index value being the last line. It is set to left jusify and if the string is longer than 20 charchters it won't display.

 

 

I'll try to get this cleaned up and documented a little better and post it up in the community section but this should get you started. I haven't found any major bugs with it yet. Let me know if you have any questions.

 

Regards,

Chris 

Download All
Message 7 of 15
(12,981 Views)

Thank you for the posting.

I will test in and get back with results.

0 Kudos
Message 8 of 15
(12,955 Views)

Has anyone tried these VIs? . I'm looking for any feedback or sggestions for improvments.

0 Kudos
Message 9 of 15
(12,902 Views)

Hi cyotani

 

As you mentioned in your previous post, the VIs need some organization and documentation.

I used what you posted to sucessfully communicate with an LCD back pack connected to a 20x4 LCD (not sainsmart).

 

The VIs didn't work directly and I had to change the order of the bits in the "I2C LCD - Write Byte.vi" according to this order:

BL-RS-RW-E-D4-D5-D6-D7 (The original byte was: RS-RW-E-BL-D7-D6-D5-D4).

 

I am attaching the modified VIs in case someone is using an I2C LCD backpack with a communication byte similar to mine.

 

I tried to figure out the initialization sequence that you are using (by looking into the Hitachi LCD driver data sheet) but wasn't able to understand all the sequence that you are using. You are sending [3-3-3-2-40-1-6-12-3-128-1]. The first 3 3's are used for default initialization and the following 2 is for setting a 4-bit communication. What about the later sequece? Can you please explain it (for example if I want to use a different LCD, say 16x2, what should change in the sequence?).

Download All
0 Kudos
Message 10 of 15
(12,896 Views)