LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Conversion from scaled ton unscaled data using Graph Acquired Binary Data

Hello !

I want to acquire temperature with a pyrometer using a PCI 6220 (analog input (0-5V)). I'd like to use the VI
Cont Acq&Graph Voltage-To File(Binary) to write the data into a file and the VI Graph Acquired Binary Data to read it and analyze it. But in this VI, I didn't understand well the functionnement of "Convert unscaled to scaled data", I know it takes informations in the header to scale the data but how ?
My card will give me back a voltage, but how can I transform it into temperature ? Can I configure this somewhere, and then the "Convert unscaled to scaled data" will do it, or should I do this myself with a formula ?

Thanks.
0 Kudos
Message 1 of 4
(2,958 Views)
Nanie, I've used these example extensively and I think I can help. Incidently, there is actually a bug in the examples, but I will start a new thread to discuss this (I haven't written the post yet, but it will be under "Bug in Graph Acquired Binary Data.vi:create header.vi Example" when I do get around to posting it). Anyway, to address your questions about the scaling. I've included an image of the block diagram of Convert Unscaled to Scaled.vi for reference.

To start, the PCI-6220 has a 16bit resolution. That means that the range (±10V for example) is broken down into 2^16 (65536) steps, or steps of ~0.3mV (20V/65536) in this example. When the data is acquired, it is read as the number of steps (an integer) and that is how you are saving it. In general it takes less space to store integers than real numbers. In this case you are storing the results in I16's (2 bytes/value) instead of SGL's or DBL's (4 or 8 bytes/value respectively).

To convert the integer to a scaled value (either volts, or some other engineering unit) you need to scale it. In the situation where you have a linear transfer function (scaled = offset + multiplier * unscaled) which is a 1st order polynomial it's pretty straight forward. The Convert Unscaled to Scaled.vi handles the more general case of scaling by an nth order polynomial (a0*x^0+a1*x^1+a2*x^2+...+an*x^n). A linear transfer function has two coefficients: a0 is the offset, and a1 is the multiplier, the rest of the a's are zero.

When you use the Cont Acq&Graph Voltage-To File(Binary).vi to save your data, a header is created which contains the scaling coefficients stored in an array. When you read the file with Graph Acquired Binary Data.vi those scaling coefficients are read in and converted to a two dimensional array called Header Information that looks like this:
ch0 sample rate, ch0 a0, ch0 a1, ch0 a2,..., ch0 an
ch1 sample rate, ch1 a0, ch1 a1, ch1 a2,..., ch1 an
ch2 sample rate, ch2 a0, ch2 a1, ch2 a2,..., ch2 an
...
The array then gets transposed before continuing.

This transposed array, and the unscaled data are passed into Convert Unscaled to Scaled.vi. I am probably just now getting to your question, but hopefully the background makes the rest of this simple. The Header Information array gets split up with the sample rates (the first row in the transposed array), the offsets (the second row), and all the rest of the gains entering the for loops separately. The sample rate sets the dt for the channel, the offset is used to intialize the scaled data array, and the gains are used to multiply the unscaled data. With a linear transfer function, there will only by one gain for each channel. The clever part of this design is that nothing has to be changed to handle non-linear polynomial transfer functions.

I normally just convert everything to volts and then manually scale from there if I want to convert to engineering units. I suspect that if you use the express vi's (or configure the task using Create DAQmx Task in the Data Neighborhood of MAX) to configure a channel for temperature measurement, the required scaling coefficients will be incorporated into the Header Information array automatically when the data is saved and you won't have to do anything manually other than selecting the appropriate task when configuring your acquisition.

Hope this answers your questions.
Chris

Message Edited by C. Minnella on 04-15-2005 02:42 PM

0 Kudos
Message 2 of 4
(2,944 Views)
Just a note, I've posted my description of the bug in create header.vi under the subject "Bug in Cont Acq&Graph Voltage-To File(Binary).vi:create header.vi example".

Chris
0 Kudos
Message 3 of 4
(2,937 Views)
Hello,

C. Minella is right concerning the use of “Convert unscaled to scaled data”.

Concerning the conversion of your voltage value into temperature value, you will have to use a conversion scale. This scale is normally furnished when your purchase your instruments, it is specified in the documentation.

Under NI-DAQmx it is possible to declare this scale when you are creating your task (customized scaling). It allows you to observe the wanted value in spite of the measured voltage value when you are performing an acquisition.

In the example Cont Acq&Graph Voltage-To File(Binary).vi, the coefficients of this scale are not include in the binary file header.
However if you want to include the scaling coefficients defined in creating your NI-DAQmx task you have to include them in the header binary file.
When you will read your values do not forget to extract this values to make the appropriate calculation, otherwise they will not be taken into account when they will be read and you will get only the scaled value (corresponding to the voltage measurement).

To achieve that you can use property nodes, referring to the defined scale in your DAQmx task, to include them in the header (as it is done in the VI “Create Header”).
The other solution consists in not including the coefficient in the header and scaling the voltage value to the temperature value once the data have been read and scaled (as C. Minella do)

Best regards,

Alexandre D
National Instruments France
0 Kudos
Message 4 of 4
(2,905 Views)