Yes it's correct. What's happening is that the 24-bit counter is rolling over from 0 to its max value of 2^24 -1. You probably
want to see is something like 3, 2, 1, 0, -1, -2, ..., right? You can do that fairly easily in software. The following isn't perhaps the most formal or elegant, but it'll get the job done.
Your count value is stored in an unsigned 32-bit integer datatype, but only bits 0-23 are used. Note that bit 23 is "on" for the largest half of the numbers, the ones we'll want to treat as negative positions.
First convert your count from a u32 to an i32. Then if bit 23 is "on", replace the count with (count - 2^24). Note: the 2^24 constant should be an i32 datatype.
Topic 2. Using a DAQ-STC counter to m
easure position from a quadrature encoder is not a foolproof measurement. Have your read through the tutorial and app note yet?
http://zone.ni.com/devzone/conceptd.nsf/2d17d611efb58b22862567a9006ffe76/6f25cba2cd73417786256869005e5fc3?OpenDocument
If you care about repeatability after back-and-forth moves, or if your system experiences oscillations at the end of motion, you will probably need a true quadrature interface. You can either build the quadrature interface circuit described in the tutorial / app note, or buy a 660x-series counter/timer board which has quadrature built in.
Other advantages of the 660x series are:
- tracks +/- positions on its own without software conversions
- can use index channel for repeatable hardware reset of "zero" position.
The cheaper 6601 can meet your needs for today, but be aware of the following improved features in the 6602:
- 4 additional counters
- 3 DMA channels for buffered operations instead of 1
- 4x higher resolution
on timing (80 MHz vs. 20 MHz)
ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.