08-10-2011 10:43 AM
I am implementing a PCI-6602 counter and am using the function DAQmxCreateCILinEncoderChan() to measure linear position. I would like to use an external pulse to reset the the counter to 0. I would like this to be independent of phase.
Can I set this as equivalent to the ZIndex pulse? If so can I set the argument ZindxPhase so that the reset occurs at any phase of my encoder?
or is there another way to perform an asynchronous counter reset?
Thanks
Solved! Go to Solution.
08-10-2011 11:51 AM
No, you really can't reset the count independent of phase using the z-index reload feature on a 6602. The newer X-series counters provide for a phase-independent hardware-edge-driven count reset, but I'm not certain whether it's available for modes other than simple edge counting.
I'm just piecing together an almost-workaround that'd need an M- or X- series board with digital change detection, but it's kinda convoluted and not for the faint of heart. [Executive summary: extend the z-index pulse for 4 quad states using another counter and the change detect event signal.]
A different pain-in-the-neck workaround would be to parallel wire your encoder to another counter and use the desired z-pulse as a sample clock. You'd need these two encoder tasks to be "arm-start triggered" together to keep in sync. Then neither counter uses z-indexing, but the 2nd counter keeps a record of the positions where the 1st counter *should* have been reset. In post-processing, you can find where the 1st counter passed through those positions and apply the appropriate offsets. See? Told you it'd be a pain...
-Kevin P
08-10-2011 01:21 PM
Thanks Kevin for the prompt reply.
Your idea of a second counter may be what would work best four our app.
I will give it a try today.
08-10-2011 01:56 PM
Kevin,
Taking the 'parallel wire' approach... I could setup a second counter using the DAQmcCreateCILinEncoderChan() function applied to a second task. Can I have 2 DAQmxReadCountF64() functions reading into arrays simultaneously in the same thread?
08-11-2011 01:38 PM
It may depend on what you mean by "simultaneously."
They will be separate tasks buffering at different rates and will need to be read using separate Read calls. Within a given thread, those read calls would have to be consecutive. However, the board & driver will be buffering their captured data simultaneously. That's why the post-processing you'll need to do on the data will still be valid. Just be sure to "arm-start trigger" the tasks off a common hardware signal.
-Kevin P