The REV through-bore encoder advertises an absolute pulse output with a 1025us period with the pulse time varying from 1 to 1024us, linearly scaling from 0-360 degrees of rotation. This would be great to use, as it reduces required inputs to a single Digital I/O and carries the benefits of a hex-bore absolute encoder (for relatively cheap), but I’m unsure of the best way to take this as input onto the RoboRIO.
I’ve considered a couple methods so far:
-
Use a simple RC low-pass filter to filter the pulsed output to an analog value, and use this as analog input to the RIO. Unfortunately, the signal frequency is low enough that a fast filter would have significant voltage variation, and this feels like a generally hacky solution.
-
Use the
Counter
class in WPILib to measure the rising-rising edge time and the rising-falling edge time and compare them to each other to get the value of interest (as described by Ether and Jared Russel). As I understand it, this would involve instantiating twoCounter
objects in thekSemiPeriod
mode, on the same digital input, settingsetSemiPeriodMode()
totrue
andfalse
on the rising-falling and rising-rising time counters respectively, and taking the ratio ofgetPeriod()
for each, multiplying by 360 to get output in degrees). Not sure if there would be problems with using twoCounter
s on the same digital input, or if the class has nuances to its usage beyond what I know now.
Has anyone else used this encoder, or have any thoughts on usage of its absolute output with the RIO?