07-12-2016 06:00 PM
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
Solved! Go to Solution.
07-12-2016 06:11 PM
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.
07-12-2016 06:29 PM
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
07-12-2016 07:17 PM - edited 07-12-2016 07:18 PM
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).
07-12-2016 07:31 PM
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