User login

Powered by Drupal, an open source content management system

Theory and Practice of Tangible User Interfaces

Lab 7: A Crawler

Submitted by Becky on Tue, 10/21/2008 - 22:54

Assignment: Servo Motor: Actuation Assignment 2

Collaborators:

 

Description: In this lab, we learned how to use and control servo motors using servo_control_serial.txt and servo_control_pot.txt. Following that, I attached a produce basket to the servo motor, controlled by a potentiometer, to create a crawler.

Components:

  • arduino
  • servo motor
  • potentiometer
  • produce basket
  • wire
  • usb cable
  • computer

Code:

/*
* Servo with Potentiometer control
* Theory and Practice of Tangible User Interfaces
* October 11 2007
*/

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
}
}

Images/Video:

 







lab 07: system at rest

A produce basket attached to the servo motor.<br />Servo motor connected through Arduino; controlled by potentiometer.

lab 07: the object up close

Produce basket attached to servo with thread.

lab 07: twisted

When the motor turns from its starting position, the basket squishes; when it turns back to its starting position, the basket unsquishes; leading to motion of the basket.

Observations/Conclusions:

 

I tried to attach a number of objects to the servo motor to create this crawler. I began by trying to create a crawler from natural objects. I tried to attach sticks to one another with string and then to the servo, again with string. The joints were too weak to maintain their shape while the servo moved, so the object had a tendancy to collapse. I think, if I had set these objects using glue, they might have been a good material for a crawler.

I decided to use this produce basket after a few failed attempts with the sticks. My prediction for how the crawler would move was different than how it is moving. I did not predict that the basket would shear as it does.

This system is particularly suited for motion on low-friction surfaces.

Although I was not trying to make an animal-like object, I think that most of the things I worked on seemed a bit creature-like because they seemed to be moving on their own.