Go Down

### Topic: PWM controls current or voltage? (Read 9847 times)previous topic - next topic

#### batata004

##### Jul 29, 2015, 05:02 pm
Hi,

I read a lot about transistor in the internet but I still have a question. I know the transistor amplifies the current in the base to an equivalent amount of current in the collector/emitter. As far as I know I control the voltage across the base with an Arduino using analogWrite(pin,0), analogWrite(pin,100)..., analogWrite(pin,255). But you see, I am controlling the voltage not the current! So how does changing the voltage across the the base am I also changing the current? I am not using any resistor in my base, I connected it directly to my arduino PWN pin. But when I change the voltag across the base I can see a very different current coming out from the transistor so probably changing the voltage in the base is someway changing the current in the base which changes the current in the output of the transistor.

Thank you all!

#### jremington

#1
##### Jul 29, 2015, 05:37 pm
You MUST use a base resistor or you will end up destroying the output of the Arduino. 220 Ohms is the minimum value to safely use.

A suitably chosen base resistor converts the PWM voltage (minus the transistor base-emitter voltage drop) into a base current, which is amplified by the transistor.

#### DVDdoug

#2
##### Jul 29, 2015, 05:58 pmLast Edit: Jul 29, 2015, 05:58 pm by DVDdoug

Quote
PWM controls current or voltage?
Voltage.   It switches between 0V and 5V at about 450Hz.     At 0V you'll get (almost) zero current.

At 5V you'll get maximum current (determined by the load).    But with no base resistor, you'll get the maximum current the Arduino can deliver (POTENTIALLY DAMAGING IT) and you'll get less than 5V.

The relationship between voltage, current, and resistance is described by Ohm's Law.   Higher voltage = higher current.   Higher resistance = lower current.)

This gets tricky with transistors & diodes because the resistance changes when the voltage changes.   For example, with less than 0.5V across a diode junction (or the base-emitter junction of a transistor) the resistance is low and very little current flows.  As you reach 0.7V the resistance drops to almost zero and you'll get a ton of current if there's nothing to limit it.

LEDs are diodes and they behave the same way, but they have a higher "breakdown" voltage.

Ohm's Law is a law of nature and it's always true.    But, we can't directly apply it to diodes and transistors because we generally don't know the changing resistance.

So when we make current calculations for an LED, we apply Ohm's Law to the series resistor.   (We also apply Kirchhoff's Law to determine the voltage across the resistor from the known breakdown voltage across the LED.)

A transistor is a current amplifier, but in digital circuits it's either on (saturated) or off.   It's generally used   as a "switch" to switch on & off a voltage at a higher current than is available from the control device.

Most amplifier circuits are also voltage  amplifiers even though a transistor by itself is a current amplifier.     For example, say you have an amplifier with a gain of 10...   You put 1V in and you get 10V out.    You put 2V in and you get 20V out.   And, the current depends on the resistance of the load.

#### batata004

#3
##### Jul 29, 2015, 06:15 pm
@jremington thank you I will use one

@DVDdoug thank you so much, you were veery clear. But check this out: if I dont use a base resistor, I still can control the output current of the transistor when I use analogWrite(pin,100) or analogWirte(pin,255). According to you and according to @jremington, the lack of a base resistor should make arduino output the A LOT of current and destroy it. BUT if that was the case I could not control the output current from the transistor but I can! If I connect and LED to the output of the transistor it changes the brightness when I send a 100, 150... 255 PWM.

Probably there is something wrong with my understanding cause my arduino is not getting destroyed, the pin is working perfectly and I still can control the brightness of my LED without resistor.

#### jremington

#4
##### Jul 29, 2015, 06:39 pm
The Arduino will probably work for a while without the resistor, and then it will stop working.

#### jack wp

#5
##### Jul 29, 2015, 06:48 pm
Sorta like, "your car will run for a while, without water in the radiator" But I wouldn't want to keep doing it.

#### batata004

#6
##### Jul 29, 2015, 08:01 pm
Thanks I will use it! But can you explain me how I can control the transistor only changing the voltage across the base pin?

#### DrAzzy

#7
##### Jul 29, 2015, 09:13 pm
The same exact way you were doing it without a base resistor.

Since PWM is either on or off (switching between them very fast), either you're putting 0v onto the base resistor, which means the voltage on the base is 0v - no current flows since base and emitter are at same voltage, or it's on, in which case you're putting 5v onto the base resistor. This voltage will result in current flow through the base resistor and from there through the transistor's base, which turns it on. The voltage on the base will be... a volt or two, depending on the specifics of the transistor you're using.
ATTinyCore for x4/x5/x61/x7/x8/x41/1634/828/x313 megaTinyCore for the megaavr ATtinies - Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy

#8
##### Jul 29, 2015, 09:35 pm
I usually figure the base to emitter voltage Vbe will be 0.7V, or about 1 diode drop, and will allow all the current it can until it burns up.
The Arduino will output 4.2 to 5V, depending on the current it has to output.
So putting a current limit resistor in series from Arduino to base,  you have 5V on one side, and 0.7V on the other, and you can use Ohms Law to select a resistor value such that (5V - 0.7V) = 4.3V across the resistor determines the current flow.
With 20mA into the base of the transistor, that's usually enough to turn the transistor hard (i.e. drive it into saturation) so that the collector/emitter current is determined by the load circuit and not the base current, allowing the transistor to act as a simple switch to the  maximum extent it can.
So plug some numbers into Ohm's Law, V=IR, voltage = current x resistance.
Can rearrange a  little too: V/I = R, and V/R = I. If you know 2 out 3, you can solve for the 3rd:
V/R = R: (5V - 0.7V)/20mA = 215 ohm resistor, 220 is standard value and works well.
If Arduino voltage drops to 4.2V:
V/R = I: (4.2V - 0.7)/220 ohm =15.6mA, should still be enough to turn a transistor on hard generally.
Knowing the specifics for your transistor, a better calculation can be made.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

#### Dazwah

#9
##### Jul 29, 2015, 11:59 pm
Does this mean generally mean as you begin to lower the voltage the current also drops as the resistance going to the base is a constant.

Is the current drain to emitter proportional to the current/voltage applied to the gate?

#### 1:1

#10
##### Jul 30, 2015, 12:18 am
Quote
Ohm's Law is a law of nature and it's always true.
The XY problem:  "the over-use of one line responses that simply link though to websites that describe the XY problem"

#### TomGeorge

#11
##### Jul 30, 2015, 01:52 pm
Hi,

http://www.williamson-labs.com/480_xtor.htm

Check out the animations, particularly the one about not using a base resistor.

Tom....
Everything runs on smoke, let the smoke out, it stops running....

#### jack wp

#12
##### Jul 30, 2015, 08:05 pm
Just my 2cents worth.
This is not something that should keep you awake at night.

If the source can provide the power (amps), then the two things that will determine the amps in a circuit are the voltage, and the resistance.

You can't change the amps alone.

If you increase the volts, then the amps will increase.
If you increase the resistance, then the amps will decrease.

If you remove the resistance (open load), then you will have max voltage, but NO amps.

They all work hand in hand.

#### polymorph

#13
##### Jul 30, 2015, 09:17 pm
Quote
For example, with less than 0.5V across a diode junction (or the base-emitter junction of a transistor) the resistance is low and very little current flows.
DVDDoug meant to say "... the resistance is high and very little current flows."
Steve Greenfield AE7HD
Drawing Schematics: tinyurl.com/23mo9pf - tinyurl.com/o97ysyx - https://tinyurl.com/Technote8

#### raschemmel

#14
##### Jul 30, 2015, 11:02 pmLast Edit: Jul 30, 2015, 11:04 pm by raschemmel
Quote
I read a lot about transistor in the internet but I still have a question. I know the transistor amplifies the current in the base to an equivalent amount of current in the collector/emitter. As far as I know I control the voltage across the base with an Arduino using analogWrite(pin,0), analogWrite(pin,100)..., analogWrite(pin,255). But you see, I am controlling the voltage not the current! So how does changing the voltage across the the base am I also changing the current? I am not using any resistor in my base, I connected it directly to my arduino PWN pin. But when I change the voltag across the base I can see a very different current coming out from the transistor so probably changing the voltage in the base is someway changing the current in the base which changes the current in the output of the transistor.
Quote
If I connect and LED to the output of the transistor it changes the brightness when I send a 100, 150... 255 PWM.
There are many uses for PWM. Use of PWM for any lighting device suggests that changing the duty cycle varies the current, but as we on the forum know, that is an illusion based on the POV phenomenon making it seem to vary the brightness when in fact it is varying the number of photons hitting our eyeballs and Persistance of Vision is taking care of the rest. Use of PWM for motors is another matter. Changing the duty cycle changes the amount of energy (Joules per second) through the motor by changing the time constant for each ON pulse. Unlike the POV phenomenon, we see the motor shaft changing speed because there is a direct correlation between energy in J/s and shaft speed. If the speed changes were beyond the visibly detectable range of the human eye we wouldn't know the speed was changing unless the shaft was driving a system that enabled one to see the change in speed, (ie: a winch lifting a load with a pulley).  The correlation between PWM duty cycle and motor current is such that inertia prevents us from seeing the difference between an ON state and OFF state of the mosfet driving the motor . What we see is the shaft speed changing because of the correlation of energy to torque and hence speed.  The bottom line is that it is irrelevant whether you discuss whether PWM controls voltage or current if you are driving LEDs or motors. The fact is PWM controls brightness in LEDs and shaft speed in motors. That's really all that matters.

Go Up