Rangefinders & Stepper motors
The final goal of this week's lab is to rig things up such that, as you move your hand closer and further from a rangefinder, a cartoon head mounted on a stepper motor will move around as if it were following your hand...
Rangefinders
To measure a distance, the rangefinder uses echolocation: You first send a trigger pulse which causes a microphone to "chirp". Timing the return of the reflected sound pulse, a detector sends a response, or echo pulse containing information about the distance estimate. robot-electronics.co.uk/htm/srf05tech.htm
Trigger pulse
Assume the rangefinder has the trigger line connected to I/O line 3.
To send the trigger pulse, you can use the technique you used in Lab
02 to turn a single pin high and low. But you'll want to use the
delayMicroseconds()
function instead of
the (milliseconds) delay()
function.
Consult the documentation to find the minimum trigger pulse width. (You will want to go a bit longer than the minimum to be sure and trigger.)
Echo pulse Assume the return (echo) pulse is connected to line 4. You'll need to figure out how long the return pulse is. Consult the documentation for the Arduino pulseIn()
function. Consult the rangefinder documentation about how to interpret its width.
You will definitely want to use the timeout
option of the pulseIn()
function.
Stepper Motors
A set of 4 electromagnets are switched on, one at a time (one phase at a time). Each time the magnet tips attract the nearest teeth in a wheel made of iron (magnetic).
Stepper vs Servo motors, highlights:
- Stepper motors are less expensive than servos.
- Unlike servos, they do not use encoders and do not involve feedback on where the motor is positioned.
- Because of the way they move--in a well defined series of 4 stages for each "step"--the motion of one step is highly reliable.
- A step is also designed to be some simple fraction of the overall motion.
Keeping track of steps and position in your program is easier to do, and reliability/reproducibility of steps is high.
There's even more to the differences. if (! $homepage){ $stylesheet="/~paulmr/class/comments.css"; if (file_exists("/home/httpd/html/cment/comments.h")){ include "/home/httpd/html/cment/comments.h"; } } ?>