LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

processing two data from one serial port with labview

I need to interface 2 mpu6050s to arduino and then to labview, my question is can I take two data from the sensors through one serial port and process it using labview?

0 Kudos
Message 1 of 7
(5,236 Views)

The MPU6050s use the I2C bus for a digital interface.  Pins A4 and A5 on an Arduino Uno are used for the I2C interface.  You can connect more than one I2C device to the I2C bus.  See the fallowing link for an example.

<http://www.robot-electronics.co.uk/acatalog/I2C_Tutorial.html>

Pin A4 is the SDA signal and Pin A5 is the SCL signal on an Arduino Uno.

LIFA  has I2C Init, I2C Read and the I2C Write ructions for working with the I2C bus.

hrh1818

0 Kudos
Message 2 of 7
(3,816 Views)

i am new to labview, can u explain a bit more on i2c read and write functions as they require the address and the bytes to read parameters. i dont know what to specify in the byte to read section in write and read functons?

0 Kudos
Message 3 of 7
(3,816 Views)

This tutorial will help you with I2C.

<https://learn.sparkfun.com/tutorials/i2c>

hrh1818

0 Kudos
Message 5 of 7
(3,816 Views)

In the i2c read we need to give the device address and the data bytes to read( from the FIFO buffer), which is the same for i2c write but i cannot understand what should i put in the data bytes to write?

0 Kudos
Message 6 of 7
(3,816 Views)

The number of bytes to read depends on what you are reading from the device.  If you look at the document that I posted a link to above, you can see how I've done it there for different pieces of data.

The first required byte that you write to the device is the register address for which you want to interact.  If you are setting a register's value then you would supply a second byte containing the information that you want to write to the register.  If you are simply reading from a register, you only need to write the register address and then do the I2C read.

For reading, you need to supply the number of bytes that you want to get from the device.  This particular device will allow you to read multiple registers without manually requesting from each register individually (this is not always the case; some devices require special methods to do this) by just requesting the number of bytes with the read function.

If you take a look at the subVI called "Get All Data.vi" in my code I posted a link to above, you will see an example of this.  I write the register of the high byte of the X accelerometer axis and then read 14 bytes.  This gets me 7 pieces of data (3-axes for both the accelerometer and the gyro and the temperature; each two bytes).

You can look at some of the other VIs to see how to write information to registers on the device.

After looking at the code, let us know if you have any questions.

0 Kudos
Message 7 of 7
(3,816 Views)