20 | | * [https://www.youtube.com/watch?v=OpL0joqJmqY Retro motor tutorial!] |
| 21 | You can use your [http://playground.arduino.cc/Learning/SolenoidTutorial arduino to control a solenoid], but there are some important tricks to be aware of. |
| 22 | 1. Electromagnets are formed by coils of wire. Wire has very low resistance, so it will conduct a lot of current...far more than your Arduino can supply directly. So the Arduino must control the solenoid indirectly: the arduino will activate an electronic switch that takes a small amount of current to activate and can then pass a large amount of current. These switches can be electro-mechanical (called relays) or solid state (transistors or similar). |
| 23 | 2. When a current is passed through a coil a magnetic field builds up around the coil. When the current is removed (when the electricity is turned off), the field collapses back into the coil inducing a flow of current. If the current has no place to go, the voltage will build, potentially to quite high levels which can destroy the electronic switch. This phenomenon is called **[https://learn.digilentinc.com/Documents/390 inductive flyback]** So an escape path is needed for the current; typically a protection diode (aka flyback diode) is used. |
| 24 | |
| 25 | == DC Motors == |
| 26 | By far the most common application is the motor. There are actually many types of motors, but in our experiments we will be using common DC motors. |
| 27 | |
| 28 | * [https://www.youtube.com/watch?v=OpL0joqJmqY Retro DC motor tutorial] |
30 | | == Part II == |
31 | | * THEORY: Controlling (high) current w/micro-controller |
32 | | * DEVICES: H-bridge for direction (make one with 2x SPDT or 1x DPDT switch?) |
33 | | * relays |
34 | | * power transistor |
35 | | * Inductors, flyback, meet ELI the ICE man |
36 | | * Protection diodes |
| 36 | == Direction Control == |
| 37 | In robots, we want to be able to run the motor in either direction (forward or reverse). To reverse the direction of a DC motor, we must reverse the direction of current through it. Direction control is typically achieved using a circuit called an H-Bridge. An H-bridge can be formed by a DPDT switch (or two SPDT switches), but for computerized direction control, the H-Bridge is formed using electronic switches (transistors). |
| 38 | * [http://www.dprg.org/tutorials/1998-04a/ Good tutorial] |
| 39 | * [https://itp.nyu.edu/physcomp/labs/motors-and-transistors/dc-motor-control-using-an-h-bridge/ Detailed tutorial] |
38 | | == Part III == |
39 | | * THEORY: PWM for speed control (view with oscilloscope) |
40 | | * DEVICES: Arduino motor shields. |
41 | | * HANDS-ON: Drive DC motors, controlling speed and direction using a motor shield. |
| 41 | == Speed Control == |
| 42 | If you don't consider the load on a motor, the higher the voltage you apply, the faster the motor will spin (at least for an ideal DC motor). However, it's not easy for a digital device like the Arduino to adjust the analog voltage to a motor; instead, motor speed control is achieved using a clever technique called [https://www.arduino.cc/en/Tutorial/SecretsOfArduinoPWM pulse-width modulation or PWM]. You may have used PWM with your Arduino to vary the brightness of an LED in the "Fade" sketch (if you didn't, [https://www.arduino.cc/en/Tutorial/PWM please try it now]. |
| 43 | |
| 44 | **Exercise**: Observe the PWM signal with an oscilloscope (ask a mentor for help) |
| 45 | |
| 46 | We will use an [https://www.adafruit.com/products/81 Arduino motor shield] to control the direction and speed of the DC motors in our mini-bots. Although you can program the shield yourself, a convenient [https://learn.adafruit.com/adafruit-motor-shield/library-install library] is available for download. |
| 47 | |
| 48 | **Exercise**: Connect a motor shield to an arduino and use it to control the speed and direction of one of the mini-bot gear motors. If your USB port can't power the motor (very possible), use an AA battery pack (see a mentor) to provide a separate power source for the motors via the motor shield power connections. |