Trouble of retrieving values from absolute encoder

Dear Community,

I am using Arduino Uno and encoder EP50S8-1024-3F-N-5 and trying to read the data from the specified encoder. This model has 13 wires coming from it, where two of them for power supply (V+ and ground), 10 of them is for retrieving data (10-bit resolution), and the last one is shield wire.
Since this encoder uses 5V, I plugged its V+ to Arduino's 5V and ground to Arduino's ground. Moreover, I connected wires responsible for data retrieving to the pins 3-11. I am not quite sure where to plug the shield wire, but in the datasheet of this encoder, as I understand it, it is said that I have to ground it as well.

The code I am using in Arduino:

int pin_state[10];
byte input_pin[] = {2,3,4,5,6,7,8,9,10,11};

template <typename T>
Print& operator<<(Print& printer, T value)
{
    printer.print(value);
    return printer;
}

void setup() {

  Serial.begin(9600);

  for(byte i = 0; i < 10; i++){ 
    pinMode(input_pin[i], INPUT);
  }

}

void loop() {
  ReadEncoderValue();
  delay(1000);
}

void ReadEncoderValue(){
  for(byte i = 0; i < 10; i++){
    pin_state[i] = digitalRead(input_pin[i]);
  }

  for(byte i = 0; i < 10; i++){
    Serial << pin_state[i] << '|';
  }
  Serial << '\n';
}

As a result, the states of the pins are always 0 even if I turn the encoder's shaft.
I think I am doing something incorrectly in wiring, if so, could you point me where I am doing it wrong.

According to a data sheet that I found, the outputs are NPN open collector (N : NPN open collector output). That means that you need pull-up resistors on the Arduino inputs. Try the internal pullups:

pinMode(pin, INPUT_PULLUP);

That encoder has 1024 positions and uses Grey code.

Item specifics
Power supply: 12-24 VDC å±5%
Resolution: 1024
Output phase: GRAY
Control output: NPN

Thanks for your answers. Now, I got what I needed.
To those, who may find this topic interesting, I changed input pins to the following as Mr/Mrs groundFungus suggested:

 pinMode(pin, INPUT_PULLUP);

Afterwards, my Arduino Uno started to read reasonable values, but it wasn't correct Gray code that I needed.
To correct this, the input value has to be inverted:

pin_state[i] = !digitalRead(input_pin[i]); // this is correct
pin_state[i] = digitalRead(input_pin[i]); // this is not correct[color=#222222][/color]

You will nail it now! Have found a Grey code table? The idea is that only one bit changes from one position to the next. Any change indicates a move.

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