I am working on a design project for school. We have to build a setup inside a can that will make the can tip over. We have our basic design figured out, and I have programmed my Arduino Uno to do what it needs to do. Let me start by giving you an inventory of what I know I need:
Arduino Uno
Dc motor (to spin a weight attached to a wire around really fast)
transistor
resistor???
wires, etc.
battery
So we bought a small DC motor (not sure of the specs) and an Arduino kit just to play with and try to figure it out. We started by testing our system with an LED in place of the motor, and it worked. Then we used the motor instead, and it did not work. So we eventually (after roughly 2 hours) figured out how to use a transistor to make the motor run in our system.
We were not very careful in what kind of motor, transistor, and resistors we purchased. Off the top of my head, I am not sure of the specs of any of these things, but I just assume we got all the wrong stuff.
So that should be enough of an introduction. Let me try to put my question in a concise format:
I have a 9V battery which is to power an Arduino Uno AND a DC motor. What kind of DC motor do I need? What kind of transistor do I need? What kind of resistors do I need, if any?
Nobody on my team has any electrical background. We are mechanical engineering students. We do not understand voltage and current very well. Personally, I know nothing about any of this. Thank you for your help!
First a schematic or other diagram of how everything is wired would be very helpful in most cases when you are asking for advice on this forum.
IANfinity:
So we bought a small DC motor (not sure of the specs)
If it has any markings, look them up on-line. You might be able to find a data sheet for it. After all this is the Information Age...
IANfinity: I have a 9V battery which is to power an Arduino Uno AND a DC motor.
Regardless of your other problems if it's the standard rectangular 9V battery, you want a different power supply. A 9V battery usually has less than an 700 mAh,(or it can also be expressed as 0.7 Ah), of charge capacity. The units "mAh" or "Ah" stand for "milliAmpere-hours" or "Ampere-hours", in other words how much current the battery can supply for one full hour. This is enough to power an Arduino and a few other things like LEDs for several hours, but it wouldn't power most DC motors for long and at least some it couldn't supply enough current to get them moving (though it might not be the case with your motor).
On the other hand, common alkaline AA usually have a capacity of over 2200 mAh. They have a nominal voltage of 1.5 VDC (nominal because the exact voltage of any battery varies a bit based on how much charge is remaining), but six of them can be put in series to get a nominal 9 VDC. By the way, all the standard "letter" sized alkaline batteries have nominal voltages of 1.5 VDC. The only difference is the maximum charge capacity and as you might guess the capacity increases with the battery size.
IANfinity: What kind of DC motor do I need?
The primary requirement will be "Can the motor do what I want it to do?", in this case spin your weight reliably with enough force to tip over the can. Any other requirements will be imposed by limitations like volume, weight, and power constraints (which in this case shouldn't be a problem). With a few extra components and the right programming an Arduino can control almost any DC motor.
IANfinity: What kind of transistor do I need? What kind of resistors do I need, if any?
The transitor will have to be able to handle the voltage and the current levels necessary to power your DC motor, while still being able to be controlled by the output of an Arduino pin, which can only output 0 or 5 VDC @ a maximum current of 40 mA. The number and rating of resistors will be determined by what's necessary to properly bias the transistor.
You should also have a couple of diodes as well.
Here's a link to a tutorial about working with small DC motors and Arduinos. It's written by an active forum member that goes by "Grumpy_Mike".
IANfinity:
We have to build a setup inside a can that will make the can tip over.
Dc motor (to spin a weight attached to a wire around really fast)
The basic approach might work, but I suggest if you're trying to make the can fall over then 'really fast' is not a good way to do it. You want as much weight as you can get, as high up and as far away from the central axis of the can as possible, and then spin it around that axis at about the same frequency that the can will naturally wobble if you put it on end and then spin it so the base rolls around in a small circle. That way your weight will drive the natural resonant frequency of the motion and tend to amplify it. If you try to drive it much faster, it's likely to just sit there rattling. Once you have the hardware in place you'll be able to experiment and see what speed works best. I would have thought that a rigid rotor would work a lot better than a weight on a string.
Far-seeker:
First a schematic or other diagram of how everything is wired would be very helpful in most cases when you are asking for advice on this forum.
IANfinity:
So we bought a small DC motor (not sure of the specs)
If it has any markings, look them up on-line. You might be able to find a data sheet for it. After all this is the Information Age...
IANfinity: I have a 9V battery which is to power an Arduino Uno AND a DC motor.
Regardless of your other problems if it's the standard rectangular 9V battery, you want a different power supply. A 9V battery usually has less than an 700 mAh,(or it can also be expressed as 0.7 Ah), of charge capacity. The units "mAh" or "Ah" stand for "milliAmpere-hours" or "Ampere-hours", in other words how much current the battery can supply for one full hour. This is enough to power an Arduino and a few other things like LEDs for several hours, but it wouldn't power most DC motors for long and at least some it couldn't supply enough current to get them moving (though it might not be the case with your motor).
On the other hand, common alkaline AA usually have a capacity of over 2200 mAh. They have a nominal voltage of 1.5 VDC (nominal because the exact voltage of any battery varies a bit based on how much charge is remaining), but six of them can be put in series to get a nominal 9 VDC. By the way, all the standard "letter" sized alkaline batteries have nominal voltages of 1.5 VDC. The only difference is the maximum charge capacity and as you might guess the capacity increases with the battery size.
IANfinity: What kind of DC motor do I need?
The primary requirement will be "Can the motor do what I want it to do?", in this case spin your weight reliably with enough force to tip over the can. Any other requirements will be imposed by limitations like volume, weight, and power constraints (which in this case shouldn't be a problem). With a few extra components and the right programming an Arduino can control almost any DC motor.
IANfinity: What kind of transistor do I need? What kind of resistors do I need, if any?
The transitor will have to be able to handle the voltage and the current levels necessary to power your DC motor, while still being able to be controlled by the output of an Arduino pin, which can only output 0 or 5 VDC @ a maximum current of 40 mA. The number and rating of resistors will be determined by what's necessary to properly bias the transistor.
You should also have a couple of diodes as well.
Here's a link to a tutorial about working with small DC motors and Arduinos. It's written by an active forum member that goes by "Grumpy_Mike".
Here are some pictures.
This is everything
Here is a close up of the wiring setup.
My program is just a modified version of the "blink" program, which is what our proffessor reccomended in class. I have pin 2 coded to wait 32 seconds then turn the motor on, "digitalWrite(pin 2, HIGH)", then stop after 6 seconds (which should be enough time to tip the can over, but this would be no problem to edit if need be). You can see the red wire going from pin 2 to the base of the transistor. The black wire connects the emitter to the blue wire which connects to the pin labeled (GND). The red wire connected to the collector is what we connect to the positive part of the motor. The green wire, which is in the 5V pin on the power strip connects to the negative part of the motor. The motor DID turn on with this setup, and seemed as if it would have enough power. The motor did NOT turn on without the transistor.
I do not understand much of what it's saying. The equations we've been given in class are I=V/R, which I understand to be Current=Voltage/Resistance. According to the notes from the lecture, the easy way to calculate the resistance you need is to use R=(Source Voltage - Forward Voltage)/Forward Current. Honestly, I haven't thought about it too much, but I don't understand how to determine my forward voltage or forward current. I assume the source voltage is 9V (if I use my 9V battery).
The motor says "SuperJack" and "R-3" on the bottom. I can't find any info on it on the web. I found SuperJack's company website, but it wasn't much help. We are probably going to buy a different motor anyways, since we want one that has a gear on the shaft rather than just a smooth cylindrical shaft.
We do know how to put a resistor on this setup, we just haven't done it yet. We have 10kohm, 220ohm, and 270ohm resistors (these came in our Arduino kit).
The reason we are using an Arduino for this project is because we will most likely need to use one for our final design project coming up, and we wanted to get some practice with how it works.
So from what you have said about the 9V batter, I think that this setup does NOT need a resistor. Is this correct?
We are sending 9V through the Arduino, which takes up 5V, so we now have 4V going to the transistor. So would 4V be the forward Voltage to the transistor?
The collector has a current of 600mA or .006A. Correct? So do I just add that current to the current coming from the battery? What would the current from the battery be?
I know I am all over the place with these questions, I just don't know what's going on. I haven't looked at your tutorial yet, so I apologize if anything I've asked is answered there.
Basically, I want the motor to be able to get enough power for at most maybe 10 seconds, and I want nothing to be fried/ruined in the process.
PeterH:
The basic approach might work, but I suggest if you're trying to make the can fall over then 'really fast' is not a good way to do it. You want as much weight as you can get, as high up and as far away from the central axis of the can as possible, and then spin it around that axis at about the same frequency that the can will naturally wobble if you put it on end and then spin it so the base rolls around in a small circle. That way your weight will drive the natural resonant frequency of the motion and tend to amplify it. If you try to drive it much faster, it's likely to just sit there rattling. Once you have the hardware in place you'll be able to experiment and see what speed works best. I would have thought that a rigid rotor would work a lot better than a weight on a string.
hmmm, this is very insightful. I don't have a great understanding of physics (currently in Physics 1), but I can see what you are saying. A rigid rotor might actually work better. I really don't know. We'll probably go with whichever way is easier/cheaper for us to put together.
Ok first let's get some corrections of very fundamental concepts out of the way...
IANfinity:
We are sending 9V through the Arduino, which takes up 5V, so we now have 4V going to the transistor. So would 4V be the forward Voltage to the transistor?
The way you have this wired up the motor is being supplied off the 5V regulator on the Uno board. This is not generally a good idea for motors and other actuators, becase the Uno is limited to supplying a maximum 200 mA through the 5V pin. You may have been lucky and not needed to draw that much current for your motor, but exceeding this can damage the Uno. So when you do get a new motor, make sure it can function at the voltage of whatever power supply you are using (e.g. if you continue to use a 9 V battery, get a motor with a maximum voltage rating higher than 9 VDC). That way it can be directly connected to the power supply and not go through the power loop on the Uno.
IANfinity:
The collector has a current of 600mA or .006A. Correct?
No, 1 A = 1000 mA, therefore 600 mA = 0.6 A. Furthermore the 600 mA is the maximum the current that the collector can handle for sustained periods, and more than that will likely damage the transistor. The actual current at any given moment depends upon the voltage and current at the transistor's base. We'll get back to that below...
IANfinity:
So do I just add that current to the current coming from the battery? What would the current from the battery be?
The current from the battery will be the total current for the entire circuit. If you hook the motor directly to the battery and have another wire going to the VIN on the Uno board, it will be the sum of the currents drawn by the motor and the Uno (per Kirchhoff's Current Law ). Becasue this isn't a purely resistive circuit, and you don't know a lot of electrical theory, the easiest way to determine the currents present in the circuit is to actually measure them with your multimeter (remember to do it with the meter in series with the point you are measuring).
IANfinity:
We do know how to put a resistor on this setup, we just haven't done it yet. We have 10kohm, 220ohm, and 270ohm resistors (these came in our Arduino kit).
When you are using an arduino pin as an output you always want at least a couple hundred ohms on the pin to limit the current to below 40 mA! Otherwise you could permenantly damage the pin on the microcontroller IC. If that happens at best you won't be able to use it reliably in the future.
IANfinity:
My program is just a modified version of the "blink" program, which is what our proffessor reccomended in class. I have pin 2 coded to wait 32 seconds then turn the motor on, "digitalWrite(pin 2, HIGH)", then stop after 6 seconds (which should be enough time to tip the can over, but this would be no problem to edit if need be). You can see the red wire going from pin 2 to the base of the transistor. The black wire connects the emitter to the blue wire which connects to the pin labeled (GND). The red wire connected to the collector is what we connect to the positive part of the motor. The green wire, which is in the 5V pin on the power strip connects to the negative part of the motor. The motor DID turn on with this setup, and seemed as if it would have enough power. The motor did NOT turn on without the transistor.
OK, it seems like you have everything connected like a basic low side switch. Which is all well and good, except you don't have a resistor between pin 2 and the transistor's base. This is not a good idea; (as mentioned previously) you always need to make sure the current from an Arduino pin being used as an output is below 40 mA and the amount of current necessary to use this transistor as switch is quite a bit less than 40 mA. I would put at the very least the 220 ? resistor, though you could probably use 10K ? and that would be closer to the optimal biasing.
IANfinity:
The motor says "SuperJack" and "R-3" on the bottom. I can't find any info on it on the web. I found SuperJack's company website, but it wasn't much help. We are probably going to buy a different motor anyways, since we want one that has a gear on the shaft rather than just a smooth cylindrical shaft.
Well that sometimes happens, but at least you tried. If you do get a different motor be sure that information about the normal operating values and maximum ratings for both voltage and current are available, either directly from the seller or on the manufacturer's website, before you purchase anything.
IANfinity: Basically, I want the motor to be able to get enough power for at most maybe 10 seconds, and I want nothing to be fried/ruined in the process.
With a few changes to your current design that is certainly possible. First, see if you can wire the positive lead of your motor directly to the battery, not the 5V pin. Second, you probably want to have a diode, a 1N4004 will do, wired in parallel with the motor. Have the end with the end with the light colored band (the cathode) connected to the positive terminal of the motor, and the other (the anode) to the motor's negative terminal. Third, you really should replace the 9V battery with a number of alkaline AA batteries in series. The exact number will depend on if you get a new motor and what type, but 4 to 6 will probably work. Battery holders wired this way should be easy to find, especially for AAs.
Far-seeker:
Ok first let's get some corrections of very fundamental concepts out of the way...
IANfinity:
We are sending 9V through the Arduino, which takes up 5V, so we now have 4V going to the transistor. So would 4V be the forward Voltage to the transistor?
The way you have this wired up the motor is being supplied off the 5V regulator on the Uno board. This is not generally a good idea for motors and other actuators, becase the Uno is limited to supplying a maximum 200 mA through the 5V pin. You may have been lucky and not needed to draw that much current for your motor, but exceeding this can damage the Uno. So when you do get a new motor, make sure it can function at the voltage of whatever power supply you are using (e.g. if you continue to use a 9 V battery, get a motor with a maximum voltage rating higher than 9 VDC). That way it can be directly connected to the power supply and not go through the power loop on the Uno.
IANfinity:
The collector has a current of 600mA or .006A. Correct?
No, 1 A = 1000 mA, therefore 600 mA = 0.6 A. Furthermore the 600 mA is the maximum the current that the collector can handle for sustained periods, and more than that will likely damage the transistor. The actual current at any given moment depends upon the voltage and current at the transistor's base. We'll get back to that below...
IANfinity:
So do I just add that current to the current coming from the battery? What would the current from the battery be?
The current from the battery will be the total current for the entire circuit. If you hook the motor directly to the battery and have another wire going to the VIN on the Uno board, it will be the sum of the currents drawn by the motor and the Uno (per Kirchhoff's Current Law ). Becasue this isn't a purely resistive circuit, and you don't know a lot of electrical theory, the easiest way to determine the currents present in the circuit is to actually measure them with your multimeter (remember to do it with the meter in series with the point you are measuring).
IANfinity:
We do know how to put a resistor on this setup, we just haven't done it yet. We have 10kohm, 220ohm, and 270ohm resistors (these came in our Arduino kit).
When you are using an arduino pin as an output you always want at least a couple hundred ohms on the pin to limit the current to below 40 mA! Otherwise you could permenantly damage the pin on the microcontroller IC. If that happens at best you won't be able to use it reliably in the future.
IANfinity:
My program is just a modified version of the "blink" program, which is what our proffessor reccomended in class. I have pin 2 coded to wait 32 seconds then turn the motor on, "digitalWrite(pin 2, HIGH)", then stop after 6 seconds (which should be enough time to tip the can over, but this would be no problem to edit if need be). You can see the red wire going from pin 2 to the base of the transistor. The black wire connects the emitter to the blue wire which connects to the pin labeled (GND). The red wire connected to the collector is what we connect to the positive part of the motor. The green wire, which is in the 5V pin on the power strip connects to the negative part of the motor. The motor DID turn on with this setup, and seemed as if it would have enough power. The motor did NOT turn on without the transistor.
OK, it seems like you have everything connected like a basic low side switch. Which is all well and good, except you don't have a resistor between pin 2 and the transistor's base. This is not a good idea; (as mentioned previously) you always need to make sure the current from an Arduino pin being used as an output is below 40 mA and the amount of current necessary to use this transistor as switch is quite a bit less than 40 mA. I would put at the very least the 220 ? resistor, though you could probably use 10K ? and that would be closer to the optimal biasing.
IANfinity:
The motor says "SuperJack" and "R-3" on the bottom. I can't find any info on it on the web. I found SuperJack's company website, but it wasn't much help. We are probably going to buy a different motor anyways, since we want one that has a gear on the shaft rather than just a smooth cylindrical shaft.
Well that sometimes happens, but at least you tried. If you do get a different motor be sure that information about the normal operating values and maximum ratings for both voltage and current are available, either directly from the seller or on the manufacturer's website, before you purchase anything.
IANfinity: Basically, I want the motor to be able to get enough power for at most maybe 10 seconds, and I want nothing to be fried/ruined in the process.
With a few changes to your current design that is certainly possible. First, see if you can wire the positive lead of your motor directly to the battery, not the 5V pin. Second, you probably want to have a diode, a 1N4004 will do, wired in parallel with the motor. Have the end with the end with the light colored band (the cathode) connected to the positive terminal of the motor, and the other (the anode) to the motor's negative terminal. Third, you really should replace the 9V battery with a number of alkaline AA batteries in series. The exact number will depend on if you get a new motor and what type, but 4 to 6 will probably work. Battery holders wired this way should be easy to find, especially for AAs.
Thank you so much!!! That was extremely helpful. Last night, we had a guy that did this project last semester come to help us with the wiring. He didn't seem to know all that much either, but he told us to get 2 9V batteries and use one to power the arduino and the other to power the motor. We attached a fishing weight to our motor, and it wasn't strong enough to spin it fast (using just the 1 battery). So I'm headed out to Radioshack now (bringing some notes I've jotted down about what you've told me), and I'll see if I can find some more appropriate equipment.