Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 14 of 14

Thread: Rotary encoder find

  1. #1

    Rotary encoder find

    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)

    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?

  2. #2

  3. #3

  4. #4
    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?

  5. #5
    Senior Member vjmuzik's Avatar
    Join Date
    Apr 2017
    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)

  6. #6
    Senior Member
    Join Date
    Feb 2016
    With a crisp image, google translate is helpful for this sort of stuff.

  7. #7
    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.

  8. #8
    #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() {
    while (!Serial) {}
    Serial.println("Encoder Test:");

    long positionLeft = -999;

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

    if (Serial.available()) {;
    Serial.println("Reset both knobs to zero");

  9. #9
    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.

  10. #10
    Senior Member
    Join Date
    Oct 2015
    Roma (IT, EU)
    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.

  11. #11
    Senior Member
    Join Date
    Feb 2016
    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.

    //wire channels a and b to inputs 0 and 1
    void setup() {
    void loop() {
    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.
    //wire channels a and b to inputs 14 and 15
    void setup() {
    void loop() {
    Click image for larger version. 

Name:	teensyScope.jpg 
Views:	56 
Size:	45.2 KB 
ID:	20131
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	1.jpg 
Views:	82 
Size:	110.7 KB 
ID:	20129   Click image for larger version. 

Name:	3 (.jpg 
Views:	72 
Size:	107.5 KB 
ID:	20130  

    Last edited by Gibbedy; 05-16-2020 at 04:38 PM.

  12. #12
    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
    Click image for larger version. 

Name:	20200517_175035.jpg 
Views:	89 
Size:	155.6 KB 
ID:	20161

    This pic i rotated it slightly and then let it sit still
    Click image for larger version. 

Name:	20200517_175111.jpg 
Views:	85 
Size:	132.8 KB 
ID:	20162

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


  13. #13
    Senior Member
    Join Date
    Oct 2015
    Roma (IT, EU)
    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.

  14. #14
    Yeh its going crazy, after i put the delay on there it showed that pattern.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts