Turning a gear-tooth sensor into a quadrature output encoder


Given the problems I’ve had writing working code for direction sensing with the hall-effect sensors in the kit (and apparently Kevin Watson is having the same problems), I was wondering if there was some kind of very simple circuit I could build that translates the different pulse widths into a single digital channel (if 0, forward, if 1, reverse), thus making the programming identical to that of to that of a quadrature encoder.

What about an independently-clocked counter IC? The rising edge of a pulse starts the counting, the falling edge stops it. You could then read the count line corresponding to the highest power of two that differentiates the two types - if you get zero you have a short pulse, if one you have a long one.

I.e. get an 8 bit counter (0-255). Start a count on rising edge. Use an external clock of 1MHz to increment the counter after that. Stop the clock on falling edge. Now read bit 5 (2^6 = 64). If bit 5 is 1, you have been counting for at least 64usec and you know your direction. After reading, simply reset the counter to 0.

Or, is there a way to translate from pulse widths to an analog voltage (like the analog-to-PWM conversion in the RC in reverse?)

My expertise is more in software, so someone with a mind in hardware would probably have a better idea.

If you are interested in an external part, you’d probably be best of with a small microcontroller to handle it for you. Then you can write more software. :wink:


Yeah, I’ve already gone ahead and got it working on a Gumstix module, and I could always run a serial interface over to the RC if I wanted, I was just wondering whether there was some super-simple circuit I was forgetting.

All the same our team isn’t going to use them, most likely, but I was curious more than anything :yikes: :slight_smile:

Building custom circuits out of discreet ICs is kind of passé these days. A bit of Verilog code and a small gate array, like a Xilinx Spartan 3, could easily discriminate between the two pulses. It would be very fun (for me, anyways) if teams got a FPGA demonstration board in the KOP that would allow them to easilly build such circuits.


Leave it to Kevin to bring the control system fashion police into the matter :stuck_out_tongue: