Handling 76,000 encoder pulses/s with Teensy?

A while ago, I got this nice and cheap linear stage off eBay, that’s driven by a Faulhaber DC motor (with a 1:262 gear head). The motor also has an encoder coupled to it - and this is where the trouble starts. The encoder is fairly high res (512 pulses per turn) and - at 9000 rpm - generates 76,000 pulses/s. Initially, I looked into controlling the stage with an Arduino, but that doesn’t seem very feasible, as this hits the limit of what the Arduino can handle. I posted this on the Arduino board a while back, and someone suggested flip-flops to divide down the signal, but after briefly looking into it, I found it a bit beyond my hobby/amateur level of skills.

So I shelved the project for while. But recently I came across the Teensy 3.1, and while all it’s capabilities are probably a bit overkill, the 72 MHz CPU speed seemed promising. So, would the Teensy be able to handle the above number of pulses from the encoder (I guess, most frequently, this is implemented by generating an interrupt request per pulse and then incrementing a counter)? Is there any other (Arduino IDE-compatible) micro controller, I should look into (the Due has way too big of a foorprint)?

One thing I’m a bit concerned about, though, is the compatibility of libraries. At a minimum, I’d need one for driving an LCD or OLED display. Are the Arduino libraries usually compatible or are there specific Teensy libraries available?

Thanks!

I would say that it takes at least 30 - 50 instructions to handle each state change / pulse. At 75Kps, that means 3.5 - 4MIPS. Piece of cake for a 72MIPS chip.

However, if your code isn’t efficient, …

The person who suggested dividing down the signal was on the right track. The fact that you’re considering faster devices to process a signal that is higher resolution than you need reinforces this.

I’d say that if you know how to connect a motor to the Arduino, then you can make a divider. This [circuit minus the LED is about as simple a divider as you can get. By selecting an output Q0-Q11, you control how much it divides your input signal. It will take less than two minutes to wire up on a breadboard or solder together.](http://eeeguide1.blogspot.com/2014/10/simple-led-flasher.html)

This circuit minus the LED is about as simple a divider as you can get

Thanks! This is awesome and looks pretty straightforward to put together. The previous suggestions I got, weren't as specific and what I came up with when searching, looked much much more complicated.

dannyf:
I would say that it takes at least 30 - 50 instructions to handle each state change / pulse. At 75Kps, that means 3.5 - 4MIPS. Piece of cake for a 72MIPS chip.

However, if your code isn’t efficient, …

Or, if the interrupt latency variations over time matter.

Some poorly written “Arduino” libraries wreck latency.

I would never attempt 75,000 interrupts/sec on even a 80+MHz Cortex M3/M4. That rate crosses the line of what gets done with hardware pre-processing and what can be all firmware.

I wouldn’t approach this problem using interrupts. The MK20 controller on the Teensy 3.2 has quadrature hardware in 2 of the 3 FlexTimer modules. This would highly reduce the software overhead of dealing with interrupts for every transition in the quadrature output and could easily handle the transition rates you will see when you run your stage at full speed.

You can find more information on it in the K20 subfamily reference manual in section 36.4.25 (page 888): http://www.freescale.com/files/32bit/do … 2SF1RM.pdf

-Bill