potential divider for ADC

Shafto

Senior Member
I want an input pot to change the timing for lighting a sequential LED array, original post on that is here: http://www.picaxeforum.co.uk/showthread.php?t=7752

The supply voltage for the LED arrays is 9V, then I would use a 5V reg off the 9V to feed the picaxe.

I was thinking I would just use 2 10k resistors, one of them variable from the 9V source for the ADC input, so it would be ~0V-4.5V. This sound like a keen plan or should I be doing this a different way for some reason? Would 100k and 100k be better? I'm pretty new with electronics still, just want to put this together the best way possible.

Thanks for the help!
 
Last edited:

andrew_qld

Senior Member
5v Regulator would be OK. Just make sure you make the regulator big enough to handle the current. A 1-watt T-220 regulator should be heaps.

For the resisitors, you just have to check how much current will flow through them and make sure the picaxe and the resistors won't melt.

From Ohms law, Current (in amps) = Volts / Resistance.

So if you have 9 volts / 10k (worst case where the variable resistor was at the +4.5 v end) you would have 9 / 10,000 = just under 1mA flowing. This is quite OK for the picaxe (which can handle up to 20mA or so flowing through it).

Power = Current x Volts. So the resistor will have 0.0009A x 9V or 0.008 of a watt. The smallest resistor you are likely to be using is (probably) 1/4 or a watt, so this is also OK.

Cheers,
Andrew
 

Michael 2727

Senior Member
Any 2 equal value resistors placed across the supply
will divide the voltage in half at the Resistors/Pot junction.

The resistance could be 1 Ohm to 10M Ohms and the
Voltage result will be the same. BUT -
The Current will always depend on the TOTAL RESISTANCE used.

( *across the supply rails *)
2 Ohms will pass a heap of current e.g. @ 5V = 2.5 Amps.
Twenty Meg Ohms will pass micro currents e.g. @ 5V = 250 nanoamps.

An ADC input uses very little current to take an accurate reading.
( It only takes what it needs, so high current availability will not hurt it )
(Over Voltage WILL)

NOTE:
The current out of the Resistor/Pot Junction will depend
on the resistance between +POS and the Junction,
which could be very high, if a POT was used directly to +POS.
(which would tap voltages from 50% to 100% of the total supply)

Most Pots are rated at around 50mA Only, SO -
Place the Pot below the resistor and (+POS Top, 0V NEG Bottom)
use a resistor that will limit the current to 20mA or less to be safe,
when the Pot is set at Minimum Ohms.
(this will tap voltages from 0% to 50% of the total supply)
(which will also protect any Picaxe pin accidently programmed incorrectly)

Note:
An ADC input uses very little current to take an accurate reading.
An good Digital Multimeter uses very little current to take an accurate reading.
A crappy Digital Multimeter or some older Analogue Multimeters may
give an incorrect voltage reading because they draw (some) although small
current to take a correct reading.
e.g. 2 x 100,000 Ohm resistors @ 5V = 0.000025A will flow from +POS to NEG/0V.
( 5V / 200,000 Ohms = 0.000025 Amps, 25 microamps ) Across the TOTAL Supply.

1 x 100,000 Ohm resistor @ 5V = 0.000050A will flow +POS to the R+R Junction .
If your Meter/Whatever was to draw more than 50µA to take a correct reading
(Junction to NEG/0V) then the voltage will fall below the true 50% value.
Be aware of this.
If you try to draw more current than the resistors allow the voltage will drop.

This ends the lesson for today :p
 

Shafto

Senior Member
Thanks guys.. good info here.

So it's a good idea to use the 9V divided in half for up to 4.5V? ...rather than using a voltage divider on the 5V supply?
 

BeanieBots

Moderator
10k plus 10k pot is correct if you want reference to the 9v.
Using 100k plus 100k pot will present too high a resistance to the PICAXE input. The reason is more complex than simple ohms law on the resistors. It involves the way in which the ADC works.

If all you want is a signal that does not change except when you move the POT, then it would be better to use a 10k pot from the 5v supply. Easier too, one less component.
 
Last edited:

Shafto

Senior Member
That's originally how I had planned to do it, but reading the manual it says you need to set up the analog inputs in a potential divider because they reference voltage and not current?

So I took that to mean that you couldn't just use the 5V supply with a 10k VR to the input.. wouldn't that just be limiting current?

So I was deciding between something like 10k and 100k on the 5V supply which would be ~0~4.5V or why not just 10k and 10k on the 9V I thought... but then I decided to ask here first...

Beanie, are you saying that I can just go 5V--10Kvr--input ?
 

BeanieBots

Moderator
No, you still need the potential divider action.
One end of the pot to 5v, the other end to 0v.
The wiper goes to the ADC input.
When in the middle, the POT will look like a 5k/5k potential divider giving 2.5v.
 
Top