A general question about electronics

hello guys,
our main goal here is to program microcontrollers, in our case the arduino.
i was reading a little bit about diodes and transistors, well my question is: out applications are most likely controlling LEDs, motors, servos so the application of our electronics like transistors is know right ? is there any other usages for it ? i mean all the basic circuits for each devices are already know how to connect and how to program

Our main purpose is more than programming the Arduino, it is getting a complete project going.

The Arduino on its own is boring. What we can add to it is the fun part. Yes there are a lot of basic circuits used but there are needs for interfacing new sensors or using the basics in strange ways.

Weedpharma

weedpharma:
Our main purpose is more than programming the Arduino, it is getting a complete project going.

The Arduino on its own is boring. What we can add to it is the fun part. Yes there are a lot of basic circuits used but there are needs for interfacing new sensors or using the basics in strange ways.

Weedpharma

yea sure i meant in a project, so what do you mean in a strange way ?
well i read always about electronics like the caps and resistors and transistors, the main stuff which you should be able to use without any microcontrollers first, but i never felt i can do anything alone without making research for examples projects :confused:

The arduino output current is limited, and not able to drive many devices. You can use amplifiers, such as transistors, or relays to drive heavy loads.

If you don't know much about transistors/resistors, etc. you may find a relay to be easier to use. Either mechanical, or solid state relays are easy to connect.

good point, now i am reading about transistors, but yet the amplifier thing doesn't sink in ! i mean what exactly it means does it amplify the current ? if so how is that ? is that by connecting the Base to arduino and the Collector to lets say 12V battery and emmiter to the rest of the circuit for NPN type ?

No, you would use PNP for that (i.e. "high side switch").
Use NPN when you want to connect the circuit to Gnd (i.e. "low side switch").

In this case, where the Arduino digital output is driving the base, the transistor is acting as a switch, controlling the flow of large amounts of current with a smaller amount of current. So you could say the current flow is "amplified". Technically, the larger current flow is either on or off, and controlled by whatever else is in the circuit (such as LED current limit resistor, or the impedance of a motor coil) so I don't think of that as "amplified", more as switched on or off.

When I think "amplifier", I envision varying amounts of base current (for NPN or PNP) or gate voltage (for MOSFETs) which directly impact the collector/emitter or source/drain current that is allowed to flow.

CrossRoads:
No, you would use PNP for that (i.e. "high side switch").
Use NPN when you want to connect the circuit to Gnd (i.e. "low side switch").

i am really confused when i was reading about the current NPN it's from emmitter to the collector the electrons goes but for the conventional current goes from collector to emitter,
the opposite for PNP from collector to emmitter and emitter to collector
this logic is really confusing

so you say the NPN should be connected like if it is at the end of the circuit before the gnd ?

CrossRoads:
In this case, where the Arduino digital output is driving the base, the transistor is acting as a switch, controlling the flow of large amounts of current with a smaller amount of current. So you could say the current flow is "amplified". Technically, the larger current flow is either on or off, and controlled by whatever else is in the circuit (such as LED current limit resistor, or the impedance of a motor coil) so I don't think of that as "amplified", more as switched on or off.

When I think "amplifier", I envision varying amounts of base current (for NPN or PNP) or gate voltage (for MOSFETs) which directly impact the collector/emitter or source/drain current that is allowed to flow.

yes on off exactly but about the amplifier linear, i guess there is special types of transistors i mean special models that are linear to make amplifier with the base when it's amplified by the microcontroller the current goes up ?

firashelou:
i am really confused when i was reading about the current NPN it's from emmitter to the collector the electrons goes but for the conventional current goes from collector to emitter,
the opposite for PNP from collector to emmitter and emitter to collector
this logic is really confusing

PNP and NPN (as well as P-channel and N-channel MOSFETs) are basically mirrors of eachother.

In both cases, the emitter (or source for MOSFET) goes to a supply rail (a positive voltage for PNP/P-ch, ground for NPN/N-ch), the collector (or drain for MOSFET) goes to the appropriate side of the load.
For PNP transistors, you turn them on by applying a negative current to base (ie, pulling it towards ground through a resistor), for NPN, you turn them on by applying a positive current to base (ie, pulling it towards supply through a resistor). Likewise for P-channel MOSFETs, you apply a voltage below supply to the gate to turn it on, and for N-channel MOSFETs, you apply a voltage above ground to the gate to turn it on.

For BJT's, NPN transistors are easier to work with - it's easy to switch voltages higher than the supply voltage with them (unlike PNP, where you usually require another NPN transistor to switch it), and for equal performance, NPN's are cheaper (they're easier to make, apparently).

Same goes for MOSFETs - both on ease of use and cost. MOSFETs make better switches than BJTs.

yes on off exactly but about the amplifier linear, i guess there is special types of transistors i mean special models that are linear to make amplifier with the base when it's amplified by the microcontroller the current goes up ?

No. For linear operation, like for an audio amplifier, you would bias the transistor so small variations at the base are amplified into larger variations, while staying in the linear range of the transistor and not distorting the audio.

For use with a microcontroller, the input is either on or off - so the output is either on or off. The transistor is a switch. Imagine replacing the transistor with a relay - that's what is effectively being controlled. Is the transistor amplifying anything? No. It is just turning on or off, and the circuit it is connected to is what really controls the perceived amplification. You're just turning the transistor to its full-on region where it most effectively act as an on-switch.

firashelou:
i am really confused when i was reading about the current NPN it's from emmitter to the collector the electrons goes but for the conventional current goes from collector to emitter,
the opposite for PNP from collector to emmitter and emitter to collector
this logic is really confusing

With semiconductors you have to deal with charge carriers being of either polarity - electrons are -ve
and holes are +ve. In n-type there are lots of free electrons and only miniscule numbers of holes (at
equilibrium), in p-type there are loads of free holes and only miniscule numbers of free electrons (at
equilibrium).

Sometimes the current is mainly electrons, sometimes it is mainly holes, so you have to be aware
of charge polarity. In an NPN transistor amplifier the base-emitter junction is forward biased and
conducting, the base-collector junction reverse biased and also conducting - this is because the
base is extremely thin and nearly all the electrons from the emitter diffuse far enough into
the base to see the electric field of the base-collector junction and be whisked off towards it. This
makes the base current much smaller than the emitter current, hence amplification (typically 100 to
400 times)

In saturation (transistor as a switch, fully on) there is no electric field to whisk electrons to the collector,
so fewer get there (they still get there because of diffusion because the emitter is doped > 1000
times more strongly than the collector, so the emitter electrons totally dominate the device numerically).
However the base current is about 5 to 10% of the emitter current in full saturation, ie the current
gain is much lower.

so you say the NPN should be connected like if it is at the end of the circuit before the gnd ?
yes on off exactly but about the amplifier linear, i guess there is special types of transistors i mean special models that are linear to make amplifier with the base when it's amplified by the microcontroller the current goes up ?

In linear mode the collector is kept at least a volt or two higher than the base, in switching the
collector needs to be as close to the emitter voltage as possible. Most transistors can be used as
linear amplifiers or as switches quite happily. Some are optimized for amplification (low noise,
high gain), others optimized for switching (deep saturation, low on resistance, low charge-storage)

In saturation lots of charge carriers permeate the whole device, making switch-off times slower than
switch-on as all these charges have to clear to the collector before the current falls off.

In practice linear amplification is made more linear through negative feedback (as in an opamp),
since you can trade raw gain for linearity, and gain is easy.

In fact most interfacing to analog circuitry uses opamps as gain providers, ADCs and DACs sometimes
have an opamp stage built-in to make this even simpler.

Hiya firashelou,

Here's an easy way to think about transistors, at least npn transistors, such as the very common 2N2222:

You are familiar with the simplest way to light an LED, right? Connect your pin to a resistor, then through the anode of your LED, and out the cathode - to ground, like this:

If you want the LED to be very bright, make the resistor value (R) quite small, say a hundred or one fifty ohms. This will give you close to 20 milliamps, and your Arduino can handle the current just fine. But, what if you are turning on a bunch of LEDs, or doing something else that takes a lot of current - you will exceed the current capacity of your Arduino's pin quickly!

So put in a transistor, like this:

Regulate the current draw on your Arduino with the resistor Rb. Make it big enough to limit the current the pin needs to provide, while small enough to reliably turn the transistor on. If Rb is 10K ohms, then the draw on the Arduino is about .5 milliamps. And if you keep the value of R the same as the transistor-less example above, the LED will still see 20 milliamps, and be just as bright. The difference is that most of the current runs through the transistor, and not the Arduino. Your Arduino puts out .5 ma, and the LED sees 20 ma. The current is amplified by a factor of 40x*.

  • a bit less, as I didn't take the voltage dropping that transistors (and diodes) do into account.

CrossRoads:
No. For linear operation, like for an audio amplifier, you would bias the transistor so small variations at the base are amplified into larger variations, while staying in the linear range of the transistor and not distorting the audio.

For use with a microcontroller, the input is either on or off - so the output is either on or off. The transistor is a switch. Imagine replacing the transistor with a relay - that's what is effectively being controlled. Is the transistor amplifying anything? No. It is just turning on or off, and the circuit it is connected to is what really controls the perceived amplification. You're just turning the transistor to its full-on region where it most effectively act as an on-switch.

ah ok thanks for the explanation, so about the linear operation which devices we use here to make very small amount at the base, is it by simply adding some potentiometer or else ?

ChrisTenone:
Hiya firashelou,

Here’s an easy way to think about transistors, at least npn transistors, such as the very common 2N2222:

You are familiar with the simplest way to light an LED, right? Connect your pin to a resistor, then through the anode of your LED, and out the cathode - to ground, like this:

If you want the LED to be very bright, make the resistor value (R) quite small, say a hundred or one fifty ohms. This will give you close to 20 milliamps, and your Arduino can handle the current just fine. But, what if you are turning on a bunch of LEDs, or doing something else that takes a lot of current - you will exceed the current capacity of your Arduino’s pin quickly!

So put in a transistor, like this:

Regulate the current draw on your Arduino with the resistor Rb. Make it big enough to limit the current the pin needs to provide, while small enough to reliably turn the transistor on. If Rb is 10K ohms, then the draw on the Arduino is about .5 milliamps. And if you keep the value of R the same as the transistor-less example above, the LED will still see 20 milliamps, and be just as bright. The difference is that most of the current runs through the transistor, and not the Arduino. Your Arduino puts out .5 ma, and the LED sees 20 ma. The current is amplified by a factor of 40x*.

  • a bit less, as I didn’t take the voltage dropping that transistors (and diodes) do into account.

thanks for that explanation very simple, well yes so far i read about the multiplier factor, so yes it’s like a relay the main line connected between +5 and GND and not arduino so the arduino controls the base, so if i want to make this base changeable i must add a variable potentiometer or something which by varying the resistance i make variation to the main current which will give a brighter or dimmer LED right ?

MarkT:
With semiconductors you have to deal with charge carriers being of either polarity - electrons are -ve
and holes are +ve. In n-type there are lots of free electrons and only miniscule numbers of holes (at
equilibrium), in p-type there are loads of free holes and only miniscule numbers of free electrons (at
equilibrium).

Sometimes the current is mainly electrons, sometimes it is mainly holes, so you have to be aware
of charge polarity. In an NPN transistor amplifier the base-emitter junction is forward biased and
conducting, the base-collector junction reverse biased and also conducting - this is because the
base is extremely thin and nearly all the electrons from the emitter diffuse far enough into
the base to see the electric field of the base-collector junction and be whisked off towards it. This
makes the base current much smaller than the emitter current, hence amplification (typically 100 to
400 times)

In saturation (transistor as a switch, fully on) there is no electric field to whisk electrons to the collector,
so fewer get there (they still get there because of diffusion because the emitter is doped > 1000
times more strongly than the collector, so the emitter electrons totally dominate the device numerically).
However the base current is about 5 to 10% of the emitter current in full saturation, ie the current
gain is much lower.
In linear mode the collector is kept at least a volt or two higher than the base, in switching the
collector needs to be as close to the emitter voltage as possible. Most transistors can be used as
linear amplifiers or as switches quite happily. Some are optimized for amplification (low noise,
high gain), others optimized for switching (deep saturation, low on resistance, low charge-storage)

In saturation lots of charge carriers permeate the whole device, making switch-off times slower than
switch-on as all these charges have to clear to the collector before the current falls off.

In practice linear amplification is made more linear through negative feedback (as in an opamp),
since you can trade raw gain for linearity, and gain is easy.

In fact most interfacing to analog circuitry uses opamps as gain providers, ADCs and DACs sometimes
have an opamp stage built-in to make this even simpler.

well that's what i am reading about but it's not making it simple and easy to understand :confused:

first i would like to know something: a wire is conductor because it has holes in it which will be filled by the coming electrons ? is that how it works in term of physics ?
if so then when the cable holes are all full how can that conduct more electrons therefore more current ?

The wire originally doesn't have any (or at least, many) holes. When a voltage potential is applied to the wire, making a series circuit, the potential shoves electrons away from the end of the wire connected to the negative side of the potential ( source, battery, power supply, etc.) towards the end of the wire connected to the positive potential (electrons have a negative charge and repell each other). At the same time, electrons at the end of the wire connected to the positive potential are sucked away from the wire and into the supply. As electrons are pushed from the negative side of the supply (by the voltage potential), the positive side is sucking electrons away from the wire (the load), thus making holes available for the electrons coming from the negative side ( the same thing is propagated through the wire. As atoms in the wire have electrons sucked away, they attract electrons from the atoms having electrons pushed at them from the negative side.

Electron current is the movement of those electrons from the negative potential towards the positive potential.

Conventional current is the visualized movement of the holes from positive to negative, as the electrons flow in the opposite direction.

I think,,, my brain hurts....

Metals have electrons as charge carriers and positive fixed charges - good conductors like copper and
silver have about 1 electron per atom free to move, meaning they are supremely good electrical
conductors.

In a semiconductor electrons and holes are being generated and recombining all the time, usually
the product of the concentrations of electrons and holes (at equilibrium) depends on the semiconductor
material and temperature only - so when you dope a semiconductor as n-type the free electrons become
more numerous (perhaps by a million or a billion-fold), and the holes less numerous by the same factor.

So to a first approximation there are no holes, but the rate of electron-hole generation/recombination
hasn't changed, its just that holes have an incredibly short lifetime, electrons a far far longer life. You'll
hear the phrases "majority carrier" and "minority carrier".

When a pn-junction conducts vast numbers of carriers move across the junction, changing from
majority carriers into minority carriers, and meaning the concentration of minority carriers
increases above equilibrium levels by perhaps a dozen orders of magnitude - this is no longer
equilibrium and the rate of recombination rises way way above the background rate. This causes
light to be emitted in an LED for instance as each recombination can generate a photon of light
if conditions are favorable.

Having majority carriers move across a (forward-biased) pn-junction to become minority carriers
is called "carrier injection" and is important to LEDs, laser diodes, and BJTs, which all rely on non-
equilibrium behaviour.

123Splat:
The wire originally doesn't have any (or at least, many) holes. When a voltage potential is applied to the wire, making a series circuit, the potential shoves electrons away from the end of the wire connected to the negative side of the potential ( source, battery, power supply, etc.) towards the end of the wire connected to the positive potential (electrons have a negative charge and repell each other). At the same time, electrons at the end of the wire connected to the positive potential are sucked away from the wire and into the supply. As electrons are pushed from the negative side of the supply (by the voltage potential), the positive side is sucking electrons away from the wire (the load), thus making holes available for the electrons coming from the negative side ( the same thing is propagated through the wire. As atoms in the wire have electrons sucked away, they attract electrons from the atoms having electrons pushed at them from the negative side.

Electron current is the movement of those electrons from the negative potential towards the positive potential.

Conventional current is the visualized movement of the holes from positive to negative, as the electrons flow in the opposite direction.

I think,,, my brain hurts....

123Splash thanks for your reply, but when does the circuit becomes saturated ?! when the electrons fill in all the holes and then the battery holes how come they keep going again and again ?

MarkT:
Metals have electrons as charge carriers and positive fixed charges - good conductors like copper and
silver have about 1 electron per atom free to move, meaning they are supremely good electrical
conductors.

In a semiconductor electrons and holes are being generated and recombining all the time, usually
the product of the concentrations of electrons and holes (at equilibrium) depends on the semiconductor
material and temperature only - so when you dope a semiconductor as n-type the free electrons become
more numerous (perhaps by a million or a billion-fold), and the holes less numerous by the same factor.

So to a first approximation there are no holes, but the rate of electron-hole generation/recombination
hasn't changed, its just that holes have an incredibly short lifetime, electrons a far far longer life. You'll
hear the phrases "majority carrier" and "minority carrier".

When a pn-junction conducts vast numbers of carriers move across the junction, changing from
majority carriers into minority carriers, and meaning the concentration of minority carriers
increases above equilibrium levels by perhaps a dozen orders of magnitude - this is no longer
equilibrium and the rate of recombination rises way way above the background rate. This causes
light to be emitted in an LED for instance as each recombination can generate a photon of light
if conditions are favorable.

Having majority carriers move across a (forward-biased) pn-junction to become minority carriers
is called "carrier injection" and is important to LEDs, laser diodes, and BJTs, which all rely on non-
equilibrium behaviour.

this is a bit confusing but thanks MarkT :slight_smile: