>Set the pin to be an output. Set the output LOW. A little later set it back >to an input. Now check the pin to see if it is still low. The cap that you >dumped by setting it low is now charging up. If the pin is not high, count >bananas until it is. One banana, two bananas, ...., 119 bananas, hey, now >the pin's high. Do this with your full power supply voltage to see how many >bananas get counted. Then do it with 4.5 volts and then with 4.0 volts. >Remember this. Put it into your code. There is another trick here that I have thought of using, and it relates quite easily to using battery powered equipment. If needing to make a number of analogue measurements, set the system up to use the Vref+ as the reference for all the analogue measurements. This should be at a voltage that will be stable even at battery end of life. Now all external measurements use this, and will be a valid value right through to battery end of life, because the reference is good till then. When measuring the battery voltage switch to using the internal 5V reference. Now measure the value of the Vref+ pin. Remember that the value obtained will be inverse to the battery state, i.e. the larger value given by the A/D means a lower battery voltage. Unless you are really looking for punishment this does not matter, as you are only looking for the battery end point to report low battery. It may mean setting two end points in your code - one for flat battery, and one for low battery, and these would need to be determined experimentally, but that would not be a big deal. Result is no extra pin needed to measure the PIC supply voltage, while having stable measurement of everything else right through to battery end of life. Off course this does not work too well if there is a regulator supplying the PIC off something like a car battery, but then you will be able to use the internal 5V reference as it will be stable anyway, so you can use the Vref+ pin as an analogue input for the battery voltage through a suitable divider :) -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body