Is there anyway to read the voltage directly instead of AnalogueRead?

Hi, I'm attempting to use a potentiometer to measure angular position of a stepper motor in order to catch skipped steps and avoid losing positioning accuracy. My issue is that analogueRead returns max value of 1023 when the pot output voltage >= 4.3v, the 5v pin outputs roughly 4.73 volts so this means the upper portion of the pot (4.3-4.73v) is all read as 1023.

Is there a way to directly read the voltage so that I can compare it with the reference voltage being supplied to the pot input pin? Im using a Teensy 4.1, if that changes anything. my next option would be to only use the inner portion of the pot angular range and thus avoid the outer limits where this issue occurs, this would work but unfortunately decrease my useable range of motion.

Add a series resistance ?

From the Teensy 4.1 product page

Analog Range
The analog input range is fixed at 0 to 3.3V. On Teensy 4.1, the analogReference() function has no effect. The analog pins are not 5V tolerant. Do not drive any analog pin higher than 3.3 volts.

You can use a voltage divider to reduce 5V to the acceptable 3.3V range. Suggest 10K between 5V and analog input, 20K from analog input to GND.

Easier to just power the pot from 3.3volt.
Leo..

Hi,
Please note that most potentiometers have ends of their tracks that do not change resistance for their start and end.
A 270 degree pot may only show a change in resistance over 260 degrees.
The first 5 degrees showing some low fixed value and the last 5 degrees showing some high value, near the maximum value quoted for the potentiometer.

Hop-on and Hop-off resistance

At the start and end of travel, the resistive track of a potentiometer is connected to low resistance metal parts which connect the resistive element to the end terminals. The change in resistance when the wiper enters or exits the resistive track is known as the hop-on and hop-off resistance.
(https://eepower.com/resistor-guide/resistor-types/potentiometer/#)

A 10K pot is not exactly 10K, in fact the cheaper the pot, the bigger the discrepancy.

@confused_but_eager , can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.

Tom.. :smiley: :+1: :coffee: :australia:

@jremington Thanks for the reminder, I had forgot that the teensy is a 3.3v controller. Changed pot input to 3.3v and things are much better now.

@TomGeorge Thanks for info, after changing to the 3.3v the pot is working much better. As you mentioned the entrance and exit of the track does seem fixed but is a very small range.