DC motor control using BJT

Trying to control the speed of a DC Motor (MFA 918D100112/1 ) using PWM pin on Arduino connected to the base of an npn BJT (2N3904). This is the proposed circuit:


I am not sure of the resistor values to choose. As I understood correctly R2 is used as a weak pull down resistor for when the base is floating, and R1 is used to ensure a Vbe is 0.7 V for saturation when the Arduino pin supplies 5 V. R3 is used as a current limiting resistor in order not to fry the transistor.

How do I choose the right values for the resistors? I hope I have understood the theory correctly.

That's the wrong transistor. Specified for only 200mA. The motor states 300mA running current and the stall/startup current will be a lot more than that. And you can't successfully run a motor specified for 12-24V on a 3V battery.

Steve

1/

Make R1 `150 ohms, R3 0 ohms, use a BC337 and add a diode eg 1N4001 across the motor , cathode to supply,
and use about 12V as the supply.

Allan

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html

And don't forget to connect the Arduino gnd to the motor supply gnd.
Also remove R2 it is not necessary with a BJT, or increase it to 10K.

Thanks... Tom... :slight_smile:

allanhurst:
1/

Make R1 `150 ohms, R3 0 ohms, use a BC337 and add a diode eg 1N4001 across the motor , cathode to supply,
and use about 12V as the supply.

Allan

Here's how to figure this out ["teach a guy to fish" donchaknow ;D]

Find the datasheet of the transistor you plan to use -- let's use the BC337. I typically search for the device on a site like Mouser, then click on the datasheet link [if you already have the part in hand, then try to find the same manufacturer that made the part you have -- but, the specs for a part number are fairly standard, so you can get away with looking at a different manufacturer's datasheet].

On the datasheet, first, make sure the transistor can handle the highest voltage involved. In this case, you'll probably be using 12V, so make sure the Collector-Emitter Voltage is at least 1.5 times 12V or 18V -- so if the Collector-Emitter Voltage is 18V or higher, you're good to go. The BC337 is 45V so excellent! BTW: you'll usually find this specification in the MAXIMUM RATINGS section.

Then, check to see if it can handle the highest current. Now, this is a little more tricky, because it's more about the transistor's ability to handle the amount of power it will be dealing with. BUT, because this is a switching application, it's a lot simpler. What you want to look at is the VCE(sat). In most cases you'll find that under the ELECTRICAL CHARACTERISTICS. The VCE(sat) is the voltage across the Collector-Emitter junction when the transistor is turned fully on. Some datasheets have graphs that allow you to see what this is at different amounts of collector current [the current going from the Collector to the Emitter]. And some datasheets, just specify this for one or a few different collector currents. The two datasheets I looked at, for the BC337 [Central and ON Semi], this is only spec'ed at IC = 500mA. Which is 0.7V.

Notice how, in that VCE(sat) entry, along with an IC stipulation, there is also an IB indicated? That's because, to turn a transistor on "hard" for switching purposes -- I.e. put it into saturation -- the ratio of the Collector current (or IC), to the Base current (or IB) needs to be in the range of 10 to 20. Notice that the IC value is 500mA, and the IB value is 50mA and that the ratio of the two [500mA/50mA] is 10. That's how much base current is needed, when the collector current is 500mA, to get the Collector-Emitter junction down to 0.7V. BUT, this ratio of=10 stipulation is not written in stone.

Fun Fact: the ratio of the Collector current to the Base current (or IC/IB) is called the Beta. The Greek symbol ß is also used to represent Beta.

What we, next, need to look at, is the MAX Power Dissipation which is 625mW, for the BC337. First let's cut that in half-- because the value they give is the ABSOLUTE MAXIMUM (in other words, right before the thing starts burning up!). So, half of 625mW is 312.5mW. Caveat: this is the power rating at room temperature. If you plan to use this transistor at higher ambient temperatures, then use the derating formula (the one called "Derate Above 25°C"): 5.0mW/°C. So, if the highest ambient temperature will be, say 30°C, then 5.0*(30-25) = 25mW ... so, the ABS MAX power is: 625mW - 25mW = 600mW. And, thus, our excepted Max, which is half the ABSOLUTE MAX, will, instead, be 300mW.

So, let's play with some numbers. An Arduino output can, technically, deliver up to 40mA -- but, that's also an ABSOLUTE MAX. The "happy" max is more like 20ma [the datasheet for the ATmega328P (which is the MCU used in the Arduino Uno) uses "20mA" when it talks about things like VOL (how low the output goes when a LOW is written to a pin) and VOH (how high a pin goes)]. But, since we need all the current we can get, lets call it 30mA. At a base current of 30mA, and a Beta of 10: 1030ma = 300mA. And, the VCE will be a little less than 0.7V at 300mA, but let's call it 0.7V. The power that will be dissipated in the transistor, when it is full on, with 300mA flowing in the Collector will be: 0.7V300mA = 210mW. Which is well below our accepted max of 300mW, so the transistor should survive!

So, to set the base current to 30mA, use this formula: (VCC-VBE)/IB = RB
OR: (5V-0.7V)/30mA = 143Ω [or the standard value: 142Ω]

--That concludes part 1 -- part 2 to follow after a little more than 5 minutes :stuck_out_tongue:

-- Part 2 ----

But, what if the motor needs more current to properly function? Well, that's going to be a problem. Unless we bend the "rules" a bit. Does the Beta really need to be 10? With the datasheets that I found for this transistor, it's hard to tell, so some experimentation will be needed [caveat: this is fine for a personal project, but if this is for something that will go into production and be sold -- then you can get yourself into trouble designing something that doesn't adhere to the datasheet]. BUT, if experimentation is acceptable, then, try upping the base resistor. For instance, let's see what value of base resistor would need to be to drive the motor at a 300mW transistor dissipation level. First, let's guess at what the VCE(sat) will be: How about 1V

To figure out the collector current when the Emitter-Collector voltage is at 1V and the power dissipation is at 300mW, use this formula (derived from P=IE):

I = P/E = 300mW/1V = 300mA

Oops, that's not any better. How about if the VCE(sat) is 0.8V:

I = P/E = 300mW/0.8V = 375mA

So, you might be able to squeeze a little more drive out of that transistor, by increasing the Beta, but only if doing so doesn't raise the VCE(sat) much higher than 0.7V -- only experimentation will tell.

But, the better option is a beefier transistor. How about the 2SC6097 with VCE(sat) more like 150mV at IC=1A and IB of only 50mA [i.e. a **ß** of 1A/50mA = **20**!]

And, with a Collector Dissipation of 800mW, we have some wiggle room! After all, this transistor is rated to 3A!

So, let's see what we can do with a 20mA Arduino output:

20mA*20 = a collector current of 400mA

The 2SC6097 datasheet has an IC - VCE "characteristics curve", so we can do a better job of designing this thing (and be in compliance with the datasheet!). If you look at the 20mA line, you can see what the VCE will be for different Collector Currents! Notice that at an IC of 0.5A, the VCE is less than 0.1V! And, even at 1A it's around 0.13V. So, to get a ballpark, lets see what the IC is when the VCE is 0.13V and the power dissipation in the transistor is 800mW/2 = 400mW:

I = P/E = 400mW/0.13V = 3A

So, we should be able to drive this transistor with a mere 20mA and be OK, even if the current demand is greater than 400ma -- i.e. at Betas greater than 20, because, even if the VCE increases from what it would be at Beta 20, it's already so low that there isn't as much impact on power dissipation as there was with that BC337, with a VCE of 0.7V [which is high, for a switching transistor]. In fact, were good all the way up to 3A. And, even better, such high currents, if ever present, should only be intermittent stall current [we hope], and when the motor is buzzing along in normal use, the current will only be in the 300mA range -- or perhaps something higher, if a load is placed on the motor. At any rate, our little transistor appears capable of handling it all.

BTW: remember all that stuff about Beta in the active region? What that value [300 to 600 for the 2SC6097] means, is, the beta can go that high, but the higher the beta, the further the transistor is from that full turn-on point called saturation. And, in fact, if the Beta reaches the maximum current gain possible for that transistor (with some particular Collector current and Collector to Emitter voltage), then the transistor is no longer saturated, but is, instead, in that region called, "active", that is used more for linear amplification type applications. And, when designing a transistor application, it's all a bunch trade offs. When switching, the beta doesn't, necessarily need to be at 10. That's just the best tradeoff for minimal VCE and the lowest power dissipation. But, if, say you need to drive more current with a limited base current (like in the case of trying to drive things with an Arduino), then you can up the Beta (by increasing the base resistor), as long as you're not going to fry the transistor in the process. And, in those cases, adding a heatsink may help.

This little tutorial is just a 101 -- it's a far bigger subject, but hopefully this will give you a leg up on figuring out how to drive things with a bipolar transistor.

And, I tend to lean more towards a MOSFET when driving anything with even a modest current demand.

  • ReverseEMF......

I agree on a mosfet - a bit dearer, but a better choice - easier to drive, much lower 'on' resistance.

eg IRFL44N, FQP30N06L.

But a BC337 would do. Just about. And very cheap.

Zetex make some very good switching BJT's - eg the ZTX450 for this application..

Your analysis is more or less what I did.

Allan

allanhurst:
But a BC337 would do. Just about. And very cheap.

But, what about stall current, and the possibility of heavy load on the motor? Do you really think the BC337 will handle that?

Also, at Mouser the 2SB6097 is 0.53USD at qu 10. The BC337 is 0.354USD at qu 10. So, yes, a bit cheaper, but the 2SB6097 has such better drive capacity (and at less strain on the Arduino output). And for driving a motor, you probably want that range.

Hi,
Stall current 2.41A;
See attachment.

Tom.. :slight_smile:

1696627.pdf (212 KB)

ReverseEMF:
Notice how, in that VCE(sat) entry, along with an IC stipulation, there is also an IB indicated? That's because, to turn a transistor on "hard" for switching purposes -- I.e. put it into saturation -- the Beta needs to be 10.

The Beta needs to be 10? Does that mean I should get transistors with a beta of 10 for switching applications? The beta is listed on the device datasheet, right?

ReverseEMF:
...So, you might be able to squeeze a little more drive out of that transistor, by increasing the Beta, but only if doing so doesn't raise the VCE(sat) much higher than 0.7V -- only experimentation will tell...

How do I increase the beta of a transistor? Please explain further.

Beta is nothing to do with this, beta is the small signal current gain in linear operation, which does not
apply to switching (where the transistor is either saturated or cut-off, not in the forward region).

In saturation you need the base current to be about 5 to 10% of the collector current for a BJT.

For that amount of stall current a MOSFET or darlington are needed, a single BJT cannot do the job.

MarkT:
Beta is nothing to do with this, beta is the small signal current gain in linear operation, which does not
apply to switching (where the transistor is either saturated or cut-off, not in the forward region).

In saturation you need the base current to be about 5 to 10% of the collector current for a BJT.

For that amount of stall current a MOSFET or darlington are needed, a single BJT cannot do the job.

Beta (or "Forced Beta") is a way of expressing the set point when designing with a transistor. Beta is merely the ratio of IC to IB, and the way to put a transistor in saturation is to force the beta to a smaller value than the specified beta (i.e. the HFE in the datasheet -- or the beta that results in Linear operation). A transistor is an analog device. There, really, is no such thing as an active "switch". There is merely a device that can be set to various degrees of control. For bipolar transistors, it's current controlled by current. For a MOSFET, it resistance controlled by voltage. Just as a MOSFET can never have a channel resistance of zero, a transistor can never have a Collector-Emitter with no voltage drop when controlling current. There is the ideal switch (0Ω when closed, ∞Ω when open), then there is the reality: analog devices being made to function like a switch -- but, it's always imperfect -- no transistor can ever reach the ideal model.

One example of the importance of managing beta is making transistor logic transition faster. By managing beta, to keep the "on" state at the point between active and saturation -- i.e. never allowing the transistor to reach the saturation state -- makes the "switch" faster, because the more a bipolar transistor moves into the saturation region, the more a charge develops at the base -- which must be discharged before the transistor can even begin to transition towards "off". But, the further the transistor moves into the active region, the more current is allowed to pass through the Collector-Emitter junction. So, it becomes a balance between switching speed, and current demand.

In other words, there really is no such thing as "all the way on" -- all the way on would be a VCE of 0.000...V
AND, there is no such thing as all the way off, either. There's always some leakage current.
There are only degrees of "off" and degrees of "on" -- because an Analog device is being used to mimic a switching function.

With a Bipolar Transistor, it's all about current ratios. And Beta is a measure of the target ratio at play, for a particular application. For a switch, the beta is in the lower ranges -- typically 10. For, applications in the active range, the beta is higher. It's like an Op-Amp. The beta rating of a transistor is like the open-loop gain of an op-amp. And the functional beta of a transistor circuit is is like the gain in an op-amp circuit, programmed by the resistor network.

ReverseEMF:
There, really, is no such thing as an active "switch".

Active means requires a power source (aside from being driven by an input signal), right? The power source might be for powering whatever circuits or devices for the switch system to operate.

Southpark:
Active means requires a power source (aside from being driven by an input signal), right? The power source might be for powering whatever circuits or devices for the switch system to operate.

Yeah, I was hunting for a word that would encompass all types of "switch" that are really just analog devices made to emulate an ideal switch. Maybe "active" is not the correct word. Mainly a word that would as broadly as possible, intersect the set of devices such as bipolar transistors, MOSFETs, even switching diodes. So, I wasn't really referring to a system, just a device.

And, come to think of it, not even a mechanical switch is really an ideal switch. Place a high enough voltage across it, when open, and ZAP, it's no longer open [at least during the event]. And, even when it's closed, run a high enough current through it, and it will melt into something altogether different.

It seems to me, there is no such thing as a true switch. Everything is just an approximation.

ReverseEMF:
And, come to think of it, not even a mechanical switch is really an ideal switch. Place a high enough voltage across it, when open, and ZAP, it's no longer open [at least during the event]. And, even when it's closed, run a high enough current through it, and it will melt into something altogether different.

It seems to me, there is no such thing as a true switch. Everything is just an approximation.

Yes, Mother Nature has to get her oar in somewhere and stuff the idealized theory up! :o :o :o

Although a few guys called Voltaire, Ohm and Ampere can also be blamed... :o :o :o

Tom... :slight_smile:

ReverseEMF:
For a switch, the beta is in the lower ranges -- typically 10. For, applications in the active range, the beta is higher. It's like an Op-Amp. The beta rating of a transistor is like the open-loop gain of an op-amp. And the functional beta of a transistor circuit is is like the gain in an op-amp circuit, programmed by the resistor network.

I repeat, beta is the small signal current gain, its nothing to do with operating a transistor at saturation, and
its measured in the standard forward region of operation.

At saturation the base collector junction is forward biased, there is no transistor action in the standard sense
as the collector repels charge carriers from the base rather than attracting them. The current flows because
the density gradient of charge carriers is extreme(*), and carriers from the emitter have a better than evens
chance of diffusing to the collector before interacting with the base electrode. In fact usually 90% chance or
so.

In normal transistor action the emitter carriers just have to diffuse to near the base-collector junction, rather
than all the way to the collector contact. The reverse biased base-collector junction then attracts them across
very efficiently.

(*) The density of carriers in the emitter is about 10,000 times higher than the collector, the base is intermediate.

MarkT:
I repeat, beta is the small signal current gain, its nothing to do with operating a transistor at saturation, and
its measured in the standard forward region of operation.

OK, maybe I'm using the term incorrectly. I learned that Beta is the ratio of lC to IB. Typically, when the VCE(sat) is specified in a datasheet, it includes the IC and IB where this saturation voltage is expected, and is usually a ratio of 10 to 20. So, this is not Beta? I understand that there is a beta [typically referred to as "hFE"] for the active region of the transistor [the maximum Beta?]. But, it's my understanding that there is also a "forced Beta" for driving the transistor into saturation, or near saturation.

I mean, the lC to IB ratio varies for different operating points, even in the active region. Transistor datasheets often specify more than one hFE, for various Collector currents.

In the regions, near saturation, the ratio can be quite a bit less. In fact, this ratio doesn't just, suddenly change from the datasheet hFE, to the 10 or 20 ratio that occurs when the transistor is "turned on". It's a smooth transition [not linear, but also, not sudden]. So, at what point does it stop being the Beta, and exists, merely, as a current ratio?

MarkT:
I repeat, beta is the small signal current gain, its nothing to do with operating a transistor at saturation, and
its measured in the standard forward region of operation.

ON Semiconductor/Fairchild appears to disagree (unless the Greek letter β doesn't refer to Beta):


This is from the ON Semi 2N3906 datasheet.

And, here's a diagram showing that hFE is not just one value, but can be vastly different depending on operating point.

I suppose you can argue that the VCE(sat) point (red dot), is not a Beta value, because the transistor is in Saturation, but, it's still the ratio of IC to IB, which, as I understood, is the definition of Beta. So, maybe the point of contention is type of Beta. Perhaps the distinction is Active Region Beta, vs.Saturation Beta. OR, Maximum Possible Beta [those hFE specifications on the datasheet] and Forced Beta [i.e. using Beta to position the operating point on the Characteristic curve]. For switching, the goal is to get as close to the ideal switch model in a tradeoff between practicable and practical. This usually means a Beta of 10 to 20. For a, for instance, Class A amplifier, the beta will, typically be set to a higher point. But, rarely will the transistor operate at its maximum possible beta. Usually a linear amplifier design goal is to swamp out variations in beta [due to temperature changes, changes in collector current, and production variances].

Hi,
Some reference material;

Transistor gain summary
The various notations for transistor gain can be summarised as below.

  • Beta; Β: This is the basic notation for the forward current gain of a transistor.
  • hfe: This is the current gain for a transistor expressed as an h parameter (hybrid parameter). The letter f indicates that it is a forward transfer characteristic, and the letter e indicates it is for a common emitter configuration. The small letter h indicates it is a small signal gain. hfe and small signal Beta are the same.
  • Hfe: The Hfe parameter differs from hfe in that it is the h parameter for the DC or large signal steady state forward current gain.

The different abbreviation used for the transistor gain, Hfe, hfe & Beta are all widely used, although the parameters Hfe, hfe tend to be more widely used in datasheets.

Tom.... :slight_smile:
Ohhh "z-parameters", takes me back and back and back......