LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2-axial accelerometer calibration-verify

Hi there,

i'm an italian engineering student who try to learn LabView and i have one issue with an homework-software.

The target is to calibrate a two-axial accelerometer. 

I have an input file with 4 columns e 5 rows: each row is a measurement point (the average value of a 1000-points measure) and the columns contains:

  • X-angle
  • Y-angle
  • X voltage
  • Y voltage

In Taratura.vi I:

  1. Extract single colums from file;
  2. Use angles for build the rotational matrix and multiply it for the gravity vector (Ruota-g.vi);
  3. Pseudo-invert the obtained matrix;
  4. Do the dot-product between the obtained matrix and the voltage-matrix -> i obtain a 2x4 2-dim vector with sensibility, axis directions and offset
  5. Save the 2x4 array in a global variable;

Then in Verifica.vi i open a second file with some points i can use for verify the calibration:

  1. I extract columns
  2. Calculate voltage as dot product between the 2x4 vector in global variable and new angle vector > then i compare it to measured voltage and it's OK
  3. Calculate acceleration arrays (rotational matrix in dot product with g-vector) 
  4. Calculate acceleration arrays as pseudoinverse of global variable array in dot product with voltage matrix -> then i compare it to previous-point arrays

I find a problem in these two last points: the array at point 3 it's ok but the array at point 4 isn't ok. I think that can be a problem in the last points because measured voltage and calculated voltage comparison is ok, but i hope in your help!

Thank you

Paolo

 

PS: i've attached some screenshots and main files

 

Immagine.png

Immagine2.png

Immagine3.png

Immagine4.png

 

Download All
0 Kudos
Message 1 of 6
(5,409 Views)

First, thank you for attaching the VIs -- with the VIs attached, we really don't need to see tiny pictures of the code (since we can open the code ourselves, and "play" with it).  However, it would have been very useful to also attach a Sample File to give us a better idea of the nature of the data.

 

Some questions --

  • You describe this as a 2-D Accelerometer and talk about X and Y directions.  Are these two axes at right angles to each other?
  • You talk about a "gravity vector", which makes me think that you are taking measurements with the Accelerometer "at rest" (i.e. not moving), but oriented somehow with respect to the earth-vertical (Z) axis of gravity.  Is this correct?
  • What are the X and Y angles?  In what units (degrees, radians, something else) are these expressed?  What are they measured with respect to?
  • Is it correct to assume that the XY plane of the Accelerometer is "vertical", that is, that the Accelerometer's Z axis is perpendicular to gravity?

The last two questions get to how you calibrate this Accelerometer.  I can think of two methods, and am not sure which you are using:

  1. Lay the Accelerometer "flat" so that X and Y are in the Horizontal Plane.  Take measurements when rotating from this plane about just the X axis.  Repeat for rotations about just the Y axis.
  2. Lay the Accelerometer on its "side" with the X Axis in the Horizontal Plane and the Y Axis pointed straight up.  Rotate the Accelerometer about its Z Axis.

Note that you can make it more "complicated" by combining rotations about X and Y Axes, in which case you need to specify the order in which you do the rotations.

 

Bob Schor

0 Kudos
Message 2 of 6
(5,368 Views)

Hi Bob, 

thank you! Sorry, i'd reached upload limits, but i can attach here more attachments. So, here you can find two files:

- Taratura_accelerometro.txt > datas used for calibration;

- Verifica_accelerometro.txt > datas used for verify the calibration

 

In first two columns you'll find rotations around X axis and Y axis, in the second two columns you'll find voltage output for X and Y respectively.

Then, here the answer to your questions:

  • Yes, they are;
  • Yes, all the measurements is taken "at rest", and i use the accelerometer as an inclinometer;
  • I measured it according to X-Y axis printed over the sensor, in a fixed system
  • Yes, that's right

I used the second method, with fixed angles in a fixed system, combining rotations and elaborating it with a fixed rotational matrix.

Thank you!

Paolo

 

PS. I've used this second post to attach the complete .zip of the project. With my first post i've thought that wasn't possible to upload .zip because in many forum users are not allowed to do that... but now i tried and it works!

0 Kudos
Message 3 of 6
(5,358 Views)

Thanks.  So here are some more comments and questions.

  • Why is there a While Loop, and why is there an Event Structure?  Don't you run this once for the Calibration file, then again for the Verification file?
  • Are you assuming (a) that the X and Y axes are orthogonal (perpendicular to each other)?
  • Are you assuming that if X=0 and Y=0, the X and Y axes both lie in the horizontal plane?
  • Are you assuming that the X and Y sensors are linear, that is, the change going from horizontal to vertical will be the same (except for sign) when the axis goes from pointing up to pointing down?
  • Are deviations from linearity (which is clearly present in your data) just "measurement error" that you handle some way?
  • I notice that you use the letters "RPY" on one of your VIs.  I assume this stands for Roll, Pitch, and Yaw, which specify rotations about axes that move with the object being rotated (for example, an aeroplane always Yaws in response to the rudder, whether flying level or in a steep dive or climb).  When I asked about the "order of rotations", I should also have asked if you are using earth-fixed or object-fixed axes (RPY are object-fixed).
  • I notice in the Verification data that you have a 90°, 90° test.  Here you need to consider Order and Axes, as it definitely "makes a difference".
  • I notice that you use Read Text followed by Spreadsheet String to Array.  Read Delimited Spreadsheet combines these two functions, simplifying your code.
  • You need to learn how to use LabVIEW Arrays.  You do not need to use Matrices.  LabVIEW's Index Array function will do the same thing as your Extract Column sub-VI (and will be instantly recognized by LabVIEW users).
  • You seem to be using a Global Variable to "remember" the Calibration factors for the Verification step.  A better method might be to have a single program with two buttons, "Calibrate" and "Verify", that use a State Machine (with an Event Structure as part of the "Get Command" State), and with the computed Calibration Factors held in a Shift Register for the Verify step.  Note that you can easily set Boolean variables (in Shift Registers) that you turn True when you have Calibrated, so if the user pushes Verify before doing Calibrate, you could either ignore the Command or pop up a message that says "You need to Calibrate first!".
  • I recommend (since this is LabVIEW, not MatLab) using Arrays instead of Matrices (I suspect NI added Matrices a few years ago to please Matlab users).  Rotation about a single axis can easily be accomplished using Array elements.

Bob Schor

 

0 Kudos
Message 4 of 6
(5,329 Views)

Hi Bob, thank you!

Here my answers:

  • Nope, in the final version of the sw i want that users can accept/do not accept the calibration and reiterate it or verify it with more than on file;
  • Yes, i assuming that X and Y axes are orthogonal and verify it and it's ok;
  • Yes, they are in the orizontal plane in a first moment;
  • Yes
  • Yes, i handle them as an error for this first step (it's an academic homework and we do some approximation)
  • I created the RPY Vi but i call the earth-fixed rotational VI in the script, so (i think.. maybe the problem is there) that i use a earth-fixed axes;
  • If i use earth-fixed axes does the order matter?
  • Ok thank you!
  • I use matrices because of the pseudoinverse function, is there a function who allow me to pseudo-invert arrays? I make some confusion because of that continuos change of data-type;
  • Yes i know that, but we must to use a global variable for that

I really don't know where the problem can be.. maybe in the pseudo-inverse or something else..

0 Kudos
Message 5 of 6
(5,300 Views)

@pdellov wrote:

Hi Bob, thank you!

Here my answers:

  • If i use earth-fixed axes does the order matter?
Yes, the order matters.  When doing 3-D rotations, I always use the "Right-hand 2-finger+Thumb" model (Thumb is Z, Up, first finger is X, forward, middle finger is Y, to the left).  Do a +90° X rotation -- Y now points up.  Now do a +90° about earth Y -- X points down, Y is forward.  Start over, do the Y rotation first (X is down), followed by X (Y is up, X is left).  These are different.
  • I use matrices because of the pseudoinverse function, is there a function who allow me to pseudo-invert arrays? I make some confusion because of that continuos change of data-type;
I don't know what your model is for the output from the Accelerometer, but you seem to be "over-analyzing" it.  What you really have are two 1D accelerometers, one along the X axis, one along the Y.  If the system is linear (which you have already said you assume that it is), then the variation in its output will vary as the dot product of the sensor's 1D axis and the 1D axis of the Acceleration (which, if it is Gravity, is aligned with the Z axis).  This, in turn, varies as the cosine of the angle between these axes (I'm ignoring a possible DC offset).
It would seem to me that under some reasonable assumptions, your output will be a simple function of angle with two unknown variables -- the "bias" value from the Accelerometer and the "gain", or "Voltage per G" (no need to use meters/second, unless you are comparing with a published data sheet -- it is simpler with more "natural" units).  You could estimate these two parameters with only two measurements, but with 5, you'll want to do some sort of error-minimization to get the "best fit" estimation.
  • Yes i know that, but we must to use a global variable for that

 Is this a requirement of the assignment?  Curious ...

 


 

0 Kudos
Message 6 of 6
(5,287 Views)