Difference between revisions of "Electronics notes/Transistors"

From Helpful
Jump to: navigation, search
m (High side versus low side switching/driving)
m (Some uses)
(5 intermediate revisions by the same user not shown)
Line 216: Line 216:
  
 
https://news.ycombinator.com/item?id=8520086
 
https://news.ycombinator.com/item?id=8520086
-->
 
 
====As a switch====
 
 
<!--
 
 
As noted bove, a BJT in saturation is essentially a switch.
 
 
Note that FETs are more suited to this than BJTs,
 
in that FETs are more energy-efficient - though also more fragile so take some more circuit design care.
 
 
 
The base resistor is usually still necessary.
 
While without one you'ld more easily get saturation,
 
you still often want to avoid drawing any real current from what's on the base pin.
 
 
 
 
A simple [[H-bridge]] is mostly transistors - though you generally want a better designed one, in practice often in IC form.
 
 
Note that simple logic gates are an extension of this.
 
 
https://learn.sparkfun.com/tutorials/transistors/applications-i-switches
 
 
 
 
The voltage drops involved put some restrictions on positioning of components in switches and gates - see (among others).
 
 
-->
 
 
 
=====High side versus low side switching/driving=====
 
{{stub}}
 
<!--
 
[[Image:High and low side.png|300px|right]]
 
High side and low side switching refers to which side of the switch the load sits.
 
 
When that's a mechanical switch, there is almost no difference.
 
 
 
<br style="clear:both">[[Image:High and low side transistors.png|300px|right]]
 
When using transistors,
 
: A high-side driver is one where the load is between Vcc and the (NPN) transistor
 
: A low-side a.k.a. sink-side driver is one where the load is between the (PNP) transistor and Gnd.
 
 
As switches there are a few differences,
 
: the way their behaviour depends more on voltage (differences) between its pins.
 
: one has slightly higher maximum current
 
: sometimes the load forces the choice
 
 
 
<br style="clear:both">'''With microcontrollers'''
 
 
Each GP(I)O pin can typically be switched to both to Vcc and Gnd.
 
For communication that's often fine ''without'' a transistor.
 
 
When switching something that isn't high-impedance load by design,
 
you'll often add a transistor, and you incur these extra voltagey details.
 
 
 
'''Driver ICs'''
 
 
Consider e.g. ULN2803 and its siblings,
 
which also has integrated [[freewheeling diode]]s, and high-side and low-side variants.
 
<br style="clear:both"/>
 
 
 
-->
 
======Some limits and choices======
 
 
<!--
 
'''Constraints from the load'''
 
 
When the load it has other ground-referenced signals, then low-side amounts to taking away the ground, which typically does weird things and you need to use high-side.
 
 
Low-side switching also means that ground levels differ, since the switching element has a non-zero voltage drop. This can matter to some uses.
 
 
Neither of these things matter to most 2-wire loads (motor, solenoid, LED, etc) as they have no need to compare anything to earth (call them floating loads),
 
so in terms of this ground argument can be driven either way.
 
 
 
 
'''If you want to switch higher voltages''' than you supply to your base, you need high-side.
 
e.g. 5V from the uC controlling a 12V LED/motor.
 
 
This because on low-side, the PNP's Vbe needs to be above ~Ve-0.6V{{verify}} to switch off,
 
and due to Ve being so much higher, it will never switch off.
 
 
 
 
 
In general, if both are equally valid, then there is a mild preference to low-side.
 
 
Not "avoid high-side at all costs", just "hey, if you have the choice anyway..." - high side switching
 
: is a little more work
 
: has a lower maximum current ("since P-type (high-side) switching elements usually have a higher on resistance than N-type (low-side) switching elements.[https://electronics.stackexchange.com/questions/188072/difference-between-high-and-low-side-switching-of-power]"{{verify}}/explain)
 
 
 
 
'''Gain matters to current'''
 
 
When switching something that can draw highish current,
 
both transistor gain and the current-limiting resistor matter.
 
 
 
For low-side, that means NPN and that nothing happens below 0.6V (Vbe, basically a constant across all BJT),
 
and it starts conducting current (I<sub>C</sub>=h<sub>FE</sub>*I<sub>B</sub>) above that, and let's assume a gain of 100, so I<sub>C</sub>=100*I<sub>B</sub>.
 
 
If you had put a 10k current-limiting resistor between a 5V uC logic device and the transistor base,
 
that means {{comment|((5-0.6)/10k)=}} ~0.46mA flows into the base, so a switched current is at most 46mA.
 
 
For a 1k that's 4.6mA and 460mA.
 
 
So yes, the output current is mainly limited by the resistor on the base (and voltage, but that will be its (lower) Vcc and constant).
 
 
Which can be a great way to protect a ~100mA transistor from frying.
 
 
But when you ''wanted'' high current, this is one reason for [[Darlington]] transistors,
 
and for just switching to FETs.
 
 
 
 
High-side:
 
 
 
 
Note that various IO pins are tristate and have a third state,
 
not connected to either.
 
 
Either make sure that IO pin never does that, or add a pullup/pulldown on the base.
 
(slightly slower response, though{{verify}})
 
 
 
 
https://electronics.stackexchange.com/questions/188072/difference-between-high-and-low-side-switching-of-power
 
 
https://electronics.stackexchange.com/questions/303148/high-side-or-low-side-led-driver-with-npn-bjt-which-is-better
 
 
http://lednique.com/driving-leds-on-higher-voltage/
 
 
http://lednique.com/gpio-tricks/interfacing-with-logic/
 
 
https://learn.sparkfun.com/tutorials/transistors/applications-i-switches
 
 
 
 
-->
 
<!--
 
When VB would always be less than VE.
 
 
-->
 
-->
  
Line 507: Line 358:
  
 
https://en.wikipedia.org/wiki/Insulated-gate_bipolar_transistor
 
https://en.wikipedia.org/wiki/Insulated-gate_bipolar_transistor
 +
 +
 +
==Phototransistor / optocouple / opto-isolator==
 +
 +
 +
A phototransistor is a transistor with amount of light being the base.
 +
 +
Uses:
 +
* switching things on at night.
 +
* galvanically isolated switching
 +
* galvanically isolated communication - then often IR (and often modulated, to avoid environment light being confusing)
 +
 +
 +
 +
Optocouples are essentially a LED plus phototransistor isolated in an IC.
 +
These are typically used for their galvanic isolation, e.g. avoiding ground loops,
 +
and are also useful when you want simple (one-way) interactions between circuits
 +
at different voltages.
 +
 +
 +
 +
Often appear as 4-pin or 6-pin ICs.
 +
* The 4-pin variants give you the LED (cathode and anode) on one side, and the transistor's (collector and emitter) on the other.
 +
* The 6-pin variant use 5 pins; it adds the transistor's base, which just works as an extra (non-isolated) trigger. In practice it may often be left unconnected
 +
 +
ICs with multiple optocouplers also exist.
 +
 +
 +
 +
Specs vary in details such as:
 +
* current use
 +
* output voltage
 +
* how much voltage difference can be isolated
 +
* added components -- may e.g. be a darlington setup
 +
...and more.
 +
 +
 +
 +
See also:
 +
* http://en.wikipedia.org/wiki/Optocouple
  
  
Line 649: Line 540:
 
-->
 
-->
  
==Phototransistor / optocouple / opto-isolator==
+
==BJTs and FETs as a switch==
  
 +
<!--
  
A phototransistor is a transistor with amount of light being the base.
+
As noted bove, a BJT in saturation is essentially a switch.
  
Uses:
+
Note that FETs are more suited to this than BJTs,
* switching things on at night.
+
in that FETs are more energy-efficient - though also more fragile so take some more circuit design care.
* galvanically isolated switching
+
* galvanically isolated communication - then often IR (and often modulated, to avoid environment light being confusing)
+
  
  
 +
The base resistor is usually still necessary.
 +
While without one you'ld more easily get saturation,
 +
you still often want to avoid drawing any real current from what's on the base pin.
  
Optocouples are essentially a LED plus phototransistor isolated in an IC.
 
These are typically used for their galvanic isolation, e.g. avoiding ground loops,
 
and are also useful when you want simple (one-way) interactions between circuits
 
at different voltages.
 
  
  
 +
A simple [[H-bridge]] is mostly transistors - though you generally want a better designed one, in practice often in IC form.
  
Often appear as 4-pin or 6-pin ICs.
+
Note that simple logic gates are an extension of this.  
* The 4-pin variants give you the LED (cathode and anode) on one side, and the transistor's (collector and emitter) on the other.
+
* The 6-pin variant use 5 pins; it adds the transistor's base, which just works as an extra (non-isolated) trigger. In practice it may often be left unconnected
+
  
ICs with multiple optocouplers also exist.
+
https://learn.sparkfun.com/tutorials/transistors/applications-i-switches
  
  
  
Specs vary in details such as:
+
The voltage drops involved put some restrictions on positioning of components in switches and gates - see (among others).
* current use
+
* output voltage
+
* how much voltage difference can be isolated
+
* added components -- may e.g. be a darlington setup
+
...and more.
+
  
 +
-->
  
  
See also:
+
=====High side versus low side switching/driving=====
* http://en.wikipedia.org/wiki/Optocouple
+
{{stub}}
 +
<!--
 +
[[Image:High and low side.png|300px|right]]
 +
High side and low side switching refers to which side of the switch the load sits.
 +
 
 +
When that's a mechanical switch, there is almost no difference.
 +
 
 +
 
 +
<br style="clear:both">[[Image:High and low side transistors.png|300px|right]]
 +
When using transistors,
 +
: A high-side driver is one where the load is between Vcc and the (NPN) transistor
 +
: A low-side a.k.a. sink-side driver is one where the load is between the (PNP) transistor and Gnd.
 +
 
 +
As switches there are a few differences,
 +
: the way their behaviour depends more on voltage (differences) between its pins.
 +
: one has slightly higher maximum current
 +
: sometimes the load forces the choice
 +
 
 +
 
 +
<br style="clear:both">'''With microcontrollers'''
 +
 
 +
Each GP(I)O pin can typically be switched to both to Vcc and Gnd.
 +
For communication that's often fine ''without'' a transistor.
 +
 
 +
When switching something that isn't high-impedance load by design,
 +
you'll often add a transistor, and you incur these extra voltagey details.
 +
 
 +
 
 +
'''Driver ICs'''
 +
 
 +
Consider e.g. ULN2803 and its siblings,
 +
which also has integrated [[freewheeling diode]]s, and high-side and low-side variants.
 +
<br style="clear:both"/>
 +
 
 +
 
 +
-->
 +
======Some limits and choices======
 +
 
 +
<!--
 +
'''Constraints from the load'''
 +
 
 +
When the load it has other ground-referenced signals, then low-side amounts to taking away the ground, which typically does weird things and you need to use high-side.
 +
 
 +
Low-side switching also means that ground levels differ, since the switching element has a non-zero voltage drop. This can matter to some uses.
 +
 
 +
Neither of these things matter to most 2-wire loads (motor, solenoid, LED, etc) as they have no need to compare anything to earth (call them floating loads),
 +
so in terms of this ground argument can be driven either way.
 +
 
 +
 
 +
 
 +
'''If you want to switch higher voltages''' than you supply to your base, you need high-side.
 +
e.g. 5V from the uC controlling a 12V LED/motor.
 +
 
 +
This because on low-side, the PNP's Vbe needs to be above ~Ve-0.6V{{verify}} to switch off,
 +
and due to Ve being so much higher, it will never switch off.
 +
 
 +
 
 +
 
 +
 
 +
In general, if both are equally valid, then there is a mild preference to low-side.
 +
 
 +
Not "avoid high-side at all costs", just "hey, if you have the choice anyway..." - high side switching
 +
: is a little more work
 +
: has a lower maximum current ("since P-type (high-side) switching elements usually have a higher on resistance than N-type (low-side) switching elements.[https://electronics.stackexchange.com/questions/188072/difference-between-high-and-low-side-switching-of-power]"{{verify}}/explain)
 +
 
 +
 
 +
 
 +
'''Gain matters to current'''
 +
 
 +
When switching something that can draw highish current,
 +
both transistor gain and the current-limiting resistor matter.
 +
 
 +
 
 +
For low-side, that means NPN and that nothing happens below 0.6V (Vbe, basically a constant across all BJT),
 +
and it starts conducting current (I<sub>C</sub>=h<sub>FE</sub>*I<sub>B</sub>) above that, and let's assume a gain of 100, so I<sub>C</sub>=100*I<sub>B</sub>.
 +
 
 +
If you had put a 10k current-limiting resistor between a 5V uC logic device and the transistor base,
 +
that means {{comment|((5-0.6)/10k)=}} ~0.46mA flows into the base, so a switched current is at most 46mA.
 +
 
 +
For a 1k that's 4.6mA and 460mA.
 +
 
 +
So yes, the output current is mainly limited by the resistor on the base (and voltage, but that will be its (lower) Vcc and constant).
 +
 
 +
Which can be a great way to protect a ~100mA transistor from frying.
 +
 
 +
But when you ''wanted'' high current, this is one reason for [[Darlington]] transistors,
 +
and for just switching to FETs.
 +
 
 +
 
 +
 
 +
High-side:
 +
 
 +
 
 +
 
 +
Note that various IO pins are tristate and have a third state,
 +
not connected to either.
 +
 
 +
Either make sure that IO pin never does that, or add a pullup/pulldown on the base.
 +
(slightly slower response, though{{verify}})
 +
 
 +
 
 +
 
 +
https://electronics.stackexchange.com/questions/188072/difference-between-high-and-low-side-switching-of-power
 +
 
 +
https://electronics.stackexchange.com/questions/303148/high-side-or-low-side-led-driver-with-npn-bjt-which-is-better
 +
 
 +
http://lednique.com/driving-leds-on-higher-voltage/
 +
 
 +
http://lednique.com/gpio-tricks/interfacing-with-logic/
 +
 
 +
https://learn.sparkfun.com/tutorials/transistors/applications-i-switches
 +
 
 +
 
 +
 
 +
-->
 +
<!--
 +
When VB would always be less than VE.
 +
-->
 +
 
 +
 
 +
==Current mirror==

Revision as of 13:18, 30 November 2019

This is for beginners and very much by a beginner. It's meant to try to cover hobbyist needs, and as a starting point to find out which may be the relevant details for you, not for definitive information.

Some basics and reference: Volts, amps, energy, power · Ground · batteries · resistors · changing voltage · transistors · fuses · diodes · varistors · capacitors · inductors · transformers · baluns · amplifier notes · frequency generation · skin effect


And some more applied stuff:

IO: wired local IO wired local-ish IO · · · · Shorter-range wireless (IR, ISM RF, RFID) · bluetooth · 802.15 (including zigbee) · 802.11 (WiFi) · cell phone


Sensors: General sensor notes, voltage and current sensing · Knobs and dials · Pressure sensing · Temperature sensing · humidity sensing · Light sensing · Movement sensing · Capacitive sensing · Touch screen notes

Actuators: General actuator notes, circuit protection · Motors and servos · Solenoids

Some stuff I've messed with: Avrusb500v2 · GPS · Hilo GPRS · JY-MCU · DMX · Thermal printer

Audio notes: basic audio hacks · microphones · amps and speakers · device voltage and impedance, audio and otherwise ·

Less sorted: Common terms, useful basics, soldering · Microcontroller and computer platforms · Arduino and AVR notes · ESP series notes · Electronics notes/Phase Locked Loop notes · mounts, chip carriers, packages, connectors · signal reflection · pulse modulation · electricity and humans · Unsorted stuff


See also Category:Electronics.


BJT family

Transistor behaviour (BJT)

This article/section is a stub — probably a pile of half-sorted notes, is not well-checked so may have incorrect bits. (Feel free to ignore, fix, or tell me)

Transistors have four distinct modes of operation:

  • Cutoff
NPN: Vb < Ve and Vb < Vc
PNP: Vb > Ve and Vb > Vc
C-E is an open circuit, nothing happens.
Maximum VCE (VCE = VCC, the least flow through the collector (verify))
  • Active (a.k.a. Forward active)
When
NPN: Vc > Vb and Vb > Ve
PNP: Vc < Vb and Vb < Ve
The C-E currrent is hFE*IB i.e. proportional to the current into the base, amplifying current
  • Saturation
When
NPN: Vb > Ve and Vb > Vc
PNP: Vb < Ve and Vb < Vc
The C-E connection is essentially a short circuit already. The transistor acts like a switch
Saturation also describes the fact that increasing the current on the base no longer has an effect on the C-E current (because it's already maximum).
  • Reverse (a.k.a. Reverse Active)
When
NPN: Vb > Vc and Ve > Vb
PNP: Vb < Vc and Ve < Vb
the gain in this direction will be much smaller
this is rarely used intentionally


When amplifying signals, note that transistors are linear in a region, but nonlinear overall, and you often want to avoid 0V with a little biasing.


https://learn.sparkfun.com/tutorials/transistors/operation-modes


Gain

A BJT's (forward) current gain, hFE, is ΔIC/ΔIB, a dimensionless value.

If the input and output impedance is equal (it often is), this can be simplified to Iout/Iin, and can be given in dB

There is also a reverse gain, which will be much smaller, and is rarely characterized because it's not typically used.



Oscillators

As a diode

Identifying a bipolar transistor's legs

FET family

Voltage controlled resistor

Transistor behaviour (FET)

Insulated-gate bipolar transistors (IGBT)

A hybrid of the above, basically the high-current ruggedness of a Bipolar with the sensitivity of a FET

https://en.wikipedia.org/wiki/Insulated-gate_bipolar_transistor


Phototransistor / optocouple / opto-isolator

A phototransistor is a transistor with amount of light being the base.

Uses:

  • switching things on at night.
  • galvanically isolated switching
  • galvanically isolated communication - then often IR (and often modulated, to avoid environment light being confusing)


Optocouples are essentially a LED plus phototransistor isolated in an IC. These are typically used for their galvanic isolation, e.g. avoiding ground loops, and are also useful when you want simple (one-way) interactions between circuits at different voltages.


Often appear as 4-pin or 6-pin ICs.

  • The 4-pin variants give you the LED (cathode and anode) on one side, and the transistor's (collector and emitter) on the other.
  • The 6-pin variant use 5 pins; it adds the transistor's base, which just works as an extra (non-isolated) trigger. In practice it may often be left unconnected

ICs with multiple optocouplers also exist.


Specs vary in details such as:

  • current use
  • output voltage
  • how much voltage difference can be isolated
  • added components -- may e.g. be a darlington setup

...and more.


See also:


Transistor behaviour, circuit styles (shared, differences)

Compound pairs

Simple logic

BJTs and FETs as a switch

High side versus low side switching/driving
This article/section is a stub — probably a pile of half-sorted notes, is not well-checked so may have incorrect bits. (Feel free to ignore, fix, or tell me)
Some limits and choices

Current mirror