Announcements

November 24, 2007
Reading for November 27th, are now posted. Enjoy!

October 2, 2007
To upload your thoughtless acts, create a new assignment page like any other lab. You'll see "Thoughtless Acts" listed as one of the assignment options.

May 24, 2008
This site has been archived and is no longer editable. Stay tuned for the next version, coming in the fall!


It's a Platform!

Project Members: 
Hannes Hesse
k7lim
Ken-ichi Ueda
n8agrin

Assignment

Post descriptions and photo(s) of your crawler on the course website.
Once you get your crawler to move forward, perhaps you would want to
generate movement from your program and use your potentiometer to
control the speed of the movement. You may also team up with a friend
and use two servos instead of one.

Description

We designed a platform using 4 servos. Our platform was supposed to be a multipurpose, move stuff around crawler, but doesn't do so well on the move stuff around part of the concept. Instead it moves itself around quite a bit, mostly in one location. Also, attaching 4 servos to the Arduino board causes the entire setup to overload and draw too much current from the USB port, a small problem in the grand scheme of things.

Our platform supports several applications:

Crab-crawler

Beer-carrier

Remote control-walker

Components

  • 4 servo motors
  • 2 pots
  • lots of wire
  • cardboard
  • foamboard
  • entrepreneurial spirit

Arduino Code

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

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

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

int minPulse = 500; // minimum pulse width

void setup() {
pinMode(servoPin, OUTPUT); // Set servo pin as an output pin
pinMode(servoPin2, OUTPUT);
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

// want to know how we get the inverse of the input for the opposite side?
// pretty simple, reverse the polarity of the second POT, genius!!!
val2 = analogRead(potPin2);

if (val > 0 && val <= 999 ) {
pulseWidth = val*2 + minPulse; // convert angle to microseconds
Serial.print("moving servo to ");
Serial.println(pulseWidth,DEC);
}

if (val2 > 0 && val2 <= 999) {
otherPulseWidth = val2*2 + minPulse;
}
updateServo(); // update servo position
updateServo2();
}

// called every loop().
void updateServo() {
// pulse the servo again if rhe refresh time (20 ms) have 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
}
}

// does the same thing as updateServo for the other side of the PLATFORM
void updateServo2() {
// pulse the servo again if rhe refresh time (20 ms) have passed:
if (millis() - lastPulse2 >= refreshTime) {
digitalWrite(servoPin2, HIGH); // Turn the motor on
delayMicroseconds(otherPulseWidth); // Length of the pulse sets the motor position
digitalWrite(servoPin2, LOW); // Turn the motor off
lastPulse2 = millis(); // save the time of the last pulse
}
}

Picture

link


Powered by Drupal - Design by Artinet