Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

AcquireData, BinaryCodes as variant

One time the AcquireData event returns BinaryCodes as variant of long integers and the other time it returns as variant of integers. I'm reading 0-10V area and the returning values are between 0-65535 (long), -32768-32767 (int). There should be a setting of PCI-6033E card that should lock the type, but I don't see it. Or do I have to check the type of variant matrix always after reading it?
0 Kudos
Message 1 of 5
(3,497 Views)
Hi Pera2,

BinaryCodes gives you access to the actual binary numbers the analog-to-digital converter reads from your signal. Because the resolution of your board is 16 bits, each binarycode in BinaryCodes will be 16 bits long. When you read this data keep that in mind. You'll want to read the binary equivalent from the values in BinaryCodes. Also, 16 bits is the size of an integer on most machines. If you choose to read the data out of BinaryCodes as decimal numbers instead of binary, you should use unsigned int (16 bits with a range of 0 to 65535) because your data should remain positive (0 - 10V). There isn't a setting on the PCI-6033E to change this. If you want to read just the numeric equivalent (decimal), you can use the ScaledData array which returns lo
ng data types (either unsigned or signed depending on the signal). To set which type of data you'll be interested in (ScaledData, BinaryCodes, or both) right click on the CWAI control; go to the "buffer" tab; select "return data" as scaled, binary, or scaled and binary.

Thanks,
Ted F.
National Instruments
0 Kudos
Message 2 of 5
(3,497 Views)
The point is that, I'm forced to get BinaryCodes as VARIANT type in VB. VARIANT can be any type of all alternatives. Obviously, VB decides what is the type of VARIANT (integer, long, single,...)... Now, I have to first check the content of VARIANT before any conversion I want to do. I have learnt that VB, for some reason, return those 16-bit values either long integers or integers. The best would be to get rid of VARIANT type variables. Why use them...
0 Kudos
Message 3 of 5
(3,497 Views)
Hello,

The BinaryCodes returned by the CWAI control are the conversions read directly off of the analog-to-digital converter (ADC) on your DAQ card without being scaled or interpreted in any way. They are returned as a VARIANT type because different DAQ cards, or even the same DAQ card when set to different ranges, will produce different types of unscaled data (for instance, higher resolution requires a larger range to store the unscaled data, or a bipolar range would return a signed number where a unipolar range would return an unsigned number).

The difference you are seeing is not between a long and an int, but between an unsigned int and a signed int--both of the ranges you state are for 16-bit integers. Are you always using the same range setting on your c
ard? This could be affecting the type of the returned variant.

TonyH
Measurement Studio
0 Kudos
Message 4 of 5
(3,497 Views)
Thanks a lot. I've been using voltage two ranges -10V..10V and 0V..10V with the same card and I was thinking that maybe first range would be longs (as there is not unsigned integers in VB) and second range integers. But what was interesting that with the same program with range 0V...10V I got different type of return values. One day integers, the other longs? However, I'm tend to believe that there is something in my code which affects this.
0 Kudos
Message 5 of 5
(3,497 Views)