Absolute rotary encoder results in serial output noise

I’ve only been dabbling with Arduinos for a few months and am hopefully making a rookie mistake. Any suggestions would be appreciated.

I picked up a used Omron Absolute Rotary Encoder (E6CP-AG3C/open collector output) on EBay.

I wired it as shown and had no problem programmatically decoding all 256 positions. All seemed good, but when the encoder is powered serial output quickly and increasingly becomes garbled. It is as if about 60% of the characters have a bit randomly flipped.

This ‘serial noise’ occurs even with the simplest sketches, no interrupts, very low resource usage, and little serial traffic. I see the issue even with old sketches that don’t even use the encoder. The traffic could be as little as sending just a few characters such as ‘ATXX’ and getting back a few character reply such as ‘OK.’

The encoder output is open-collector. I set the 8 input pins to INPUT_PULLUP and wired the encoder outputs directly to each pin. The encoder and Arduino are both powered by a common power supply with a labelled rating of 12V/1.8A. Any suggestions?

Thanks,

Corrected the diagram to show the encoder's ground is from the Arduino.

More side effects…

To recap, I have a used 256 position absolute rotary encoder. It has 10 wires: power supply+, ground, and 8 open-collector outputs, one for each bit. I’m leveraging the Arduino’s internal pulls ups for the inputs. It works and I can consistently decode all 256 positions but I’m seeing lots of crippling side-effects when the encoder is powered. These include

  1. Random bit-level corruption on bidirectional serial traffic (~60% of characters)
  2. SD card access issues - slow or fails to initialize, read data corruptions
  3. Errors/timeouts even when uploading sketches

If I disable the encoder by simply disconnecting one wire, it’s power + , the side-effects immediately disappear. The encoder is powered by the same supply as the Arduino and I’ve tried both connect the encoder’s ground to the Arduino ‘s ground (updated attachment wiring) and to the power supply ground (original attachment wiring.)

Last observation. Measuring the current on the encoder’s ground wire I see variations depending on the encoder position. The current range from as little as 20ma to 124ma. This is likely proportional to the number of bits that happen to be active for specific position. To simplify I upload this basic sketch.

#include <SD.h>

void setup() {
 pinMode(44, INPUT_PULLUP);
 pinMode(45, INPUT_PULLUP);
 pinMode(46, INPUT_PULLUP);
 pinMode(47, INPUT_PULLUP);
 pinMode(48, INPUT_PULLUP);
 pinMode(49, INPUT_PULLUP);
 pinMode(50, INPUT_PULLUP);
 pinMode(51, INPUT_PULLUP);
 
 Serial.begin(19200);
 while (!Serial) {};

 while (!SD.begin(53)) {
   Serial.println("ERR");
   delay(1000);
 }
}

void loop() {
   Serial.println("OK");
   delay(1000);
}

If I rotate the encoder so its current draw is less than about 45ma and reset, I see OK’s. It I then rotate it so the current draw is about 60ma or greater and hit reset I see endless ERR’s. As these ERR’s repeat I see the current fluxuating seemingly rhythmically between wherever it started at, and about 20ma. Rotating the encoder to a position with lower current and the ERR’s switch to OK’s.

Try powering the encoder from the 5V output on the Arduino.

Thanks for the suggestion, but I believe I discovered my error and as expected, a rookie mistake.

I started measuring current as I disconnected each encoder output and observed that the current was steady at 24ma regardless of the encoder position as long as the encoder's 2^6 and 2^7 outputs were not connected. These two were wired to pins 50 and 51 respectively.

I didn’t realize that 50 and 51 were also connected to the ICSP for MISO/MOSI. I have an SD Card reader on the ICSP pins. Setting 50/51 to INPUT_PULLUP and feeding them data from the encoder was apparently causing the side-effects. Moving the encoder to pins 32-39 resolved the issues.