06-13-2014 12:18 PM
Solved! Go to Solution.
06-13-2014 12:34 PM - edited 06-13-2014 12:37 PM
I can't speak specifically to the myRIO, but for I2C in general, you will send the following (Note: Bold items are responses from the slave, the normal font are the bits you transmit):
Start Bit -> Slave Address (Write) -> Slack Ack -> Register Address (0x11 in your case) -> Slave Ack -> Repeat Start -> Slave Address (Read) -> Slave Ack -> [Read Data (8 bits) -> Master Nack]
To do a repeated read (if your device supports it), the bracketed segment gets replaced with:
[Read Data (8 bits) -> Master Ack -> Read Data (8 bits) -> Master Ack .... Read Data (8 bits) -> Master Nack]
If you have a more specific LabVIEW I2C related question, post the code you have so far and I can take a look at it.
06-13-2014 01:05 PM
Thanks for the fast reply HappyAsthma !
Below is the VI i'm sing and its not working in the current state. Should I wait for some time between the write and read event?
06-13-2014 01:21 PM - edited 06-13-2014 01:40 PM
@RokCapuder wrote:
Thanks for the fast reply HappyAsthma !
Below is the VI i'm sing and its not working in the current state. Should I wait for some time between the write and read event?
No. You should not need to wait (the exception being if you were manually manipulating the clock). Per specification, you send a bit every clock cycle.
And I cannot open the VIs specifically since I don't have the library/drivers installed, but try using the Write Read VI to do your reads instead of manually doing 1 write and then 1 read:
http://zone.ni.com/reference/en-XX/help/373925A-01/myrioreference/myrioref_i2cwriteread/
You should send the Slave Address, Bytes To Write == 0x11, Byte Count = number of bytes you want read (your device may need a special value to be set in a register to do incremental "burst reads")
EDIT:
My guess (without seeing the VI code) is that the Write VI and Read VI are sending the STOP bit automatically once they are done writing/reading all bytes. The Write Read VI is likely configured to Write the byte(s) and then immedately Read some byte(s) before sending the STOP bit.
06-13-2014 01:40 PM
Aaaaah I get it now! So simple 🙂
Thank you HappyAsthma!
06-13-2014 01:41 PM - edited 06-13-2014 01:42 PM
@RokCapuder wrote:
Aaaaah I get it now! So simple 🙂
Thank you HappyAsthma!
Glad to hear it! 😄
Don't forget to mark the solution!
07-03-2014 05:09 AM
Is there any NI modules which contains analog measurements and digital measurements and frequency and also main I2C communication in one module???
Please give a suggesion if any third party modules also including above parameters.
07-03-2014 06:03 AM
duplicate post, continued here!
11-10-2014 02:43 AM
Sir,
11-10-2014 06:33 AM
Just because you bumped several old threads related to i2c doesn't mean we're willing to do your homework for you.
Start a new thread. Tell us what you've done. Tell us where you're stuck. Ask for help. Do NOT ask us to do your work for you.