LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I scale data generated with DAQmx?

I am writing an application based on the  Cont Acq&Graph Voltage-
to File(Binary.vi     example program.
I want to write the voltage data to a binary file which I can read and process with other applications.
The DAQmx read vi is set to Analog 2D I32 NChan NSamp and outputs 32 bit integers which
are not scaled.
I can also input the min and max expected value into the DAQmx  Create virtual channel vi.
So I would expect that if I make the min= 0 and the max = 10 then to scale the data I would
say 10 is equivalent to the unscaled number 2^31. Or at the very least 10 is equivalent to 2^N where N is some integer.
However this is not working out at all.  I have input a 2 V square wave into the program and tried various values for
the min and max value. What I get is that the max value is approximatley equal to 30,800 which is closest to 2^15 = 32768 but
not close enough.  This is really bugging me.
 
Thanks,
Alice
 
0 Kudos
Message 1 of 4
(2,691 Views)
You divide the actual range by 2**n where n is the number of bits of resolution of your DAQ board. The actual range is not the min and max that you provide. DAQmx selects the most appropriate range based on these values. Say the board supports +/-1, +/-5, and +/-10 volt ranges. If you select limits of -2 and +2, the best range that the board actually has is +5/-5 for a 10 volt range. If you have a 16 bit DAQ, that is 2**16 or 65536. Divide 10 by 65536 and you get 0.000152587890625. Multiply this number by the binary value (or array) returned by the DAQmx read and you will get the actual voltage. The actual ranges that your board has is documented in the manual and there is also a DAQmx property node that you can use to get the actual range based on your min and max. I don't have that information handy right now as I am at home but I believe there have been several posts on that subject in the multifunction DAQ forum. A search should turn something up.

Note that you don't have to do any of this if you choose to return DBLs from the DAQmx read. You can still write a binary file if you are doing this to speed up the logging of data. You will also return calibrated data from the card when you do this. The integer data is not calibrated.
0 Kudos
Message 2 of 4
(2,687 Views)

Thanks!  I also found the thread on conversion from scaled to unscaled data using Graph Aquired Binary data very helpful.

 

just a comment. I am far from a veteran labview user and I find it very onerous to figure out what  the program is writing to the

binary file. I am reading the binary file with matlab. I simply disconnected the header information rather than spend time trying to figure out

what format and order it is. And then I found that at the end of writing every 'number of samples' the program write two extra integers - the

number of samples and then a 1 before going through the loop and getting the next round of samples. I figured this out by trial and error.

 

Thanks again! I appreciate your time.

 

Alice

0 Kudos
Message 3 of 4
(2,683 Views)
Alice,

Your problem seems to be that you don't know what byte order LabVIEW is writing your binary file in.  I assume that you have left most of the settings default, in which case the file is written in big-endian order.  There is an input to set this if you would prefer to write it in little-endian.

One useful feature in LabVIEW is the context help; it can be brought up by pressing ctrl-h.  This window will show a larger view of the VI your mouse was over last, and will also show labels for all the inputs and outputs of the VI.  Below the brief description of the VI there is a link to the LabVIEW help section concerned with the selected VI, and there you can find even more information about how the VI inputs and outputs are working.  In the LabVIEW helpfile on the Write to Binary file VI it explains that big-endian is the default order type for the VI.

I hope this information helps you with this issue and future issues. Dennis did an excellent idea of explaining how the scaling in DAQmx works, thanks Dennis. If you have any further questions about either of these issues please reply, so I can make sure your issue is taken care of.

Have a wonderful Wednesday,

Michael
0 Kudos
Message 4 of 4
(2,664 Views)