Pull Down resistor + potentiometer

Hi,

I build a potentiometer myself and connected it to the GND, 5V and an Analog pin of an arduino Uno like you would do with a regular potentiometer. However, due to the mechanical construction of my potentiometer it could be that the analog pin is suddenly disconnected for a second (just a bad connection) I'm totally fine with this for this setup but I would like to be able to measure when this is happening. At the moment when the analog pin disconects I ofcourse get fluctuating values from analogRead(). How could I make a circuit that when the analog pin disconnects I get a constant value? Normally you do this with a pull-up/down resistor but I don't think this is possible in this case since the analog pin needs to connect directly to the variable resistor right?

If you make your pull down resistor high with respect to your pot it will not make a difference.

The other way to see if it is detected or not is to wire the two ends of the pot to digital outputs. Then put one high and the other low and take a measurement. Then reverse the high and low pins and measure again. If the wiper is connected then the two readings should be complementary.

Another way to check for the wiper connection is to put both digital pins high and see if it reads 1203, then put them both low and see it measured zero. If those two are OK put one high and the other low and take your measurement.

Grumpy_Mike: The other way to see if it is detected or not is to wire the two ends of the pot to digital outputs. Then put one high and the other low and take a measurement. Then reverse the high and low pins and measure again. If the wiper is connected then the two readings should be complementary.

Another way to check for the wiper connection is to put both digital pins high and see if it reads 1203, then put them both low and see it measured zero. If those two are OK put one high and the other low and take your measurement.

Clever...

Do you want a stabile value under the one second break or do you want to know if it's a break?

A simple capacitor can hold the value stabile under a short break. (Sample and hold)

Pelle

Grumpy_Mike: If you make your pull down resistor high with respect to your pot it will not make a difference.

The other way to see if it is detected or not is to wire the two ends of the pot to digital outputs. Then put one high and the other low and take a measurement. Then reverse the high and low pins and measure again. If the wiper is connected then the two readings should be complementary.

Another way to check for the wiper connection is to put both digital pins high and see if it reads 1203, then put them both low and see it measured zero. If those two are OK put one high and the other low and take your measurement.

Thanks a lot for all the answers.

If I may ask another related question. If you connect any potentiometer properly to an arduino it always nicely maps the full range of the potentiometer between 0 and 1024 if its a 10K or 1K or whatever. This is very nice ofcourse but how is it able to do this? Only the analog pin to which it is connected can read values of the resistor but this analog pin is connected to the variable resistance so it could be in the beginning, end, middle or anything in between.... Furthermore multiple parallel circuits could be connected to the 5v and GND pins so it would probably also not be ok to measure the full resistance of the potentiometer at these pins if it was even able to do so. This is maybe a dumb question but I'm starting with this and it would be very helpfull to get some more insights, I couldnt find an anser to this anywhere else. Thanks in advance.

If I may ask another related question. If you connect any potentiometer properly to an arduino it always nicely maps the full range of the potentiometer between 0 and 1024 if its a 10K or 1K or whatever. This is very nice ofcourse but how is it able to do this? Only the analog pin to which it is connected can read values of the resistor but this analog pin is connected to the variable resistance so it could be in the beginning, end, middle or anything in between.... Furthermore multiple parallel circuits could be connected to the 5v and GND pins so it would probably also not be ok to measure the full resistance of the potentiometer at these pins if it was even able to do so. This is maybe a dumb question but I'm starting with this and it would be very helpfull to get some more insights, I couldnt find an anser to this anywhere else. Thanks in advance.

With all 3 terminals connected as previously shown, you have created an adjustable voltage divider. It doesn't matter what the pot resistance value is - you are always measuring voltage on the analog input.

If only one end and the wiper is used, then it will act as a variable resistor.

dlloyd:

If I may ask another related question. If you connect any potentiometer properly to an arduino it always nicely maps the full range of the potentiometer between 0 and 1024 if its a 10K or 1K or whatever. This is very nice ofcourse but how is it able to do this? Only the analog pin to which it is connected can read values of the resistor but this analog pin is connected to the variable resistance so it could be in the beginning, end, middle or anything in between.... Furthermore multiple parallel circuits could be connected to the 5v and GND pins so it would probably also not be ok to measure the full resistance of the potentiometer at these pins if it was even able to do so. This is maybe a dumb question but I'm starting with this and it would be very helpfull to get some more insights, I couldnt find an anser to this anywhere else. Thanks in advance.

With all 3 terminals connected as previously shown, you have created an adjustable voltage divider. It doesn't matter what the pot resistance value is - you are always measuring voltage on the analog input.

If only one end and the wiper is used, then it will act as a variable resistor.

I get that but here is the thing that is unclear to me:

If you have a 1K potentiometer, and you turn it to 50%, 500ohms is mapped to value 512 (since the analog pin gives values between 0 and 1024 by default). When you connect a 10K potentiometer on the other hand and you turn it to 50%, 5K is mapped to 512. So the analog pin somehow needs to know the full resistance of the potentometer in order to be able to do this mapping. How does the analog pin knows the full resistance because it is connected to the wiper and not one of the two end pins of the resistor.

No

The analog input does not not knew the resistans, it’s measure the voltage witch is divided in two halves with the pot at 50%.
The input measure 2,5 volts. (512)

Pelle

No matter what the value of the potentiometer is be it 10 ohms or 10M ohms when the wiper is in the middle it always produces half the voltage across it. And so reading the analogue value will always be half way to the maximum. With a 10 bit A/D this maximum is 1024 and so the result you see is 512.
If you had an 8 bit A/D (maximum 255 ) the reading you would get would be 128.

The analogue input measures voltage not resistance.

You can use Arduino to calculate the resistance value at the pot's wiper. You would need a known resistor (R2) preferably the same value as the pot. I've drawn a circuit to the right. Look halfway down the page here for the formula (resistor divider example). Note that you're still measuring voltage but are calculating the resistance. One end of the pot is not used.

At the moment when the analog pin disconects I ofcourse get fluctuating values from analogRead(). How could I make a circuit that when the analog pin disconnects I get a constant value?

There's no simple hardware solution. But you can do it in software. What do you get when wiper is open? 0V?? Use an IF statement to determine when wiper is open. If open, then use previous measurement.

At the moment when the analog pin disconects I ofcourse get fluctuating values from analogRead(). How could I make a circuit that when the analog pin disconnects I get a constant value?

If R1 and R2 are equal;
In the previous circuit, the voltage would jump to 0V if the connection to the wiper disconnects.
If R1 and R2 are swapped in the previous circuit, the voltage would jump to 5V if the connection to the wiper disconnects.
With this circuit, the voltage would jump to 2.5V if the connection to the wiper disconnects.

dlloyd: With this circuit, the voltage would jump to 2.5V if the connection to the wiper disconnects.

...also if the user twists the knob all the way to minimum.

Gerry48: What do you get when wiper is open? 0V??

No you don't get 0V because the charge is still on the input capacitor of the A/D. What you get is a floating input which can give any reading.

But you can do it in software

Not in the way you described.

There's no simple hardware solution.

Yes there is see my previous answer.

...also if the user twists the knob all the way to minimum.

True.

Also, if a disconnect happens at the wiper terminal (arrow symbol), it would jump to 2.5V (for R1 = R2) regardless of wiper position.

I guess an advantage with both circuits would be that it wouldn't create a floating condition as the signal would jump to a known value.

Another advantage is that its easy to check the condition of the pot. If there's jumpy readings as the wiper is turned, this would indicate a worn or partially worn wiper or defective pot.