Jump to content
IGNORED

Reading paddles with MCU


Delicon

Recommended Posts

Does anyone have a brilliant solution to reading paddles with an MCU's ADC? Right now I am using a voltage divider, then actually calculating the resistance in software to linearize the reading, and then dividing by 1M Ohm to normalize it to 1.

 

My divider is 100K from GND to the measure point. On the other side I have 10K and the paddles 1M pot and 3.3V.

 

So it should look like this:

 

     3.3V
     -----
       |
       |
  Paddle - 1M
       |
       |
     10K
       |
       |--------------- ADC
       |
     100K
       |
       | 
      --
      \/
    GND

 

I am doing a 10bit read and this setup gives me values between 944 and 80 across the whole paddle range. I get sensitivity issues because of the non-linear nature, But I think I have dealt with it. Would any super geniuses here do it differently? Are there any easier linearizing functions than to work the voltage divider backwards?

 

Thanks,

 

Vern

Link to comment
Share on other sites

  • 2 weeks later...

I don't quite understand what the other resisters are doing, are they in the paddle controller themselves or have you added them?

Is the controller itself wired up as a pot or as a variable resistor?

What type of MCU are you using?

 

If the Paddle controller is just a 1M pot connected between 3.3V and Gnd and if your MCU has an external ADC reference voltage pins set one to Gnd and the other to (3.3/1000) x 1024 and connect the wiper of the Pot to your ADC input. You should get a reading of zero at 0V and 1000 at 3.3V - nice and linear.

Link to comment
Share on other sites

If he's using the Atari 2600 paddle, unmodified, it's set up as a variable resistor using two terminals of the pot internal to the controller. Assuming that to be the case, only the wiper and and one end are available external to the controller.

Edited by BigO
Link to comment
Share on other sites

Is the controller itself wired up as a pot or as a variable resistor?

What type of MCU are you using?

The paddles can only be a variable resistor without modification.

I am using an LPC2368 ARM7.

 

If he's using the Atari 2600 paddle, unmodified, it's set up as a variable resistor using two terminals of the pot internal to the controller. Assuming that to be the case, only the wiper and and one end are available external to the controller.

Correct.

 

Unfortunately, the only way I see of getting a mostly linear read off the paddle is with a bridge and an instrumentation amp. I was hoping the group here knew a better way.

 

Vern

Edited by Delicon
Link to comment
Share on other sites

Out of curiosity, what purpose does the 10k resistor serve?

The 10K stops the paddle from shorting directly to 3.3V when its turned all the way in one direction and equal to zero ohms. If I allowed it, the ADC reading would a read at a maximum. I wanted to add a bit of a buffer to avoid dead space caused by the ADC.

Edited by Delicon
Link to comment
Share on other sites

I see. I asked because it introduces a limitation on the total range available to the ADC. I haven't found any paddles that go completely to zero ohms, but Murphy's law and all that...

 

Is it desireable to create that same cushion on the minimum end of the range? If it's reliable at/near zero, could you put the paddle between ground and Vout and eliminate one fixed resistor? In the 2600 world, it appears that plenty of slop was left unused at either end of the pot's range to compensate for differences in capacitors, etc. A whole lot of precision applied in determining paddle position may not be fruitful.

 

If you also made the fixed resistor in that scenario = 10 Meg, the output would be more linear over the range, though the entire voltage range would be limited to around .3 v max. Probably would be out of the bounds of sensitivity for the ADC and might even create some signal to noise issues. Just a thought that might prompt you or another smart person to think of an actual good idea. :)

 

There's a discussion around here where some of the hardware heavy hitters talked about "paddle jitter" (and I participated) that contains some interesting information from a slightly different angle. I'll link to it if I can find it again.

Edited by BigO
Link to comment
Share on other sites

I am doing a 10bit read and this setup gives me values between 944 and 80 across the whole paddle range. I get sensitivity issues because of the non-linear nature, But I think I have dealt with it. Would any super geniuses here do it differently? Are there any easier linearizing functions than to work the voltage divider backwards?

 

If you use the resistance in an RC timing circuit, as the 2600 does, the results will be inherently linear. Using a pot as a rheostat rather than a voltage divider will tend to make things a bit jittery no matter what you do, but the RC timing approach is pretty simple and cheap, and it's probably no worse from a jitter perspective than using a straight ADC.

Link to comment
Share on other sites

I am doing a 10bit read and this setup gives me values between 944 and 80 across the whole paddle range. I get sensitivity issues because of the non-linear nature, But I think I have dealt with it. Would any super geniuses here do it differently? Are there any easier linearizing functions than to work the voltage divider backwards?

 

If you use the resistance in an RC timing circuit, as the 2600 does, the results will be inherently linear. Using a pot as a rheostat rather than a voltage divider will tend to make things a bit jittery no matter what you do, but the RC timing approach is pretty simple and cheap, and it's probably no worse from a jitter perspective than using a straight ADC.

 

That being the solution I would have taken, not knowing any better than "it worked for Atari." :) Out of curiosity, WHY would using a pot as a rheostat be more jittery than when it's a voltage divider? I'd have thought that the same tolerances would be in place mechanically?

Link to comment
Share on other sites

That being the solution I would have taken, not knowing any better than "it worked for Atari." :) Out of curiosity, WHY would using a pot as a rheostat be more jittery than when it's a voltage divider? I'd have thought that the same tolerances would be in place mechanically?

 

An ideal potentiometer would be modeled as two resistors in series which always sum to the same value; the wiper represents the node between them. In this ideal pot, there will be perfect conduction between the wiper and the part of the resistance element it is touching.

 

In real-life potentiometers, unfortunately, the conduction between the wiper and the element is not perfect. There is resistance between the wiper terminal and the junction of the first two resistors. As pots get old, this resistance can become large, and can vary somewhat 'randomly'.

 

Suppose a 1M pot is rotated to 1/10 scale, and the wiper resistance varies from 50 ohms to 50K. Using 'rheostat mode' measurements, the controller resistance would appear to vary from 100K (1/10 of 1M) to 150K. That's a huge variation, and there's not really much that can be done about it.

 

If the pot is used in 'voltage divider' mode, however, with one end tied to +5 and the other tied to ground, then depending upon wiper resistance, the pot may appear as either a 160K resistor connected to 0.5 volt source (200K+800K in parallel; 1/10 of 5 volts), or as a 210K resistor connected to a 0.5 volt source (above resistance plus the 50K wiper resistance). Since the goal is not to measure the resitance, but rather the voltage of the source, it's possible (and not hard) to make a circuit where the series resistance has very little effect.

Link to comment
Share on other sites

That being the solution I would have taken, not knowing any better than "it worked for Atari." :) Out of curiosity, WHY would using a pot as a rheostat be more jittery than when it's a voltage divider? I'd have thought that the same tolerances would be in place mechanically?

The problem with this solution is that an MCU needs to babysit the capacitor just like the VCS does. If you use an ADC, then it just happens, you read the value out of a register and its done.

 

Anyone know how the stella adapter does it?

 

Vern

Link to comment
Share on other sites

The problem with this solution is that an MCU needs to babysit the capacitor just like the VCS does.

 

Many microcontrollers have timer-capture or timer-enable input functions which would avoid any requirement for babysitting. I don't know about the ARM specifically, but many PIC and 8052 derivatives include such features.

Link to comment
Share on other sites

That being the solution I would have taken, not knowing any better than "it worked for Atari." :) Out of curiosity, WHY would using a pot as a rheostat be more jittery than when it's a voltage divider? I'd have thought that the same tolerances would be in place mechanically?

The problem with this solution is that an MCU needs to babysit the capacitor just like the VCS does. If you use an ADC, then it just happens, you read the value out of a register and its done.

 

Anyone know how the stella adapter does it?

 

Vern

 

I was going under the assumption that you were trying to avoid that process of reading the cap. I would do the same 'cuz it bugs me for some reason to do it that way. I think it's the (variable) dwell time required to catch the input becoming a logic 1. It could make for some challenging coding to interleave "watch the pot" with other productive tasks.

 

However, if you could afford the processor overhead, would you be able to use the cap method with a timer and interrupts? You could at least eliminate the explicit code required to control the charge/read cycle. On a timer, fire an interrupt to start the process by pulling the charge to zero as the 2600 does. Multiplex that pin between an output to pull down and an input to read. Set an interrupt on that pin to fire when the pin becomes logic 1. On the interrupt, run a routine that stores the timer value (correlated to a pot position) in a register to be read later.

 

Could you maybe hybridize the two approaches? Discharge the cap then remove the pulldown voltage to let the cap start charging, let the processor have however many cycles are equivalent to the max charge time of the cap to do other tasks (highest resistance from the pot, within the linear portion of the charging curve, etc.), then fire the ADC (timer/interrupt again) and store the value in a register. It'd still be overhead, assuming the ADC takes the same amount of time for every conversion, it would be a consistent, predictable amount of time for reading and wouldn't require explicit coding. The cap would serve the purpose of linearizing the input. Dunno if that's any better than doing a lookup or calculating the position based on the non-linear voltage.

 

I haven't really thought those ideas thoroughly through. Just tossing them out there. They may be completely useless depending on whatever the rest of your processor time needs to be used for.

Edited by BigO
Link to comment
Share on other sites

Many microcontrollers have timer-capture or timer-enable input functions which would avoid any requirement for babysitting. I don't know about the ARM specifically, but many PIC and 8052 derivatives include such features.

Very true. The ARM has 4 32 bit timers with capture circuits. I was trying to not consuming the timers though. I use two of them for the the normal ARM operation and low level stuff to do with the cart. That leaves two others, but I was thinking they could be available to the VCS someway, maybe for waveform sampling or something.

 

Its too bad Atari just didnt make that one more connection in the paddles though. Oh well.

 

Vern

Link to comment
Share on other sites

I must be a bit dim as I am still not 100% clear on this but I assume the none linearity you are trying to avoid is that created by the paddles normal CR timing method of operation as a CR time constant is not linear.

And presumably you want to aviod rewiring the original controller otherwise you would just rewire it as a pot and place a fixed resistor (say 1K) each end as you appear to want to aviod to the output voltages crashing in the supply rail. If it is just just the end on the pot you want ot aviod you could just ignor say the lower and upper 50 values and do some maths to lineariser the remaining values.

 

I have not used ARM processors, only PICs but if the ADCs are the same you need a voltage input and a recommended input resistance of 10K max due to the time it takes to charge the sampling capacitor.

 

So how about this as a soultion, keep the controller as it is, connect the output to the base of a NPN bipolar transitor. As the paddle is wired as a variable resistor the base voltage should remain at 3.3 volts keeping the transistor turned on and varing the resistance will vary the base current. The base current is then amplified by the transistor and applied to either a resistor or a potential devider and you take your ADC input for there - See circuit diagram below.

post-3734-1191317539_thumb.jpg

Please note it has been over 10 years since I did any bipolar transitor design and so I may have forgotten a few things and it won't work but feel free to give it a try.

Obviously which end the wiper of R3 is attached will determin if the output voltage goes up or down when you turn it left to right and the values of R1 and R2 (if required) will be determined by the gain of the transistor you use and the output voltage range you require.

Edited by Stephen Moss
Link to comment
Share on other sites

I must be a bit dim as I am still not 100% clear on this but I assume the none linearity you are trying to avoid is that created by the paddles normal CR timing method of operation as a CR time constant is not linear.

The non linear response comes from any variable voltage divider. Assume just the paddle and another resistor at the bottom, the 100K in this case. So V=IR, where the current through the whole circuit is

 

I = 3.3/(Rpaddle + 100K)

 

So the voltage at the ADC is the voltage across the 100K, the current is known now so using V=IR again,

 

V100K = (3.3/(Rpaddle + 100K))*(100K)

 

Rearrange to group resistances gets,

 

V100K = (100K/(Rpaddle + 100K)) * 3.3

 

So the non linear part comes from dividing by the sum of a changing resistance.

 

Vern

Edited by Delicon
Link to comment
Share on other sites

I have done some calculations and you are correct, I don't recall hearing of this effect while being taught electronic and so I asumed that a linear pot would result in a linear change.

The question now is what is causing it? Is it that a change in R also results in a change in the paracitics of the resistor or just the fact that it is in a devider circuit? If varing the paddle alone provided a non linear responce than the circuit I suggested will not work as you will still get a non linear output.

 

Why did you select 10K and 100K as the extra resistors?

By my calculations with the paddle resistantce at 1M, 750K, 500K, 250K and 0 the input voltages to the ADC would be 0.3, 0.38, 0.55, 0.942 then you get a big jump to 3.3.

If you just used a 1M then you would get 1.65, 1.88, 2.2, 2,64 and 3.3, still not linear but more linearly progressive.

 

As for how to linearise it you could perform various calculations and say split the results into four ranges and apply different offsets to the values in those ranges, however it is not outrageously unlinear and so if you do not need the 10 bit resolution I would read in as 10bit and convert it to 8 or even 7bit. Removing the two or three LSB will reduce the differences between measurements helping to make them more linear.

Link to comment
Share on other sites

The question now is what is causing it? Is it that a change in R also results in a change in the paracitics of the resistor or just the fact that it is in a devider circuit?

Its just the divider part. Its because there is a variable in the denominator. If your solution moves the variable resistance up into the numerator, then your idea should give a linear response. Your idea seems logical to me, as you adjust the linear resistance you will get a linear change in current to the base of the transistor. I havent had much time to look over your circuit.

 

Part of my problem was also a very noisy ADC circuit. I am fixing that now and looking to see if that makes the non linear nature bearable.

 

Thanks for the input,

 

Vern

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...