LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert Left-Justified Raw DAQmx Values

Solved!
Go to solution

I have a program that uses the DAQmx API in LabVIEW to download data from a device. I download the data in a raw form before sending it to loop to do some data processing. (Producer-consumer type). I use the following formula to convert the raw values to real values

 

Voltage Reading = (binary reading/2^bit)*(Vmax-Vmin)

 

This has worked fine until now. All the data that I have downloaded from previous DAQmx devices has been Right-Justified, whereas the new device is Left-Justfied.

 

These properties can be accessed from Analog Input:General Properties:Digitizer/ADC:Raw Sample Justification Property

Left-Justified  Samples occupy the higher bits of the integer.
Right-Justified Samples occupy the lower bits of the integer.

 

These properties are not settable. Any ideas on how to express a formula similar to the one above for Left-Justified raw data? I have tried rotating the bits of the raw data to no avail.

 

Thanks for your help.

 

Regards,

mcduff

0 Kudos
Message 1 of 5
(3,644 Views)

I'm not familiar with the term left justified or right justified raw daqmx values.

 

I'm going to take a guess and assume that if you had for instance a 12-bit DAQ device, those values get packed into a U16 (or I16) and the extra 4 bits are either the high order bits or the lower order bits.

 

If that is the case, then to convert, you should only need to bit shift.  Look on the Numeric >> Data Manipulation palette.  Either rotate or logical shift should do what you want and you'd just need to shift or rotate so many bits either right or left.

0 Kudos
Message 2 of 5
(3,637 Views)

Thanks for your help. I've tried that but it does not work, at leastr not in the way I have implemented it. Attached is a VI with example data. Not sure what to do.

 

Cheers,

mcduff

 

 

0 Kudos
Message 3 of 5
(3,628 Views)
Solution
Accepted by topic author mcduff

Here is a stupid question: Why are you getting the raw data?  Just have DAQmx give you the actual voltage value and then you don't have to go through this mess.

 

But if that is not an option for some weird reason, then keep the left justification and just treat it as a 32-bit ADC.  So you will actually have (10 - -10)/2^31 = 20/2^31.  You only have 31 actual bits due to the signed properties of the number (one bit is bascially the sign).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 5
(3,621 Views)

Thanks!!

 

So does that mean I have been doing the other conversion incorrectly also? I have been using a the number of bits for my resolution factor, eg, 2^16 etc.

 

Here is a stupid question: Why are you getting the raw data?  Just have DAQmx give you the actual voltage value and then you don't have to go through this mess.

 

I was trying to save resources. The data is sent to an anlysis subvi which can do filtering, ffts, etc. If I use doubles then I use 2 - 4 times the memory in my instrument loop. Admittedly, it is easier to just use doubles and not worry about this stuff. I may end up changing it that way.

 

Thanks again.

 

Cheers,

mcduff

0 Kudos
Message 5 of 5
(3,614 Views)