Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx Quadrature Encoder Initial Position

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?

0 Kudos
Message 1 of 6
(6,253 Views)

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?

RF R&D
National Instruments
0 Kudos
Message 2 of 6
(6,174 Views)

That is correct, except that it is the unscaled position, what was calling raw counts or ticks, that is exhibiting the described behavior.

0 Kudos
Message 3 of 6
(6,141 Views)

Does the initial count multiplier change if you switch from X4 to X1 encoding?

RF R&D
National Instruments
0 Kudos
Message 4 of 6
(6,099 Views)

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'?

0 Kudos
Message 5 of 6
(6,069 Views)

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.

RF R&D
National Instruments
0 Kudos
Message 6 of 6
(6,049 Views)