> -----Original Message----- > From: Olin Lathrop [SMTP:olin_piclist@EMBEDINC.COM] > Sent: Monday, September 01, 2003 2:49 PM > To: PICLIST@MITVMA.MIT.EDU > Subject: Re: [PIC:] Multiplexed-switch design problem > > > .__________. > > | 16F628 | > > | | > > | RB0 |---------o-------------| MOSFET 1 gate > > | | | > > | RB1 |---------|-------o-----| MOSFET 2 gate > > | | | | > > | RA5 | | | > > '----------' | | > > | |/ o | > > | A>--'\/\/\,--| NPN |] Pushbutton N.O. > > | R1 |\> o | > > | | | > > | | | > > | (D) | > > | | | > > | | | > > `-----------------o--|<|--' > > | 1N4148 > > ,--'\/\/\,--' > > | R2 > > GNDb > > You're making this way too complicated. Just turn on the internal pullups > when you want to read the switches and tie the other end of the switches > to ground. This even frees up RA5. (Where did you find such a hairbrain > design in the first place?) > If you check the schematic you will see that RB0 and RB1 are driving MOSFET gates. I suspect the original intent is that pressing the switches dosen't affect this gate drive. It should be fairly obvious why the circuit dosen't work as you expect: With 5 volts applied to the base of the transistor, a current will be flowing out of the emitter irrespective of the voltage on the collector. A further potential problem is that with RB0 driven low, the BC junction will be forward biased. This application either wants a mosfet or a PNP bipolar configured as a common emitter circuit rather than an emitter follower (which then inverts the switch polarity). By putting an extra diode at point (D), you are reducing the voltage by 0.6 volts which is obviously enough to fall below the logic threshold of the PIC. You could also just lower the value of R2 to acheive the same effect. Mike ======================================================================= This e-mail is intended for the person it is addressed to only. The information contained in it may be confidential and/or protected by law. If you are not the intended recipient of this message, you must not make any use of this information, or copy or show it to any person. Please contact us immediately to tell us that you have received this e-mail, and return the original to us. Any use, forwarding, printing or copying of this message is strictly prohibited. No part of this message can be considered a request for goods or services. ======================================================================= Any questions about Bookham's E-Mail service should be directed to postmaster@bookham.com. -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.