I’m creating a basic Arduino workshop in which students put together a simple temperature activated motor. However I’m having problems driving the motor off of the Arduino’s 5V pin. Here is the motor I’m using.
It has a current rating of 110mA and voltage rating of 1-3V. Of course the 3.3V pin on the Uno does not provide enough current. I tried connecting the motor from the 5V pin to ground and the motor runs for a short time before it shorts out. However when I place a small resistance in series (200 Ohms) the motor does not run at all. This should work though since the 5V pin provides 450mA from USB.
I’ve had this project working before on the same board but may be missing something. Can anyone help?
First off read this thread and then look at the circuit it uses. If you’re using a 3.3v Arduino you may need to decrease the transistor base resistor to something smaller, in the 100-300 ohm range should be OK.
Since the motor is designed to run off 1-3v, a 5v supply might over-run and overheat it. Your thought to add so resistance in series was a good one, you just went too high. The motor needs at least 1v to start and some unknown current. The stall current (Locked-rotor current:0.8A) is given as 800 mA. So lets assume it takes that to get going. So you want at least 1v of the 5v available across the motor leaving 4v to be across the resistor. Recall Ohms Law (v = i*r) and that gives you a resistance of 4/0.8 = 5 ohms (min). If the current is less then the drop across the resistor is less, leaving more voltage across the motor. At the low current end of the range, the motor should draw less than the 110 mA spec. Lets have 3v across the motor, thus 2v across the resistor with perhaps 100 mA flowing. Now the resistor needs to be 2/.1 = 20 ohms (max). So somewhere btw 5 and 20 ohms (IMO closer to the 20 end) is what you want for that series resistor. You can experiment w/o the transistor just as you did with the 200 ohm resistor.
Be aware of the power being dissipated in that resistor. With just 100 mA and 20 ohms, it’s 20*(0.1)^2 = 0.2W. I’d use a 1/2W resistor to ensure a reasonable life.
I built the circuit in CIRC03 from the link you’ve provided. I was getting some transistor overheating with the 2.2kOhm resistor but I replaced it with a 220Ohm and it seems to be working fine now.
Thank you for your help!
However I’ve run into another problem. As I said I’m trying to build a temperature controlled motor off of the Arduino. I’m using the TMP36 sensor for temperature which also uses the Uno’s 5V pin for power. I then coded the Uno to start the motor when the temperature rises above room temperature. As soon as it rises above room temperature the motor turns on and a voltage spike occurs at the output pin of the temperature sensor. The readings jump about 20-30 degrees F and the Uno freezes while the motor keeps running. I’ve connected the circuit to 3.3V which helps a bit but clearly I need a capacitor across the power rails. I’m guessing I could try a 220uF as in the circuit layout but how would I calculate what value capacitor to use? I would really like to know how to calculate it from an engineering standpoint.
I have a fly-back diode connected in parallel with the motor. I also tried placing the cap. across the power rails but that didn’t solve the problem either. Then I decided to connect an external power source (a 1.5V AAA battery) to power the motor by connecting the V+ of the battery to the collector and the V- to emitter and tied it to the Uno GND pin. Now it works with no voltage spike when the motor turns on! There was still some abnormally low readings right after the motor turned off but I reconnected the cap. across the power rails and that seemed to have solved that problem. Now I just have to understand how the whole thing works.
Then I decided to connect an external power source (a 1.5V AAA battery) to power the motor by connecting the V+ of the battery to the motor + …
... given the collector is tied to the motor - (no need for the extra resistor when running off 1.5v). What happens is that when voltage is initially applied to the motor, it looks like an inductor with a small resistance. Thus it draws a "lot" of current until the motor gets spinning. That current draws down the voltage on the caps after the regulator and in turn the regulator then starts to pump out more current to charge them back up. Depending on the time constants involved the regulator may overshoot and you'll see a voltage dip and then a surge. That supply "noise" will often show up on the outputs of devices using that supply..
FWIW you generally don’t want to run motors off the Arduino’s regulated voltages. As you’ve seen they put noise on that supply that may screwup the Arduino. Additionally the regulators are poorly heatsunk and will get (too) hot with even moderate loads.
I tried placing a diode from the motor V+ to GND and had no change in the noise level. Like I said before I have a fly-back diode in parallel with the motor. What is detrimental about not having another diode in the position that you mentioned? Also the link you’ve provided doesn’t seem to be working anymore.
Mee-n-Mac,
Thank you for explaining that to me. I understand what you’re saying. I bought a 2 cell AA battery holder and am now using that for the motor’s power source. However there still seems to be noise on the TMP36 right when the motor shuts off. The readings dip a few degrees. I don’t understand how this is still occurring since the motor now has an external power source. There’s no way for the motor to draw current from the board since there is no return path to the board. Placing the 220uF cap. from the V+ pin of the motor to GND solves this problem for the most part. I provided a link to my circuit diagram for clarity.
I did not change the circuit from the circuit diagram at all and now the board is showing the same behavior as it had in the first place. When the temperature rises above the specified temperature in the code the motor turns on. Then the sensor experiences some noise which causes the motor to turn on and off. Then the TX led on the Uno freezes as well as the serial monitor. I tired running the sensor and motor circuits separately and they work fine however when I put them together I’m having this problem again. Is it possible the board is damaged?
You were talking about voltage spikes and not having that diode was the first thing popped in my head. You can search Google ‘Arduino protection diode’ or other terms to read up on it. Here’s a vid that talks about it a little (2:20) http://www.youtube.com/watch?v=5bHPKU4ybHY#t=232
Not sure if you already stated this but, do you have decoupling cap around the motor anywhere? That maybe another thing you could add to see if that helps. It’s also talks about that in the vid.
Exactly how are the ground wires connected ? A diagram or pic is better than a schematic in this case. Show the wiring btw the Arduino Gnd pin(s), the 2N222 emitter, the TMP36 gnd pin, the cap -pin and the battery-. Are you using a solderless breadboard ?
Could you insert a ‘blanking period’ after the commands to turn the motor on/off ? That is don’t take any temp readings during the blanking period of X msecs.
BTW the flyback diode in your schematic is shown backwards. It should be reverse biased when the motor is running. Otherwise it effectively shorts out the motor.
I watched the video. I do have a diode and cap. in my circuit. The only difference is the cap. in mine is connected to ground. Take a look at the circuit diagram I posted a link to earlier.
Mee-n_Mac,
Thank you for correcting me on the polarity of the diode. I am using a solderless breadboard. I cleaned up the circuit as much as I could and took some pictures.
The first is the circuit without the motor attached. The transistor’s emitter is on the top and collector is on the bottom. The cap’s negative terminal is connected to ground and the power rails on the left are connected to the battery pack.
I also tried connecting the cap. in parallel with the motor. It’s frustrating because the results are mixed. Sometimes it works better with the cap. connected from the V+ motor pin to GND and sometimes it works better with the cap. connected in parallel with the motor or not connected at all.
You’ve got the major item OK, making sure the “large” current path is separated from the temp sensor. I might redo the BB setup a bit, put the motor+ lead and cap in the upper, left of the BB (where I circled). Perhaps move the 2N2222 from the ‘hij’ area over to the other side, ‘abcd’ area. IOW try to keep the path the motor current takes as short and confined as possible, w/minimal jumper wires. The diode, as close to the motor leads, was smack on.