RSS

How to Drive a Motor using MCU

22 Mar

Before dealing with H-bridge circuits you have to have an idea first on how to control a motor.

We will be using the logic output of the MCU for now.


The circuit shows a DC motor driven by transistor, controlled by an MCU. We all know that common microcontrollers output a logic 1 or logic 0 (5v or 0v ideal).

Common DC motor drivers are biased this way.

 

 

 

Step by step procedure

Step 1: Know the maximum current that flows across your DC motor. Normally it goes around 500mA to 2000mA!


Here is a quick demonstration on how to obtain the DC motor’s maximum current. It’s shown on 3:23min of the vid.


The stall current, or the current across the motor when you hold the spin is the maximum current. If you’re able to get yours already, list it down! That’s your Icollector.


Also remember that the voltage you used on the motor to acquire its current, will be your Vcc(that’s the 9v I used in the schematic, if you used 8volts in testing, then use it instead of my 9volts, we don’t want to mess it all up do we?)


Going back to our circuit


 

 

Up to this point, we now have:

Vcc = 9V.

Icollector = 800mA (assumed)

 

 

 

Step 2: What transistor will we use?

We already know what type it is right? It’s an NPN transistor. Now, what kind of transistor?

I will give you some common NPN transistors that are commonly found in the market. 2n3904, 2n2222, BC547, C9012, S8050.

Look up on their datasheets to know their corresponding maximum collector current.

Here’s an example. Below is for the 2n3904, Ic is 200mA.


Below is for 2n2222, Ic is 800mA.


Recalling our Icollector (motor current value), it’s 800mA. Do you think 2n2222 would be suited for our circuit? The answer is, NO. It should have an allowance for like 20 to 40% or else your transistor will burn.


By experience, I think 8050SS does the job. It has an ICmax of 1.5A. It’s usually found on RC cars, if you have a junked one, try to search up its main circuit. Or look up on your nearest electronic shop if you don’t have one.

Going back to the circuit.


 

Up to this point, we now have:

Vcc = 9V.

Icollector = 800mA (assumed)

Transistor = 8050SS

 

 

 

Step 3: DC Current Gain, Beta, Hfe = all the same. Assume a value for it. Of course that is in the range of the given values in the datasheet.

For 8050SS, the minimum DC Current Gain if 40 (We will use Hfe(2) since our values are quite close to the conditions ).


One thing that we always find hard to understand is assuming the value of DC current gain.

Here’s the thing:

If the assumed value of Hfe is small = more current is allowed to pass the collector

If the assumed value of Hfe is quite large = less current is allowed to pass the collector

In this case, we are dealing with a 800mA current flow(from our motor), so the ideal hfe value would be (choosing from 40 to 300) is ———> 50 or 40. Just assume the close to minimum.

The analogy is like this, there’s a valve and the Icollector is your water. Now, as your DC current gain increases, the area of the drain decreases squeezing the collector current. We don’t want that, or else our transistor will heat up.


 

 

Let us assume a wider opening, the closer to minimum gain.

Hfe = 50

 

 

 

 

Step 4: Solving for Ibase.

 

 

Ibase = Icollector / Hfe. Therefore in our given set of values

Icollector = 800mA

Hfe = 50

 

 

 

 

Ibase = Icollector / Hfe = 800mA / 50 = 16mA = Ibase

Ibase = 16mA. Wow that was hard!

Just take note, we were lucky because our Ibase = 16mA, a microcontroller’s single pin can only source a current of about 20mA. If your Ibase > 20mA then you need to increase your DC Gain a little more, sadly, it will tighten the passage đŸ˜¦.


If tightening the Hfe messes up everything, the last resort would be is that you’d make another transistor circuit that is connector to the base of the 1st transistor. The 1st Transistors Ibase will be the assumed current around the 2nd Transistor. We will settle this on other topics.


Step 5: Choosing the resistor

 

 

Ibase = 16mA

MCU max output = 5v (logic 1)

R = ?

 

 

 

Ohm’s law: R = V/I = 5V / 16mA = 312.5 Ohms = R

 

R = 312.5 Ohms or 300 Ohms is good.

 

“I forgot to mention the flyback diode, it’s a protection diode that protects back emf from the motor to your transistor, any diode will do such as 1n4001, 1n4002 etc. I suppose it is explained on the video above.”

 

You now have all the theory. Driving a motor is very easy, all you need to have is the strength to do it. The motivation to work. Gather as much as experience as you can.


Advertisements
 
1 Comment

Posted by on March 22, 2011 in Tutorials

 

Tags: , , , , , , , , , , ,

One response to “How to Drive a Motor using MCU

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

 
%d bloggers like this: