Rotary encoder find

Status
Not open for further replies.

Dulz

Active member
Hi everyone, i found this rotary encoder at work and would like to attempt to read it.

The details i can make out are:

Matsushita ER24 (from research i believe is panasonic)
AER12122

The instructions i will post a photo, but they are all in what i assume is Japanese.

My fist issue is, does anyone know how to wire this thing up? With unreadable instructions and i cant seem to find anything online, its a pretty big first hurdle!

Second, any advice on which teensy would be best used? I think from memory the 3.6 could count seperatly to the main code? Is that correct? And if so do they all do that?
 
20200513_161400.jpg20200513_161411.jpg20200513_161414.jpg
 
From what i can see on the instructions, it says 12v-24v. I'm assuming that is the red wire? I also am assuming that the others are signal wires and that they wouldn't need 12v?
 
Based on some other forum post I found from Russia

The outputs are open collector so they just need pulled up to the appropriate voltage for the microcontroller, in this case 3.3v for the Teensy 3.6
Red: 12v-24v
Black: 0v or Ground
Shield: Ground
White: A
Green: B
Yellow: Z (optional)
 
Hi Guys, thanks for your replys. I have had a go at connecting it to a teensy 3.6 using the wiring vjmuzik gave above.

It appears to be counting, however only counting upwards. If i spin it either way then it goes up. Any thoughts on why? I will post the code in my next reply.
 
#define ENCODER_OPTIMIZE_INTERRUPTS
#include <Encoder.h>

// Change these pin numbers to the pins connected to your encoder.
// Best Performance: both pins have interrupt capability
// Good Performance: only the first pin has interrupt capability
// Low Performance: neither pin has interrupt capability
Encoder knobLeft(9, 10);
// avoid using pins with LEDs attached

void setup() {
Serial.begin(9600);
while (!Serial) {}
Serial.println("Encoder Test:");
}

long positionLeft = -999;

void loop() {
long newLeft;
newLeft = knobLeft.read();
if (newLeft != positionLeft) {
Serial.print("Left = ");
Serial.print(newLeft);
Serial.println();
positionLeft = newLeft;
}

if (Serial.available()) {
Serial.read();
Serial.println("Reset both knobs to zero");
knobLeft.write(0);
}
}
 
I put a 10k pullup resistor to pins 9 and 10, which really smoothed it out, otherwise it was going crazy counting when it wasnt even spinning. But only counts up.
 
Do you have access to a logic analyzer or a 2-channel oscilloscope?
It would be useful to see the waveform on A and B while rotating in the two directions.
 
You could use the teensy and the arduino IDE serial plotter as a logic analyser.
Turn the encoder and take a photo. It's not ideal but here you can see two good channels.
Reversing the encoder will show reversed color order.

Code:
//wire channels a and b to inputs 0 and 1
void setup() {
  
 pinMode(0,INPUT_PULLUP);
 pinMode(1,INPUT_PULLUP);
}

void loop() {
  
  Serial.print(digitalRead(0));
  Serial.print(",");
  Serial.println(digitalRead(1));
}

Although I expect you will only be getting one channel.
Note my cheapy encoder here uses White for VCC and Red as A signal. If I were to wire it up incorrectly I expect at the least I would blow one of the channels.

Edit: You could wire your channels to an analog pin and then you have a teensy oscilloscope.
Code:
//wire channels a and b to inputs 14 and 15
void setup() {
  
 pinMode(14,INPUT_PULLUP);
 pinMode(15,INPUT_PULLUP);
}

void loop() {
  
  Serial.print(analogRead(14));
  Serial.print(",");
  Serial.println(analogRead(15));
}

teensyScope.jpg
 

Attachments

  • 1.jpg
    1.jpg
    110.7 KB · Views: 104
  • 3 (.jpg
    3 (.jpg
    107.5 KB · Views: 93
Last edited:
Thanks for the replys guys,

I played around a bit longer yesterday and was able to get it reading both ways by putting a capacitor in the line with a pullup resiter as well, however i wouldn't say it was a reliable read, every turn i could get different results and going backwards read about 20% less than going forwards.

So today I tryed the make your own oscilloscope idea, and my results definitely look different to the ones you posted. I will post pictures. It was going crazy just sitting there, so i put a delay(100) in there to try and see what was happening. The photos have the delay.

This pic the encoder was just sitting still
20200517_175035.jpg

This pic i rotated it slightly and then let it sit still
20200517_175111.jpg

There was no capacitor or pullups when i ran this test.

Jason
 
So in the first picture, the encoder was not moving? And yet, there's a pulse on one of the 2 lines (A or B)...!?
That's odd. I have no idea, have to pass.
 
Status
Not open for further replies.
Back
Top