Go Down

Topic: Motor works fine on 5V, but not on PWM (Read 1 time) previous topic - next topic

rodyamirov

Jun 28, 2012, 10:46 pm Last Edit: Jun 28, 2012, 11:00 pm by rodyamirov Reason: 1
Warning: I am quite new to electronics ... please don't be offended if I don't understand your response and ask for clarification!

SO, my goal is to eventually build an autonomous robot of some kind, with all kinds of sensors and things, and of course the first step is to get it moving.  I scrapped a surprisingly high quality little toy which had two powered wheels, each on separate motors.  I did some soldering (exciting!) and at this point there is a wire in and a wire out.

If I plug one wire into the 5V, and the other into the ground, it runs (fast!).  If I switch the wires, it runs (fast!) backwards, which I guess means it's DC.  I can hook it into the breadboard and run them both simultaneously (fast!).  So far so good!

But I want to ability to control the motion a little bit (at least on vs. off, but speed would be nice too), and what I discovered is that if I plug them into the PWM slot (9, on an Arduino UNO), then set it to output and run digitalWrite(9, HIGH), or analogWrite(9, value), nothing happens.  That is, the wheels don't spin -- there is a quite annoying very high pitched sound that indicates the circuit exists, so there's that.

It's still connected to ground, in fact nothing else changed.  Is there some reason pin 9 is just putting out less power (?).

I have it connected to the wall via an adapter, in case that affects anything.  I'm told the USB power is not good for motors.

wildbill

The Arduino i/o pins can provide very little current before you damage them. You need a seperate power source for your motors, which you can drive through transisistors or a motor shield.

Grumpy_Mike

You can not run a motor from the voltage output of an output pin. You will damage your arduino if you try. You need some sort of driver. A transistor or a FET.
If you want control of the motor's direction you need a circuit called a H-bridge.
See this for an introduction to motors:-
http://www.thebox.myzen.co.uk/Workshop/Motors_1.html

rodyamirov


You can not run a motor from the voltage output of an output pin. You will damage your arduino if you try. You need some sort of driver. A transistor or a FET.
If you want control of the motor's direction you need a circuit called a H-bridge.
See this for an introduction to motors:-
http://www.thebox.myzen.co.uk/Workshop/Motors_1.html


Thanks for this.  I am learning a lot from your link and from wikipedia definitions of all the strange words I need to become quite familiar with (transistor? diode? etc.)

rodyamirov

Is any of this technology built into the official motor shield?  I have one, but I'm not sure what to do with it, and I don't want to go buy more parts (like the transistor, or the H Bridge, or etc.) if I don't have to.

MarkT

What has happened is that you will have temperarily overloaded the output transistor(s) on the chip for pin 9.  This may or may not have caused permanent damage - this could mean the pin stops working, or doesn't work very well, or that some other circuitry on the chip now misbehaves due to the heat-damage.

I would recommend using an LED (with series resistor) to check that the pins are all still working satisfactorily.

Not only does a motor take too much current to be driven from a microcontroller or other logic chip direct, but it may generate high voltage spikes that can instantly destroy the device.  This has to be protected against by using what are sometimes termed "freewheel" diodes to provide a route for current for when the motor driving circuit turns off.  Look at some of the examples for controlling motors or relays to see where the diode(s) go(es).

The whole point of a motor shield is to drive motors - these things have been thought of!  However you must check the limitations of each shield (maximum current, voltage, power etc) for suitability with a particular motor.
[ I won't respond to messages, use the forum please ]

Grumpy_Mike

Quote
This may or may not have caused permanent damage

No this HAS caused damage, if that damage is immediately apparent is another point but the pins have been damaged. However you can still use them until they stop working and don't fire it into space.

Quote
Is any of this technology built into the official motor shield?

Yes it is built into all motor shields, official or not.

rodyamirov

Thank you to everyone who replied!  It has been very educational, and I will make a RadioShack run in the near future.

For now, though, the solution was nicely wrapped up in the shield.  I think the tutorial I found is useful for anyone who happens to read this topic, so here it is:

http://www.instructables.com/id/Arduino-Motor-Shield-Tutorial/step4/One-Motor/

dc42

#8
Jun 30, 2012, 08:33 am Last Edit: Jun 30, 2012, 08:59 am by dc42 Reason: 1
Before you go out and buy a motor shield, you need to know what voltage your motor needs and what its stall current is. Otherwise you may find that your motor shield has too large a voltage drop to use with your chosen power source, or it burns out because the motor current is too large. You can work out the stall current by measuring the resistance of the motor with a multimeter and dividing it into the voltage you are planning to use.

Broadly speaking, there are 2 types of motor shields: those using a bipolar transistor H-bridge (typically using the L293D or L298N chip) and those using a mosfet H-bridge. The bipolar ones have a large voltage drop, typically 2.5 to 3.5V. So if you want 5V to reach your motor, you will need to supply around 8V to the driver, and you will be wasting around 38% of the energy (an important consideration for a battery powered vehicle). The voltage drop also means that the driver chip gets hot. In my opinion, bipolar H-bridges are obsolete and should be avoided. Unfortunately, the official Arduino motor shield is a bipolar type.

Mosfet H-bridge drivers do not suffer from these problems. If the stall current is less than 5A then this http://www.pololu.com/catalog/product/1213 may be a suitable board for driving 2 motors.

[EDIT: or http://www.sparkfun.com/products/9457 if the stall current is 1.2A or less.]
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.

JimboZA

#9
Jun 30, 2012, 08:46 am Last Edit: Jun 30, 2012, 08:49 am by JimboZA Reason: 1


The bipolar ones have a large voltage drop, typically 2.5 to 3.5V. So if you want 5V to reach your motor, you will need to supply around 8V to the driver, and you will be wasting around 38% of the energy (an important consideration for a battery powered vehicle). The voltage drop also means that the driver chip gets hot.


I can attest to that....

I have a MotoMama which is 298 based. I tried a 3v toy motor and it wouldn't even start- 298 datasheet says minimum voltage drop is 1.8 so that didn't leave a whole lot for the motors. Tried my Magician's 6v motors, they ran slowly- only had about 3.5 volts left of 6 supplied... the voltage drop depends on the current btw, up to a max of 5v it says on the datasheet. Ran them from a 9v PP3 which was already a bit flat and they ran faster but those batteries don't last long. So today I'm going to go look at RC car rechargeable 9.6v which will do the trick I hope- should leave about 6v for the motors once the Voltage Monster in the 298 has been fed.

And the MM shield has a heatsink the size of a house, btw, so it needs a lot of volume to fit it in.
Roy from ITCrowd: Have you tried turning it off an on again?
I'm on LinkedIn: http://www.linkedin.com/in/jimbrownza

Go Up