On Sunday 08 June 2003 15:52, Dave Dilatush scribbled: > Why the transistors? They just complicate things. Seems to me > you can do this with resistors and switches only: Yes, you're right. However, 2 of the "switches" are already transistor=20 switches triggered from external signals (w/non-5V levels). But yes, I c= an=20 eliminate the transistor on the third. > > SW_1 >-----R1-----o------> To PIC comparator input > > > SW_2 >-----R2-----o > > > SW_3 >-----R3-----o > > > R4 > > > GND > > In the above, the other sides of switches SW_1, SW_2, and SW_3 > are connected to +5V and the Voltage Reference Module of the > PIC16F628 is operated in the high range (VRR bit =3D 0), where > VREF =3D 1/4 * VDD + (VR<3:0>/ 32) * VDD. > > With R4 =3D 10K for example, you could make R1 =3D 4.7K which would > effectively disable the other switches as you described, by > lifting the PIC comparator pin to about 3.40 volts. > > Making R2 =3D 22K would give around 1.56 volts when SW_2 is > pressed; and if R3 =3D 15K you'd get 2.00 volts for SW_3 and 2.64 > volts when both SW_2 and SW_3 are pressed. > > With the comparator threshold levels roughly 156 mV apart, it > would seem there's enough separation between the input levels to > tell them apart reliably, no? Seems to. I was analyzing slightly differently by thinking of the # of l= evels=20 possible (f/comparator ref using the internal Vref) and the range in whic= h=20 these fall, rather than the actual voltage. The resolution of the compar= ator=20 seems pretty good but only in a certain range (ie: not all the way from 0= V to=20 5V). I guess the non-switched resistor will play a good part in adjust t= he=20 range of signals I send to the comparator. I'll have to experiment a bit= to=20 see if practise follows theory. Thanks, -Neil. -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads