Unable to get Rotary Encoder to work with my Teensy 3.5

Status
Not open for further replies.

semaj4712

New member
I am trying to get my rotary encoder to work with my teensy 3.5 however I am pretty confused, it's been a few years since I have used a rotary encoder, but I don't remember having any issues like this in the past.

So I have a teensy 3.5, and this 7 way switch rotary encoder ... https://opensimracing.com/products/funky-switch-7-in-1

I first wired it up like this...
rot_encoder.jpg

But then upon further reading I think this is more correct, not entirely sure...
rot_encoder_2.jpg

Not sure if either of those are right, because I still cant get anything to work...

Here is the code I am currently working with, however I have tried several different iterations of this...

Code:
#include <Encoder.h>

Encoder enc(8,9);

long current_value;
long previous_value = 999;

void setup() {
  Serial.begin(9600);
}

void loop() {
  current_value = enc.read();

  if (current_value != previous_value) {
    Serial.println(current_value);
    previous_value = current_value;
  }
}


It pretty much always assumes to position is 0, so any help is appreciated
 
Hi Semaj4712,

When I looked at the product webpage you linked to, I saw that the pinout in silkscreen on the shown switch differs from the switch pinout that you showed in the diagram.
Look at the position of the GND pin:

switch pinout.png

Could that be the problem? Do you happen to have a datasheet of the switch?

Regards,
Paul
 
Hi Semaj4712,

When I looked at the product webpage you linked to, I saw that the pinout in silkscreen on the shown switch differs from the switch pinout that you showed in the diagram.
Look at the position of the GND pin:

View attachment 18368

Could that be the problem? Do you happen to have a datasheet of the switch?

Regards,
Paul

Hey Paul, your absolutely correct, I used the larger picture as a reference for the schematic, but on my breakout board, the GND is actually more in the middle like in the picture you posted. I think that is correct since I have no issues with the pushbutton functions
 
Hi Semaj4712,

Did you perhaps measure the encoder pins to see what is happening? A scope is very useful to see the voltages and timing relation between those pins.
With respect to the external pullups; the encoder library also enables the internal pullups on the chip so external pullups shouldn't be necessary [but it wouldn't hurt either to add 3K3's like you showed].

Regards,
Paul
 
Hi Semaj4712,

Did you perhaps measure the encoder pins to see what is happening? A scope is very useful to see the voltages and timing relation between those pins.
With respect to the external pullups; the encoder library also enables the internal pullups on the chip so external pullups shouldn't be necessary [but it wouldn't hurt either to add 3K3's like you showed].

Regards,
Paul

I actually was able to get this to work, I realized that if I swap the GND and PUSH pins on my board, that it actually worked, and then when I reached out to the company, they admitted that they sent me V1 of the boards by accident and the pin labels are backwards.

Everything seems to be working now, although i have not finished my code to make sure.

If I have futher issues I will let you know
 
Thinking this switch may be useful for one of my future projects, I searched further on the internet.
Is this the switch? ALPS RKJXT1F42001.
The circuit diagrams on that page may help you in debugging the circuit.

Regards,
Paul
 
Thinking this switch may be useful for one of my future projects, I searched further on the internet.
Is this the switch? ALPS RKJXT1F42001.
The circuit diagrams on that page may help you in debugging the circuit.

Regards,
Paul

That is the data sheet I had found as well, which fixed a lot of my issues I initially had with the switch.
 
Status
Not open for further replies.
Back
Top