dave cunningham wrote: > I want to use a pic to switch an inductive load on/off and it was > suggested (on usenet) that the following should work > > VCC (5VDC) > > | > | > .----o > | | 5V Coil > 1N4002 - _|_ Relay > ^ |_/_|- > | | > | | > |----o > | > | > 6.8K | > ___ |/ > o------|___|---o-------| 2N3904 > PIC Output | |> > .-. | > | | | > 6.8K | | | > '-' | > | | > GND GND Looks mostly reasonable. The diode only needs to be 1N4001, which may be a little easier to find. However, the 1N4002 will work fine, it's just specified to a higher voltage than necessary. > I've assembled the circuit (with the input being a PIC pin pulled up to > 5V via a 10K resistor), however the relay switches (on) as soon as power > is supplied to the circuit That's because of the pullup resistor. Why is it there? Are you using the RA4 open drain output? The rest of the circuit is designed for a totem pole output. > and the output state of the PIC pin has no > effect on the relay state. There is something wrong in your code or the wiring. If the PIC pin is actively driving low, the relay should be off. What is the PIC pin voltage when the relay is supposed to be off but isn't? > I've found a similar (to my > mind) relay switching circuit using a BC377 rather than 2N3904 and > missing the 6K8 resistor between ground & the transistor base. Following > that I removed the ground resistor & replaced the second resistor with a > 2K6 one (using calculations provided with the BC377 circuit), but this > doesn't work either! I would lose the 6.8Kohm resistor to ground. > Could anyone explain how the above circuit works and how the values of > the resistors are calculated? Should it in fact be functioning as in > when connected to a pic as I've described? Let's lose the resistor between the base and ground, assume you are using a totem pole output (not RA4 open drain output) PIC pin to drive the "PIC Output" node on your schematic, and assume a 5V supply to the PIC. The 2N3904 is only rated for 200mA collector current, so this must be a small relay. If not, get a bigger transistor. I would use 2N4401 here, which can do up to an amp. The only value to figure out is the single base resistor. You want enough current to flow thru the base to keep the transistor solidly on at the maximum relay current. This transistor has a small signal gain of 300, so let's only require 100 of it so that we have plenty of margin. The max collector current is 200mA. 200mA / 100 = 2mA base desired base current. The base will be at about 700mV when on, so that leave 4.3V accross the base resistor. From Ohm's law, 4.3V / 2mA = 2.15Kohms desired base resistance. There's enough slop in the assumptions so the 2.2Kohms or 2.0Kohms will work fine. ***************************************************************** Embed Inc, embedded system specialists in Littleton Massachusetts (978) 742-9014, http://www.embedinc.com -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics