From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert the data output by ADXL355 into decimal

Solved!
Go to solution

I have an ADXL355 accelerometer module, and I use NI myrio to read data through I2C.
It's a pity that I don't know much about digital logic and data conversion. How can I convert the data read by I2C into an acceleration value (decimal)?

 

I provide an ARDUINO SPI sample code (not written by me).

Thanks everyone for your help!!

-------------------------------------------------------------------------------------------------------------------

ADXL355  

ADXL355_datasheet

A.pngB.pngADXL355 datasheetADXL355 datasheetarduino codearduino code

 

0 Kudos
Message 1 of 12
(2,665 Views)

So you get three bytes for each axis and they just need to be masked, shifted, combined and cast exactly as described.

 

Can you attach a simple Vi containing default data in the indicators and a description what values you expect?

 

(Run you VI get data in the indicators. "menu...edit..make current values default", save VI under a new name and attach it here)

 

(I assume with "decimal" you mean a numeric datatype, right? What is the purpose of your shift registers? can't you just wire the indicators right after the read functions? Your stop button will not work because it is outside the while loop (dataflow!). What is the desired loop rate? Don't you want 9 bytes instead of 7? etc. Have you done some basic tutorials yet?)

0 Kudos
Message 2 of 12
(2,626 Views)

Thank you very much for your reply~

Sorry, I have been operating labview for 3 years, but I am not very familiar with communication.

I have attached VI. The data in it represents that the Z axis lies flat on the ground, which should be approximately equal to 0.98G.
243807941_298658668737971_6421360703572596754_n.jpg

 

Q.Your stop button will not work because it is outside the while loop (dataflow!).

A.I'm sorry I accidentally pulled it out of the loop


Q.I assume with "decimal" you mean a numeric datatype

A.Yes, that’s right, just like the data read in VI, I want to convert it to G, for example 0.98G


Q.What is the desired loop rate? 

A. I set the sampling rate of ADXL355 to 125HZ. I am not sure how fast the loop should be

so as not to miss the data.


Q.What is the purpose of your shift registers? can't you just wire the indicators right after the read functions?

A.My idea is if I use a shift register, so I can ensure that the data of Z1, Z2, and Z3 can be read at the same time in the next loop.


Q.Don't you want 9 bytes instead of 7? etc. Have you done some basic tutorials yet?

A.I'm sorry, I don't understand~In the data table, XYZ axis data contains (axis data3)7:0 , (axis data2)7:0 , (axis data1) 7:4 .  Or I am mistaken about the relationship between Bit and bytes?

0 Kudos
Message 3 of 12
(2,605 Views)

You have a lot to learn, not only about LabVIEW, but about your Chip and how it works with I²C (I'm more familiar with SPI, myself ...).  Some comments:

  • I'm pretty sure the Z axis points vertically (with respect to the Earth) when the chip is placed "flat on a table".  If so, then you'd expect a Z Acceleration of near 1.0 g, with X and Y Accelerations near 0.0 g.  Rotating the chip so it is "vertical" (with one edge down) should shift the "1 g" Axis to X or Y (depending on which of them becomes vertical).
  • Do you understand how the Chip uses the FIFO?  I didn't study the manual in detail (but I assume that you did), but you need to do 3 3-byte Reads from the FIFO, which return the data in the order X (3 bytes). Y (3 bytes), Z (3 bytes) (see Fig 73 on the Data Sheet).  
  • It is not clear (to me) the bit/byte order read from the FIFO.  Some Analog Devices chips I've used with myRIO return MSB first, so I need to bit-reverse each byte of data (and sometimes I need to swap the bytes).  But if you are getting reasonable values (like ±1 g and 0 g -- how would you get, say, 0.7 g?), then this might not be an issue.

Bob Schor

0 Kudos
Message 4 of 12
(2,564 Views)

@koukileo wrote:

Q.What is the purpose of your shift registers? can't you just wire the indicators right after the read functions?

A.My idea is if I use a shift register, so I can ensure that the data of Z1, Z2, and Z3 can be read at the same time in the next loop.


That makes so little sense. They are obviously read sequentially at different times with the order determined by the error wire. All your "construct" does is ensure that they display at the same time, which could be achieved equally well by other means if really needed. If all three are inputs to a subVI, that will automatically wait until all data is present.

 

Sorry, I don't have your subVIs and drivers. For now it seems your main problem is to convert the bytes to data. I'll have a look....

0 Kudos
Message 5 of 12
(2,559 Views)

This is the conversion code I found in the community, but it should be closer to 0.95G, isn't it?

The graph on the right is about 0.95G measured by the accelerometer onboard myrio.

I store about 3 seconds of data in ROW DATA for your convenience. Thank you~

 

A.pngB.png

 

0 Kudos
Message 6 of 12
(2,541 Views)

What is the problem?  I hope you realize that I cannot see the extremely tiny print on your picture.  I assume that you might have forgotten about "scaling" the data, and are concerned that the data you are getting from I²C isn't 0.95 (units of "g"), but is possibly an n-bit Integer (possibly signed or unsigned).  Somewhere in the Data Sheets you should find values called something like "Gain" and "Bias" (or "Offset") that will let you translate the (I'm assuming "integer") values from the Accelerometer Chip into Acceleration (in uniits of "g").

 

Bob Schor 

0 Kudos
Message 7 of 12
(2,535 Views)

Thank you for your reply, I will try to find the conversion method in the data sheet and the data read by I2C. Sorry, I asked the question first without thinking first~

0 Kudos
Message 8 of 12
(2,531 Views)

@koukileo wrote:

This is the conversion code I found in the community

 

B.png

 


Well, if you found it "in the community", a link would help, because the code in the picture has nothing to do with the code you have attached. Can you give us the link to the above code?

 

In any case, that "conversion" shown in the picture is pure Rube Goldberg. I am 100% sure it can be done with 10% of the code, nothing green, and very little orange, and the size of a postage stamp. 😄

0 Kudos
Message 9 of 12
(2,516 Views)
Solution
Accepted by topic author koukileo

@altenbach wrote:

 

In any case, that "conversion" shown in the picture is pure Rube Goldberg. I am 100% sure it can be done with 10% of the code, nothing green, and very little orange, and the size of a postage stamp. 😄


Indeed. This is the actually needed code for all 3 axes to implement the functionality as contained in the INO file.

ADXL355.png

 

Rolf Kalbermatter
My Blog
0 Kudos
Message 10 of 12
(2,501 Views)