Servo Motor: Actuation Assignment 2

Assignment: Servo Motor: Actuation Assignment 2

Collaborators:

 

Description

The goal of this assignment was to use a servo motor to create a "crawler". I achieved this by using the provided Arduino code, reproduced below, which allows the servo to be controlled by a potentiometer. My crawler is made primarily of cardboard and masking tape. The means of propulsion is a single paddle which bends on the "backstroke" and is held firm by a chopstick on the "forward stroke". Two skis are attached to the crawler to keep it stable. The lengths of the skis were carefully tuned to allow the paddle to only slightly make contact with the ground on the forward stroke, and keep weight off of it during the backstroke. The skis also serve to keep the crawler upright.

The main challenge I faced in this assignment was minimizing the backwards motion. Although the cardboard paddle was allowed to bend in one direction and not the other, I found that it still was rigid enough in the reverse direction to produce motion during the backstroke. I tried to solve this by further weakening the cardboard, scoreing that side of the joint, but this didn't help enough.

Components Used

The following components were used:

  • Arduino
  • Breadboard
  • Rubber band (2)
  • USB cable
  • Jumper Cable (several)
  • Potentiometer
  • Servo motor
  • Masking tape
  • Chopstick
  • Cardboard

 

Arduino Code

The following code allows the potentiometer to be used to control the rotation of the servo motor and is unmodified from that provided in the syllabus.

/*
* Servo with Potentiometer control
* Theory and Practice of Tangible User Interfaces
* October 11 2007
* Used by Eric Mai for i262 Assignment
* October 22, 2009
*/

int servoPin = 7; // Control pin for servo motor
int potPin = 0; // select the input pin for the potentiometer

int pulseWidth = 0; // Amount to pulse the servo
long lastPulse = 0; // the time in millisecs of the last pulse
int refreshTime = 20; // the time in millisecs needed in between pulses
int val; // variable used to store data from potentiometer

int minPulse = 500; // minimum pulse width

void setup() {
pinMode(servoPin, OUTPUT); // Set servo pin as an output pin
pulseWidth = minPulse; // Set the motor position to the minimum
Serial.begin(9600); // connect to the serial port
Serial.println("servo_serial_better ready");
}

void loop() {
val = analogRead(potPin); // read the value from the sensor, between 0 - 1024

if (val > 0 && val <= 999 ) {
pulseWidth = val*2 + minPulse; // convert angle to microseconds

Serial.print("moving servo to ");
Serial.println(pulseWidth,DEC);

}
updateServo(); // update servo position
}

// called every loop().
void updateServo() {
// pulse the servo again if the refresh time (20 ms) has passed:
if (millis() - lastPulse >= refreshTime) {
digitalWrite(servoPin, HIGH); // Turn the motor on
delayMicroseconds(pulseWidth); // Length of the pulse sets the motor position
digitalWrite(servoPin, LOW); // Turn the motor off
lastPulse = millis(); // save the time of the last pulse
}
}

Video

Servo Motor Crawler from Eric Mai on Vimeo.

 

Pictures