LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Transforming a Waveform chart to calibrated values

I'm trying to take an array of waveforms, and update each one so its values are all calibrated properly. I assumed that I could simply calculate each value and reinsert it into the waveform, which for the most part seems to work (the values in the waveform object are correct), but when I try to put it on a waveform chart, it does not display properly. Any ideas why this may be happening?

tholmvik_1-1599081914300.png

 

tholmvik_0-1599081881862.png

 

0 Kudos
Message 1 of 4
(1,049 Views)

It would be better if you attached an actual VI with the waveform data saved in the controls as default.

 

I see a number of odd things you are doing.

1.  You don't need to get an array length and wire to N of the For Loop when you auto-index at the tunnel of that array.

2.  You seem to be using Insert into Array rather than Build Array.  When you add elements to the array at the beginning or end, you should use Build Array.  It is much simpler to understand, harder to get wrong, and uses fewer nodes.  I probably use Build Array 99.9% of that time and rarely use Insert Into Array.  Insert Into Array should only be used if you are actually inserting into the middle of an array.

3.  You are initializing an array of zeroes and "inserting" elements into that why?

 

4.  Do you know if you are doing the same subtraction on every element of an array, you don't need to do it element by element?  Just subtract a scalar from the array.  The inner workings of your loops are confusing, but I think all you are doing is trying to subtract a scalar value from the entire array.

 

5.  Any chance your Calibration Array is empty?  Since you auto index on that, if there are zero elements, the outside For Loop will run zero times.

 

But your pictures didn't show that control on the front panel for us to be sure that is the situation.

 

 

0 Kudos
Message 2 of 4
(1,010 Views)

Hi tholmvik,

 

implementing RavensFan's suggestions/questions your VI could also look like this:

When you need to use ArraySize instead of relying on autoindexing you should take the Training resources to learn LabVIEW (as offered in the header of the LabVIEW board)!

 

As you didn't provide your VI with some useful default data we can only guess your "calibration" data is empty - you can easily check this using basic debugging techniques (as shown in the Training resources)…

Best regards,
GerdW


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

I'm puzzled by what you mean by "calibration".

 

Consider a simple example -- 1 channel from an Accelerometer that puts out a 0 to 5 V signal having a nominal "bias" of 1.5 V and a nominal "gain" of 0.3 V/g.  When you acquire 1000 samples at 1 kHz and tell DAQmx that the results are in Volts, 0..5, you'll get Waveform whose Y Array is an Array of Dbl with values (one hopes) between 0 and 5.

 

You aren't interested, however, in Volts, but want the result in g's.  What's more, you've actually calibrated this accelerometer and have found that the "true" bias is 1.4 V, and the true gain is 0.27 V/g.  [Do you see the easy way to arrive at these numbers?  Here's a clue -- put the Accelerometer "flat" on a table, not moving, and take the average of 10 readings.  Turn it upside-down (I'm assuming its faces are parallel to each other) and repeat the measurement.  Calculate true bias and true gain.]

 

I'm assuming (I should have said this first!) that the measured Voltage is a linear function of Acceleration.  So the governing equation is Volts = Acceleration * gain + bias.  Doing a little high school algebra, Acceleration = (Volts - bias) / gain.  Note that Volts and Acceleration are arrays, whereas gain and bias are scalars.  Since subtract and divide in LabVIEW allow you to mix an Array with a scalar, you don't need a For loop to operate on every element of Volts, but can just wire the Volts array and the scalar bias into the Subtract function (same with Divide).

 

Simplifying your code by this simple step might cure some "hidden bugs" ...

 

Bob Schor

0 Kudos
Message 4 of 4
(976 Views)