LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Accelerometer 3-axis

I am trying to develop a vi for accelerometer to run. I want it to return 3 arrays. But, it returns only 1 value for each of the 3 axis. Can somebody please check my code?

0 Kudos
Message 1 of 8
(4,991 Views)

There are many variations on the triaxial accelerometer (I'm working on some code for one, now, myself).  Your accelerometer appears to be a Serial Device with some form of command structure (as you are using VISA).  Mine, on the other hand, simply outputs three voltages -- the big issue with that is Calibration (how to transform Volts to g's).

 

NI has a Serial Instrument Control Tutorial that you can find on the Web.  Look at the manual for your accelerometer (if you want more help from us, you'll need to tell us the make and model so we can also look up the manual).  Note that one almost never uses "Bytes at Port" with VISA Reads -- the "preferred" way is to understand if (and how) the VISA message is "terminated" (configured when you open the VISA Port).  You ask for, say, 1000 bytes, having set VISA to terminate the Read on the Termination Character (typically 0x0A, <LF>), so you get a single line of text.  But check your manual ...

 

Bob Schor

Message 2 of 8
(4,983 Views)

Thank you for your reply. I am using ADXL335 accelerometer. When I run using the bulb on, I can see the error occuring in READ visa. I am trying to understand why?  

0 Kudos
Message 3 of 8
(4,974 Views)

@bufferlab wrote:

Thank you for your reply. I am using ADXL335 accelerometer. When I run using the bulb on, I can see the error occuring in READ visa. I am trying to understand why?  


What error?  Hard to help you solve an error without knowing what it is, such as an error number and a description.

0 Kudos
Message 4 of 8
(4,955 Views)

Well, I think we might be using the same accelerometer!  The ADXL335 generates analog voltages corresponding to the accelerations in the X, Y, and Z axes (defined with reference to the Accelerometer Chip), and requires 3v power, so needs 5 wires.  Calibration is an issue!  In a LabVIEW environment, I recommend something like the USB 6009 (or its successor, the USB 6002) which allows 3 channels of A/D sampling to give you X, Y, and Z voltages that you can convert to accelerations (did I mention you need to calibrate this beast?).

 

It is not at all clear why you are using VISA with this gadget.

 

Bob Schor

Message 5 of 8
(4,950 Views)

I am trying to make driver for my accelerometer which is 6 wired ADXL335. Now my problem is when ever I am trying to say run the accelerometer by giving for example no of points N= 4, the  it should show the out put in the array as follows.

 

x=206.9 y=2.06 z=1.633   

 

x=150.6 y=1.57 z=1.54

x=180.9 y=3.03 z=1.34

 

or it should be

x=206.9 150.6 180.9

y=2.06    1.57     3.03

z=1.633 1.54      1.34

 

That means each time when my loop runs based on N, it should add x,y,z value to the array

 

I used "for loop" for it. But now my problem is the array is showing as follows

1.png

 

 

How can I append the array or how can I make it look I want it to be?

0 Kudos
Message 6 of 8
(4,922 Views)

Hi bufferlab,

 

How can I append the array or how can I make it look I want it to be?

Delete the BuildArray nodes directly after the ScanFromString function. No need to turn scalars into 1D arrays at this point…

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 8
(4,917 Views)

I'm still confused how you are using the Analog Devices Triaxial Accelerometer chip, which outputs voltages, and yet are doing serial reads to get the data (maybe there is an Arduino in the circuit that you are not telling us about?).

 

However, it seems to me that your real question is "What is a good way of acquiring and managing data from a Triaxial Accelerometer?".  Having done this myself, I have some suggestions:

  • A "sample" consists of three values (voltages, accelerations, or however you acquire it, but an X value, a Y value, and a Z value).  This suggests the three components of a vector (specifically an acceleration vector), and a logical representation as an array of three elements.
  • You are acquiring multiple samples.  This suggests an "array of samples", or a 2D array of accelerations, where the "rows" represent samples and the "columns" represent X, Y, and Z components.
  • Let's assume that the data are acquired as "lines of text" of the form "0.123, -0.456, 0.789", i.e. number string, comma, number string, comma, number string.  Here is a While Loop that will read a line, make a 1D array of three numbers out of it, then accumulate these 1D arrays into a 2D array (I'm leaving out obtaining the data string and deciding how to exit the loop).

Triaxial Samples.png

 

Bob Schor

0 Kudos
Message 8 of 8
(4,896 Views)