05-31-2018 03:44 AM - edited 05-31-2018 03:47 AM
Hi there!.
I have a project where I use 2 quadature encoders.
Im looking into building an solution, that tracks how much further one quadature encoder have driven than the other at a specific time.
I know the simple solution is to implement just 2x counters and measure the diffrence between those 2, but I would like a bit more of "resolution".
What I essentially want be able to track how much the phase have shifted between the 2 systems, since this gives me an higher resolution than what my encoders provide, since the phase shift between the systems is not tracked in "counts" but offset in position between the pulses.
Does anyone have a good idea how to implement this? It will be used to track the heading of an small vehicle where the encoders are attatched to the wheels.
05-31-2018 08:46 AM
Many of NI's DAQ boards have counters that support a measurement mode known as "two edge separation measurement". That'll be the right place to start, but there are going to be some gotchas to watch out for.
A buffered task will let you track a time history of this phase difference, but the units won't really be "phase", they will be a delta time. At constant speed they're proportional of course, but with variable speed a single delta time measurement will tell you less than you might want.
The other gotcha arises whenever the phase crosses over multiples of 360 degrees (again, I'm talking about the actual physical phase angle, your measurement is still merely in time units.) The way two-edge separation works is that you define an edge which marks the start of the time interval and another signal edge which marks the end. Let's imagine the case where phase is increasing rapidly, and the previous measurement was approaching 360 degrees equivalent worth of time. Soon, that phase will cross 360 but your measurement won't see that. Instead it's going to measure something much closer to 0 degrees equivalent worth of time. Why? Because the quadrature encoder whose edge was expected at, say, 365 degrees worth of time also already produced the same polarity edge at 5 degrees worth of time. And that's the one whose measurement got captured.
Each time phase crosses a 360 deg boundary, this kind of thing will happen. This can sometimes be post-processed pretty readily (look for the "Unwrap Phase" function), but if you ever have a speed difference where phase changes by 180 degrees or more between samples, you will *not* be able to know whether it increased or decreased.
So that's the other big gotcha. With 4 counters (X-series boards have enough) you could "do it all". 1 to measure this phase-like time difference. 1 to measure freq or period (which allows you to calc actual phase). 2 to measure quadrature position (to remove ambiguity during large phase shifts).
-Kevin P