PIC and Transistor

Basically what I want to do is use the output pins of my PIC to activate some transistors. If i understand correctly, activating a PIC pin essentially grounds it, so an NPN won't work. I am assuming then I need to use a PNP, so when it is grounded, it activates the "switch".

Now, does it matter what is going through the collector and emitter? I would like to have a Positive voltage sitting on one side of the transistor, and the other side of the transistor would go to an ECU in a vehicle. Under most circumstances, the transistor will be ungrounded, which should mean that there is no flow through the transistor, and no signal to the ECU (that is what I want). When instructed, the PIC will ground the base, allowing current to flow through the transistor and sending the positive signal from the other side of the transistor to travel to the ECU. Basically it is -

formatting link
- but the transistor would be activated by a PIC. Maybe I am missing something, but I cannot get this work no matter which I use PNP, or NPN. Is anyone able to shed some light on this for me?

Reply to
b.clarke
Loading thread data ...

Which PIC are you using? In most cases making a PIC pin an output pin by clearing a corresponding bit in TRIS register and then setting that pin to 1 makes voltage appear on the that pin. On some PICs though, like the very common 16F84 and I am guessing other 16 series chips, pin RA4 is more like you understand it, an open drain output so if you make it an output by clearing TRISA:4 then set RA4 to zero, it will ground whatever is connected to it.

It does. Collector goes to the positive side of the circuit.

Notice that in the diagram you have given the link to, the transistor sits between the ECU and the ground, not between the positive rail and the ECU like you are saying which is quite different. You should probably stick to that arrangement rather than having the transistor between the positive rail and the ECU because if ECU is a high impedance load, the emitter of the transistor will be close to the positive rail voltage and that might create some unwanted side effects because a transistor needs voltage difference of 0.6V between base and emitter to switch. If you switch the transistor on with 5V on a PIC pin and the emitter is sitting on 4.9V because voltage drop across the ECU is 4.9V, then the voltage across base and emitter is around 0.1, maybe the transistor will switch right off again?

Eugene.

Reply to
ER

Most PIC output pins are "totem pole", meaning that they can source and sink current. An NPN will work fine with a PIC.

ungrounded,

If you want the transistor to "be on top" (meaning between the battery and the device being switched) and supply the positive voltage to a device, then you usually want a PNP type. The problem is that you need to pull the base higher than the collector to switch it off. If you are using a PIC with 5V outputs and trying to switch 12V, you have a real problem. Never fear, the manufacturers have already solved it for you though. What you want is a "high side driver". This is something like a P-channel MOSFET with a built in charge pump to be able to pull the gate (base equivalent) up to a high voltage, but using a logic level input. Take a look at the VN820.

OTOH, your schematic clearly shows a low side switch. Many NPN type transistors would be able to do this with relative ease.

Reply to
Anthony Fremont

Put a resistor (10k) between the transistor base and the PIC output. Then put another resistor (22k) between the PIC output and the 12v rail. For added safety put a 5.1v zener diode between the PIC output and ground.

Use a NPN transistor. Ground the emitter. Collector to ECU.

HTH

Alan

-- Sell your surplus electronic components at

formatting link
Search or browse for that IC, capacitor, crystal or other component you need.

Reply to
Alan

look up "tristate" maybe you dont need a transistor, what is the load?

Reply to
Ed-

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.