Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Printing RepWalker Mutation RA04
05-06-2014, 07:03 AM (This post was last modified: 05-06-2014 07:08 AM by steamboat.)
Post: #13
First movement
Finaly I assembled the new #20 brain fastener you will find it on myweb page

[Image: 2014-05-05.222125-k.jpg]


To start moving the legs I have written a quick and dirty programm - take it as a first trial and add your own brain...

// written by Rainer Radow 2014-05-04 for the RepWalker
// easy code without special features...
// based on "zoomkat 10-22-11 serial servo test"
// Powering a servo from the arduino usually *DOES NOT WORK* - so you need an extra energy source!

String readString;
#include <Servo.h>
Servo servo_left, servo_right; // create servo objects to control a servo

int serial_input_value;

// here you can set the necessary value in ms to control the movement of the legs and the Shellmo
// STOP Shellmo
const int stop_l = 1200; // different timings for zero position because of the different internal circuits of the servos
const int stop_r = 1250;

// run FORWARD
// to add or substrct 150 ms is a good start - you can fine-tune it later
const int forward_l = stop_l + 150; // because of the servo arrangement you have to turn the servos in different directions
const int forward_r = stop_r - 150; // think about it ;-)

const int half_forward_l = stop_l + 70; // because of the servo arrangement you have to turn the servos in different directions
const int half_forward_r = stop_r - 70; // think about it ;-)


// run backwards
const int backward_l = stop_l - 150; // run backwards
const int backward_r = stop_r + 150;

// make a right turn while moving in forward direction
const int right_turn_fw_l = stop_l + 150;
const int right_turn_fw_r = stop_r + 150;

// make a left turn while moving in forward direction
const int left_turn_fw_l = stop_l - 150;
const int left_turn_fw_r = stop_r - 150;

// ================================================================================​==========
// ================================================================================​==========

void setup() {
Serial.begin(9600); //switch on the serial communication
servo_left.writeMicroseconds(stop_l); // run forward
servo_right.writeMicroseconds(stop_r);

servo_left.attach(7); //the PWM pin for the left servo control
servo_right.attach(5); //the PWM pin for the right servo control

Serial.println("Shellmo-test-"); //print a hello to the serial monitor - if this is switched on in the Aruino Software.
}

// ================================================================================​==========
// ================================================================================​==========

void loop()
{
// only necesary for serial communication -------------------------------------------------------
while (Serial.available())
{
char c = Serial.read(); //gets one byte from serial buffer
readString += c; //makes the string readString
delay(2); //slow looping to allow buffer to fill with next character
}

if (readString.length() >0)
{
Serial.println(readString); //so you can see the captured string
serial_input_value = readString.toInt(); //convert readString into a number

switch(serial_input_value)
{
case 5:
// STOP
Serial.println("HALT - stehen bleiben!");
servo_left.writeMicroseconds(stop_l);
servo_right.writeMicroseconds(stop_r);
break;

case 8:
Serial.println("Lauf Voran!");
servo_left.writeMicroseconds(forward_l);
servo_right.writeMicroseconds(forward_r);
break;

case 2:
// go backwards
Serial.println("Zurueck");
servo_left.writeMicroseconds(backward_l);
servo_right.writeMicroseconds(backward_r);
break;
case 3:

break;
case 4:
// turn on the table left
Serial.println("Links!");
servo_left.writeMicroseconds(backward_l);
servo_right.writeMicroseconds(forward_r);
break;
case 7:
// turn vorward left
Serial.println("links voran");
servo_left.writeMicroseconds(half_forward_l);
servo_right.writeMicroseconds(forward_r);
break;
case 6:
// turn on the table right
Serial.println("Rechts!");
servo_left.writeMicroseconds(forward_l);
servo_right.writeMicroseconds(backward_r);
break;
case 9:
// turn vorward right
Serial.println("rechts voran");
servo_left.writeMicroseconds(forward_l);
servo_right.writeMicroseconds(half_forward_r);
break;
}
readString=""; //empty for next input
}
}

Rainer
http://www.steamboating.de
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
First movement - steamboat - 05-06-2014 07:03 AM
Servo - steamboat - 05-07-2014, 04:04 AM
Hip-joint back to 5 mm - steamboat - 05-10-2014, 08:18 PM
RE: Printing RepWalker Mutation RA04 - sho - 05-14-2014, 01:01 AM

Forum Jump:


User(s) browsing this thread: 1 Guest(s)