Pages: [1]   Go Down
Author Topic: PWM with TIP120 driver makes motor beep  (Read 1886 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi everyone,
I'm trying to drive a DC motor salvaged from a printer with the following very simple circuit based on the TIP120 transistor



With this code everything works fine and the motor runs normally

Code:
void setup()
{
   pinMode(5, OUTPUT);
   digitalWrite(5, HIGH);
}
void loop {}

But when I change the code to this one I have problems

Code:
void setup()
{
   pinMode(5, OUTPUT);
   analogWrite(5, 220);
}
void loop {}

What happens is that the motor starts making a continuous high-pitched beep noise. Not very different from a PC speaker beep.
It just makes that noise and it doesn't turn at all.
If I change the PWM value to around 250 it start to turn normally and makes no noise.

Does anyone know what the problem may be and how to solve it so that I can use lower PWM values ? My goal is to make the motor turn as slow as possible.
Logged

South Texas
Offline Offline
Edison Member
*
Karma: 8
Posts: 1024
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yep -

You might need to hook up a capacitor to the lead going to the base of the transistor (arduino pin 5 to ground). What you are hearing is the PWM signal in the motor. PWM Is not quite analog, but does have some of the properties (most of the time...)

You might have a problem - the motor might be designed to run in a certain speed range and won't perform well outside this range. If you want slow rotation you would be better off with a gear motor or a stepper motor.

Try starting the motor at PWM of 255 and slowly reducing that number. You need enough torque to get the motor started and then it will require less torque once it is moving.

What is this motor conected to?
Logged

Dallas
Offline Offline
Sr. Member
****
Karma: 3
Posts: 337
nephew as a kittens
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sounds like the PWM is working but the motor is stalled, even at that relatively high duty cycle. Maybe you need a bigger battery voltage.
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 223
Posts: 6593
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

1. You have the diode connected in the wrong place, you'll blow the transistor if you leave it like that. Connect it in parallel with the motor, anode to TIP120 collector, cathode to +9v. This will also make the circuit more efficient and more likely to work as intended.

2. I recommend adding a large capacitor (e.g. 1000uF) between motor +ve terminal and TIP120 emitter.

3. A TIP120 like any Darlington has a relatively high voltage drop, it could be as high as 3 volts depending on motor current. You can measure the voltage drop across the TIP120 when you digitalWrite HIGH to the pin. Darlingtons are obsolete, mosfets are much better for switching large currents.

4. If the 9v supply is a 9v rectangular battery, then unless it's the expensive lithium variety, it's unlikely to be able to supply enough current to drive the motor well.

5. If you get the motor working with PWM but it still makes a noise, increasing the PWM frequency will help make it quieter.
« Last Edit: January 26, 2012, 09:58:30 am by dc42 » Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

1. You have the diode connected in the wrong place, you'll blow the transistor if you leave it like that. Connect it in parallel with the motor, anode to TIP120 collector, cathode to +9v. This will also make the circuit more efficient and more likely to work as intended.

Just doing this helped _a lot_ . I can now run down to PWM values of 160 which is pretty good for what I need to do.
If this is the best way to wire up a TIP120 and a motor, I'm surprised at the number of wrong tutorials that can be found by googling. Lots of them suggest wiring the diode the way I originally did.

2. I recommend adding a large capacitor (e.g. 1000uF) between motor +ve terminal and TIP120 emitter.

I suppose a ceramic capacitor will be ok, or is an electrolytical cap ok too ?
For the sake of learning, what's the purpose of this capacitor ? Is it for smoothing out the current going to the motor ?

3. A TIP120 like any Darlington has a relatively high voltage drop, it could be as high as 3 volts depending on motor current. You can measure the voltage drop across the TIP120 when you digitalWrite HIGH to the pin. Darlingtons are obsolete, mosfets are much better for switching large currents.

4. If the 9v supply is a 9v rectangular battery, then unless it's the expensive lithium variety, it's unlikely to be able to supply enough current to drive the motor well.

The supply is a laptop PSU, it's rated 3.5A @ 9.5V, so I think it should be fine, even considering the voltage drop of the darlington.
I've read that mosfets are more sensitive to static and in general less rugged than transistors, and I'll need to use this circuit in an environment that is not extremely friendly. I may of course be misinformed.
Do you have any suggestion for a good mosfet that can replace the TIP120 for driving relatively small motors (from printers or RC toy cars) ?

5. If you get the motor working with PWM but it still makes a noise, increasing the PWM frequency will help make it quieter.

Noise is rather ok now. But if I want to increase the PWM frequency, do you think using this code will be ok ?
http://arduino.cc/playground/Code/PwmFrequency
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 223
Posts: 6593
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

2. I recommend adding a large capacitor (e.g. 1000uF) between motor +ve terminal and TIP120 emitter.

I suppose a ceramic capacitor will be ok, or is an electrolytical cap ok too ?
For the sake of learning, what's the purpose of this capacitor ? Is it for smoothing out the current going to the motor ?

You'll have a hard time finding a 1000uF ceramic capacitor, and if you do, it will be huge! It's to smooth out the current pulses drawn by the transistor/motor combination so that the power supply has a more even load. This is especially important when running from a battery.

I've read that mosfets are more sensitive to static and in general less rugged than transistors, and I'll need to use this circuit in an environment that is not extremely friendly. I may of course be misinformed.
Do you have any suggestion for a good mosfet that can replace the TIP120 for driving relatively small motors (from printers or RC toy cars) ?

When you're handling and soldering them, they can be damaged by static charge between the gate terminal and the other terminals. Once they are in a circuit, whatever is driving the mosfet gate (e.g. Arduino) will protect the gate, and they are then more rugged than transistors, e.g. they can take higher current pulses and they are not damaged by avalanche breakdown due to overvoltage provided the total avalanche energy is limited. They also have a built-in reverse diode between source and drain (in an equivalent position to where you originally connected the diode in tour circuit)  so they are protected against negative-going transients too.

There are hundreds of mosfets to choose from, but if you want to drive it directly from the Arduino it needs to have "logic level gate drive". To replace an NPN transistor like the TIP120 you need an N-channel mosfet. For switching currents up to 3A or so, IRLZ24PBF is the cheapest I have found (voltage rating is 60V). For higher current you need a lower on-resistance to avoid the need for a heatsink, and IRLB8742PBF would be a good choice for switching relatively low voltages (voltage rating is 30V).

Noise is rather ok now. But if I want to increase the PWM frequency, do you think using this code will be ok ?
http://arduino.cc/playground/Code/PwmFrequency

Yes, but be aware that changing the PWM frequency affects anything else using the timer associated with that PWM pin. In particular, Timer 0 is used for system timekeeping, e.g. millis() and micros() functions. So choose which PWM pin to use with care.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Idaho, USA
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

dc42 - You mentioned "logic level gate drive" as a requisite for a transistor driven directly by the Arduino. Is the reason for this that the output of the Arduino is very low amperage? Also, logic level, to me, means on or off - is this thinking correct? What other type(s) of gate drive might there be? Just trying to get my head around some of the terms. Thanks.
Logged

Save a fool from his folly, and you fill the world with fools.

United Kingdom
Offline Offline
Tesla Member
***
Karma: 223
Posts: 6593
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

"Gate drive" refers to the voltage you apply between the gate and source terminals of a mosfet to turn it on, and "Logic level gate drive" means this is around 5v instead of higher. In other words, the Arduino has outputs that change by 5v, so if you want to drive a mosfet from such an output without having to amplify it first, you need a mosfet that will switch fully on with just 5v between its gate and source.

Mosfets that are not "logic level" are typically specified for 10v gate drive.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Pages: [1]   Go Up
Jump to: