Pages: [1] 2   Go Down
 Author Topic: running motor with no motor shield  (Read 488 times) 0 Members and 1 Guest are viewing this topic.
Offline
Jr. Member
Karma: 0
Posts: 69
Carpe Diem
 « on: May 01, 2012, 03:40:46 pm » Bigger Smaller Reset

Hi All,

I have regular toy motors that I want to use directly with the arduino pins. I was going to plug one end of the motor to pin 4 and the other to pin 5 then set one high and the other low to go forward, and do the reverse to go backward.. My question is what resistor should I use on these pins so that the load wouldn't cause the arduino to restart, or worse, get fried..

I understand that the arduino pins can handle up to 40 mA. My problem is that I don't know how to calculate which resistors to use.. =)

Thanks!

ps please explain how you got to the answer so I can do it myself in the future

 Logged

Manchester (England England)
Offline
Brattain Member
Karma: 269
Posts: 25394
Solder is electric glue
 « Reply #1 on: May 01, 2012, 03:49:48 pm » Bigger Smaller Reset

To calculate the resistor use ohm's law. Resistance = voltage / current
For 40mA and 5V this works out at about 100 ohms.

However there are two points, back voltage from the motor will damage the arduino if you don't fit diodes. You will find that 40mA is not enough to drive a motor.

You don't need a shield but you do need some driving circuit.
 Logged

Offline
Jr. Member
Karma: 0
Posts: 69
Carpe Diem
 « Reply #2 on: May 01, 2012, 03:55:01 pm » Bigger Smaller Reset

I see.. Thanks, looks like I'll just buy the shield then.
 Logged

France S-O ou exil en IDF
Offline
Edison Member
Karma: 12
Posts: 1048
 « Reply #3 on: May 02, 2012, 08:29:27 am » Bigger Smaller Reset

Quote
I understand that the arduino pins can handle up to 40 mA
NO ! Arduino team is wrong when they write 40mA !, they do not respect Atmell specifications.
Atmell guaranteed only 20mA in continuous use
Read the datasheet : 40mA are ABSOLUTE MAXIMUM RATING !

*NOTICE:
Stresses beyond those listed under “Absolute Maximum Ratings” may cause permanent damage to the device.
This is a stress rating only and functional operation of the device at these or other conditions beyond those
indicated in the operational sections of this specification is not implied.
Exposure to absolute maximum rating conditions for extended periods may affect device reliability.

You could also see important notice concerning source or sink mode :

3. Although each I/O port can sink more than the test conditions (20 mA at VCC = 5V, 10 mA at VCC = 3V) under steady state
conditions (non-transient), the following must be observed:
ATmega48PA/88PA/168PA/328P:
1] The sum of all IOL, for ports C0 - C5, ADC7, ADC6 should not exceed 100 mA.
2] The sum of all IOL, for ports B0 - B5, D5 - D7, XTAL1, XTAL2 should not exceed 100 mA.
3] The sum of all IOL, for ports D0 - D4, RESET should not exceed 100 mA.
If IOL exceeds the test condition, VOL may exceed the related specification. Pins are not guaranteed to sink current greater
than the listed test condition.

4. Although each I/O port can source more than the test conditions (20 mA at VCC = 5V, 10 mA at VCC = 3V) under steady state conditions (non-transient), the following must be observed:
ATmega48PA/88PA/168PA/328P:
1] The sum of all IOH, for ports C0 - C5, D0- D4, ADC7, RESET should not exceed 150 mA.
2] The sum of all IOH, for ports B0 - B5, D5 - D7, ADC6, XTAL1, XTAL2 should not exceed 150 mA.
If IIOH exceeds the test condition, VOH may exceed the related specification. Pins are not guaranteed to source current
greater than the listed test condition.

 Logged

Aides toi et la communauté t'aidera

Offline
Newbie
Karma: 0
Posts: 8
 « Reply #4 on: May 02, 2012, 08:49:23 am » Bigger Smaller Reset

You cann't do what you explained - you WILL fry Arduino. If you want to drive motor both directions you need at least motor driver IC like L293 or better use shield, if you need only one direction you can use one MOSFET transistor.
 Logged

Global Moderator
UK
Online
Brattain Member
Karma: 137
Posts: 19003
I don't think you connected the grounds, Dave.
 « Reply #5 on: May 02, 2012, 10:02:27 am » Bigger Smaller Reset

Quote
If you want to drive motor both directions you need at least motor driver IC
No, you could do it with a DPDT relay.
 Logged

Pete, it's a fool looks for logic in the chambers of the human heart.

Manchester (England England)
Offline
Brattain Member
Karma: 269
Posts: 25394
Solder is electric glue
 « Reply #6 on: May 02, 2012, 10:08:22 am » Bigger Smaller Reset

Quote
Atmell guaranteed only 20mA in continuous use
No you are miss reading the specification.
The 20mA refers to the the other parameters, those range of parameters they give regarding output voltage and so on only apply when the pin load is 20mA. They are not saying it will not work higher, the guaranteed only applies to the parameters.

Yes 40mA is the point at which damage starts to be done.
 Logged

France S-O ou exil en IDF
Offline
Edison Member
Karma: 12
Posts: 1048
 « Reply #7 on: May 02, 2012, 10:48:53 am » Bigger Smaller Reset

Quote
No you are miss reading the specification
No.
I am french and I read a little english but I think that atmell datasheet is clear :
Exposure to absolute maximum rating conditions for extended periods may affect device reliability.

I think it's clear : if you do not want to risk you should not always use the micro to the absolute maximum rating.
Notice :
1) they are also limitation per PORT and not only per output.
2) Outputs can source more mA that they can sink-> have a look to the I/O schematic and you will understand that this is normal.

It is so simple to interface with a transistor, especially with an motor, than risk killing the micro.
 Logged

Aides toi et la communauté t'aidera

Manchester (England England)
Offline
Brattain Member
Karma: 269
Posts: 25394
Solder is electric glue
 « Reply #8 on: May 02, 2012, 11:54:24 am » Bigger Smaller Reset

Quote
I think that atmell datasheet is clear
Yes it is clear, but you are not understanding it.

Quote
Exposure to absolute maximum rating conditions for extended periods may affect device reliability.
Yes very true, that is why I said:-
Quote
40mA is the point at which damage starts to be done.

Quote
Outputs can source more mA that they can sink-> have a look to the I/O schematic and you will understand that this is normal.
Not according to the data sheet. Yes that is normally the case but not on this processor.
Section 10.2 says:-
Quote
Figure 10-2 shows a functional description of one I/O-port pin,
That is it is not, a schematic. That resistor in the FET is the 30K pull up resistor . Anyway you cannot make this assertion because the limit on current sourcing will be higher than the 40mA absolute limit, so it has no meaning.
Do you know how much current a pin can source? I did some measurements and clocked in excess of 250mA, well into the damage region.
 « Last Edit: May 02, 2012, 12:00:58 pm by Grumpy_Mike » Logged

France S-O ou exil en IDF
Offline
Edison Member
Karma: 12
Posts: 1048
 « Reply #9 on: May 02, 2012, 03:46:41 pm » Bigger Smaller Reset

What impact on reliability?
During 40 years in R & D I've never seen colleagues take such risks.
End of discussion.
 Logged

Aides toi et la communauté t'aidera

Global Moderator
UK
Online
Brattain Member
Karma: 137
Posts: 19003
I don't think you connected the grounds, Dave.
 « Reply #10 on: May 02, 2012, 03:53:55 pm » Bigger Smaller Reset

No, not end of discussion.
As you yourself quoted
Quote
Although each I/O port can source more than the test conditions (20 mA at VCC = 5V, 10 mA at VCC = 3V) under steady state conditions (non-transient), the following must be observed:
20mA is clearly NOT the maximum recommended, as long as the listed conditions are met.
 Logged

Pete, it's a fool looks for logic in the chambers of the human heart.

Manchester (England England)
Offline
Brattain Member
Karma: 269
Posts: 25394
Solder is electric glue
 « Reply #11 on: May 02, 2012, 04:11:16 pm » Bigger Smaller Reset

Quote
During 40 years in R & D I've never seen colleagues take such risks.
What risk? The experiment with the output pin sourcing that much current? I knew what I was doing and I expected that pin to blow. Have you never worked with a safety department, they do that sort of thing all the time.
Actually the pin still worked but I suspect it is damaged. I did it for this page
www.thebox.myzen.co.uk/Tutorial/LEDs.html
 Logged

France S-O ou exil en IDF
Offline
Edison Member
Karma: 12
Posts: 1048
 « Reply #12 on: May 02, 2012, 06:42:52 pm » Bigger Smaller Reset

Quote
Have you never worked with a safety department, they do that sort of thing all the time.
I have "just" worked in submarine links with coaxial cable and fiber optic.
Lifetime warranty : two failures in 25 years for all repeaters (beetween 50 to 100 units per link)
Also I have a "little" idea of what reliability is.

Now do as you hear it, I just wanted to correct a confusion between what should be the operating data and marketing information.

Have a nice day
 Logged

Aides toi et la communauté t'aidera

Offline
Newbie
Karma: 0
Posts: 8
 « Reply #13 on: May 03, 2012, 05:27:52 am » Bigger Smaller Reset

I guess question was how to drive motor - not who can better interpret datasheets
 Logged

France S-O ou exil en IDF
Offline
Edison Member
Karma: 12
Posts: 1048
 « Reply #14 on: May 03, 2012, 06:28:42 am » Bigger Smaller Reset

With my poor English and using Google translation I will try.
In my humble opinion it is safer not to drive the motor dirrectement by the arduino, it is better to use dedicated circuits such as H-bridges (eg L293 / 1€ on Ebay). These circuits include protection diodes which act against the effects of Lentz's law (see Wikipedia for more information).

If the motor is designed to 5V, there is no resistance to calculate.
If the motor is designed for less than 5V, 3V for example, you need to know the value of motor current for U = 3V.
Then just apply Ohm's law : U = R * I
U = volts
R = Ohms
I = amps
U = Usupply - Umotor = 5V - 3V = 2V with example's values.

Attention, motor does not consume the same current whith no load or loaded.
When the load increases the motor's speed decreases and the current increases.
 Logged

Aides toi et la communauté t'aidera

 Pages: [1] 2   Go Up