FYI: interfacing E38S6G5-600B-G24N 600P/R rotary encoder

This is an FYI, sort of a post-mortem. TL;DR: supply >5V and specify INPUT_PULLUP.

E38S6G5-600B-G24N is an industrial 600 pulse/revolution A/B bi-phase rotary encoder; this product, among many like it, are used for building DIY racing wheel controllers for its higher resolution compared to garden variety potentiometer-like incremental encoders. Interfacing wise, works mostly the same. The only differences are that it needs 5V-24V power input, and that the output is "NPN-type" which necessitate pullups. Internal pullups in AVR suffices for that.

I had one that didn't seem to work at first, and came across this thread-> Racing Wheel Rotary Encoder whont work in which the user sadly gave up using this part. Since that thread is long locked and there are not much information for this part in the first place, I decided to drop some information here.

As said in TLDR, this part require 5-24V input, and 5V means 5V; it can't be substituted with 4.975V or whatever from Arduino. This is not a forgiving part like typical 5V components that states min/typ/max = 3.7/5.0/7.2V in DC characteristics, it works from 5.0V.

To generate "more than 5 volts", a simple voltage doubler can be used e.g. -> operational amplifier - Op amp based DC-DC voltage doubler - Electrical Engineering Stack Exchange , just feed it voltage from 5V pin and analogWrite(13, 127). I used 1N4148 for diodes, 47uF for C1. Larger is better. It will be less than 10V and not a clean one at all, but it should work. It may be supplied with 12V from other sources just fine. Do not feed that 12V through external pullup resistors though, for it burns inputs on Arduino.

I'm hoping this will help others in the future.

1 Like

Thank you! I had the exact same issue with an ESP32 and the E38S6G5-600B-G24N rotary encoder.

I had 4.750V on the supply pin, and as you mentioned, this is not 5V.

I wanted to use the simple capacitive voltage doubler, but didn't have the correct components to hand, so I had to use a LM317T to adjust another supply voltage and use a logic level converter to read.

I'm only getting values 0-3 though...which doesn't seem right.

Could you share your code, please, if possible?

EDIT: The problem was that I failed to understand the example code provided by the vendor and adapt it to my platform.


  pinMode(2, INPUT_PULLUP); // internal pullup input pin 2 
  
  pinMode(3, INPUT_PULLUP); // internalเป็น pullup input pin 3
//Setting up interrupt
  //A rising pulse from encodenren activated ai0(). AttachInterrupt 0 is DigitalPin nr 2 on moust Arduino.
  attachInterrupt(0, ai0, RISING);
   
  //B rising pulse from encodenren activated ai1(). AttachInterrupt 1 is DigitalPin nr 3 on moust Arduino.
  attachInterrupt(1, ai1, RISING);

In this block, the A and B lines need to be set up as input (pull-up high) with interrupts attached to rising changes. I found better stability using BOTH instead of RISING. Not sure if that is correct though.

Can i just put 12v into encoder Vcc from other source and ground? Also do i need to do something about data cabels (A and B) when i would connect them straight to arduino pins? Some type of resistor or idk? I tried everything to get this encoder working but to no avail so this is the last change when i would just give up.

1 Like

Yes you can as long as your grounds are connected together. As far as the rest of your question (what pins to connect A and B to) I can tell you I've interfaced with encoders before and the statement regarding A and B lines going to interrupts is a MUST. You cannot attempt to poll these. So you can connect them straight to Arduino pins, but those pins must be external interrupt pins (preferably using different interrupt vectors for efficient and fast interrupt code)

From jack828's reply it sounds like the A and B lines are just open collectors (and also that is what the webpage shows). This means interfacing it to any voltage level just requires a pull up to that voltage and the amount of current going into your MCU pin will be (Volts / Resistance).

This also means you can possibly get away with just using the MCU's internal pull up resistors depending on rpm speed of encoder and length of the A and B line wires. The higher the speed and/or the longer the wires the more likely you will need external pull up resistors instead (10k max, ~3k min). Make sure to turn off the internal pull up resistor if you are using an external one. You basically need the resistance to be as high as possible while still producing a stable signal at all rpm speeds.

I personally like to 'temporarily' use a potentiometer for the pull ups (one for each line). To start, set them to their highest resistance (or 10k whichever is less). I then setup the encoder with something to spin it to approximately the fastest it will need to be read at (if you can precisely set the rpm, this is by far the best way to do it). I then use an oscilloscope to look at the waveform and adjust the potentiometer until I get just enough of a square wave to consistently trigger the interrupt (or the resistance is higher than 10k at which point you just use 10k). If you don't have an oscilloscope you'll have to do this via firmware and output the calculated rpm to see if it matches. Regardless of method, once you get it stable...just check what resistance the potentiometer is set to and replace it with the closest match resistors.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.