Use a resistor, cap, and zener (no a/d): 0-30vdc+-----/\/\/---+----------+-------PIC I/O | | | | +--|>|--+ +--||--+ | | | | | | Gnd----------+-----------+ To take a reading, drop the pin to gnd for a few ms, then float the pin and check it to see when it goes high. Put it on an interrupt pin or interrupt on change and you can just use a timer. Put it on the CCP pin in capture mode and you'll get the interrupt and the exact time when the pin changes. If the voltage is over 5 volts then there will be some current draw, but only very little (much less than a regular voltage divider) -Adam Roman Black wrote: > > Drew Vassallo wrote: > > > > >i have an unknown voltage that will vary from about 0 volts up to about 30, > > >and i need to determine what that voltage > > >is via a 16F877 pin. > > > > I don't know about the inputs of a 16F877, but I assume that 30V is a little > > out of spec. > > > > >i know that i could just do a simple voltage divider, put that on a A/D pin > > >and figure it up. > > >what i'd like to do is find a way to get it without drawing current all the > > >time. > > > > Then why not just put a transistor in to open the current path when not in > > use? Turn it on, take your reading, turn it off. > > Do both together, turn the transistor on and power up > your 2R divider (so about 30v==5v), then turn it off, > and a small C on the bottom resistor will determine > the time to discharge, and the PIC pin can measure the > time to reach the 0.2v at the schmidt input low > threshold, time will be relative to the amount of > volts on the 2R divider at the start. This will > work. It will have to measure from 30v to about > 4.8v minimum, as the PIC schmidt pin needs to exceed > 0.8v to give high level. > > It would take two pins and two transistors. ie, > PIC pin drives npn, drives pnp to turn on 2R divider. > And it is only good for 30v to 4.8v range. > > Now I challenge someone to do it with ONE PIC pin!! > Or less/no transistors! Or better range! > > Requirements: > 1. must measure up to 30v > 2. must draw no current from measuring circuit > when not needed. > > :o) > -Roman > > -- > http://www.piclist.com hint: PICList Posts must start with ONE topic: > [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads