04-15-2014 01:25 PM
I'm using the USB-6215 for a quadrature encoder. I'm trying this two ways, with the same results:
I add encoder channels A/B to PF0 and PF1 (terminal 1 and 2), using counter 0. Power is of course from the connector.
1) NI-Measurement and Automation Explorer
I create a new virtual channel for Position->Angular.
2) Matlab
encoder_in_ch = sess.addCounterInputChannel(deviceID, 'ctr0', 'Position');
encoder_in_ch.EncoderType = 'X4';
However, when counting down below '0', the values stored jump to 4.295x10^9 (4294967294), which is 32-bits (2^32). Eg "15, 14, 13...1,0, 4.295e9,"
Then back to 0,1,...55, etc when moving back above zero.
Why is this not stored as a negative number, but a 32 bit values?
I see this in NI-MAX as well, and in the data that matlab stores for the encoder position.
04-16-2014 12:15 PM - edited 04-16-2014 12:15 PM
In DAQmx, you can read back data as either U32 or as a DBL.
You're reading the result as U32. Casting it to I32 will give you the negative number that you are looking for.
U32(0xFFFFFFFF) = 4294967295
I32(0xFFFFFFFF) = -1
Reading the data as a DBL I believe will also give negative values for position.
Best Regards,