10-17-2018 02:10 PM
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
Solved! Go to Solution.
10-17-2018 02:25 PM
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…
10-17-2018 02:41 PM
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...
10-17-2018 02:53 PM
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…
10-17-2018 03:36 PM
Dear GerdW,
I attach you the vi. The screenshot I attached previously is from the read subvi.
10-18-2018 01:59 AM
10-18-2018 02:24 AM
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.
10-18-2018 02:42 AM - edited 10-18-2018 02:42 AM
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…
10-18-2018 03:27 AM
So with this I will get the acceleration in m/s^2?
Below is the two's complement function
10-18-2018 03:44 AM - edited 10-18-2018 03:45 AM
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):
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".)