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: 

System calibration as a solution of nonlinear equations

Solved!
Go to solution

Good day,

 

The challenge of the day is to provide a calibration for an accelerometer output, expressed as a binary value.

 

I have an accelerometer whose operating range can be set (±2g, ±4g, ±8g).  The accelerometer itself then generates a binary value at 16bit resolution.  Hence, that 2^16 value (0-65535) represents an acceleration whose value depends on the ranges we set.

 

So, we make the asumption that the response is linear, allowing us to claim:

Acceleration = Scale x Binary Value + Offset

 

I have three axes worth of data, accelerometer A, B and C.  If I hold the accelerometer stationary, the only thing I should be reading is the accleration due to gravity, g.  This gets me the relationship

 

(A)^2 + (B)^2 + (C)^2 = g^2

 

since, in any orientation, the magnitude of the combination of all three acceleration readings should be the acceleration due to gravity (and that shouldn't change no matter which way you happen to be pointing the accelerometer).

 

What this gives me, then, is a nonlinear relationship of 6 variables (three scale factors and three offsets). I should be able to take six measurements in arbitrary orientations, which will give me six output values of each acclerometer.  I should then be able to pull out the scale factors and offsets for each accelerometer, either in terms of g or relating to what I think g is.

 

My question, then, is how can I get Labview to do this?  I'm see that there's a Solve Linear Equations tool, but I'm not seeing one appropriate for the nonlinear case.  I'm also quite comfortable believing I'm just missing it 🙂

 

Thanks!

0 Kudos
Message 1 of 6
(2,577 Views)

OK, so I've dug a bit deeper and believe that the Nonlinear System Solver is the appropriate starting point, as found in the example file Equation Explorer.vi.

 

In that example, I can define a system of nonlinear equations and the vi should spit out the solutions (zeros) of the variables.  I got it to work with some arbitrary test data generated through excel.

 

Now, I'm moving on to the next level of complexity in the model, and have derailed m'self again..

 

The simulated device:

a three axis accelerometer, each of which would generate an output of the form Voltage = Scale * Acceleration + Offset. 

 

In a perfect world, the only accleration I'll be seeing is gravity (9.8 m/s^2), and I set that gravity in a random direction (indicating the accelerometer is at an arbitrary orientation).  Knowing that orientation, I then calculated what the components of the acceleration would be along all three axes, and then applied values for Scale and Offet to deterine what the equivalent voltage reading off the accelerometers would be.

 

So now I start the long way home again.  From a Labview perspective, I know that I have three voltage outputs which would feed into a known relationship

 

((Vx - OffsetX)/ScaleX)^2 + ((Vy - OffsetY)/ScaleY)^2 + ((Vz - OffsetZ)/ScaleZ)^2 - 96.04 = 0

 

where the 96.04 comes from g^2.  This is my nonlinear equation with six unknowns in it and three constants.

 

Since I have six unknowns, I need six equations, which I can get by rerunning my simulation, right? 

 

I put six generated "voltages" (Vx, Vy, Vz) into this form using my expected values for Scale and Offset, and run the vi. However, the vi returns nothing.  I know there should be a solution vecotr, because that's what I used to created the simulated data.  Is there something I'm overlooking?

0 Kudos
Message 2 of 6
(2,543 Views)

Please put some of your test data into your VI, Make Current Values Default, Save, and then post the VI. Also provide the orientations used for the data points.

 

I worked with another programmer on a similar problem about two years ago. I will check his transformations to see if they could be used to help you. His geometry was somewhat different but I think the underlying mathematical structures may have been compatible.

 

Lynn

0 Kudos
Message 3 of 6
(2,540 Views)

Attached.  I also included the excel file I use to generate the random values, just in case you'd like that half, too.

Download All
0 Kudos
Message 4 of 6
(2,535 Views)
Solution
Accepted by topic author gpsmith

From the Detailed Help file for the nD Nonlinear System Solver.vi:


 

Formula Parsing VI Variables

The Formula Parsing VIs accept only the following variables:

Note Note  Use these same variables to specify the formula string description for the Nonlinear Curve Fit VI.

aa0, ..., a9

bb0, ..., b9

.

.

.

zz0, ..., z9

For variable and function names, only lowercase letters are allowed. The VIs interpret capital letters as errors.

 


 

1. I found this by opening the front panel of the Nonlinear Solver VI while running your VI. The error information said there was a problem with the formula.

2. I replaced the Scale__ and Offset__ variables with a0, a1, b0, b1, c0, and c1 in the X and F(X) arrays.

3. I expanded the Start and End values to -10 and 10.

 

This seems to work much better. At least it runs.

 

Lynn

Message 5 of 6
(2,526 Views)

Thanks!  That's got me rolling again (as the output is moderately close to what I started with)

0 Kudos
Message 6 of 6
(2,514 Views)