Do you need an interrupt or wake up on button press? I can help you with the formulas, but the ADC method is much less math. :-) You do not need to used the constant current source, that is only for stability, also the constant current source or resistors only draw power when a button is pressed. The charge/discharge requires constant power. Chad --- ransom peek <> wrote: > Thank you Leon Heller (R2R ladder), Dave Mucha (device add-on), and > Chad > Russel (excellent ADC binary ladder suggestion) for ideas to use one > I/O > for multiple bit switches. Cannot add cost of addl IC, and cannot > have > constant current drain (no power off mode in design, just lets PIC go > to > sleep) thru voltage divider. Have simplified requirement, so need to > read just 3 bit switches with on PIC I/O. > > The App Note AN234 shows the circuit below, using comparator. Need > to > measure time it takes to charge capacitor. Need to choose resistors > to > provide enough gap in charge times so that each switch combination is > unique. > > I think the idea is to change I/O to output ground, discharging > capacitor. Then change back to comparator input to let capacitor > charge. Software to measure the time it takes the cap to charge to > the > "threshold". A value of 100 ohms for R5 is recommended. > > Need some help with these questions: > > 1. What kind of values should I try for R1, R2, R3, and C1? > > 2. How long a delay to discharge the capacitor? > > 3. What is meant by "threshold" level of cap charging up to? For a > 3 > volt nominal voltage circuit (VDD=3 volts) what voltage level should > I > test for? > > 4. How to know when threshold voltage is reached - do I just keep > checking the comparator while timing or does the comparator have an > interrupt upon reaching a threshold voltage? > > VDD > > (100 ohms) > ! > > R5 > / > ! > > PIC COMPARATOR I/O-----/\/\/\/\/---------------------/ > ---------/\/\/\/\/--------- > > ! ! > SW1 > R1 ! > > ! ! > ! > > C1 === ! / > ! > > ! > !------/ > ---------/\/\/\/\/-------! > > ! ! > SW2 > R2 ! > > GND ! > ! > > ! > / > ! > > !----/ > ----------/\/\/\/\/-------! > SW3 > R3 > > Ransom Peek > ===== My software has no bugs. Only undocumented features. __________________________________ |