Lab 7: Output: DC Motors
- Due Oct 18, 2017 by 10:30am
- Points 10
- Submitting a file upload
- File Types pdf
Before the Lab
You should have experimented with the piezo buzzer and various ways to control it. Congratulations!
In Lab Exercise
Objective
We will be learning how to control the DC motor with the various input devices you have learned about.
Background Information
The circuit we're building in this lab will be significantly more complex than prior circuits. In addition to using the components you are already familiar with, you'll also be using a DC Motor, a diode (marked 1N4004), and a transistor (marked TIP120).
DC motors convert direct current into rotational motion. It's our first actuating device.
Diodes allow current to flow only in one direction and not in the other direction. Motors often create current spikes as they turn on and off. These spikes can damage the transistor, so we use a diode in this circuit to protect the transistor from these spikes. Diodes have polarity, so the direction you install them matters (same as with LEDs, aka Light Emitting Diodes). The bar in the schematic diagram corresponds to a white stripe on the actual diode. Current can only flow in the direction of the triangle in the diagram.
Transistors have three terminals: base, collector, emitter. The base controls the amount of current allowed to flow between the collector (positive terminal) and emitter (negative terminal). Because the motor requires much more power than the Arduino is capable of providing, we use batteries to power the motor. The transistor allows us to control the amount of current that flows from the battery on through the motor.
Activities
- Build the circuit shown below.
- Load the sketch below to use the potentiometer to control the motor.
(TIP120 image credit: http://tangibleinteractionuw.blogspot.com/2014/04/jered-and-ciera-arduino-sensor.html)
/* DC Motor with potentiometer control
* Theory and Practice of Tangible User Interfaces
* Fall 2017
*/
int motorPin = 9;
int potPin = A0;
int potVal = 0;
int motorCtrlVal = 0;
void setup() {
pinMode(potPin, INPUT);
pinMode(motorPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
potVal = analogRead(potPin);
Serial.print("potVal: ");Serial.println(potVal);
motorCtrlVal = map(potVal, 0, 1024, 0, 255);
Serial.print("motorCtrlVal: ");Serial.println(motorCtrlVal);
analogWrite(motorPin, motorCtrlVal);
}
Homework
Explore motion as an output, in a form of a display or tactile feedback. Use your DC motor to create vibration or rotational motion (e.g., pinwheels, dancing wires, etc.). Optional: Combine it with other outputs (sound, light, etc.).
Also explore an off center weight with the motor to see what kinds of different motions this allows you to create.
Debugging Hints
DC Motor & Battery Power
If you are sure your circuit and code are OK, it might be an issue with the motor and battery pack. If the battery won't start even when you turn the pot all the way, try giving the motor a "kick start" by rotating it slightly in the correct direction (or try both directions). The match between the battery power and DC motor is very important, and we are using exactly the same parts as last year, but it seems this year's batch of motors might take slightly more power than last year, so some of them have a hard time getting started with just two AA batteries.
You can try using more AA batteries in different configurations to change the current or voltage supplied to the motor. See more details on different possible battery arrangements here: http://electronics.howstuffworks.com/everyday-tech/battery6.htm
At the Invention Lab or Jacobs Hall they can help you connect the batteries in different configurations and show you other batteries you could try using.
Just be careful not to short the batteries because that can be dangerous by leaking battery acid and getting really hot, or in extreme cases exploding. A short is created when power and ground are connected to each other directly with no resistor or other parts in between.