PDA

View Full Version : Teensy2.0 and two quad encoders?



albireo13
05-28-2013, 05:35 PM
I am using a Teensy 2.0 to interface to two quadrature rotary encoders.
Each encoder is 2048 CPR. Rotation rate is

I'd like to use 2 interrupts for each encoder. However, the complication is that I also have a BT module
which is connected up to the HW TR and RX pins (7 and 8). These are usually 2 of the 4 HW interrupt pins.

So, my thought is:
1. use one interrupt for each encoder ... pin 5 and 6 ... and use each encoder in one interrupt mode

Is there another way I can run with two interrupts for each encoder, to increase my resolution?

PaulStoffregen
05-28-2013, 05:53 PM
Is there another way I can run with two interrupts for each encoder, to increase my resolution?

Not really. You might try using AltSoftSerial to free up those 2 pins, but the extra interrupt latency might be worse that just using only 1 interrupt per encoder. Definitely DO NOT use SoftwareSerial, because it disables interrupts for much too long.

A Teensy 3.0 might be your best option. It supports interrupts on all pins, and it has 3 hardware serial ports.

albireo13
05-28-2013, 06:27 PM
Thanks Paul. I was afraid of that. I don't want to mess with the serial/BT interface so, I will try and run with 1 interrupt per encoder.
I can always migrate to a Teensy 3.0 if I find I want to increase resolution.
BTW, my encoder max rotation rate is about 0.5Hz, or about 1024 cnts/sec.