# Newbie question: How to use a potentiometer with just one fixed end to generate voltage?

#### popcalent

Joined Mar 17, 2018
128
I suspect this is basic, but I can't figure it out....

I have a potentiometer that I only have access to the variable end and one of the fixed ends [1]. I want to use it to feed an ADC. The potentiomenter is supposed to be 1M, but in reality it measures between 815 and 840K (and between 50 and 80Ω on the other end). I tried using a voltage divider. With 5V and an R1=390K resistor, the voltage that goes into the ADC ranges approximately between 0V and 2.5V [2]. If I keep making R1 smaller, and smaller, to get closer to 5V, there's a point where it gets stuck at 4.60V (unless I use really small resistors, which get really hot), and it never reaches 0V on the other end. Also, with small resistors, the voltage doesn't change when I turn the pot, until it suddenly changes from one extreme to the other...

There must be an easier solution to work this out... Help, anyone? Thanks!

[1] It's the Atari Paddle. Only the variable end and one of the fixed ends are wired into the DB-9 connector. Ripping the Paddle to gain access to the other fixed end is out of the question because I want this to work with any Atari Paddle, not just with an altered one.

[2] The ADC I'm using is the ADC0804. I haven't look at it much yet, because I'm working on fixing this other issue first. Is it possible that the ADC0804 has a way of telling it that the maximum voltage is 2.5V, and therefore 2.5V should be 0xFF?? Is that the function of the Vref pin? If that's the case, that would make everything simpler, but I'd still like to know how to do the other thing.

#### WBahn

Joined Mar 31, 2012
30,252
How are you hooking it up such that you are getting heating problems?

It has been a LONG time (nearly 40 years) since I used this family of parts, but I seem to recall that the Vref input is actually called Vref/2 and is the center tap of a resistive voltage divider that is powered by Vcc. You can control the span of the conversion range by applying half that voltage to the Vref/2 pin. This tends to introduce an offset, but you can trim that out by applying a fixed voltage to the Vin- input.

So you may be able to achieve what you want by putting a 1 MΩ resistor between the paddle resistor and your 5 V Vcc, then apply (via a potentiometer) about 2.5 V to the Vref/2 pin. Using a different potentiometer applying a voltage to the Vin- input, turn the paddle to where you want to get 0 out of the ADC and adjust the Vin- voltage until it is just changing from 0x01 to 0x00. Then turn the paddle all the way the other way and adjust the voltage at the Vref/2 pin so that the output is just changing from 0xFE to 0xFF. You might have to repeat these steps a couple of times to home in on the proper values -- I just don't remember whether they strongly affected each other or not.

#### Ian0

Joined Aug 7, 2020
10,067
One thing I wonder about the ADC0804, because it is old, is just how much current the analogue inputs take. The datasheet doesn't seem too clear.
That might be a problem compared to the high resistance of the variable resistor.

#### popcalent

Joined Mar 17, 2018
128
How are you hooking it up such that you are getting heating problems?
I'm talking about really small resistors, less than 100Ω, and when the pot is down to zero.

So you may be able to achieve what you want by putting a 1 MΩ resistor between the paddle resistor and your 5 V Vcc, then apply (via a potentiometer) about 2.5 V to the Vref/2 pin. Using a different potentiometer applying a voltage to the Vin- input, turn the paddle to where you want to get 0 out of the ADC and adjust the Vin- voltage until it is just changing from 0x01 to 0x00. Then turn the paddle all the way the other way and adjust the voltage at the Vref/2 pin so that the output is just changing from 0xFE to 0xFF. You might have to repeat these steps a couple of times to home in on the proper values -- I just don't remember whether they strongly affected each other or not.
Will try that. I'm using a 4053 analog multiplexer because the paddle came in pairs, so I want to read both voltages. Unfortunately, the resisors are not measuring the same when turned all the way up, so adjusting the Vref/2 and Vin- inputs for one, will mess up the other one.

#### popcalent

Joined Mar 17, 2018
128
One thing I wonder about the ADC0804, because it is old, is just how much current the analogue inputs take. The datasheet doesn't seem too clear.
That might be a problem compared to the high resistance of the variable resistor.
I know it's old, but I'm using the ADC0804 because that's what I have. Since the Atari paddle comes in pairs, I use a 4053 analog multiplexer to read one or the other. So the paddle's variable resistor goes to the 4053 first, then the output of the 4053 goes to the ADC0804.

#### Jon Chandler

Joined Jun 12, 2008
1,073
This post, from Atari Age details how to read Atari paddles. In short, they don't work as a voltage divider – the variable resistor charges a capacitor, and the time required to charge the capacitor to a certain voltage correlates to resistor position. The paddle does not require an ADC to read. A digital port pin can be used as the point at which the port changes from low to high can be determined. I believe Microchip has an app note on this technique.

You've got several decent examples there. They may be as straight forward as you'll find. Do you have a good grasp of how the paddle controllers work? If not, maybe that will help you make more sense of the code.

Just in case:

The paddles work by charging a capacitor (inside the console) through a variable resistance (the pot in the paddle controller).

Starting with the capacitor at 0 volts, it will take a certain amount of time for the capacitor to charge up to a specific voltage. That amount of time varies based on the position (resistance) of the pot in the controller. In other words, the position of the paddle controller determines how long it takes for the capacitor to charge.

If you know when the capacitor started charging and you know when it reaches the "charged" state, you basically know what the position of the paddle controller is because you know how long it took to charge.

How do you know when it started charging? You tell it when to start.

How do you tell it when to start? You write code that discharges or "dumps" the capacitor.

How do you know when it gets charged? You keep checking the voltage level of the cap.

How do you check the voltage level on the cap? The cap is attached to an input of the TIA. Reading that pin over and over, you'll see a "0" until the charge is high enough for the digital logic to read the charge voltage as a "1".

How do you know how long it took to charge? You count the number of processor cycles it takes for the input pin to reach a "1" after the charge was dumped. I think people generally count scan lines to accomplish this.

See the second example you provided for a reference to which registers and bits in the registers are used to dump the charge then read the input value.

Have you read the "Stella Programmers Guide"? (It's all over the 'net, Google it). Section 12.1 should help you pick out the parts of code that you're looking for.

There's a potentially misleading statement in 12.1: "The microprocessor discharges this capacitor by writing a "1" to D7 of VBLANK then measures the time it takes to detect a logic one at that port." That bit about "measures the time", that measuring is done by the programmer keeping track of processor cycles between the dumping and the time the input pin reaches a logic 1.

Edited May 25, 2008 by BigO

#### DickCappels

Joined Aug 21, 2008
10,232
To start with, just get your pot (actually a rheostat the way you are using it) working. The CD4053 has significant resistance, which you don't want right now.

Use Ohm's law to predict the voltage across the resistor that is grounded. You will never get to zero volts on it using only resistors. Are you ok with using an op-amp or two?

#### Ya’akov

Joined Jan 27, 2019
9,237
This post, from Atari Age details how to read Atari paddles. In short, they don't work as a voltage divider – the variable resistor charges a capacitor, and the time required to charge the capacitor to a certain voltage correlates to resistor position. The paddle does not require an ADC to read. A digital port pin can be used as the point at which the port changes from low to high can be determined. I believe Microchip has an app note on this technique.
This is, in effect a 1-bit ADC. It’s pretty clever when you think about the limitations the designers faced when it was implemented. Today we have all kinds of ADCs for free on even tiny MCUs (no pun intended). At that time, even having enough GPIO might have been a struggle but at least it didn’t increase the size of the BoM, and the cost (a deadly sin).

#### popcalent

Joined Mar 17, 2018
128
This post, from Atari Age details how to read Atari paddles. In short, they don't work as a voltage divider – the variable resistor charges a capacitor, and the time required to charge the capacitor to a certain voltage correlates to resistor position. The paddle does not require an ADC to read. A digital port pin can be used as the point at which the port changes from low to high can be determined. I believe Microchip has an app note on this technique.
I'm not intending to interface the paddle with an actual Atari or a microcontroller. I just want to convert the position of the paddle to binary as a fun weekend project. This occurred to me because I have the paddle, I have this particular ADC. Using a microcontroller to charge capacitors and measure how much time they take to charge goes beyond the scope of what I want to do.

#### Ya’akov

Joined Jan 27, 2019
9,237
I'm not intending to interface the paddle with an actual Atari or a microcontroller. I just want to convert the position of the paddle to binary as a fun weekend project. This occurred to me because I have the paddle, I have this particular ADC. Using a microcontroller to charge capacitors and measure how much time they take to charge goes beyond the scope of what I want to do.
You can use the same method though with discrete logic and the ADC. You can charge the cap and measure the voltage with the ADC, which will tell you the position, then use more discrete logic to discharge it and do it again.

#### Jon Chandler

Joined Jun 12, 2008
1,073
Here's a tutorial on the method I described, which is probably the most effective way you'll find to read a rheostat.

Funny thing about the world of electronics – it doesn't care about the way you want it to work.

#### Ian0

Joined Aug 7, 2020
10,067
This is, in effect a 1-bit ADC. It’s pretty clever when you think about the limitations the designers faced when it was implemented. Today we have all kinds of ADCs for free on even tiny MCUs (no pun intended). At that time, even having enough GPIO might have been a struggle but at least it didn’t increase the size of the BoM, and the cost (a deadly sin).
I think I'd disagree with its being a 1-bit ADC. If that were the case then all Sigma-Delta circuits would be 1-bit.
In those days, counters were more readily available than ADC, so the time interval could be measured by a 6522 Versatile Interface Adaptor, or the potentiometer could me used with a 555 to make an oscillator and the frequency could be measured.

#### Ian0

Joined Aug 7, 2020
10,067
I know it's old, but I'm using the ADC0804 because that's what I have. Since the Atari paddle comes in pairs, I use a 4053 analog multiplexer to read one or the other. So the paddle's variable resistor goes to the 4053 first, then the output of the 4053 goes to the ADC0804.
What I'm saying it is may take a significant amount of current on its inputs, which would make it difficult to read a 1M input impedance accurately. If you are multiplexing two devices to one input, then the input is going to take a significant amount of time to charge to the new level at that impedance.
It would probably be worth buffering it with an op-amp.

#### Ya’akov

Joined Jan 27, 2019
9,237
I think I'd disagree with its being a 1-bit ADC. If that were the case then all Sigma-Delta circuits would be 1-bit.
In those days, counters were more readily available than ADC, so the time interval could be measured by a 6522 Versatile Interface Adaptor, or the potentiometer could me used with a 555 to make an oscillator and the frequency could be measured.
Since there is only one level that can be detected across the entire relevant time interval, there is only one bit of information, that’s the basis for my comment. In the case of ΣΔ schemes, the sampling rate is greater than what is needed to reconstruct the relevant time interval so the effective bit depth is increased by integration over time.

But, given that it depends on the perspective from which you observe what is happening, I think your argument could be considered valid as well (though I think my point is cogent).

I agree that the counters were more available, as were GPIO—compared to ADCs. This was what I was getting at in the second half.

#### popcalent

Joined Mar 17, 2018
128
Use Ohm's law to predict the voltage across the resistor that is grounded. You will never get to zero volts on it using only resistors. Are you ok with using an op-amp or two?
Yes. I can do that.

#### popcalent

Joined Mar 17, 2018
128
Here's a tutorial on the method I described, which is probably the most effective way you'll find to read a rheostat.

Funny thing about the world of electronics – it doesn't care about the way you want it to work.
In this case, there's a microcontroller pin set as both an input and and output. I'm not using a microcontroller.

#### popcalent

Joined Mar 17, 2018
128
You can use the same method though with discrete logic and the ADC. You can charge the cap and measure the voltage with the ADC, which will tell you the position, then use more discrete logic to discharge it and do it again.
Won't the capacitor charge to 5V (or whatever Vcc) every time regardless of the value of the potentiometer only slower or faster?

#### popcalent

Joined Mar 17, 2018
128
What I'm saying it is may take a significant amount of current on its inputs, which would make it difficult to read a 1M input impedance accurately. If you are multiplexing two devices to one input, then the input is going to take a significant amount of time to charge to the new level at that impedance.
It would probably be worth buffering it with an op-amp.
How do I do that? Do I connect the pot to the non-inverted input of the op-amp, and the output of the op-amp to both the input of the 4053 and the inverted input of the op-amp?

#### WBahn

Joined Mar 31, 2012
30,252
Won't the capacitor charge to 5V (or whatever Vcc) every time regardless of the value of the potentiometer only slower or faster?
Yes, but you are not interested in the final voltage, you are interested in the amount of time it takes to reach a particular intermediate voltage.

You reset the capacitor to some initial voltage. You then release the reset and start a timer. When the capacitor voltage passes some threshold level, say half or two-thirds of the way towards the final value, you capture the counter value. A bit of simple math lets you estimate what the value of the average resistance is. If you do this hundreds (or possibly even just tens) of times a second, you have sufficient resolution to make it seem as though you are continuously responding to the paddle inputs in real time.

#### BobTPH

Joined Jun 5, 2013
9,177
Reading the time to charge a cap is basically a very bad single slope ramp ADC, non-linear.

Or you could sink a constant source with the variable resistor and the voltage across it would be linear in the resistance, which the charging capacitor method is not.

Do you have a higher voltage than 5V? If you have 8 or more, you could easily get 0-5V out.

An opamp follower would still be needed due to the high resistance.

If you only have 5V, you could use constant current source that produces 2.5V full scale and change the ADC reference as @Ya’akov suggests.