Reading analog encoder data incomplete

Hi guys!

I’m having troubles trying read the datas of an analog encoder. Simply, I connect a encoder to Arduino and read his datas using analogRead function. The normal behaviour would be get datas between 0 and 1023, but this never happen. I have twelve equals encoders and I the behaviour is the same with all.

These are the problems I can see:

  • The value never reach 0 or 1023, instead of this, for example, the value return 23 and 997 as min and max value respectively.
  • The range is not the same in each sensor.
  • The min and max value of the range of a sensor change in execution time. This do impossible work with the sensor correctly.

After research, do tests and ask a lot, I used a generator to get a constant voltage of 5v. Beside, I put three condensers: one of 470uF, other of 1uF and one of 1uF of tantalum between GND and Vin (I use Vin to get a constant voltage using the generator). After of all this, the behaviour is the same, even seeing with a multimeter that the voltage that out from Vin is 5v.

What can be happening?

This is the encoder that I’m using

Thanks for the help,
Greetings!

Research will show you the Vin pin is for 7 to 12 volts. 5 Volt supply goes to the 5 volt pin. If you use 7-12 volts to power the Arduino, then the 5 volt pin will supply the 5 volts for your encoder.

Also, the encoder will supply 4090 steps as opposed to the Arduino only able to make 1024 steps. Is this ok?

Paul

Post a hand drawn wiring diagram, as your description of the wiring is not clear. Did you connect the grounds?

Thanks for the answers. I’m going to respond between lines:

Paul_KD7HB:
Research will show you the Vin pin is for 7 to 12 volts. 5 Volt supply goes to the 5 volt pin. If you use 7-12 volts to power the Arduino, then the 5 volt pin will supply the 5 volts for your encoder.

Also, the encoder will supply 4090 steps as opposed to the Arduino only able to make 1024 steps. Is this ok?

Paul

Sorry, I didn’t explain enough well. I connect the power to Vin with a volt highest than 7 volts, then the encoders are fed through the 5V pin.

On the other hand, yes, I know that Arduino only read 10 bits. In fact, I bought the Arduino Due that it can read until 32 bits, but I didn’t know that Arduino Due can only give until 3.3 volts and the encoders need 5 volts, so I can’t use the Arduino Due and I assume that Arduino is working on 10 bits.

jremington:
Post a hand drawn wiring diagram, as your description of the wiring is not clear. Did you connect the grounds?

I don’t have a schema, but I’ve done a wiring’s picture. In the picture, I’m using six encoders, where them grounds and voltages pins are connected and united in a cable respectively. The black cable supply the voltage to the Vin pin, the red cable is use to the Arduino’s ground, the gray cable is use to the encoders’s ground and the orange cable is use to supply voltage to the encoders.

I hope this info is useful.

Thanks again,
Greetings!

jcorfer:
These are the problems I can see:

  • The value never reach 0 or 1023, instead of this, for example, the value return 23 and 997 as min and max value respectively.
  • The range is not the same in each sensor.
  • The min and max value of the range of a sensor change in execution time. This do impossible work with the sensor correctly.

The first two issues are to be expected - you need to calibrate each encoder, they are just carbon-film potentiometers inside I suspect.
The last issue suggests you are not using the Arduino 5V as the sensor reference voltage, and you need to
for best accuracy as the ADC is ratiometric to the 5V rail (unless you use AREF pin and analogReference(EXTERNAL))

MarkT:
The first two issues are to be expected - you need to calibrate each encoder, they are just carbon-film potentiometers inside I suspect.
The last issue suggests you are not using the Arduino 5V as the sensor reference voltage, and you need to
for best accuracy as the ADC is ratiometric to the 5V rail (unless you use AREF pin and analogReference(EXTERNAL))

Thank you for the answer.

It's assumed that the encoders are absolute hall effect, so that shouldn't be necessary calibrate. After read your answer, I've done tests using a generator of 5 volts and AREF pin, also I changed the code adding the analogReference(EXTERNAL) function in setup function. The values that I get from encoders keep being incompletes.

I've could see two stranger behaviour:

  • The voltage that come to AREF pin is 4,98v, and the voltage that out from 5v pin is 4,81v. I've done tests with the condensers and without they, and the result is the same. Besides, if I remove the USB input, the voltage that come to AREF pin is 4,8v and the voltage that out from 5v pin is 3,510v.
  • In executing time, if I change the position of the encoders stem, also it change the min and max value of the range of each encoder.

These behaviours are very stranger, I'm staying without ideas about what is that happening and even less about how fix it.

Thanks for the help, hopefully we can find a solution.
Greetings!

jcorfer:
Thank you for the answer.

It's assumed that the encoders are absolute hall effect, so that shouldn't be necessary calibrate. After read your answer, I've done tests using a generator of 5 volts and AREF pin, also I changed the code adding the analogReference(EXTERNAL) function in setup function. The values that I get from encoders keep being incompletes.

I've could see two stranger behaviour:

  • The voltage that come to AREF pin is 4,98v, and the voltage that out from 5v pin is 4,81v. I've done tests with the condensers and without they, and the result is the same. Besides, if I remove the USB input, the voltage that come to AREF pin is 4,8v and the voltage that out from 5v pin is 3,510v.
  • In executing time, if I change the position of the encoders stem, also it change the min and max value of the range of each encoder.

These behaviours are very stranger, I'm staying without ideas about what is that happening and even less about how fix it.

Thanks for the help, hopefully we can find a solution.
Greetings!

AREF should be never be higher than Vcc, that can fry the chip.