From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

how to read a MPU 6050 through Labview.

Im currently attempting to get my Sparkfun MPU 6050 IMU board to work with Labview. I have the chip set up using i2c through an Arduino Uno and can read the raw values from the chip through the Arduino no problem.

What I am trying to do now is read the values from the chip through labview, has anyone done this before?? I have tried to change around some VI's that I came across for other different devices but to no avail yet.

Hopefully someone can help me with this.

Thanks Brian.

Download All
0 Kudos
Message 1 of 47
(34,573 Views)

What specifically are you having trouble with?  Can you post your code (Arduino and LabVIEW).

Thanks,

-Sam K

LabVIEW Hacker

Join / Follow the LabVIEW Hacker group on Google Plus.

0 Kudos
Message 2 of 47
(18,812 Views)

At the moment im just trying to read the accelerometer values but the values im getting keep changing. I have a few questions that might clear things up for me. Im really new to this so bare with me, my knowledge of labview is very small, the same can be said about C programing.

1. Do I need to write to the chip through the I2c write function first?

2. In the I2c read function what do the inputs represent, 'Address' and 'Bytes to read'

3. Again in the I2c read function what sort of output does it give. 'I2c Data Bytes'

4. In the I2c write function what do the inputs represent 'Address' and 'I2c Data Bytes'

If I can understand these fuctions this can help me with my program because at the moement Im just using trial and error.

Thanks Brian.

0 Kudos
Message 3 of 47
(18,812 Views)

When using I2C in LIFA, the general format is:

Init Arduino > Init I2C > Start Loop > I2C Write > I2C Read > End Loop > Close Arduino

"Address" is the device address (the unique identifier for the device without the read/write bit)

The "Bytes to Read" and "I2C Data Bytes" are the data that is being transmitted.  They are both arrays of bytes.  Many times, you will need to combine multiple bytes to reconstruct the data (this depends on the device).

When you are just trying to get the values from the device (e.g. X-axis of the accelerometer) you need to write the register address and then read the resulting output from the device.

In general, I recommend looking at existing code that does things similar to what you are trying to do.  For example, I use I2C in my library an ADXL345 accelerometer and the LSM303DLM accelerometer.

0 Kudos
Message 4 of 47
(18,812 Views)

Thanks for your reply Nathan, I have tried to adapt your ADXL345 program to suit my chip but im still having a problem with the output numbers. The numbers change each cycle but are different each time and dont reflect the numbers I should be getting so im doing something wrong. At the moment im just trying to read the accelemoter Xaxis,

On the data sheet there are two registers for the accelerometer Xaxis, what is the difference between the two?

If I am trying to read just the Xaxis what number should I input to the 'Bytes to read' terminal on the I2c function?

Im still confused about what output I am getting from the I2c read function, I understand its an array of bytes but how may and how do I distinguish what is what? I have searched for this answer on the net but haven't been able to find anything yet.

I have attached  the adapted version of your program, if you coukd have a look at it and see if im doing anything wrong I would be very gratefull.

Thanks Brian

0 Kudos
Message 5 of 47
(18,812 Views)

It's tough to open those files unfortunately because they are still linked to the ADXL library.

Anyways,  I've been meaning to make this for a while now so I took several hours to write up a small library for this sensor.  Hopefully you will be able to either use this as-is or expand it to include functions you need.

Let me know if it works.

Now, to answer your questions:

Brian-89 wrote:

On the data sheet there are two registers for the accelerometer Xaxis, what is the difference between the two?

If I am trying to read just the Xaxis what number should I input to the 'Bytes to read' terminal on the I2c function?

Im still confused about what output I am getting from the I2c read function, I understand its an array of bytes but how may and how do I distinguish what is what? I have searched for this answer on the net but haven't been able to find anything yet.

  1. The first byte is the MSB (most significant byte) and the second byte is the LSB (least significant byte).  You have to combine the two bytes into a 16-bit signed integer (2 bytes).
  2. To read the data for a single axis, you need to read both bytes then see answer 1 above.
  3. The output is an array of the bytes that you requested (e.g. if you write register 0x6B and read two bytes, you will get the bytes from both 0x6B and 0x6C registers).  Once you have that you have to interpret them depending on what those bytes represent (see answer 1 for an example).
0 Kudos
Message 6 of 47
(18,812 Views)

I was able to get my library for this sensor tested tonight and it works well.  Any further updates to this library will be posted here:  https://decibel.ni.com/content/docs/DOC-34263.

0 Kudos
Message 7 of 47
(18,812 Views)

se puede usar un acelerometro gy-521 en lugar de un ADXL335

0 Kudos
Message 8 of 47
(18,812 Views)

se puede usar un acelerometro gy-521 en lugar de un ADXL335

0 Kudos
Message 9 of 47
(18,812 Views)

The GY-521 is simply a MPU-6050 broken out so that you can use it.  You can use the library that I have posted here.

0 Kudos
Message 10 of 47
(18,812 Views)