LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

myRIO i2c probelm

Solved!
Go to solution
Hi I've just started using the myRIO. I'm using the I2C to connect a remote device (motor controller). I figured out how to send data (speed), but Im having problems reading some values with the I2C function of myRIO. I want to read the register at 0x11 of my device. How can I specify which register I want to read? Thanks.
0 Kudos
Message 1 of 12
(9,717 Views)

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.

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If someone helped you out, please select their post as the solution and/or give them Kudos!
0 Kudos
Message 2 of 12
(9,707 Views)

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?

0 Kudos
Message 3 of 12
(9,696 Views)
Solution
Accepted by topic author RokCapuder

@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.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If someone helped you out, please select their post as the solution and/or give them Kudos!
0 Kudos
Message 4 of 12
(9,687 Views)

Aaaaah I get it now! So simple 🙂

 

Thank you HappyAsthma!

0 Kudos
Message 5 of 12
(9,674 Views)

@RokCapuder wrote:

Aaaaah I get it now! So simple 🙂

 

Thank you HappyAsthma!


Glad to hear it!  😄

 

Don't forget to mark the solution!

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If someone helped you out, please select their post as the solution and/or give them Kudos!
0 Kudos
Message 6 of 12
(9,672 Views)

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.

0 Kudos
Message 7 of 12
(9,544 Views)

duplicate post, continued here!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 12
(9,538 Views)

Sir,

     I have to control the motion of 4 DC rhino Servomotors using Spartan 3E board.I have to implement through I2C communication.I have made a VI for controlling a single motor.steps that I have followed are-
1.I have used the J1 header pins I/O1 and I/O2 as SCL and SDA pins respectively.
2.In the VI, initially both SCL and SDA lines are high.
3.while the scl is high ,sda makes a transition from high to low.
4.after that I have set the SCL line low to send the address and the data byte on the SDA line.After the communication is over , again both the lines become high.
Problems:
1.While sending the data through the VI to vary the speed of the motor ,its not varying."
2.the motor is not stopping upon sending data 0 .
3. I have to control the motion of 4 motors at a time.I am facing problem as to how to address them and what all changes I need to make in the VI.
 
Please provide me the valuable suggestions and modification needed in the VI as soon as possible.
Thanking You,
Regards
Pooja
0 Kudos
Message 9 of 12
(9,325 Views)

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.

0 Kudos
Message 10 of 12
(9,309 Views)