Week 6 Lab

From Robert-Depot
Jump to: navigation, search

from Electronic Technologies for Art

Controlling the speed AND direction of a motor

WHY: Because you can control both speed and direction of a motor at once... everything you need for forward/backward motion.

L293 quadruple half H-Bridge http://focus.ti.com/lit/ds/symlink/l293.pdf:

Bidirectional control.png

Bidirectional motor photo.jpg Bidirectional motor detail.jpg

Use the processing-controlled Dimmer example (PWM) for speed, press the two buttons above to select direction.

Arduino serialtest.png

Caution: powering off of external power supply (12V instead of USB power 5V). This means you need to move the power select jumper from "USB" to "EXT", and connect your +12V supply to the power jack.

External power.jpg

You will also need to run +12V, +5V and GND from the arduino to your breadboard. The two grounds (at the top and the bottom row of your breadboard) will still need to be tied together, as usual.

12vpower off arduino.jpg 12vpower to breadboard.jpg Common ground.jpg

  1. Connect PWM output (pin 9) to Pin 1 on L293. This is the Enable (EN) input. PWM here will turn on/off the motordriver, accomplishing speed control.
  2. Make two simple Active High digital input switches, and hook them up to Pins 1A and 2A. Pressing 1A will spin it one way, pressing 2A will spin it the other way, and both at once will do a "Fast Stop". This is described in the logic table above.

D in.pngD in.png

Moving a solenoid

WHY: With forceful linear motion, you can lock/unlock doors, pull strings, move arms (levers), push keys, punch buttons, tap foreheads. What Would You Do?

Use the same high-current load driver circuit (with TIP120) from earlier labs. The diagram below, substituting the Solenoid for the lamp in the diagram below. Also, you will need to hook up external power, +12V instead of +5V to drive the solenoid.

Lamp fader.png Solenoid control.jpg

Switching a Relay

WHY: For really high current loads. To interface digital logic (5V) and AC powered (120v AC) devices. To control the mythical blender.

Use the same circuit as with the solenoid (i.e. diagram above), simply swap the solenoid with a Relay. An electromechanical relay has a giant wire-coiled magnet inside, same as a solenoid.

Moving a Servo

WHY: With precise angular motion, you can... hmm... turn knobs, tune radios, steer cars.

In this example, turn a knob to have a motor turn, correspondently.

Set up potentiometer input

Pot in.png

Attach Servo: Servo control.jpg

// potentiometer_servo
// turning the knob turns the servo
// Robert Twomey - roberttwomey.com

#include <Servo.h> 
Servo myservo;  // create servo object to control a servo 
               // a maximum of eight servo objects can be created 

int a_in = 0; // analog in pin
int val = 0;  // variable to store analog value

int pos = 0;    // variable to store the servo position 
int delay_time = 15; 
void setup() 
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object 

void loop() 
  val=analogRead(a_in); // read value from potentiometer
  pos=map(val, 0, 1023, 0, 180); // map 0-1023 value to 0-180 degrees
  myservo.write(pos); // set servo position



Over the course of the next two weeks, we are going to do a mid-term project. Consider it a rehearsal for the final. Your mission: find an object and control it. This could be a toy (see Robosapien example below), a car, a clock (see clock example below), a blender (see blender example below). For this week's homework, you will identify the object you want to control, and write up a preliminary diagram describing how you will control it. A block diagram or flow diagram is a good example: are there inputs coming from sensors, into the microprocessor? If so, put them in the diagram. What are the actuators that are going to produce the output: motors + servos for moving parts, lights for blinking parts (are we bored with this yet), sound, smells. Think expansively! Can you make something bigger than 4x4x4 feet? Something heavier than you are?

This is going to be a two week project, and a rehearsal for the final. We are going to get our first ideas out of our system with this project, letting you either build on this project or go in a new direction for the final. E-mail me if you are concerned whether or not your idea is feasible. Please post these three things to your User page on the wiki:

  1. A written proposal (2 paragraphs)
  2. Diagrams, both technical (showing how sensors, processor, and actuators will connect) and aesthetic (giving us a sense of how it will look).
  3. Bring the thing you want to control, and any sensors, actuators, or other hardware.

Next week, in class, we will workshop your projects and come up with technical implementations (i.e. what circuits/chips/devices do you need to make your project work.) This project will count for part of your final and as homework, approx 25%. Final will remain 35%.

Robosapien example: http://www.arduino.cc/playground/Main/RoboSapienIR

Clock example: http://www.cibomahto.com/2008/03/controlling-a-clock-with-an-arduino/

Blender example: http://www.willitblend.com/