Maker Pro
Maker Pro

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.
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?
 
N

Noway2

Jan 1, 1970
0
Without referencing a particular device or pin, generally speaking, you
can drive the output of the PIC IO either high or low which means that
you can use an NPN transistor. What you will need to consider, though,
is how much base current you will need to flow in order to drive the
transistor sufficiently and you need to be sure that you don't exceed
the limits of the PIC's drive capability. If it turns out that the
current drive is insufficient, you can use a FET instead and if
necesary drive an NPN or PNP transistor with the FET.

Again, generally speaking, using an NPN or PNP device determines wether
you use it as a "source" or "sink" device when used as a switch. In
this case, by source or sink, I mean is it switching on the power side
or the ground side of the circuit (load).

One thing to keep in mind if you do decide to use a PNP transistor, if
you ground the base by turning on a PIC IO you could very well apply an
extreme Vbe that could damage or destroy the device.
 
C

Chris

Jan 1, 1970
0
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.
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?

Transistors can be used as switches. You want a switch that connects
your ECU to GND when it's active, and disconnects when it's inactive.
You can use an NPN transistor to do this, as shown (view in fixed font
or M$ Notepad):

|
| ------. .----o
| | |
| | |
| | |
| | |
| | ___ |/
| o-|___|-o-|
| PIC | | |>
| | .-. |
| | | | ===
| | | | GND
| | '-'
| | |
| | ===
| | GND
| |
| |
| ------'
|
(created by AACircuit v1.28.5 beta 02/06/05 www.tech-chat.de)

I would assume your transistor will sink less than 20mA when on, so use
2.2K resistors for R, and use a small-signal NPN like a 2N3904 or
2N4401 for the transistor. These are commonly available.

To turn the transistor ON, set the PIC output to "1".

Good luck
Chris
 
J

John Popelish

Jan 1, 1970
0
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.

No. You get to select which pins act as outputs and which act as
inputs. If output is selected, you can order the pin to a logic high
or logic low state. The output circuit has just a bit more current
capability in the low state (sinking current) than it has in the high
state (sourcing current), but the difference is not all that great.
The easiest kind of transistor to drive is a logic level, N channel
mosfet. You connect the gate to the active-high output pin and the
source to ground. The drain connects to a load which is always
connected to a positive supply. If the load is inductive, you may
need a diode across it, to limit the turn off voltage.
I am assuming then I
need to use a PNP, so when it is grounded, it activates the "switch".

In this case, you need a resistor between the output pin and the base,
to limit the output current to what can safely pass through that pin.
And the emitter of the PNP transistor must be tied to the same
supply rail as the PIC.
Now, does it matter what is going through the collector and emitter?

Not to the PIC.
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.

The transistor will pull up to almost the supply voltage for the PIC,
probably 5 volts.
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?

Simulate the ECU by connecting a 1k resistor between the collector and
ground.
 
J

John Fields

Jan 1, 1970
0
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.
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?

---
Yes, according to your later post, (the one with the link to the
drawing) the problem I see is that you're expecting the PIC IO
driving "N" to at least sink the incandescent lamp neutral
indicator's current (and there's also funny going on with the
side-stand relay as well) while at the same time trying to pull the
transistor's input low. That won't happen.

Neglecting all of the other IOs, you should wire up the "N" function
like this:

View in Courier:

+12
|
+---+---+
+5 |NI /SSR|
| +---+---+
[86] |
| C
+-----------B NPN
| | E
_ | C |
N |---+--[860]----B NPN GND
| | E
PIC | | |
| GND
|
|
+--->To 47k resistor
 
J

John Popelish

Jan 1, 1970
0
<No. You get to select which pins act as outputs and which act as
<inputs.

Yes, I know, sorry...I do have them selected as outputs.

Just for clarification, this is what I am trying to do.

http://wotid.com/tls/images/ssatre/transistor_tre.jpg

The exception is that the signal coming through the gearbox, will be
replace with the output of my PIC.

Hope that helps.

A little. Do you want the PIC to approximate the selector switch in
the gear box (7 separate connections that each pull down to ground, in
turn)? If so, I would use 7 mosfets. 6 of them could be small, but
the one that represents the neutral contact has to also drive the
neutral lamp, so it would be a bigger device.
 
actually I only need to approximate 1,2 and 3. Neutral and 4,5 and 6
will actually turn the PIC pin the opposite way and disable the
transistor.
Make sense?
 
J

John Fields

Jan 1, 1970
0
actually I only need to approximate 1,2 and 3. Neutral and 4,5 and 6
will actually turn the PIC pin the opposite way and disable the
transistor.
Make sense?
 
<Do you want the PIC to approximate the selector switch in the gear
box
<(7 separate connections that each pull down to ground, in turn)?

actually I only need to approximate 1,2 and 3. Neutral and 4,5 and 6
will actually turn the PIC pin the opposite way and disable the
transistor.
Make sense?
 
Sorry

<Do you want the PIC to approximate the selector switch in the gear box

<(7 separate connections that each pull down to ground, in turn)?

actually I only need to approximate 1,2 and 3. Neutral and 4,5 and 6
will actually turn the PIC pin the opposite way and disable the
transistor.
Make sense?
 
J

John Popelish

Jan 1, 1970
0
actually I only need to approximate 1,2 and 3. Neutral and 4,5 and 6
will actually turn the PIC pin the opposite way and disable the
transistor.
Make sense?

Nope. Please start back at the beginning and describe what circuit
and signals you are dealing with. What part of the bike schematic is
included and what additional stuff are you trying to add. I can't
make any sense of your last several posts, put altogether.
 
Top