Originally Posted by Jared341
There are many ways that one could implement a 1x quadrature decoder.
For a few reasons, a 1x decoder that requires a transition on both phases prior to incrementing the count is advantageous (namely, it can discriminate between the constantly changing direction vs. constant direction case).
Ok, lets get specific. When we write our own interrupt encoder routines, the B channel is just looked at when a TEU pulse occurs on the A chan to get the direction. However, the tcounters in CRIO are a bit of a mystery to me still and I need some more tutoring.
Here, the upSource is A chan and the downSource is B chan. This is called by encoder.cpp.
Counter::Counter(EncodingType encodingType, DigitalSource *upSource, DigitalSource *downSource, bool inverted)
wpi_assert(encodingType == k1X || encodingType == k2X);
if (encodingType == k1X)
SetUpSourceEdge(true, false); // THis is clear to me
SetUpSourceEdge(true, true); // This is clear to me
SetDownSourceEdge(inverted, true); // This needs explanation
As I understand it, the tcounters have independent sources than can be set to count up or down. How does setting the B chan to always count down on a TED and down on TEU if inverted=true set up the counter to give the proper direction?