Need motor circuit help

Thread Starter

CanElec

Joined Nov 23, 2008
24
Hi all,

I am designing a line follower. I have the Tamiya dual motor gearbox, which contains two Tamiya FA-130 motors: http://www.superdroidrobots.com/product_info/tamiya_motors.htm They are the first ones on that page. I am going to use my ATMega32 to provide PWM to each motor to control speed.

My question is about the circuit. I will run the two PWM ports to transistors which will switch the motors on/off rapidly. I was going to use simple 2N3904 NPN transistors: http://www.fairchildsemi.com/ds/2N/2N3904.pdf but it looks like the max current through these is 200mA? Apparently the motors use up to 660mA each? Do I need to get different transistors?

Also, once I get the right transistors, how do I determine the size of the base resistor? Also will I need a resistor in line with the motors?

One more question: Should I use a different power supply strictly for the motors? For the ATMega32 I am using a 9v battery through a voltage regulator for 5v. If I use this same 5v for the motors, will the high speed switching for the PWM cause the voltage to fluctuate to the microcontroller?

Thanks!
 

hgmjr

Joined Jan 28, 2005
9,027
If you need any assistance with the ATMEGA32 PWM coding be sure to let us know.

A 5V logic-level controlled MOSFET would be a better choice than the BJT.

There are differing philosophies but separating out the supply voltage for the motor and the microcontroller will give you valuable isolation of the micro from any noise that the motor will likely produce.

hgmjr
 

berniek

Joined Dec 24, 2008
1
Hi all,

I am designing a line follower. I have the Tamiya dual motor gearbox, which contains two Tamiya FA-130 motors: http://www.superdroidrobots.com/product_info/tamiya_motors.htm They are the first ones on that page. I am going to use my ATMega32 to provide PWM to each motor to control speed.

My question is about the circuit. I will run the two PWM ports to transistors which will switch the motors on/off rapidly. I was going to use simple 2N3904 NPN transistors: http://www.fairchildsemi.com/ds/2N/2N3904.pdf but it looks like the max current through these is 200mA? Apparently the motors use up to 660mA each? Do I need to get different transistors?

Also, once I get the right transistors, how do I determine the size of the base resistor? Also will I need a resistor in line with the motors?

One more question: Should I use a different power supply strictly for the motors? For the ATMega32 I am using a 9v battery through a voltage regulator for 5v. If I use this same 5v for the motors, will the high speed switching for the PWM cause the voltage to fluctuate to the microcontroller?

Thanks!
Hi. 2N3904 transistors definitely will not handle the current loading unless the motor loading is low, and the PWM rate of increase is low to avoid quick acceleration. A better choice would be a logic level FET, as it does not have the on-state voltage drop of a Darlington transistor. A typical N-channel FET (same polarity as the 2N304) would be the IRLZ24NPBF in a TO-220 case, in stock at Digi-Key. Be aware that you will need to clamp the drain (or collector if you use a conventional transistor) to the power supply) with a diode to keep the motor inductance from avalanching the FET (over-voltage development at PWM turnoff). You will also need to choose the PWM frequency carefully to avoid so-called eddy current heating in the rotor iron. In small motors of the type you are using, 15-20 KHz should be OK. Put a 10-15 ohm resistor in series with the gate. FETs tend to oscillate at high frequencies without that damping resistor, leading to problems which are real head-scratchers. If you are doing a surface mount project, an SO-8 FET (FDS7096N3) is also available, but your PWM rise and fall times must be fast to avoid excessive switching losses. A surface mount compromise from a power handling standpoint would be the SOT-223 STN4NF03L, both also available from Digi-Key. By the way, Digi-Key has dropped their $25 minimum purchase requirement.

Hope this helps. Please write back to me if you need more information. Best wishes for the holidays.

BernieK
BernieK@technicaldevelop.com
www.technicaldevelop.com
 

SgtWookie

Joined Jul 17, 2007
22,230
If you're thinking about using a 9v "transistor" battery to power the motors, you'll need to change tactics.

It'll be enough to power your Atmega for maybe a few hours or so, but not the motors.

An average 9v "transistor" battery has a very limited mAh capacity. If you try to run motors that have a 660mA draw from one, you might even cause the battery to explode, because it will look like (for practical purposes) a dead short across the battery terminals. This will cause most of the battery's power to be dissipated in the battery's own internal resistance, causing a lot of heat.

Instead, consider using a number of "AA" cells in series. Alkaline cells are 1.5v each, where rechargeables are about 1.2v each.
 

Thread Starter

CanElec

Joined Nov 23, 2008
24
Thanks all for the great help! The only electronics distributer that is close to me is http://www.sayal.com/ unfortunately they don't have any of the logic level MOSFETs mentioned in this thread. They have hundreds of MOSFETs though, I just don't know which one to pick. I tried searching for "logic level" in the description but no luck. Is there a way for me to figure out which MOSFET to get without going through hundreds of datasheets?

Thanks!
 

SgtWookie

Joined Jul 17, 2007
22,230
Basically, most of International Rectifier's logic level MOSFETs start off with:
"IRL"
You might have a look at IRLL014 and IRLD014. The IRLL is a surface-mount version, the IRLD is a DIP, which may be easier for you to deal with. Both are small, logic-level compatible, and will carry well over 1A.
 

Thread Starter

CanElec

Joined Nov 23, 2008
24
I now have two potentiometers going to two ADC channels of the uC. Each channel controls a PWM channel in the uC. I have attached two LEDs to the PWM outputs OC1A and OC1B.

Each potentiometer controls its respective LED and dims/brightens it. This works great.

I then removed the LEDs, and hooked up my motor circuit. OC1A and OC1B go to the gates of both MOSFETs. I hooked up a 3v AA battery supply and tried it out.

The motors turn, but they aren't independent like the LEDs were. Starting with both pots turned down, turning pot1 up will increase motor1's speed. If you then turn pot1 down again, you can increase pot2 and motor2 will increase in speed.

However, here is the problem: if you turn a pot up, say pot1, motor1 increases in speed, but then if you increase pot2 without turning pot1 down first, motor2 increases, but motor1 starts decreasing. With both pots up at the same time, both motors slow to almost nothing.

They are fine independently, but when running together they seem to affect the other motor greatly. Any ideas? I've included a crude sketch of my motor circuit.

The MOSFETs are IRLZ44A.
 

Attachments

SgtWookie

Joined Jul 17, 2007
22,230
The tiny AA batteries have at most a 2500mAh rating; much less if you're using cheap or partially exhausted batteries. When you "pour on the juice" to two motors that are rated 660mA @3.6v, you're placing a very heavy load across the batteries, which causes their internal resistance to be a large factor.

Try using three Energizer rechargeable 2500mAh rated batteries in series, one series string for each motor. The batteries when fully charged will measure 1.2v, so three in series will be 3.6v.
 

Thread Starter

CanElec

Joined Nov 23, 2008
24
I am using a total of 4 new energizer AA batteries. They are split into 2 series. So 2 batteries are in series, giving 3 volts, and the other two are in series, giving 3 volts. Then the two +ve are attached and the 2 -ve are attached making the two pairs of batteries in parallel. So I should have plenty of current on tap.
 

eblc1388

Joined Nov 28, 2008
1,542
Paralleling batteries for whatever reason is never a good idea or practice.

They don't "run out" in exactly the same way and so will cause circulating current to flow.
 
Top