LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

adxl345 output voltage

Solved!
Go to solution

Hello, 

 

I have programmed the adxl345 with labview and linx via I2C protocol and I have the following question.

The output from the accelerometer is given in voltage if I am not mistaken. In order to convert it to m/s^2 I have to multiply it by 16*g where g=9.81 m/s^2 (suppose of course I have 16g resolution)?

 

thank you in advance

0 Kudos
Message 1 of 10
(3,587 Views)

Hi bill,

 

The output from the accelerometer is given in voltage if I am not mistaken.

You are mistaken! You get a digital value over I²C bus.

I guess you get a 13 bit value (±4096) for your ±16g range. So you need to scale the received value by 16g/4096…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 10
(3,578 Views)

Excuse me for my poor description before. I used the linx function"adxl345 read" , so as you can see in the screenshot below the output values are already scaled, but I don't think they are in m/s^2...

 

 

0 Kudos
Message 3 of 10
(3,571 Views)

Hi Bill,

 

the problem with images is: we cannot debug them using LabVIEW…

 

Which values do you receive from your ADXL345? (What are the values of those 6 bytes?)

How are those 6 bytes converted to 3 I16 values? What's inside that subVI named "2 cmp dec"?

Is the resolution programmed in the ADXL345 the same as is used to scale the received values? In the case structure the value "1024" is used, indicating a 10 bit resolution of the ADXL…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 10
(3,568 Views)

Dear GerdW,

 

I attach you the vi. The screenshot I attached previously is from the read subvi.

0 Kudos
Message 5 of 10
(3,564 Views)

Hi canye,

 

unfortunately you didn't attach that "Read" subVI.

And you didn't answer my questions on the specific data you receive from your sensor…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 10
(3,530 Views)

I thought you had the linx library and the adxl345 toolbox installed. 

 . If you look at the Read vi, when I modify the resolution then the values ara multiplied by a number depended on the resolution choice. But before that the number are values from 0-1023.

Download All
0 Kudos
Message 7 of 10
(3,527 Views)

Hi canye (aka Bill),

 

I thought you had the linx library and the adxl345 toolbox installed. 

Nope. Now I miss that "U16 2 Complement to Decimal" function…

 

But before that the number are values from 0-1023.

So you get input values 0 - 1023, which represent a measurement range of ±16g? An input of 0 means -16g, while an input of 1023 denots (nearly) +16g?

Then all you need to do is to scale by

acc := (input - 512)/16

Simple math…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 10
(3,525 Views)

So with this I will get the acceleration in m/s^2?

 

Below is the two's complement function

0 Kudos
Message 9 of 10
(3,519 Views)
Solution
Accepted by topic author canye23

Hi Bill,

 

that last subVI is quite non-sense (aka Rube-Goldberg) and can be replaced by a wire (or better: with a "Convert to I16" function):

check.png

 

So with this I will get the acceleration in m/s^2?

When you receive raw values in the range of 0…1023 for a ±16g measurement range then you should apply the scaling shown above…

(When you need values in m/s² you need to multpliy by ~9.81 in the end, the scaling above outputs values with unit "g".)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 10
(3,516 Views)