07-22-2015 03:28 PM
Hello,
I am building an application that requires trackig the raw counts from a quadrature encoder connected to a NI USB-6212. In order to count each rising and falling edge of both channel A and channel B, I have configured a DAQmx Linear Encoder Channel for 4X decoding with the units set to ticks. In order to prevent the counter from rolling over when the ticks become negative, I convert the U32 value from DAQmx Read to I32. So far this all works as expected. I would additionaly leik to retain to position of the encoder if the VI is stopped but remains in memory. For this reason I wire the value of the raw counts to a shift register which is read into the initial position input of the DAQmx Create Channel VI. For some reason, the DAQmx Create Channel VI quadruples whatever value is wired to the inital position input. I solve this by deviding the previous counts by 4 before writing to initial position. However, the problem occours that if the value of the previous count was not an even multiple of 4, the inital position must be rounded to the nearest integer, causing the count to jump when restarting the VI. How can I reset the inital postition to the exact value of the encoder at the end of the previous iteration?
07-23-2015 06:59 PM
Do you mean that the scaled position indicates a number that is the initial position multiplied by 4 in addition to any ticks that have taken place in the current acquisition?
07-24-2015 08:29 AM
That is correct, except that it is the unscaled position, what was calling raw counts or ticks, that is exhibiting the described behavior.
07-27-2015 06:49 PM
Does the initial count multiplier change if you switch from X4 to X1 encoding?
07-28-2015 12:39 PM
Yes, It does. In 1X decoding mode, the starting count equal to the supplied initial position, but then I only count 1/4 of the pulses I expect to see. Perhaps I am misunderstanding the meaning of 'inital position'?
07-29-2015 01:34 PM
Have you tried running an example program? I would recommend running the Counter - Count Edges.vi that's found in the NI Example Finder. Try running that and see if the issue persists.