ivp wrote: > Hi all > > I have a project which needs two timing intervals set. I did the > proof-of-concept with a 16F88 but would like to use a 12F675 > in the actual product > > Using the 8 pins of the F88's PortB, each interval was set digitally > with its own 4-way DIP switch. ie B<3:0> and <7:4> ranged 0-F > individually. The value for each nybble is the counter for a 10ms > timer, so Interval1 can be set from 0 to 150ms, and likewise Interval2 > also from 0 to 150ms > > I have two A/D pins free on the 12F and can use those to measure > distinct voltages. That could be done with two 12-way rotary > switches + resistors, possibly using a 12ms timer to get the same > approximate range > > My preference would be to use the 4-way DIP switches initially > and probably replace those with solder bridging pads later once > the client has a better idea of what the optimum settings are > > Referring to the attached drawing, is there an algorithm to determine > the values of the resistors so that the A/D can best discriminate a > voltage which corresponds to the binary setting of the DIP ? Or has > anyone done or seen this done before ? > > TIA > > Joe > > * > * > ********** > Quality PIC programmers > http://www.embedinc.com/products/index.htm > > ------------------------------------------------------------------------ > Joe, Can you flip the circuit around so the single resistor goes to ground=20 and Vdd is sourced to the four switchable resistors? If so, it makes=20 calculating the divider ratios easier. Assign each switchable resistor=20 a binary weight and put this into a spreadsheet. Then start plugging=20 standard 1% resistor values into the spreadsheet to get the output=20 values. This will give you 16 distinct output voltages with all open=20 equal to zero. Other than fiddling with the values, this is the easiest=20 hardware solution. If you use the rotary switch, all you have to do is=20 equally weight all resistors since you will only have one switch closed=20 at a time. Bill --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .