voltage sensor from 0 to 12 VCC

Armagon

Member
I am trying to build a voltage sensor with range from 0 to 12 VCC. but I don?t know how, someone can explain me how can I do that

Thanks
________
mflb
 
Last edited:

Jeremy Leach

Senior Member
There's loads of possibilities. But if we're talking PICAXEs then you've got a ready-made voltage sensor with the ADC inputs. They take the analogue voltage (usually 0 to 5V) and convert it into a digital number (typically 0 to 1023).

A simple solution to measure a 0 to 12 Volt DC voltage would be to simply have a potential divider (two resistors) between the voltage source and the negative supply rail , with the centre tap (point where resistors meet) going to an ADC input of a PICAXE.

Choose values of the potential divider so that a 12 Volt input voltage presents a 5 Volt value to the PICAXE.

One consideration must be whether your voltage source has a low enough 'output impedence' to drive the ADC input - but that might be getting too technical. Tell us more about what you're really trying to measure.
 

BeanieBots

Moderator
The potential divider described by Jeremy will give you 0v to 12v.
However, for 8X batteries, you might like to consider putting in an offset because the battery will be just about dead once it gets to around 1v per cell.
This can be done with op-amps. A search of this forum should reveal some hints and tips on how to do it.

Edited by - beaniebots on 14/11/2006 23:30:37
 

moxhamj

New Member
Use a voltage divider with a 15K resistor and a 10K resistor. 10/(10+15) = 0.4, and 0.4*12=4.8V. 12V into the 15K, and measure in the middle. Then run this into the ADC of the picaxe.
 

Michael 2727

Senior Member
<code><pre><font size=2 face='Courier'>
+ POS o
12V |
|
|
.-.
15K | |
| |
'-'
|
| To ADC &gt;&gt;&gt;
o------------o
|
|
.-.
10K | |
| | Output
'-'
|
|
|
- NEG o------------o
Common NEG


(created by AACircuit v1.28.6 beta 04/19/05 www.tech-chat.de) </font></pre></code>
 

premelec

Senior Member
Please note that the ADC reading is dependent on the PICAXE supply voltage so it needs to be regulated as a reference for the measured voltage from divider. There have been discussions in past forum on how to self measure the PICAXE voltage if that becomes an issue [needs an established lower volt reference].
 

sprockett

New Member
I am working on a similar project which ivolves monitering 11.1V lithium polymer batteries to make sure they dont go below 9v (and become damaged).
What is the expected current required by the picaxe 08m to monitor the voltage?
I was just going to use a trimpot of sutiable rating and tune it to suit.
 

Michael 2727

Senior Member
The picaxe will draw very little, the
voltage divider itself will most likely draw
many times the picaxe current.
You could try -
Top Resistor = 62,000 Ohms
Bottom Resistor = 47,000 Ohms
Which should output around 4.79V to the ADC.
Then use a 5.1V zener across the ADC to
shunt any over voltage.
Or 68,000 Ohms = 4.54V and a 4.7V zener.
Just to be on the safe side.

Using the 47K on the bottom side may slow
the MAX ADC sampling rate slightly but in
this case I don't think you will have to worry about that as it is quite fast anyway.
 
G

Guest

Guest
+ POS o
12V |
|
|
.-.
68K | |
| |
'-'
|
| To ADC &gt;&gt;&gt;
o------------o
| |
| |
.-. --- Diode
47K | | /\
| | | Output
'-' |
| |
| |
| |
- NEG o------------o
Common NEG

Is this what you mean when you talk about the 5.1v zener across the ADC?
 

tarzan

Senior Member
Don't forget the {code} {/code} tags with square brackets. [ ]

<code><pre><font size=2 face='Courier'>+ POS o
12V |
|
|
.-.
68K | |
| |
'-'
|
| To ADC &gt;&gt;&gt;
o------------o
| |
| |
.-. --- Diode
47K | | /\
| | | Output
'-' |
| |
| |
| |
- NEG o------------o
Common NEG

Is this what you mean when you talk about the 5.1v zener across the ADC? </font></pre></code>
 

premelec

Senior Member
note that the input resistance for full accuracy should be 10K or lower - implying that the parallel value of the two divider resitors [R1R2/(r1+r2)] should be &lt;=10K
 

Michael 2727

Senior Member
Thanks for the Pic Tarzan, I'm getting lazier ~ ;o)

And the diode is correct also.

Normally you keep the ADC bottom resistor
at 10K, but seeing as you seemed concerned
about wasting power I included the higher
values.
As I said the ADC sampling times per second
may react a little slower for accuracy, but
you probably only need to sample once every
few seconds or more so the result will be
just the same.
The above values may not be as accurate at high speed ADC sampling.
 

Dippy

Moderator
Whilst a zener will afford some protection it will also reduce your resolution because of its characteristics i.e. Vr vs Ir. They are NOT an 'on-off' perfect switch!

For an 8 to 12V input range with the 68K/47K + zener shown above the 'o/p' to PICAXE ADC would only vary from about 2.6 to 3.1 volts i.e. 0.5V range - is that enough for you?

Take the zener out and you'll get 3.1 ish to 4.8ish i.e. a range of about 1.7V. Better resolution (but no protection). The choice is yours.

The op-amp offset is a neat idea but I am guessing that may be a tricky at your stage and probably not really necessary for this project.

As said above your PICAXE needs a 5V regulated supply. You will NOT get accurate results running from battery as (also said above) the PICAXE uses the Vsupply as a reference.

I'm a little worried about the high source impedance (68K) for your ADC input. I'd go for a lower resistance pot/div.
You can always switch the pot/div circuit before ADCing to save power. I have in the past used an FET as a low sided switch to do this - fine if you have a spare PICAXE leg and therefore NO power consumption* when you don't need to use it. The relatively small resistance change for FET vs Temp is irrelevant. You could use a bipolar or PICAXE o/p as a low sided switch but I honestly don't know the Vdrop characteristice vs temp etc. - they may be perfectly OK. ANyone tried it?

A bodge which does work (up to a point) for medium input impedance is to have a cap at the junction - though this is useless if you are doing rapid (fast repetitive) A/Ds - - which you shouldn't need to do for batteries. The cap also flattens out any spikes. If you can be bothered to see how PIC ADCs operate (300 page Data Sheet) you will see the reason for this, though I do NOT recommend this for precision work.

I'm pretty certain that reading a huge Data Sheet is the last thing on your mind - but do it one day. Also read up on basic electronics, its handy.

Well thats my 2 bob's worth. I'm off.

*Note: Yes, call me a liar for a few nanoamps!
 

sprockett

New Member
Thanks Dippy and others.
I dont need to moniter the battery continuosly so i will use a FET to turn the Voltage divider on only when i use the ADC(once every min or 2)using a spare pic output, then i can keep the bottom resistor at 10k and keep the current drain to a minimum. My circuit already has a 12v-5v switch-mode so that should not be an issue.
..
 

premelec

Senior Member
this isn't quite as simple as you might think - if you put the FET between 10K &amp; v- then the 12 V+ goes to PIC input thru the upper resistor - if you try switch the FET in series with the high resistor you need higer Vgs voltage to turn it on... a solution is to put a P type unit with collector or drain toward V- and use an N type unit to switch the gate/base of the P unit through a resistor to V- turning it on to put the voltage divider in the circuit.
 
Top