Teensy 4.x H/W Quadrature Encoder Library

I want to use the QuadEncoder + Interrupts on PinA and PinB. It seems that switsching the Pins (2 and 3) with the XBAR to the encoder disabled the interrupts and vice versa, attaching interrupts to the Pins, disables the QuadEncoder. The later blocks the former.

Any idea to habe Filtering of the QuadEncoder and Interrupt response on the signal transition (without applying the signal to two Pins)?

Best regards

Edmund

Not really sure what you are asking. But if the question is if you can attach an interrupt to same pins as you are using while you are using the encoder library the answer is no. The library uses it own set of interrupts to determine when the triggers are set.

The library provides filtering capabilities as illustrated in the QuadEncoder Example.

You might want to check this thread out on how to set up an interrupt based on a compare value: QuadEncoder Compare Interrupt
 
OK, thank you. As far as I could see that is not described on the teensy homepage or in your library, maybe it should be added.

Anyhow the library works very well for me and the filter function makes it very stable for high speeds.
 
is it possible to use 6 quadrative encoders on a T4.1 ?

how does it work ? does the t4.1 have 2 processors and one of them is dedicated to counting pulses ?
 
is it possible to use 6 quadrative encoders on a T4.1 ?

how does it work ? does the t4.1 have 2 processors and one of them is dedicated to counting pulses ?

You can get the library and its examples, etc. from the github link below. The T4.1 has only one CPU, but it also has many peripherals, including several types of timer that can count pulses or measure periods, and one particular type of timer called QuadTimer that can do quadrature up/down counting on the basis of A and B signals from an encoder. It looks like the library supports only 4 instances, but I'm not sure if that is the absolute limit. Still, if you use this library for 4 of your 6 encoders, that should help a lot. Use QuadEncoder for whichever encoders have the highest resolution and speed, and use the Encoder library for the slower ones. There is a link to the T4.1 processor reference manual at the bottom of the T4.1 product page at pjrc.com. I highly recommend at least looking through the table of contents to get a sense of the capabilities, and then read the section on QuadTimer.

https://github.com/mjs513/Teensy-4.x-Quad-Encoder-Library
 
Hi Joe,

thank you for the prompt reply - i like your idea to improve performance using 4 of the 6 encoders with this library

i will do some reading :)
 
is it possible to use 6 quadrative encoders on a T4.1 ?

how does it work ? does the t4.1 have 2 processors and one of them is dedicated to counting pulses ?

joepasquariello said:
It looks like the library supports only 4 instances, but I'm not sure if that is the absolute limit.
The IMXRT1062 has a only 4 hard wired quad encoders built in so the library was built that limit. So yes its a hard limit on the library
 
Hi mjs513

I'm having a curious issue with this library when definint phase A as pin1 and phase B as pin 3 on a Teensy 4.1.

The signal and phase offset looks good on the scope (there is overshoot and a little ringing) but it only randomly counts +- a count occasionaly.

DS1Z_QuickPrint19.png

If I define pin 2 to be phase A the whole lot works fine.

I have changed the teensy 4.1 to make sure it is not a hardware issue and the problem occurs with both.

I note that UART1 default Tx is also Pin1. I am not using this UART but I am wondering if I need to disable that mapping somewhere in case that is keeping pin1 defined as an output somehow?
 
Hi mjs513

I'm having a curious issue with this library when definint phase A as pin1 and phase B as pin 3 on a Teensy 4.1.

The signal and phase offset looks good on the scope (there is overshoot and a little ringing) but it only randomly counts +- a count occasionaly.

View attachment 30800

If I define pin 2 to be phase A the whole lot works fine.

I have changed the teensy 4.1 to make sure it is not a hardware issue and the problem occurs with both.

I note that UART1 default Tx is also Pin1. I am not using this UART but I am wondering if I need to disable that mapping somewhere in case that is keeping pin1 defined as an output somehow?

That really is strange. I just did a simple setup with a KY-040 rotatary encoder attached to pins 1 and 3 to try and duplicate. I then ran the simple encoder example and it did not have a problem working:
Capture.PNG

You could try telling it to use pullups:
Code:
QuadEncoder knobLeft(1, 1, 3,1);
to see if it helps.

Also could be something in the sketch or your hardware? Does it work with Paul's Encoder library?
 
The Encoder example available from the Arduino list works just fine, is this using your library?

If so, there is obviously something in my project screwing things up.... will need to dig around and look for anything playing with pin 1...
 
The Encoder example available from the Arduino list works just fine, is this using your library?

If so, there is obviously something in my project screwing things up.... will need to dig around and look for anything playing with pin 1...

The example above is using the QuadEncoder Library.
 
Back
Top