mrgizmo wrote: >I am using a 2n3904 to drive a 12V relay off a 16F628 pic at 5V input, I'm >not sure how to figure out the resistor for the base? > > > The gain of most general purpose NPN switches (PN2222A, PN3904) is about 100; that means it will sink 100mA if the base has 1 mA of current driving it. That's because an NPN transistor is a CURRENT AMPLIFIER. For a relay, I'd calculate the load at 2x the current needed to reliably close it. Let's say that 100mA at 12V is needed to reliably actuate the relay. I would then need (for a load of 200mA) a drive of 2mA minimum from the PIC through the base. To calculate the resistor value, you will use ohm's law, I=E/R. The transistor switches at 0.6V above GND, so the resistor will have imposed on it ((VCC of PIC) - 0.6). To obtain the proper drive of 2mA, 0.002 = ((VCC of PIC)-0.6)/R. Multiply both sides of the equation by R makes 0,002R = Vcc-0,6 for a VCC of 5V, R is 2200 ohms... and slightly less is fine.. for a VCC of 3.6V, R is 1500 ohms... and slightly less is fine. --Bob -- Note: To protect our network, attachments must be sent to attach@engineer.cotse.net . 1-520-850-1673 USA/Canada http://beam.to/azengineer -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist