Nigel Duckworth wrote: > > Hi All, > > I have to measure my PIC16C711's own battery supply (2 x AA cells) so need to > generate a reference for the A to D, cost is everything on this one. I just took a stab at the "cost is everything" approach and came up with a 3 resistor one 1N4148 diode and one cap design. It doesn't need an A to D input, just 3 normal PIC inputs. * will work on any PIC, even 12-core PICs * very low parts cost * can be turned on/off by the PIC * very low power waste even when turned on * should give ok accuracy with a lookup table Unfortunately needs 3 PIC pins total, but you were already using 2. :o) Turning a PIC output pin hi activates the circuit and it starts to draw a tiny amount of power, from the PIC pin through a 100k resistor into a 1N4148 diode. This resistor lets about 20uA through, which is the max power draw of the circuit and occurs at battery=3.4v. At battery =2.4v, a typical low limit, there is still about 10uA into the diode so diode current is within the 10uA to 20uA range. Ideal for us, the diode forward voltage will change very little on this part of the curve, AND it uses the tinyest of power. 2 birds. ;o) This charges a small cap (a low leakage one), up to the diode forward voltage, through a 56k series resistor. The cap is connected to a PIC "sense" pin and another PIC I/O pin through a 10k resistor. These are both set as inputs and their port data bit is set to low. Total; 1 diode, 1 cap, 3 resistors, 3 PIC pins We wait the minimum time for cap to be fully charged, then the PIC I/O pin with the 10k resistor goes from hi-impedance input to a hi output. The sense pin measures the time to go from low to hi, and this will be determined by the battery voltage so a simple lookup table will give decent precision to measure a few battery levels. To do a battery voltage measurement should not take much more energy than that needed to charge the cap once to 5v, and with a small cap (and obviously; high resistor values) each measurement will only cost a tiny bit of the battery. There will be some spread between the Vin hi voltages of different PICs, giving slightly different readings from PIC to PIC. But with most products battery level sensing is only needed in 8 or less levels, to drive a bar indicator etc. You said minimum cost? This is a cheap way to do it. :o) -Roman -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body