Arduino Forum

Using Arduino => Motors, Mechanics, Power and CNC => Topic started by: kivig on Aug 12, 2011, 04:31 am

Title: Transistor for 12V motor drive?
Post by: kivig on Aug 12, 2011, 04:31 am
Hi,
In short - are there any transistors or ssr capable of driving 12V, 1A or less motor directly from Arduino data pin known to anyone?
Thanks.

I'm making sort of cnc router and I need to drive 12V DC (definitely below 1A, but I'd prefer 1A for safety) motors from arduino. At moment I have suitable mechanic relays. They're not planted yet, but as there will be literally thousands of on/off switches for every contour I'm afraid the relay is a bad choice as it should wear out quickly. So, I'm looking if there's a chance to find reasonably priced alternative.

I want to drive motors directly without intermediate components and PCBs to keep things simple and so in case of failure I know exactly what is wrong and can replace that part quickly, without tester. But my knowledge about transistors is quite limited and purely theoretical.
Title: Re: Transistor for 12V motor drive?
Post by: Grumpy_Mike on Aug 12, 2011, 04:37 am
There are just so many to choose from.
I use the BD679 darlington driver but there are lots more.
However a FET will dissipate less heat on heavy loads so look at a IRLB8748 or other similar logic level FET.

Normally people use stepping motors for a CNC.
Title: Re: Transistor for 12V motor drive?
Post by: dc42 on Aug 12, 2011, 09:26 am
As Mike says, a logic-level MOSFET would be better, it will run cooler and have less voltage drop. Also if you get an avalanche-rated one it is reasonably tolerant of back emf when switching inductive loads like motors. I use type STP40NF10L. At 100V 40A it's overkill for your application but will work just fine.
Title: Re: Transistor for 12V motor drive?
Post by: kivig on Aug 12, 2011, 04:06 pm

There are just so many to choose from.
I use the BD679 darlington driver but there are lots more.
However a FET will dissipate less heat on heavy loads so look at a IRLB8748 or other similar logic level FET.

Normally people use stepping motors for a CNC.

Hi,
thanks for suggestions. What resistor do you use?
Also looking at IRLB8748 specification I don't really get how to calculate what resistance is needed.

Yeah, and there are surely reasons for using steppers :) But as there are ready kits I thought I'll try to make thread/motor drive with encoder first.


As Mike says, a logic-level MOSFET would be better, it will run cooler and have less voltage drop. Also if you get an avalanche-rated one it is reasonably tolerant of back emf when switching inductive loads like motors. I use type STP40NF10L. At 100V 40A it's overkill for your application but will work just fine.

Hi,
STP40NF10L - unfortunately couldn't find it in local stores. Where do you get them?
Title: Re: Transistor for 12V motor drive?
Post by: BetterSense on Aug 12, 2011, 04:22 pm
For a 12V 1A motor, wouldn't a simple TIP120 be fine? Are they not fast enough for PWM or something?
Title: Re: Transistor for 12V motor drive?
Post by: Grumpy_Mike on Aug 12, 2011, 05:49 pm
For a FET there is no need for a resistor as such because the gate is high impedance so you can do without. However if it is being switched very fast with PWM then you are best with a series 100R to limit the current out of the arduino to safe levels. This is because a gate looks like a discharged capacitor and that initially is a short circuit.
Title: Re: Transistor for 12V motor drive?
Post by: CrossRoads on Aug 12, 2011, 06:55 pm
If its N-channel, I'd add 10K pulldown resister to ground on the gate as well so the MOSFET won't be on as the arduino starts up and the pins are inputs before the sketch starts and drives the pin low.
Or a pullup if you want it on to start.
Title: Re: Transistor for 12V motor drive?
Post by: kivig on Aug 13, 2011, 04:05 am

For a 12V 1A motor, wouldn't a simple TIP120 be fine? Are they not fast enough for PWM or something?

Hi,
actually I don't need pwm everywhere, so this should be viable too.


For a FET there is no need for a resistor as such because the gate is high impedance so you can do without. However if it is being switched very fast with PWM then you are best with a series 100R to limit the current out of the arduino to safe levels. This is because a gate looks like a discharged capacitor and that initially is a short circuit.

Good to know :) Thanks.


If its N-channel, I'd add 10K pulldown resister to ground on the gate as well so the MOSFET won't be on as the arduino starts up and the pins are inputs before the sketch starts and drives the pin low.
Or a pullup if you want it on to start.

Hi,
actually I'm curious about what happens when Arduino starts. So when the pins are initially inputs they can have a charge? Is it possible that they go output HI at some point of initialization so they'll be ON even with 10K?
Title: Re: Transistor for 12V motor drive?
Post by: CrossRoads on Aug 13, 2011, 04:35 am
They are inputs when powered up or Reset.  State will be unknown.
10K will pull them low.
Use 5K, 1K, anything down to  ~220 ohms.
Title: Re: Transistor for 12V motor drive?
Post by: dc42 on Aug 14, 2011, 11:22 pm
I am in the UK so I got my STP40NF10L mosfets from www.rapidonline.com (http://www.rapidonline.com), however you can also get them from Farnell/Newark and Digikey.

I also recommend a pulldown resistor with mosfets (I use 100K), and the 100 ohm series resistor suggested by Mike if you are doing PWM.
Title: Re: Transistor for 12V motor drive?
Post by: kivig on Aug 17, 2011, 04:04 am

They are inputs when powered up or Reset.  State will be unknown.
10K will pull them low.
Use 5K, 1K, anything down to  ~220 ohms.

Thanks!


I am in the UK so I got my STP40NF10L mosfets from www.rapidonline.com (http://www.rapidonline.com), however you can also get them from Farnell/Newark and Digikey.
I also recommend a pulldown resistor with mosfets (I use 100K), and the 100 ohm series resistor suggested by Mike if you are doing PWM.

Thanks for links, most are new to me. Rapidonline seems to have good prices.


I'm currently a bit short on finance (nuts and bolts cost next to nothing, but there's a lot of them) so I ordered BD679A and a piece of IRLB 8748PBF to see the difference. I'll change them all later if they'll heat.
Thanks for all the advices!
Title: Re: Transistor for 12V motor drive?
Post by: MarkT on Aug 20, 2011, 04:49 pm
I am doubtful of the assertion that the 12V motor will take less than 1A...  Unless its a unipolar stepper motor I suspect the winding resistance is low enough to pull many amps stall current.  The current a motor takes at no load when up to speed is a tiny fraction of the stall current.
Title: Re: Transistor for 12V motor drive?
Post by: kivig on Oct 02, 2011, 06:06 pm
I've finally finished the hardware part and try to drive the motors.

Something didn't work, so I tried to connect just a single transistor (in attachment). The motor is turning on and off, but it spins at only about half of it's speed. When shorting between transistor legs it goes full speed.
I have tried both BD679A and IRLB8748PbF. Result is the same, except if I disconnect the gate of IRLB8748PbF from arduino, while motor running, touching the gate is enough to put motor to max RPM. I guess it's because it is a FET, but I have no idea if this is normal as didn't had any experience with transistors. (yeah I know - braking the circuit while it's working usually isn't a bright idea :) )


I am doubtful of the assertion that the 12V motor will take less than 1A...  Unless its a unipolar stepper motor I suspect the winding resistance is low enough to pull many amps stall current.  The current a motor takes at no load when up to speed is a tiny fraction of the stall current.

Probably you are right. Motors are Chinese and all I managed to get from seller was 1A, so...
But transistors seem to stay barely above room temperature, and IRLB8748PbF should be an overkill if I understand it right.
Title: Re: Transistor for 12V motor drive?
Post by: CrossRoads on Oct 02, 2011, 06:56 pm
Move the NPN/N-channel transistor so it goes between the motor and Ground.
NPN/N-channel are better as a current "sink" than as a current "source".

With the NPN also put a 150 ohm resistor between the arduino pin and the base so you don't overcurrent the output pin.
Title: Re: Transistor for 12V motor drive?
Post by: kivig on Oct 02, 2011, 08:31 pm

Move the NPN/N-channel transistor so it goes between the motor and Ground.
NPN/N-channel are better as a current "sink" than as a current "source".

With the NPN also put a 150 ohm resistor between the arduino pin and the base so you don't overcurrent the output pin.


I was quite surprised, but changing the order returned 100% (with IRLB8748PbF, with BD679A it reaches only about 90%) to motor speed! How's that possible?

I double checked - the order is the cause indeed, which leads to another problem - with relays I was going to have two on each motor lead to turn it in both directions. Is it impossible to do the same with transistors?

Edit: As these transistors have built in diode, it appears definitely impossible this way.
Title: Re: Transistor for 12V motor drive?
Post by: CrossRoads on Oct 02, 2011, 08:49 pm
Have you consider using an H-Bridge?
L293D will let you spin both directios, has the correct transistors builtin to do that.
http://www.ti.com/product/l293d
Title: Re: Transistor for 12V motor drive?
Post by: dc42 on Oct 02, 2011, 09:11 pm
To drive the motor in both directions, you need an H-bridge. See attached diagram. Note that if you make the mistake of driving both output pins high at the same time, you will short out the 12v supply, so a fuse is highly recommended.

The built-in diode in a power mosfet is not a problem, it is an advantage because in a half-bridge or full-bridge configuration, it acts as a flyback diode.

Alternatively, use an H-bridge chip such as the L293D (if you are certain that the motor stall current is less than about 0.5A) or the L298 (for higher current), but expect to lose up to 3.6v or so in the chip, so you will need to increase your 12v supply to 15v or so.
Title: Re: Transistor for 12V motor drive?
Post by: kivig on Oct 03, 2011, 03:54 am
Thank you very much for the circuit!
Do I understand it right, that the "rule" is - high side should be P-channel and low side N-channel?
Is it possible to drive P-channel transistor gate directly from Arduino pin without inverting it or all P-channel transistors operate as "inverted"?


Have you consider using an H-Bridge?

This is the first time I hear of such IC :) Seems to be the easiest way, but I'm worried about 1A limitation as I don't have precise spec on motor and might change them later.
Title: Re: Transistor for 12V motor drive?
Post by: dc42 on Oct 03, 2011, 09:02 am

Thank you very much for the circuit!
Do I understand it right, that the "rule" is - high side should be P-channel and low side N-channel?


If you were to use N-channel mosfets for the high side, you would need to drive them with a gate voltage at least 5v or 10v higher than the motor supply voltage, and such a supply is not normally available. That is why it is easier to use P-channel mosfets on the high side.


Is it possible to drive P-channel transistor gate directly from Arduino pin without inverting it or all P-channel transistors operate as "inverted"?


To turn the P-channel mosfet off, its gate voltage has to be about the same as its source voltage, which for your system is +12v. If you were using a 5v motor supply and could find a P-channel mosfet that needs only 5v to turn it on sufficiently to pass your motor current, then you could drive the gates of the P-channel mosfets directly from Arduino pins. The purpose of the NPN transistors in my diagram is to shift a 0->5v signal to a 0->12v one (actually 12v->0 because of the inversion). The inversion is also convenient because it allows a single Arduino pin to control both one N-channel mosfet and the opposite P-channel mosfet.



Have you consider using an H-Bridge?

This is the first time I hear of such IC :) Seems to be the easiest way, but I'm worried about 1A limitation as I don't have precise spec on motor and might change them later.


The L298N might be a better choice than the L293D. It is rated at 2A max DC per channel (it is a dual H-bridge), and you can connect the 2 channels in parallel to get 4A total. However, its voltage drop at 1A is 1.8v minimum, 3.2v maximum, so you will need to increase the motor supply voltage to about 15v. You will also need to provide 4 flyback diodes.