Incorrect analog readings

Status
Not open for further replies.

deadbird

New member
Hi everyone.

I'm currently having issues reading correct analog values using TeensyLC.

My aim is to read pots values from a joystick. For X axis for instance, center resistance is 5.5kohm, leftmost is 3.5kohm, rightmost 7.5kohm. The resistance is thus very linear.

Problems occurs when reading analog from the teensy, using this code:

Code:
#include <ResponsiveAnalogRead.h>

ResponsiveAnalogRead analog(A8, true);


void setup() {
  Serial.begin(38400);
}

void loop() {
  analog.update();

  int aa = analog.getValue();

  Serial.println(aa);
  delay(20);
}

Still for the X axis, the center values is around 56, leftmost around 5 and rightmost around 750! It's as if the pot was logarithmic...

I feel I'm missing something obvious, but I really can't see what...:confused:
 
The analog inputs should be fed from a low impedance source, otherwise the impedance of the analog input is essentially in parallel with the impedance of the pots used. Either change your pots to a lower impedance value or use a buffer circuit to lower the source impedance.
 
A photo of the wiring might be helpful, along with voltage measurements across the range of travel without the Teensy connected. Responsive analog read should be fine but testing with the default analog read would also be a valid test to rule out something odd buried in the process it uses to smooth output.
 
10K typical for a voltage divider application so that's not it.

GW's point that troubleshooting is best done reading pins directly is valid but also not the problem.

That really only leaves wiring.

What part are you using?
 
....what happens when you pass thru the y axis near the middle of the x?

Could you have the wrong wiper?
 
Still for the X axis, the center values is around 56, leftmost around 5 and rightmost around 750! It's as if the pot was logarithmic...

I feel I'm missing something obvious, but I really can't see what...:confused:

Maybe connect a voltmeter to the pot and watch the actual signal as you turn it.

There are indeed "audio taper" pots made with a response that approximates a logarithmic curve, so they attenuate the signal in a way that makes sense for audio levels. If you have one of those pots, you could indeed be getting a log-like response. Easiest way to check is with a voltmeter and check if you really do get half the voltage when the pot is turned near 12-oclock.
 
Status
Not open for further replies.
Back
Top