prefered resistance value for readadc

kevrus

New Member
i wish to monitor an input with 13 equal resistance stages using the analogue input. would 10k be a suitable value to use for each resistance step?
thanks...kev
 

premelec

Senior Member
Bear in mind that to get accurate A/D conversion the input source impedance into the PICAXE pin should be 10K or less... I don't know just how you are connecting your resistors - but this 10K is a fundamental consideration and as you go above 10K you risk losing accuracy.
 

kevrus

New Member
effectively, there will be a number of normally closed switches in series, with the resistances across them, the idea bieng that whichever switch is opened, that will present a differing resistance value to the analogue input therefore identifying the opened switch...
 

hippy

Technical Support
Staff member
I don't think it's quite as simple as that for larger numbers of buttons. Adding an extra 10K in series with 12 x 10K is only a small change to detect. Even 1% errors in the resistors would add up to more than what you are adding.

A Forum Search ( top right of page ) should hopefully show previous discussions on this issue.
 

Michael 2727

Senior Member
<A href='http://www.rev-ed.co.uk/picaxe/forum/Topic.asp?topic_id=4593&amp;forum_id=26&amp;Topic_Title=12%2Binputs%2Bon%2Ba%2Bsingle%2BADC&amp;forum_title=No+new+posts+please%21+18' Target=_Blank>External Web Link</a>
 

gengis

New Member
<b> kevrus </b>

I've been following this thread with some interest because that was my idea too (use switches to short resistors to present the A/D input with a voltage value)

I planned to use binary weighted switches and my first thought was to just select resistors in multiples of -1R, 2R, 4R, 8R etc.. and use the shorting switches. Calculating out the various values of resistors available (in 5% tolerance) and calculating the tolerance error it looks less practical.

The obvious solution to what you are proposing is to just put the resistors in a string, of say, 13 470 ohm resistors or so and take the voltage output by using the switches to tap the voltage divider string.

If you have the power supply resources, your shorting switch thing will work providing you add a simple op amp voltage follower to buffer the output impedance.

Is there some reason you want to use shorting type switches?

I'm going to use a voltage divider string and just tap the voltages into the AD on my first project (with dip switches) because I already bought the switches. Plan B will be to use a rotary switch and tap into a voltage divider string - or use a potentiometer with detents, or ten turn pot and turns counting dial.

<b> For the other gurus out there </b> - where did the 10K input impedance come from? I'm on dialup and my last three attempts to download the microchip data sheet have failed.

 

hippy

Technical Support
Staff member
That impedance recommendation does come from the datasheets, page 119 of the 16F88 I have says, &quot;maximum recommended impedance for analog sources is 10K&quot;. It seems to be the same across the 12F/16F range.

For the forthcoming 28X2 and 40X2, (18F2420/18F4420) recommended maximum impedance drops to 2K5.

Higher impedances can be used, but this may introduce inaccuracies in readings and differences between consecutive readings.
 

gengis

New Member
Thanks hippy

The datasheet finally did download successfully. It looks like the actual input impedance of the pin is on the order of 2 megohms (more or less depending on temperature, supply voltage and manufacturing variability) so the recommended 10K is probably a good conservative value. It might be possible to use it at 50K with good results - some empirical knowledge/results are needed.
 

hippy

Technical Support
Staff member
I don't really understand &quot;source impedance&quot; and the way I view it is that it doesn't really relate to the actual input impedance ( as if it were the bottom R of a voltage divider ) but more to how quickly the sample and hold capacitor within the ADC can be charged up( or discharged ) when sampled before the conversion starts. The bigger the resistance the longer it takes to alter the capacitor, and ADC reading will give readings less or more than what they really are. Multiple READADC commands can probably help there if the input signal is not changing rapidly.

It's probably an interesting experiment to try; a pot between +V/0V via various R's to READADC and watch to see if the reading keeps changing after the pot has stopped moving.
 

alpacaman

Member
What I like about this forum is learning the different approaches to solving a problem. I never thought of using switches to short out the resistor values.
In a resent project I needed 9 switches. I ended up using 10 resistors in series - a voltage divider like Flooby - and each switch would short one of the divider points to ground. Worked nicely.

 
 

BeanieBots

Moderator
Resistance is the value that would be measured if using a constant current current such as method employed by a DMM set &quot;resistance&quot;.
Impedance is an expression used that takes other things into acount that can effect the current drawn for an applied voltage no matter what the waveshape of that voltage.

For example, what is the RESISTANCE of a capacitor?
Well, if it's a good quality one, it will be infinite. At least that is what your DMM will say.
However, it's IMPEDANCE is given by the expression 1/(2.PI.f.C) where PI=3.1415926 f=frequency of voltage waveform and C is the capacitance in Farads.
(only valid for sinusoidal voltage)

Hence, if your source is a simple resistor, the impedance will be the same as the resistance. If you add a capacitor in parallel with the source, then the resistance stays the same but the impedance will decrease and will include a function similar to the equation stated above specific to any waveform (or load) applied to that source.

In the case of a PIC, the load varies as part of the action of the readadc command so the DC 'resistance' of the input also has an AC element added to it. You can reduce the source IMPEDANCE in this case by adding a capacitor to the input.

No, I don't what value because I don't know the dynamic action of the SH capacitance that causes the effect in the first place but a few 10's of nF should significantly reduce any errors caused by having too large a DC RESISTANCE. The price paid for such a reduction is reduced response time.
 

premelec

Senior Member
Fundamentally the source impedance can be thought to be in series with the input impedance. Thus if I have 1 volt in series with 1 megohm that I connect to a 1 megohm input that input would read .5 volts rather than 1 volt.

This simply leads to the considertion that if I want 1/1024 drop in voltage from the source impedance effect I'd need it to be around 1/1024 * actual input impedance - if I want to actually get that resolution about 1/2048 -

OK so this isn't completely accurate but I've tried to express it so it's more intuitive - also the A/D conversion is a digital operation with the input impedance varying in some fashion...

The hard core calculation of a series voltage divider is (R2*Vin)/(R1+R2)...

It's possible with 8 bit resolution instead of 10 bit you could raise the source impedance and get similar 1 bit accuracy as you would with the lower source impdeance and 10 bit resolution... depends in part on what goes on in the PICAXE... meantime 10K is the recommended value and you can try higher and note that input varies with temperature and such as well as voltage on the unit etc... have fun...
 
Top