Voltage Measurement for your Robot

by Scott Preston - 2007-09-06 10:07:46
I was able to do this with 2 resistors and 1 capacitor.
      681 kohm        470 ohm 
Vx ----/\/\/\---o-----/\/\/\----Pin to stamp
unknown         |
voltage       ===== 0.01 uF film
                |
               Vss

The source code for the basic stamp is:

' {$STAMP BS2}
' {$PBASIC 2.5}
' {$PORT COM1}

rct VAR Word    ' RCtime value
Vx VAR Word     ' voltage value calculated
Cn1 CON 48576   ' first constant, see below
Cn2 CON 8       ' second constant, ditto
' circuit attached to P15
LOW 15
start:
RCTIME 15,0,rct
LOW 15
Vx= Cn1 / rct + Cn2
DEBUG DEC ? rct,DEC ? vx
PAUSE 500
GOTO start

You will have to experiment with the constants and values. I had to sit with my battery and take readings while I worked on the robot, then as the battery drained I took readings and voltage measurements and made my self a look-up table.

Poll Of The Day

My Books

Robotics Programming 101

Robotics Programming 101

Robotics Programming 101 shows how program a real robot, speech, vision, more...

Ubuntu Robotics - A Robotics Programming 101 Extra

Ubuntu Robotics - A Robotics Programming 101 Extra

This extra highlights all of the Ubuntu specific robotics configuration details in Robotics Programming 101.

Only $0.99 on Amazon.Com

Motion Detection - A Robotics Programming 101 Extra

Motion Detection - A Robotics Programming 101 Extra

This extra shows you how to write a motion detector for your robot with a network or web camera.

Only $0.99 on Amazon.Com

The Definitive Guide To Building Java Robots

The Definitive Guide to Building Java Robots

This was my first book on robotics and using the Java Language to interface between sensors, motors and microcontrollers with a PC capable of doing speech and vision.