Show Posts
Pages: [1] 2 3
1  Topics / Robotics / Re: Octopod Robot Spider on: July 21, 2011, 01:30:05 am
The "super glue" I used failed. I have been very busy the last few days with work. I am going to try and make time this weekend to reglue. Any suggestions on what type?

How far along is your code?
My code is in 2 parts. The first part is for hardware sontrol. It is a based off the code discussed here:http://arduino.cc/forum/index.php/topic,63203.msg476116.html#msg476116
The second part is for the autonomous feature. It will choose how to react to the environment.
Has the bot been able to lift and support itself? The legs look somewhat long for the small size servo being used.
When I test fit it all together it seemed to work fine. I am hoping because the tibia is the long part, and it will not have a great range of motion while walking.When testing I used 5vdc. I did not try to lift. I would like to get 6v to the servos in the future.

I will update as progess is made.
2  Topics / Robotics / Re: Octopod Robot Spider on: July 12, 2011, 01:51:30 pm
Not at the moment. There is no written plan. Soon I will write it down and post my sketch.
3  Topics / Robotics / Octopod Robot Spider on: July 11, 2011, 11:59:24 pm
This is the basic chassis of a robot spider I am building. At the moment, I am out of glue to finish it. The plastic parts are all handmade. It uses 24 cheap Tower Pro SC90 Servos and a Arduino Mega1280 to control it.
4  Using Arduino / Programming Questions / Re: Help with nested loops on: June 28, 2011, 02:59:34 am
Can you please show me how the DoWalkingSequence() function is wrote? I am not understanding how to use it?
I am not sure how this: DoWalkingSequence(forward,sizeof(forward)/sizeof(byte));
works.Such as the sizeof area, and what would change if i wanted to go backward. Thanks again for all the help.
Bob
5  Using Arduino / General Electronics / Re: Correct transistor wiring on: June 10, 2011, 03:29:45 am
PSU to relay/diode. Then relay/diode to collector side of a NPN transistor. Emitter to ground. A resistor to the base from the arduino. Connect your grounds of the PSU and arduino. This assumes you have a NPN transistor.
6  Using Arduino / General Electronics / Re: Correct transistor wiring on: June 10, 2011, 03:06:39 am
You need a resistor on the base of the transistor to the arduino.
7  Using Arduino / General Electronics / Re: Correct transistor wiring on: June 10, 2011, 02:48:32 am
http://www.arduino.cc/playground/uploads/Learning/relays.pdf

This should help with how to wire it. Make sure to use a diode as show. Running a relay straight from your arduino is bad for it. The coil builds up high voltage spike that is put into our arduino. The sketch you need is a simple switch one.
8  Using Arduino / Programming Questions / Re: Help with nested loops on: June 07, 2011, 08:41:47 pm
So if I use the DoWalkingSequence() function, it will use less memory because it wont have to load the whole master array? It just loads the specific rows? And it also uses less memory because of the byte type variable? Also, how does the function fit into a loop? I have briefly looked over enums and #defines. I am still reading on them. When I started this project, I knew when my sketch got to a certain level, it would become too complex for me to understand by just reading to learn. That is why I choose to use this method of locomotion. I would love to use some kind of inverse kinematics to move the robot. But I am finding it difficult to learn it by the internet.

If I can use the DoWalkingSequence() in a loop it would work very well for what I am doing. Thank you for the advice and help.
Bob
9  Using Arduino / Programming Questions / Re: Help with nested loops on: June 07, 2011, 02:34:37 pm
To be honest, I do not have the servos yet. And the values in the arrays are not correct. Nor is the platform on which the servos will be attached built. The platform is going to be homebuilt. So I do not know the angles to set in the array for the functions. It will be a matter of putting it all together and measuring the values. The ones in the array are just estimates. When I get my servos and attach them to the platform, I can get real values for the array. Also, I do not know if 8 arrays will be enough to complete the loop. 8 is the very least I can have. I tried to make this a variable, but the sketch failed to compile.
 I also will have 4 other instructions;counter-clockwise,clockwise,drift_left,drift_right. All of these will have the same basic array numbers.

I am interested in the "space saving to be had." For the backwards I was gonna try for (i=7;i>0;i--)
forgive me if that is totally wrong. I have not looked it up yet.
Would it be better to have 1 master array and have the different functions call on different parts of that array?
Thanks for the help,
Bob
10  Using Arduino / Programming Questions / Re: Help with nested loops on: June 07, 2011, 12:09:59 pm
The sketch so far with just forward and backward.
Code:
#include <Servo.h>
#define number_of_servos 24  // the number of servos, up to 48 for Mega, 12 for other boards
#define servo_pin_start 22
const int battery_led = 13;      // select the pin for the battery low LED
const int battery_read_Pin= 10;   // input pin for the battery
String status_report="Checking...";
String status_report_sensor="Checking Sensors";
String error_report="None";
int battery_total_return;
int battery_value_ave;
int battery_low=LOW; // set battery variable to battery is charged
int battery_read;  // variable to store the value coming from the battery
int battery_sum;
int position_saved[number_of_servos];
int standing_state=LOW;
int i;
int j;
int x;// for multipule reads
int status_number;
int servo_number=number_of_servos;
const int servo_timer_delay=350;
const int low_battery_value=750; //voltage to start low battery state
int number_of_battery_reads=1;
Servo Servos[number_of_servos] ; // max servos is 48 for mega, 12 for other boards
byte forwards[8][number_of_servos]={
  {     
    135  ,90  ,135  ,90  ,45   ,90  ,45  ,90, 180  ,90  ,180  ,90  ,0    ,90  ,0   ,90,  180  ,0   ,180  ,0   ,0    ,180 ,0   ,180      } 
  ,
  {     
    135  ,45  ,135  ,45  ,45   ,90  ,45  ,90,  180  ,180 ,180  ,180 ,0    ,90  ,0   ,90,  180  ,90  ,180  ,90  ,0    ,180 ,0   ,180      } 
  ,
  {     
    135  ,45  ,135  ,45  ,45  ,45  ,45  ,45,  90   ,180 ,90   ,180 ,90  ,90  ,90  ,90,  180  ,180 ,180  ,180 ,0   ,0   ,0   ,0      }
  , 
  {     
    90  ,135  ,90  ,135  ,90   ,45 ,90  ,45,  90  ,180  ,90  ,180  ,90   ,0  ,90  ,0,  90  ,180  ,90  ,180  ,90   ,0  ,90  ,0       } 
  ,
  {     
    45  ,135  ,45  ,135  ,0    ,45 ,0    ,45,  90  ,180  ,90  ,180  ,90   ,0  ,90   ,0,  0   ,180  ,0   ,180  ,180  ,0  ,180  ,0       } 
  ,
  {     
    45  ,135 ,45  ,135  ,0    ,90  ,0   ,90,  90  ,90  ,90  ,90   ,90   ,90  ,90  ,90,  0   ,180 ,0   ,180  ,180  ,0   ,180 ,0              } 
  ,
  {     
    90  ,90  ,90  ,90  ,90  ,90  ,90  ,90,  90  ,90  ,90  ,90  ,90  ,90  ,90  ,90,  90  ,90  ,90  ,90  ,90  ,90  ,90  ,90              }
  ,
  {
    45  ,45  ,45   ,45  ,135 ,45  ,135 , 45,  180 ,90  ,180  ,90  ,90  ,90  ,90  ,90,  180 ,0   ,180  ,0   ,0   ,180 ,0   ,180              }
};
byte backwards[8][number_of_servos]={
  {
    45  ,45  ,45   ,45  ,135 ,45  ,135 , 45,  180 ,90  ,180  ,90  ,90  ,90  ,90  ,90,  180 ,0   ,180  ,0   ,0   ,180 ,0   ,180          }
  ,
  {
    90  ,90  ,90  ,90  ,90  ,90  ,90  ,90,  90  ,90  ,90  ,90  ,90  ,90  ,90  ,90,  90  ,90  ,90  ,90  ,90  ,90  ,90  ,90           }
  ,
  {
    45  ,135 ,45  ,135  ,0    ,90  ,0   ,90,  90  ,90  ,90  ,90   ,90   ,90  ,90  ,90,  0   ,180 ,0   ,180  ,180  ,0   ,180 ,0             }
  ,
  {
    45  ,135  ,45  ,135  ,0    ,45 ,0    ,45,  90  ,180  ,90  ,180  ,90   ,0  ,90   ,0,  0   ,180  ,0   ,180  ,180  ,0  ,180  ,0           }
  ,
  {
    90  ,135  ,90  ,135  ,90   ,45 ,90  ,45,  90  ,180  ,90  ,180  ,90   ,0  ,90  ,0,  90  ,180  ,90  ,180  ,90   ,0  ,90  ,0             }
  ,
  {
    135  ,45  ,135  ,45  ,45   ,90  ,45  ,90,  180  ,180 ,180  ,180 ,0    ,90  ,0   ,90,  180  ,90  ,180  ,90  ,0    ,180 ,0   ,180       }
  ,
  {
    135  ,45  ,135  ,45  ,45   ,90  ,45  ,90,  180  ,180 ,180  ,180 ,0    ,90  ,0   ,90,  180  ,90  ,180  ,90  ,0    ,180 ,0   ,180           }
  ,
  {
    135  ,90  ,135  ,90  ,45   ,90  ,45  ,90, 180  ,90  ,180  ,90  ,0    ,90  ,0   ,90,  180  ,0   ,180  ,0   ,0    ,180 ,0   ,180         }
};
void setup() {
  Serial.begin(115200);
  for(servo_number=0; servo_number < number_of_servos; servo_number++){
    Servos[servo_number].attach(servo_pin_start+servo_number);
    Servos[servo_number].write(forwards[1][servo_number]);
    position_saved[servo_number]=(forwards[1][servo_number]);
  }
  pinMode(battery_led,  OUTPUT);  // declare the ledPin as an OUTPUT:
}
void battery(){
  battery_total_return=0;
  battery_sum=0;
  for (x=0;x<number_of_battery_reads;x++){
    battery_read=analogRead(battery_read_Pin); // read the value from the sensor:
    battery_sum= battery_sum + battery_read;
  }
  battery_total_return = battery_sum / number_of_battery_reads;
  if (battery_total_return<low_battery_value){
    battery_low=HIGH;
    error_report="Battery";
    digitalWrite(battery_led, HIGH);   // turn the battery low led on 
  }
  else  {
    battery_low=LOW;
    error_report="None";
    digitalWrite(battery_led, LOW); // turn the battery low led off:   
  }
}
void hold(){ 
  for (servo_number=0;servo_number<number_of_servos;servo_number++){
    status_report="Holding...";
    status_number=0;
    Servos[servo_number].write(position_saved[servo_number]); // puts servo in last standing position
    position_saved[servo_number]=(position_saved[servo_number]);
  } 
  check_status();
  return;
}
void forward() {
  for (i=0;i<8;i++){
    status_report="Forward";
    status_number=i;
    for (servo_number=0;servo_number<number_of_servos;servo_number++){
      Servos[servo_number].write(forwards[i] [servo_number]); // puts servo in stand position
      position_saved[servo_number]=(forwards[i] [servo_number]);
    }   
    check_status();
  }; 
  return;
}
void backward() { 
  for (i=0;i<8;i++){
    status_report="Backward";
    status_number=i;
    for (servo_number=0;servo_number<number_of_servos;servo_number++){
      Servos[servo_number].write(backwards[i][servo_number]); // puts servo in stand position
      position_saved[servo_number]=(backwards[i][servo_number]);
    }
    check_status();
  }   
  ;
  return; 
}
void counter_clockwise() {
  for (servo_number=0;servo_number<number_of_servos;servo_number++){
    Servos[servo_number].write(forwards[i] [servo_number]); // puts servo in stand position
    position_saved[servo_number]=(forwards[i] [servo_number]);
  }   
  check_status();
  return;
}
void clockwise() {
  for (servo_number=0;servo_number<number_of_servos;servo_number++){
    Servos[servo_number].write(forwards[i][servo_number]); // puts servo in stand position
    position_saved[servo_number]=(forwards[i][servo_number]);
  }   
  check_status();
  return;
}
void check_status(){
  battery();
  debuger();
  delay(servo_timer_delay);
  if (battery_low==HIGH){
    hold();
  }
}
void debuger(){
  Serial.print(status_report);
  Serial.print(" ");
  Serial.print(status_number+1);
  Serial.write(9);
  Serial.print("Error: ");
  Serial.println(error_report);
  Serial.println("  ");
  Serial.print("Leg#");
  Serial.write(9);
  Serial.print("1");
  Serial.write(9);
  Serial.print("2");
  Serial.write(9);
  Serial.print("3");
  Serial.write(9);
  Serial.print("4");
  Serial.write(9);
  Serial.print("5");
  Serial.write(9);
  Serial.print("6");
  Serial.write(9);
  Serial.print("7");
  Serial.write(9);
  Serial.println("8");
  Serial.println(" ");
  Serial.print("Knee ");
  Serial.write(9);
  Serial.print(position_saved[0]);
  Serial.write(9);
  Serial.print(position_saved[1]);
  Serial.write(9);
  Serial.print(position_saved[2]);
  Serial.write(9);
  Serial.print(position_saved[3]);
  Serial.write(9);
  Serial.print(position_saved[4]);
  Serial.write(9);
  Serial.print(position_saved[5]);
  Serial.write(9);
  Serial.print(position_saved[6]);
  Serial.write(9);
  Serial.println(position_saved[7]);
  Serial.print("Leg ");
  Serial.write(9);
  Serial.print(position_saved[8]);
  Serial.write(9);
  Serial.print(position_saved[9]);
  Serial.write(9);
  Serial.print(position_saved[10]);
  Serial.write(9);
  Serial.print(position_saved[11]);
  Serial.write(9);
  Serial.print(position_saved[12]);
  Serial.write(9);
  Serial.print(position_saved[13]);
  Serial.write(9);
  Serial.print(position_saved[14]);
  Serial.write(9);
  Serial.println(position_saved[15]);
  Serial.print("Hip ");
  Serial.write(9);
  Serial.print(position_saved[16]);
  Serial.write(9);
  Serial.print(position_saved[17]);
  Serial.write(9);
  Serial.print(position_saved[18]);
  Serial.write(9);
  Serial.print(position_saved[19]);
  Serial.write(9);
  Serial.print(position_saved[20]);
  Serial.write(9);
  Serial.print(position_saved[21]);
  Serial.write(9);
  Serial.print(position_saved[22]);
  Serial.write(9);
  Serial.println(position_saved[23]);
  Serial.println(" ");
  Serial.print("Volt");
  Serial.write(9);
  Serial.println("Batled");
  Serial.print(battery_sum);
  Serial.write(9);   
  Serial.println(battery_low);
  Serial.println("----------------------------------------"); 
  Serial.println("      ");
  Serial.println("      ");
  Serial.println("      ");
  Serial.println("      ");
  Serial.println("      ");
  Serial.println("----------------------------------------"); 
}
void loop()
{       
  backward();
  forward();
}
11  Using Arduino / Programming Questions / Re: Help with nested loops on: June 06, 2011, 11:53:58 pm
Code:
void forward() {
  for (i=0;i<8;i++){
    status_report="Forward1";
    status_number=i;
    for (servo_number=0;servo_number<number_of_servos;servo_number++){
      // if (ping_hit==HIGH) return;
      Servos[servo_number].write(forwards[i] [servo_number]); // puts servo in stand position
      position_saved[servo_number]=(forwards[i] [servo_number]);
    }   
    check_status();
  }; 
  return;
}
Works Great!!

@wildbill
The position_saved is the last position it was in. So when it has to pause walking, it can still run through the loops in the sketch.
But instead of a new array it just post last know array, which is position_saved
Code:
void stand(){ 
  for (servo_number=0;servo_number<number_of_servos;servo_number++){
    status_report="Stand...";
     status_number=0;
    Servos[servo_number].write(position_saved[servo_number]); // puts servo in last standing position
    position_saved[servo_number]=(position_saved[servo_number]);
  } 
  check_status();
  return;
}
I changed the array from an "int" to a "byte". I hope that was all I had to do to change it. seems to work fine.
Thanks for the help.
Bob
12  Using Arduino / Programming Questions / Re: Help with nested loops on: June 06, 2011, 02:44:00 pm
@ AWOL
Corrected my mistake.

The current sketch I have works perfect. I am just trying to condense it even more. I am not even sure how to describe what I am after.
Code:
  int forward[8][24]={
 {135  ,45  ,135  ,45  ,45   ,90  ,45  ,90,  180  ,180 ,180  ,180 ,0    ,90  ,0   ,90,  180  ,90  ,180  ,90  ,0    ,180 ,0   ,180}, // set servos to the first position
 {35  ,95  ,135  ,45  ,45   ,90  ,45  ,90,  180  ,180 ,180  ,180 ,0    ,90  ,0   ,90,  180  ,90  ,180  ,90  ,0    ,180 ,0   ,180}, // set servos to second position
 {135  ,45  ,135  ,45  ,45   ,9  ,45  ,90,  180  ,180 ,180  ,180 ,0    ,90  ,0   ,90,  180  ,90  ,180  ,90  ,0    ,180 ,0   ,180}, // set servo to next position
 {135  ,25  ,135  ,45  ,45   ,90  ,45  ,90,  180  ,180 ,180  ,180 ,0    ,90  ,0   ,90,  180  ,90  ,180  ,90  ,0    ,180 ,0   ,180},// set servo to next position
 {15  ,45  ,135  ,45  ,45   ,90  ,45  ,90,  10  ,180 ,180  ,180 ,0    ,90  ,0   ,90,  180  ,90  ,180  ,90  ,0    ,180 ,0   ,180},// set servo to next position
 {135  ,45  ,135  ,45  ,45   ,90  ,45  ,90,  180  ,180 ,180  ,180 ,0    ,90  ,0   ,90,  180  ,90  ,180  ,90  ,0    ,180 ,0   ,180},// set servo to next position
 {135  ,45  ,135  ,45  ,45   ,90  ,45  ,90,  180  ,180 ,180  ,180 ,0    ,90  ,0   ,90,  180  ,90  ,180  ,90  ,0    ,180 ,0   ,180},// set servo to next position
 {135  ,45  ,135  ,45  ,45   ,90  ,45  ,90,  180  ,180 ,180  ,180 ,0    ,90  ,0   ,90,  180  ,90  ,180  ,90  ,0    ,180 ,0   ,180}// set servo to next position

};
I know I am close. I just dont know how to put it together.
13  Using Arduino / Programming Questions / Re: Help with nested loops on: June 06, 2011, 02:21:52 pm
@ramo102
Thank for showing the mistake in the "for" loop.

"But this doesnot work" should have been "But this does not work".  Meaning, I still cant get it to work correctly.


Another way for me to describe what the sketch does is:
If you were to take a series of pictures of a spider walking forward, say eight of them, each picture is a step in the whole loop. In order to get forward progress you "play" the loop forward. And then to walk backward, you "play" the loop backwards.
So I will have 6 loops:

forward();
backward();
counter-clockwise();
clockwise();
drift left();
drift right;

this code works but I have to write each position with the postions_to_forward1 and postions_to_forward2
Code:
void forward() {
  status_report="Forward1";  //this is step 1
  for (servo_number=0;servo_number<number_of_servos;servo_number++){
    if (ping_hit==HIGH) return;
    Servos[servo_number].write(positions_to_forward1 [servo_number]); // puts servo in stand position
    position_saved[servo_number]=(positions_to_forward1 [servo_number]);
  }   
  check_status();
  status_report="Forward2"; // this is step 2
  for (servo_number=0;servo_number<number_of_servos;servo_number++){
    Servos[servo_number].write(positions_to_forward2 [servo_number]); // puts servo in stand position
    position_saved[servo_number]=(positions_to_forward2 [servo_number]);
  }     
There should be a way to
forward(); is made of 8 arrays. Each array is like a picture of the step. To make the robot walk forward, I write the arrays(pictures) to the servos, in sequence, to get the desired direction.
Code:
for (i=0;i<number_of pictures_max;i++){                                                             // this is each step for the picture
     for (servo_number=0;servo_number<number_of _servos;servo_number++) {    // this is the array loaded
          Servos[i][servo_number].write(position_for_servo[i][servo_number]);       // writes to servo   
          position_saved[i][servo_number]=(step_number[i][servo_number]);          // saves the position
}
delay(1000)                                                                                                      //delay for servos to move
}
i is the number of the picture in the sequence.
servo_number is one of the 24 servos.


Code:
Servos[i][servo_number].write(forward[i][servo_number]);

This is not wrote correct.


Thanks for the help,
Bob     
14  Using Arduino / Programming Questions / Re: Help with nested loops on: June 06, 2011, 03:48:10 am
Each loop does the same thing but with different array values. There are 24 values in the array, all for servo positioning.

positions_to_forward1 is the very first postion. Say it lifts legs up. This writes all 24 servos to a position.
positions_to_forward2 is then next one. Say it moves the legs forward. This writes all 24 servos to a new position.
positions_to_forward3 is next. Say it puts the legs down
and positions_to_forward8 is last to move the legs backward.

I want to turn the forward() into something more like this:


Code:
forward();
status_report="Forward1";
for (step_number=0;step_number>8;step_number){// eight different steps

    for (servo_number=0;servo_number<number_of_servos;servo_number++){
    Servos[servo_number].write(step_number[servo_number]); // puts servo in stand position
    position_saved[servo_number]=(step_number[servo_number]);
    check_status();
  } 


But this doesnot work.
15  Using Arduino / Programming Questions / Re: Help with nested loops on: June 06, 2011, 03:14:50 am
There are many forward positions. Each is a snap shot of the leg position during that step.

Code:
const int positions_to_forward2[number_of_servos]={
  135  ,45  ,135  ,45  ,45   ,90  ,45  ,90,
  180  ,180 ,180  ,180 ,0    ,90  ,0   ,90,// legb back/kn180
  180  ,90  ,180  ,90  ,0    ,180 ,0   ,180};
const int positions_to_forward3[number_of_servos]={
  135  ,45  ,135  ,45  ,45  ,45  ,45  ,45,
  90   ,180 ,90   ,180 ,90  ,90  ,90  ,90,// lega down/kn180
  180  ,180 ,180  ,180 ,0   ,0   ,0   ,0}; 
const int positions_to_forward4[number_of_servos]={
  90  ,135  ,90  ,135  ,90   ,45 ,90  ,45,
  90  ,180  ,90  ,180  ,90   ,0  ,90  ,0,//legb up/forward/kn180
  90  ,180  ,90  ,180  ,90   ,0  ,90  ,0};//standa
const int positions_to_forward5[number_of_servos]={
  45  ,135  ,45  ,135  ,0    ,45 ,0    ,45,
  90  ,180  ,90  ,180  ,90   ,0  ,90   ,0,//lega back
  0   ,180  ,0   ,180  ,180  ,0  ,180  ,0};
const int positions_to_forward6[number_of_servos]={
  45  ,135 ,45  ,135  ,0    ,90  ,0   ,90,
  90  ,90  ,90  ,90   ,90   ,90  ,90  ,90,// legb down
  0   ,180 ,0   ,180  ,180  ,0   ,180 ,0};
const int positions_to_forward7[number_of_servos]={
  90  ,90  ,90  ,90  ,90  ,90  ,90  ,90,
  90  ,90  ,90  ,90  ,90  ,90  ,90  ,90,//lega stand
  90  ,90  ,90  ,90  ,90  ,90  ,90  ,90};//legb stand

If I did want it to stand I would
Code:
void stand(){
  status_report="Stand...";
  for (servo_number=0;servo_number<number_of_servos;servo_number++){
    Servos[servo_number].write(position_saved[servo_number]); // puts servo in last standing position
    position_saved[servo_number]=(position_saved[servo_number]);
  } 
  check_status();
  return;
}

But to walk forward i use the different positions_to_forward# to load that array onto the servos.
Pages: [1] 2 3