mikemontauk
Active member
[Hardware - Teensy LC w/ Bourns PEC12R-2120F-S0012 quadrature encoder; encoder to Teensy LC pins 21 and 12; filter circuit for the encoder is per the datasheet]
When I upload the code attached a clockwise turn of the encoder one increment (detent) yields -4 in the serial monitor, as expected from a quadrature encoder. However, when I uncomment the code for the SSD1306 display, the same experiment yields -3.
Expected output (with the display code commented out):
Concerning output (with the display code included):
The scope seems to indicate the same signals on pins 21 and 12, regardless of the display code being excluded or included:
Display code included; 1 clockwise detent increments to -3, not -4:
Display code excluded; 1 clockwise detent increments to -4, as expected:
I first identified this issue on a custom MKL26Z64VFT4 board with the teensy bootloader, and then reproduced it on a genuine Teensy LC.
This issue does not occur if I use, for example, pins 20 and 21 for the encoder. Furthermore, using "#define ENCODER_OPTIMIZE_INTERRUPTS" did not seem to change anything.
In view of all of the evidence above, my assumption is that some part of the display code (such as the SPI, SSD1306, or GFX bits) is/are initializing pin 12 for MISO and maybe that is affecting the use of that pin for the encoder?
Any input would be greatly appreciated.
When I upload the code attached a clockwise turn of the encoder one increment (detent) yields -4 in the serial monitor, as expected from a quadrature encoder. However, when I uncomment the code for the SSD1306 display, the same experiment yields -3.
Expected output (with the display code commented out):
Concerning output (with the display code included):
The scope seems to indicate the same signals on pins 21 and 12, regardless of the display code being excluded or included:
Display code included; 1 clockwise detent increments to -3, not -4:
Display code excluded; 1 clockwise detent increments to -4, as expected:
I first identified this issue on a custom MKL26Z64VFT4 board with the teensy bootloader, and then reproduced it on a genuine Teensy LC.
This issue does not occur if I use, for example, pins 20 and 21 for the encoder. Furthermore, using "#define ENCODER_OPTIMIZE_INTERRUPTS" did not seem to change anything.
In view of all of the evidence above, my assumption is that some part of the display code (such as the SPI, SSD1306, or GFX bits) is/are initializing pin 12 for MISO and maybe that is affecting the use of that pin for the encoder?
Any input would be greatly appreciated.