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.