Arduinos and Motors Part 1

So tonight I took my first look at Arduinos and motors, watching a couple videos and reading a few webpages that talk about this topic.

Im spending time on how DC (direct current) motors interact with Arduinos because this weeks Humboldt Microcontrollers (MCUs) Group meeting will be at least partly focused on motors and MCUs. When the group is discussing this topic, it would be nice if I have at least a general understanding of what theyre talking about, even if some or a lot of what they say is over my head, both knowledge and experience-wise.

I started out by watching the Jeremy Blum Arduino Basics #5 video tutorial, which addresses motors and transistors. I didnt try to do the exercises in the video while I watched it today because figuring out the exercises, wiring up the breadboard, writing the code and figuring out what I did wrong will take a couple hours, based on my experience with the earlier Blum video tutorials. Tonights video viewing was just to find out what components were used in the exercises and to get an overview of what Jeremy is trying to teach in the video. At right is the DC motor that came with the official Arduino Starter Kit. I need to figure out whether that motor will work with the exercise Jeremy presents, because he doesnt always use parts from the starter kit that I have.

After watching the video, I did some online reading, starting out with the Adafruit Arduino Lesson 13: DC Motors. I wanted to read this over to compare Adafruits intro to Arduino and Motors to what Jeremy discussed in his video. Next I read a blog entry titled, Using motors with an Arduino. The post author said, "Motor control turned out to be trickier than I expected, and I dont see a lot of "Arduino motor control for dummies" pages on the web, so Im writing one." The blog post had some good tips about the authors experiences controlling motors with an Arduino. Something the post author did was buy a Freeduino motor shield kit (shown at left) and solder it together. That might be a fun, interesting and useful way for me to improve my soldering skills!

The post talks about controlling motors with an MCU using Arduino shields for motors, using a motor driver carrier PCB, using electronic speed controllers (ESCs) and using H-bridges. One of the authors goals was to find an inexpensive Arduino motor control method because they were shopping for parts to teach a summer camp class in robotics. After the post was written, someone suggested the author use a transistor as a very inexpensive way to run small motors and protect the Arduino from a high current load. The tutorial linked by the author for the transistor method shows pretty much the same concept as Jeremy explained in the #5 video.

One last webpage I read about motors and MCUs was on a Wikispaces wiki called Arduino-Info. This page had some info not covered on the other online places I visited today. It talked about two ways to totally protect the Arduino from the motors high voltage or high current. (I dont know if you need to protect it from one or the other or both. Something else to try and figure out before this Thursday evenings meeting.) The two complete isolation methods are to use an opto-isolator (as shown to the right above) or use a mechanical relay.

Tomorrows goal for my "Arduinos and Motors, Part 2" post will be to start figuring out how to breadboard the first exercise in Jeremys video. He uses a breadboard that has three terminal posts hooked up for the exercise, and I dont have posts on my breadboard. So Ill need to figure out if those posts are essential, or if theyre just a convenience that I can work around on my breadboard.

The Blum videos are Arduino basics tutorials, but someone as inexperienced with electronics as I am needs to spend a fair amount of time researching and talking to people to figure out how to hook up the different circuits shown in the videos. Thats mostly a good thing because figuring that stuff out, rather than just blindly following each step, helps me to better understand and remember the concepts presented in the videos.

However, when someone new to microcontrollers comes to the Humboldt Microcontrollers Group to learn how to use MCUs, we need to be aware of that persons potential frustrations when they dont have a clue about how to hook up some of the circuits in the Blum videos.

Reminder! This Thursday, June 12, from 6 to 8 PM is the third meeting of the Humboldt Microcontrollers Group at 1385 8th Street, Arcata, California, USA. To make sure no one gets locked out of the building (which happened two weeks ago), well start out the night by meeting at the big table right by the front door. Well also have a sign on the door with a cell phone number of someone whos in the meeting so if were not by the door later in the evening, people who are inadvertently locked outside can call for someone to come open the door.

**********
Read More..

Arduinos and Motors Part 3

Tonights post is a chance to formulate some thoughts for tomorrows meeting of the Humboldt Microcontrollers Group, where well be talking about Arduinos and motors, and maybe motors with MCUs in general.

Tomorrows meeting will be reviewing issues related to Jeremy Blums Arduino Basics #5 video tutorial. I didnt progress on my first MCU-controlled motor exercise from video #5 yet. Didnt have a chance today to figure out whether either of the two standard DC motors I have are suitable for use with the transistors I have available. That will likely get figured out either at the meeting tomorrow or sometime this weekend.

So here are a list of questions about MCU-controlled motors for tomorrows meeting, if theres time to get to them. If theres not time, Ill research the answers on my own. If you have other questions, let me know, and Ill try to make sure they get brought up at the meeting.
  1. When do you use a motor shield instead of just a transistor?
  2. Has anyone in the Humboldt Microcontrollers Group ever built a motor shield?
  3. What are the features of a motor shield for projects people in the group have done?
  4. What are some of the applications for Arduino-controlled motors?
The main applications I know of that Id work on for Arduino-controlled motors are 3D printers, robots and moving Halloween props. Im hoping the others at tomorrows meeting have a few more ideas, especially smaller and less expensive projects where I can get some experience on practical applications for the motors without having to spend too much time or money on the project. Maybe I can find open source plans for a micro quad copter that uses an MCU and doesnt cost too much for the components.

Tomorrow night, June 12, is the third meeting of the Humboldt Microcontrollers Group. Well be meeting from 6 to 8 PM at 1385 8th Street in Arcata, California, USA. People interested in microcontrollers or Arduinos are invited to join us -- the event is free, you dont have to know how to program microcontrollers, and theres no need to be a member of anything to participate.

So if you live in Arcata, Eureka, McKinleyville, Fortuna, Trinidad, Blue Lake or any of the other fine parts of the Humboldt region, you should consider participating in a new activity in the area -- the Humboldt Microcontrollers community.

**********


Read More..

Arduinos Motors Why Use A Diode

[Tonights post is by Ed Smith, participant in the Humboldt Microcontrollers Group]

As you go through various electronics tutorials youll notice that almost every wiring diagram for electric motors has a diode across the motor terminals. Heres an example of what Im talking about, from Jeremy Blums excellent Arduino Tutorial series:
Diagram courtesy Jeremy Blum.

Youll notice that he has a capacitor across the terminals as well; well get to that.

Diodes are very simple, very crucial little bits of silicon. They allow electricity to flow in one direction, but not the other. If you wired the one in Blums diagram backwards, something would explode the moment you turned the transistor on, as the diode would allow the electricity to bypass the motor and flow straight from input to GND (ground, return, earth, common, whatever youd like to call it). Blam! Oriented the correct way, no current flows through it from VCC to GND.

The diode is in the circuit because electricity that is flowing tends to want to keep flowing, just like water. If your transistor (switch, MOSFET, whatever) is turned on, current is flowing and the motor is running and you suddenly switch off the transistor then the current tries to keep flowing, slams into the turned off switch and stacks up. If youve ever turned a garden hose off quickly and noticed how the hose jumped, or turned a faucet off quickly and heard pipes banging, this is roughly the same effect. The water has mass, and when it crashes into the valve/faucet it generates a pressure spike. We measure electrical pressure in voltage rather than the PSI (pounds per square inch) we use for water (and its not the electrons mass that causes issues; the actual cause is more complicated than I want to get into here), but the result is the same: it eventually causes damage. In your house it will knock the pipes loose and/or burst them. In this circuit it will destroy the transistor, likely leading to a direct short to GND, a motor that runs indefinitely, and a transistor that may end up on fire.

The diode allows that spike to flow back around to the input of the motor. Then the electricity can happily go in a circle like it wants to, without either slamming into the transistor and spiking the voltage or flowing to ground through the transistor and running the motor.

(Unrelated comment on the diagram: In the video in which the above circuit is shown, Jeremy says the resistor is used to isolate the transistor/motor from the Arduino; this is not actually the case. The resistor limits the amount of current the Arduino puts through the transistor when it is switching it on. Without this resistor the Arduino and possibly the transistor will die. Dont forget that resistor!)

A PropScope USB oscilloscope was used to get some shots of this effect. I used an Arduino putting out a 490Hz PWM (pulse-width modulation) signal to switch an IRLZ34N MOSFET (metal-oxide-semiconductor field-effect transistor), driving a small motor out of a cassette tape player. (The MOSFET is rated at 55 volts, so it can take a spike the level that I was generating without damage. Its also far, far, far overkill for driving the little motor I used.) In each set of pictures below, the first picture is at an ~16% duty cycle (on 16% of the time, off 84%), and the second is at a 50% duty cycle. Input voltage was ~5.1 volts from an ATX power supply. The red trace is the signal to the MOSFET (5V turns it on and allows the motor to run, 0V turns it off). The blue trace is the voltage after the motor just before the MOSFET.

Heres no diode, no capacitor:


Thats a 15.9 volt spike; if we were using a 10 volt transistor we would have issues! Generally a 2X over-rated part is nice and safe, but not this time. Were we driving a 12V motor this spike would be a lot higher, of course.


At a higher duty cycle the spike is both lower and shorter duration, I dont know why. Still, 12.27 volts is a big jump over the five volt input! Please note that this spike is due to current flowing through the motor coils, not due to the physical rotation of the motor. Any electrical device with a coil of any kind in it (relays are a common one) will cause this sort of spike.

The diode used is a UF4007, rated for 1000 volts and 1 amp; again, just a bit overkill. Note that the diode rating is how much it can block before it breaks down and allows two way flow, not how much can safely flow through it. With the diode in place, per the oscilloscope trace below,


5.8 volts is a much more reasonable spike; thats only a 0.7V gain. The reason for this gain is the diodes "forward voltage", which is a measure of how much of a voltage drop the diode causes to the voltage going through it. The higher the current, the higher the drop. For example, this diode has a ~1.7V drop when its maximum rating of 1 amp is flowing through it. Note how long the spike lasts! The energy that would have gone into the spike is now flowing in a circle through the motor, and it takes the motor a while to use it.


This time the longer duty cycle didnt change the spikes voltage much. Instead the lower energy level manifests as a shorter duration spike. Also interesting is that in both cases the motors RPM was higher with a diode than without. This is likely because without the diode the motor has a reverse voltage across it trying to turn it in the other direction. With a diode, that energy is trying to turn the motor in the same direction its already rotating.

Now about the capacitor I mentioned earlier! In the video in which the diagram was shown, Blum just said that the diode and capacitor protect things from noise and spikes. The diode takes care of spikes, as we saw. This leaves the noise for the capacitor to address. In this situation, "noise" typically speaks of electromagnetic noise rather than audible noise. Brushed motors are very noisy electrically and electromagnetically speaking, as the brushes connect and disconnect there are small arcs that broadcast themselves nicely.

I didnt have a 1µF capacitor sitting around, so I used a 10µF. Everybody loves overkill right?
Heres what I got on the scope:


Thats a bit different, isnt it? Also interesting is that the motor ran much faster at this PWM duty cycle than it did in the previous examples. Note that we never actually got up to 5V; that spike is long gone.


Less time, and even further from getting to 5V! The motor ran much faster, as well. The reasons behind this Im not entirely sure of, but heres my best guess.

When the MOSFET (or transistor) turns on, the negative side of both the motor and the capacitor are quickly pulled to 0 volts. When the MOSFET turns off, the capacitors negative/ground pin is still at 0V, and the capacitor still has a 5V charge in it. This drives the motor until that charge has equalized. The curve continues up and comes back down in both situations. I think that this is due to that same spike being partially dumped into the capacitor, charging further. I am far from sure on that. Also of note, the low duty cycles were audibly quieter as well as electrically quieter.

One thing to be aware of before this starts looking like a wonderful idea is that the stored energy in the capacitor (its internal charge is equal, but its ground pin is still a volt or three above what the MOSFET considers to be ground) will be pulled violently to ground when the MOSFET turns on. With a 10µF capacitor at a couple of volts and a MOSFET rated for 30 amps at 55 volts this is not an issue, but with a larger capacitor and/or a smaller MOSFET, it could be.

In closing, any time you are switching a device that contains a coil of any sort (relays, motors, solenoids, inductors, coil guns, transformers, etc.) you need a diode to direct that voltage spike to somewhere safe. The capacitor is more optional, and youre better off using a smaller capacitor than a large one unless you know you are having problems with electrical noise that you cannot solve in any other way.

**********
Read More..



Blog Archive

Diberdayakan oleh Blogger.