### Author Topic: Simple Battery voltage monitor  (Read 2799 times)

0 Members and 1 Guest are viewing this topic.

#### Truckstop

• Full Member
• Posts: 93
• I Void Warrenty's
##### Simple Battery voltage monitor
« on: August 09, 2009, 06:11:17 AM »
So iv been reading allot of the older posts and liked the idea of a Robot cookbook full of Scraps of data. but have not found anywhere yet where anyone has actually started this. So here is my first contribution to the SoR site. A page for the future "cookbook"

This is a simple schematic For building a battery voltage reader device compatible with the basic stamp Microcomputers. it is very easy to build and not to hard to understand. it use's the RC time command. This circuit is good for a few things, one could be to activate a hunger mode and encourage a self recharge.

681 kohm        470 ohm
Vx ----/\/\/\---o-----/\/\/\----P0 to stamp
unknown                       |
voltage                    ===== 0.01 uF film
|
Vss

(I like ASCII ART)
So here we go..
Suppose you want to monitor the voltage of a 12 or a 6 volt battery being used to power a project. There is no need to buy an analog to digital converter just for that. To measure the battery voltage, you can let it charge a capacitor through a resistor, and you can calculate the voltage from the charging time of the capacitor using the Stamp's RCtime command. Here is a circuit and some BS2 code. The following RC circuit is connected to BS2 pin P0:

Use stable components for best results, a 1% 681kohm resistor and a polystyrene or polycarbonate film capacitor. Here is BS2 program you can copy and paste..

{\$STAMP BS2}
{PBASIC2.5}    'also works in 2.0

rct var word             ' RCtime value
Vx var word             ' voltage value calculated
' we want this to = applied voltage Vx
Cn1 con 48576       ' first constant, see below
Cn2 con 8               ' second constant, ditto
' circuit attached to P0
low 0
loop:
RCtime 0,0,rct
low 0
Vx=Cn1 / rct + Cn2
debug home,dec? rct,"Vx=",dec Vx/10,".",dec1 Vx
pause 500
goto loop

The program displays the raw RCtime value and the calculated voltage. You will see that as you increase the applied voltage, Vx, the time to charge up the capacitor up decreases.

Here is a table of actual values I collected: This shows the applied voltage measured by a voltmeter, and the raw RCtime value from the program.

volts Vx RCtime, rct
18       282
17       300
16       319
15       342
14       368
13       401
12       434
11       479
10       528
9       592
8       673
7       780
6       932
5      1152
4.5      1310
4      1514
3.5      1805
3      2201
2.5      2908 note--more fluctuation in rct at lower Vx

The RCtime values you find will be somewhat different, and the calculated voltages will be several tenths of a volt off from the true values. That is due to differences in component values from circuit to circuit. For best results you will have to find the appropriate values of the constants Cn1 and Cn2 for your particular circuit.

Enjoy

Truckstop
« Last Edit: August 09, 2009, 06:24:20 AM by Truckstop »
The Mongoose: Natures Assassin
The Hyena: Nature's A\$\$hole
And.....
The Lemming: Natures Retard