Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

How to read signed values from DAQ6533?

I am using DAQ6533 card to read A/D values @ 48kHz. The values are signed (2's comp). Is there an easy efficient way to read the values as signed integers?
Message 1 of 2
(3,201 Views)
Hi Naveed,

When dealing with 2's complement, you will have to do your conversions in software. The hardware will be able to read the digital signals on the line but will return these digital values to software as an unsigned binary number. Therefore 1000 on the first four digital lines will be returned to software and read in your API as 8.

Unsigned binary -> 2's complement:
Loop through the number of bits you have (32 for example) and bitwise "xor" each bit starting with the least significant. However, the bits will remain unchanged until the least significant 1 in the number which also remains 1. For example:
1010100 -> 0101100.

2's complement -> Unsigned binary
You can take the reverse of the above.

Another way...
Just take 2^bits+1 - 2's
complement to get the number and 2^bits+1 - number to get the 2's complement. This method requires a double precision floating point number though.

Anyway, hope that helps.

Ron
0 Kudos
Message 2 of 2
(3,201 Views)