Let's Make Robots!

A spider called "Chopsticks"

OddBot's picture
Plays with brave children, runs from large fly swatters!
Weight: 
2500 grams
AttachmentSize
Chopsticks_servo_alignment.zip591 bytes
_28_servo_RedBack10.zip6.73 KB

I have seen a number of fantastic Hexapod style robots, most using laser cut parts and very expensive servos. Chopsticks is a robot Spider made from cheap standard servos, polymorph and yes you guessed it... Chopsticks!

Think of it as a Chinese version of Frits's paintsticks and hotglue philosophy.
I have added videos in YouKu as well as YouTube for my Chinese friends.
Detailed assembly instructions can now be found on
Make Projects.

The disposable chopsticks are made from a very lightweight wood (Bamboo) that gives the chassis a good strength to weight ratio. The polymorph is much heavier by comparison but perfect for creating the custom shapes needed.

I am using 28 servos on this robot, 24 for the 8 legs, 3 for head movements and 1 for the mandibles. Because 28 servos are quite heavy and these are not heavyduty servos I cut the chopsticks in half to reduce the size of the legs and the strain on the servos. This should also increase the battery life.

The polymorph servo mount in the center of this leg piece slides along the chopsticks making it easier to get the servo in.

After some experimentation I now have one spider leg I am happy with. Just 7 more to be made :-)

 


 

Tues 5th of April 2011

I now have 4 left and 4 right legs made. This took a lot longer than I though largly because of waiting for the polymorph to cool. Occasionally the polymorph would be too hot and glue itself to the servo housings. Then I would have to pry/melt/scrap it off and start again. I rushed towards the end so if I ever need to replace a broken servo then I will probably have to rebuild half of the leg as well.

I've made a simple spine consisting of 2 whole chopsticks joined by 4 sections of polymorph. Now I need to work out how to mount the Spider controller and the batteries. Once I have it walking I will add the head and mandibles.

 


 

Sunday 10th of April 2011

I had a lot of problems when I had more than 16 servos connected at once. The power would "brown out" and the current indicated a short circuit. I built a sheild using some prototype PCB so that I could power the servos directly from the battery but I still had the same problem. This eliminated the Spider controller as a source of the problem.

If I connected the servos one at a time then I had no problems and the total current draw was only about 2A. I added 17x 220nF monolithic ceramic capacitors to suppress any noise being generated from the servos but the problem persisted. The servos I am using tend to twitch a bit when you apply power to them.

It seems that 28 servos twitching at once causes a current spike. Although my 2700mAH NiMh batteries should be able to handle the current surge I suspect that the battery holder is limiting the current. I switched over to a 7.2V, 4500mAH NiMh racing pack that I normally use for the Wild Thumper chassis along with the high power switch and heavy duty power cable.

This solved the brownout problem and allowed Chopsticks to stand under his own power. Since servos connected to an Arduino can twitch a bit while the bootloader is active I have added power FETs to my shield so that power to the servos is controlled by digital outputs D11 and D12.

I have wired my sheild so I have two banks of 16 servos that can be individually turned on or off. This further reduced the current surge and means that when the spider is standing still it can turn off the servos not used to support it's weight to conserve power. I did a quick test to see how much current is being drawn while standing still. At the moment there are only the 24 leg servos connected as I have not built the head yet.

Now that I have the robot powering up ok I can mount the battery and controller properly and tidy up the leg wiring. To begin with I need a frame to mount the PCBs on. Out come the chopsticks and polymorph.

Mounting the Frame was a bit tricky. The polymorph wanted to bond to the servos and the battery. I'm trying to keep this robot so that it can be easily disasembled for repairs which means NOT glueing everything together into one big lump.

After a bit of experimentation I got the high current switch mounted so thet the switch was easily accessible at the rear of the robot. The Spider controller is sitting high enough that the legs can fold up underneath.

After plugging in all the servos (24 for now) I tried to tidy up the cables a bit. I checked the weight. The robot is now 2.2Kg (4.85lb). At this point about 1/4 of that weight is polymorph. The rest is almost all servos and the battery. The chopstick weigh almost nothing.

Once I have the robot walking I can add the head and sensors.

Since it is a Spider robot it seems only right to use the IR compound eye but I am going to take things up a couple of notches. To begin with I will use multiple eyes to give the robot a wider range of view. Secondly I will increase the range of the eyes by increasing the maximum current that can flow throught the IR LEDs from 50mA to at least 250mA. As long as I keep the duty cycle down to 1% with a maximum on time of 100uS then the LEDs are rated for up to 1A of current.

 


 

Monday 11th of April 2011

My new heavy duty servo shield arrived today. I designed it specifically for robots like Chopsticks where the servos need a higher voltage and more current than the Spiders on board switch mode regulator can supply. I designed this PCB before the whole issue of switching power to the servos in groups came up.

Since my earlier problems were largely due to using batteries and wire that could not handle the current load I started off with some cable that had a 30A rating. I was not sure if these servos are 6V or 7.2V so I put some heavy duty diodes in series to drop the voltage to aproximately 6V. I use 4x 3A diodes in parallel to effectively make a 12A diode and put two of these 12A diodes in series to give me roughly 1.2V drop.

You can see this ugly lump of diodes cable tied to the frame.I am waiting to hear back from the servo factory as to the voltage rating of these servos. I'm hoping they are rated at 7.2V so I can ditch the diodes and increase the power of the servos.

I powered up the new servo sheild and everything worked fine. All my previous problems were due to underestimating the current requirements of 28 servos (I have seen the ampmeter spike above 10A on power up).

 


Wednesday 13th of April 2011

 

I now have the servo specifications from the factory and they are 4.8V - 6V servos. Good thing I played it safe. I decided to make a new sheild for the robot with a high current switch and voltage drop diodes mounted in the prototype area.

Now power to the servos is controlled by D12. When D12 is low the Pch FETs turn on. This allows the 7.2V from the battery to go through the diodes where it looses 1.2V and provide 6V to the servos. There is a 3mm yellow LED that lights up when D12 goes low to let me know the servos have power.

 


 

Saturday 16th April 2011

I am somewhere in China (Longnan City, JiangXi province) and I brought Chopsticks along to work on at night in the Hotel. I finally have him walking!

The gait I am using only lifts one foot at a time because he ways nearly 2.5Kg (5.5lb) and these servos are only cheap standard servos so they are struggling. If I replace 8 of the servos with stronger servos then I could change to a much faster gait that lifts 4 feet at once.

I managed to tweak the code to get a more reasonable speed. Added another video and attached the code for anyone interested in how I generate the gait.

Still a lot of work to be done, He needs a head, I wanted to add pan/tilt/roll and mandibles but unless I reduce the weight (LiPo battery would help) or replace 8 servos then I might have to stick with an array of compound eyes.

 


Sunday 17th April 2011

I am back in the office and had a chance to get Chopsticks doing basic maneuvers. Aside from moving sideways which I haven't had time for, the maneuvering code is mostly done. He sounds a bit like a drunken horse in the new video :D

I have attached the code as "RedBack4.zip". You will see that I had to break the walk sequence down into left/right legs for both forward and backward. In this case the speed for left and right legs range from -4 to +4 with 0 being stop. This allows gentle turns as well as turning on the spot.

 

 


 

Monday 18th April 2011

Now that I have the Chopsticks mobile I'm starting work on the head beginning with 4x IR compound eyes arranged as 2 pairs. I looked at photos of spider eyes on Google and decided that this robot should also have many eyes of which these are only the first 2.

On this robot I want to extend the range of the eyes to improve it's interaction with people. I am connecting more sensors in parallel which increases the amount of light being detected and the LEDs will be driven at higher currents. I hope to increase the range to around 1 meter.

To make this robot more interesting, these two "Primary Eyes" are on seperate pan/tilt kits mounted at 90 degees to each other. This allows the robot to track two objects simultaneously or use both eyes in stereo mode to determine distance with reasonable accuracy.

 


 

Tuesday 19 of April 2011

I upgraded the 8 "thigh" servos that support most of the robots weight from 5Kg/cm to 12Kg/cm servos. The robot now draws less power when standing still as the new servos are not struggling to support the robots weight.

This has allowed me to add a new faster walking gait. I've added a video showing the two gaits one after another for comparison.

 

 


 

Friday 22nd of April 2011

I've had a lot of trouble with the eyes. I'm not getting the range I hoped for. I've written some simple code just to get the robot to follow my hand which was complicated slightly by two very curious and completely independant eyes. I have attached the code as RedBack6.

I'm trying to keep the code for each eye relatively independant so that the robot is capable of playing with 2 children at once. Later I want to add personality to the robot. Planned personality features are:

  • Boredom when no moving objects are present for a certain period of time - go and explore
  • Fear when children have it trapped - curl up on the floor and play dead
  • Annoyance if you do not play nice - avoid you until you leave it alone
  • Sleepy if the batteries are getting low - avoid playing, move slowly to save power
  • Happy when receiving a lot of attention - more tolerant of negative traits like fear and boredom
  • Sad when ignored and cannot find a friend when exploring. May sulk or sleep.

To make the personality more realistic some traits will affect others, for example being sleepy will increase tolerance for boredom. A full battery will make it more eager to explore. Some traits will transform such as fear turning to anger if kept in that state too long.

 


 

Tuesday 26th of April 2011

I haven't had time to do much but I have begun on his personality. If something gets too close for comfort then he tries to hide. after a short while he looks about to see if it's safe. For anyone interested I have attached the code as version 9.

 

 


 

Friday 24th of June 2011

Chopsticks was announced the winner of MAKE magazines "Robots with character" competition.

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
MoX's picture

hi OddBot

Very fun robot !

I like the way you use the two Primary Eyes and the reactions of the robot : it's like a small animal protecting itself.

Impressive job :)

 

OddBot's picture

If your master took you to a school where you were surrounded by children ten times your size and they all started waving their hands in front of your eyes you would scrunch down and cover your eyes too :-P

can u connect it to bluetooth and like a ps3 remote or phone that uses gyrometer to control the robot

and if so could someone please put up a isntructable of how to do so please

I am new and i just recentally finished this robot but i got bored of it like within a month (no offense) and i would really like it to have another way of controlling it but i am kinda like a newbie    i am also only 12 and i can do c programing but arduino is just a little harder 

could the person who makes an instructable also be specific or something please thanks in advance

OddBot's picture

This robot could easily be controlled via bluetooth or any other remote control system. Right now I do not have such code or schematics.

Please post your robot as a robot project so everyone can see what a great job you have done! I would love to see it.

Ask your questions either within your robot project or as a seperate forum topic. You will then get several people who have done it before offering you sample code, schematics and suggestions.

i saw this bluetooth robot tank that somebody make and he made a android app and windows application that sends a bluetooth signal to his robot:http://letsmakerobots.com/node/27249   

he said in his url to extra info:Can be used to control other robots through the usb arduino. Just put it in the arduino sketch w as the front, as s back, as a left, right and d as we can steer with the arrow keys. Yet we can write anything and send it by pressing the send.

how can we do this with this robot

OddBot's picture

As I said. Post the robot and post the question in the forum.

i am going to start makeing the post (my internet got screwed for like all of last week so i couldn't)

 

but i developed some code for bluesmrif and i would like to test it but i cant find the rx and tx pins on the spider controller  

here is the code i make and could somebody test it and tell me where thoose 2 pins are as i post it

i used alot of the sample code and added some of my own

 

 

 

//#include <LiquidCrystal.h>

//#include <EEPROM.h>

#include <Servo.h>

#include "constants.h"

#include "IO_pins.h"

 

char val;         // variable to receive data from the serial port

int ledpin = 2;  // LED connected to pin 2 (on-board LED)

// define global variables

 

int lp=5;                  // left  pan  value (scanning)

int rp=5;                  // right pan  value (scanning)

int lt=-1;                 // left  tilt value (scanning)

int rt=+1;                 // right tilt value (scanning)

 

int stride=25;             // position in walking sequence 

int pos=0;                 // 0 = Sitting    28 = Standing    56 = Curled Up

 

int Lspeed;                // determines left  legs stride and direction (-4 to +4)

int Rspeed;                // determines right legs stride and direction (-4 to +4)

int Cspeed;                // determines crab walk  stride and direction (-4 to +4) 

int Aspeed;                // average speed used to adjust walkspeed

 

int OLspeed;               // Old left  speed value 

int ORspeed;               // Old right speed value 

int OCspeed;               // Old crab  speed value (straffing speed)

int lift;                  // amount to lift legs by when walking, drumming etc.

 

int walkspeed=25;          // number of milliseconds between walk sequence steps

int drumspeed=100;         // set the tempo of the drum sequence

unsigned long drumtime;    // timer used to control drum tempo

unsigned long walktime;    // timer used to control walking speed

unsigned long modetime;    // used to prevent the robot changing between walkmodes too quickly

 

 

// define servo center positions (Spider at rest)

int svc[84]={

  1000,1000,1000,1000,     // D26 thigh4, D27 thigh3, D28 thigh2, D29 thigh1

  1080,1100,1040,1000,     // D30 knee 4, D31 knee 3, D32 knee 2, D33 knee 1

  1650,1700,1430,1220,     // D34 hip  4, D35 hip  3, D36 hip  2, D37 hip  1

  1800,1460,1400,1250,     // D38 hip  8, D39 hip  7, D40 hip  6, D41 hip  5

  1770,1800,1870,1770,     // D42 knee 8, D43 knee 7, D44 knee 6, D45 knee 5

  2000,2000,2000,2000,     // D46 thigh8, D47 thigh7, D48 thigh6, D49 thigh5 

  0,   0,   0,   0,        // D50 Lpan  , D51 Ltilt , D52 Rpan  , D53 Rtilt

 

  // define servo center positions (Spider standing)

  1500,1480,1500,1520,     // D26 thigh4, D27 thigh3, D28 thigh2, D29 thigh1

  1050,1050,1050,1050,     // D30 knee 4, D31 knee 3, D32 knee 2, D33 knee 1

  1650,1700,1430,1220,     // D34 hip  4, D35 hip  3, D36 hip  2, D37 hip  1

  1800,1460,1400,1250,     // D38 hip  8, D39 hip  7, D40 hip  6, D41 hip  5

  1900,1900,1900,1750,     // D42 knee 8, D43 knee 7, D44 knee 6, D45 knee 5

  1500,1500,1500,1450,     // D46 thigh8, D47 thigh7, D48 thigh6, D49 thigh5

  0,   0,   0,   0,        // D50 Lpan  , D51 Ltilt , D52 Rpan  , D53 Rtilt

 

  // define servo center positions (Spider curled up)

  650, 650, 650, 650,      // D26 thigh4, D27 thigh3, D28 thigh2, D29 thigh1

  730, 730, 690, 650,      // D30 knee 4, D31 knee 3, D32 knee 2, D33 knee 1

  1650,1700,1430,1220,     // D34 hip  4, D35 hip  3, D36 hip  2, D37 hip  1

  1800,1460,1400,1250,     // D38 hip  8, D39 hip  7, D40 hip  6, D41 hip  5

  2300,2270,2330,2270,     // D42 knee 8, D43 knee 7, D44 knee 6, D45 knee 5

  2500,2450,2400,2400,     // D46 thigh8, D47 thigh7, D48 thigh6, D49 thigh5 

  2100,2000,2100,2000      // D50 Lpan  , D51 Ltilt , D52 Rpan  , D53 Rtilt

};

int svt[28];               // storage of temporary servo calculations used to control speed and direction of servos

 

int svp[28];               // actual servo positions

 

//----------------------------------------------------------- define servos ---------------------------------------------------------

 

Servo sv[28];                                              // Yes! servos can be an array

 

void setup()

{

  for(int i=0;i<24;i++)                                    // copy center positions into servo position array

  {

    svp[i]=svc[i];

    if (svp[i]==0) svp[i]=1500;     

  }

 

  delay(1000);

  pinMode(12,OUTPUT);                                      // pin 12 used to turn on/off servo power

  digitalWrite(12,1);                                      // power up servos - servos remain dead until they are initialized and receive a signal

 

  //--------------------------------------------------------- Servos initialized in a sequence to prevent the legs becoming tangled ---

 

 

  for(int i=0;i<4;i++)                                     // initialize left thighs

  {

    sv[i].attach(26+i,700,2300); 

    sv[i].writeMicroseconds(svc[i]);

    delay(50);

  }

 

  for(int i=20;i<24;i++)                                   // initialize right thighs

  {

    sv[i].attach(26+i,700,2300); 

    sv[i].writeMicroseconds(svc[i]);

    delay(50);

  }

 

  for(int i=8;i<16;i++)                                    // initialize all hips

  {

    sv[i].attach(26+i,700,2300); 

    sv[i].writeMicroseconds(svc[i]);

    delay(50);

  }

 

  for(int i=4;i<8;i++)                                     // initialize left knees

  {

    sv[i].attach(26+i,600,2500); 

    sv[i].writeMicroseconds(svc[i]);

    delay(50);

  }

 

  for(int i=16;i<20;i++)                                   // initialize right knees

  {

    sv[i].attach(26+i,600,2500); 

    sv[i].writeMicroseconds(svc[i]);

    delay(50);

  }

  Serial.begin(115200);       // start serial communication at 115200bps

  pinMode(ledpin = 13, OUTPUT);  // pin 13 (on-board LED) as OUTPUT

}

//------------------------------------------------------------------------------bluetooth following--------------------------------------------------------------------------------------------

void loop() 

{

  if( Serial.available() )       // if data is available to read

  {;}

    val = Serial.read();         // read it and store it in 'val'

 

  if( val == 'w' )       // is w was received, then go forward

   { 

     lspeed=4;

     rspeed=4; 

     if ((millis()-walktime)>walkspeed)

      {

       walktime=millis();

       if (Lspeed!=0 || Rspeed!=0 || Cspeed!=0) Walk1();

      }

   } 

 

  if( val == 's' )       // is s was received, then go backward

   { 

     lspeed=-4;

     rspeed=-4; 

     if ((millis()-walktime)>walkspeed)

      {

       walktime=millis();

       if (Lspeed!=0 || Rspeed!=0 || Cspeed!=0) Walk1();

      }

   } 

 

  if( val == 'd' )       // is d was received, then go right

   { 

     lspeed=4;

     rspeed=-4; 

     if ((millis()-walktime)>walkspeed)

      {

       walktime=millis();

       if (Lspeed!=0 || Rspeed!=0 || Cspeed!=0) Walk1();

      }

   } 

 

  if( val == 'a' )       // is a was received, then go left

   { 

     lspeed=-4;

     rspeed=4; 

     if ((millis()-walktime)>walkspeed)

      {

       walktime=millis();

       if (Lspeed!=0 || Rspeed!=0 || Cspeed!=0) Walk1();

      }

   }

  if( val == 'e' ) 

   {

     lspeed=4;

     rspeed=2;

     if ((millis()-walktime)>walkspeed)

      {

       walktime=millis();

       if (Lspeed!=0 || Rspeed!=0 || Cspeed!=0) Walk1();

      }

   }

  if( val == 'q' )

   { 

    lspeed=2;

    rspeed=4;

     if ((millis()-walktime)>walkspeed)

      {

       walktime=millis();

       if (Lspeed!=0 || Rspeed!=0 || Cspeed!=0) Walk1();

      }

   } 

  if( val == 'n')

   {

     if (pos>0) 

      {pos=0;

       walkspeed=50;

       SitStand();

      } 

   }  

  if( val == 'm') 

   {

    if (pos!=28)                                           // get back on feet if required

    {

      pos=28;

      walkspeed=25;

      lp=5;                                                // reset left eye scan to active

      rp=5;                                                // reset right eye scan to active

      SitStand();

    }

   } 

  if( val == 'b')

   {

    if(pos==28)                                            // if the robot is standing then sit down slowly

    {

      pos=0;

      walkspeed=50;

      lp=1;                                                // set left eye scan to lazy

      rp=1;                                                // set right eye scan to lazy

      SitStand();

    }

    if ((millis()-drumtime)>drumspeed)                     // control the tempo of the drumbeat

     {

      drumtime=millis();

      Drum();                                              // drumbeat sequence

     }

   }

  if( val == 'v' )

   {  

    pos=56;

    walkspeed=50;

    lp=1;                                                // set left eye scan to lazy

    rp=1;                                                // set right eye scan to lazy

    SitStand();

    HideEyes();

   } 

 }   

 

 

 

//=========================================================== Cycle through 4 legged walk sequence ==================================

void Walk1()

{

  lift=-500;

  stride++;                                                // cycle through gait sequence

  if (stride>23)

  {

    stride=0;                                              // restart stride sequence

    if (OLspeed>Lspeed) OLspeed--;                         // limit rate of Lspeed change to prevent leg tanglement 

    if (OLspeed<Lspeed) OLspeed++;

    if (ORspeed>Rspeed) ORspeed--;                         // limit rate of Rspeed change to prevent leg tanglement 

    if (ORspeed<Rspeed) ORspeed++;

    if (OCspeed>Cspeed) OCspeed--;                         // limit rate of Cspeed change to prevent leg tanglement 

    if (OCspeed<Cspeed) OCspeed++;

  }

 

  for(int i=0;i<4;i++)                                     // keep knees and hips moving

  {

    svp[i+4]-=OCspeed*4;                                   // move left  knees allowing for speed and direction

    svp[i+16]-=OCspeed*4;                                  // move right knees allowing for speed and direction

    svp[i+8]+=OLspeed*4;                                   // move left  hips allowing for speed and direction

    svp[i+12]-=ORspeed*4;                                  // move right hips allowing for speed and direction

  }

 

  switch(stride)

  {

  case 0:

    svp[3]=svc[3+pos]+lift;                                // lift leg1

    svp[1]=svc[1+pos]+lift;                                // lift leg3

    svp[23]=svc[23+pos]-lift;                              // lift leg5

    svp[21]=svc[21+pos]-lift;                              // lift leg7

    break;

 

  case 1:

    svp[11]=svc[11+pos]-(OLspeed*48);                      // move leg1 forward

    svp[9]=svc[9+pos]-(OLspeed*48);                        // move leg3 forward

    svp[15]=svc[15+pos]+(ORspeed*48);                      // move leg5 forward

    svp[13]=svc[13+pos]+(ORspeed*48);                      // move leg7 forward

 

    svp[7]=svc[7+pos]+(OCspeed*48);                        // extend/retract knee1

    svp[5]=svc[5+pos]+(OCspeed*48);                        // extend/retract knee3

    svp[19]=svc[19+pos]+(OCspeed*48);                      // extend/retract knee5

    svp[17]=svc[17+pos]+(OCspeed*48);                      // extend/retract knee7

    break;

 

  case 6:

    svp[3]=svc[3+pos];                                     // lower leg1

    svp[1]=svc[1+pos];                                     // lower leg3

    svp[23]=svc[23+pos];                                   // lower leg5

    svp[21]=svc[21+pos];                                   // lower leg7

    break;

 

  case 12:

    svp[2]=svc[2+pos]+lift;                                // lift leg2

    svp[0]=svc[0+pos]+lift;                                // lift leg4

    svp[22]=svc[22+pos]-lift;                              // lift leg6

    svp[20]=svc[20+pos]-lift;                              // lift leg8

    break;

 

  case 13:

    if (OLspeed>Lspeed) OLspeed--;                         // limit rate of Lspeed change to prevent leg tanglement 

    if (OLspeed<Lspeed) OLspeed++;

    if (ORspeed>Rspeed) ORspeed--;                         // limit rate of Rspeed change to prevent leg tanglement 

    if (ORspeed<Rspeed) ORspeed++;

    if (OCspeed>Cspeed) OCspeed--;                         // limit rate of Cspeed change to prevent leg tanglement 

    if (OCspeed<Cspeed) OCspeed++;

 

    svp[10]=svc[10+pos]-(OLspeed*48);                      // move leg2 forward

    svp[8]=svc[8+pos]-(OLspeed*48);                        // move leg4 forward

    svp[14]=svc[14+pos]+(ORspeed*48);                      // move leg6 forward

    svp[12]=svc[12+pos]+(ORspeed*48);                      // move leg8 forward

 

    svp[6]=svc[6+pos]+(OCspeed*48);                        // extend/retract knee2

    svp[4]=svc[4+pos]+(OCspeed*48);                        // extend/retract knee4

    svp[18]=svc[18+pos]+(OCspeed*48);                      // extend/retract knee6

    svp[16]=svc[16+pos]+(OCspeed*48);                      // extend/retract knee8

    break;

 

  case 18:

    svp[2]=svc[2+pos];                                     // lower leg2

    svp[0]=svc[0+pos];                                     // lower leg4

    svp[22]=svc[22+pos];                                   // lower leg6

    svp[20]=svc[20+pos];                                   // lower leg8

    break;

  }

  ServoUpdate();

}

 

void Drum()//=============================================== Drum feet on floor when bored =====================================================

{

  int lift=200;

  int thump=200;

  drumbeat++;

  if(drumbeat>31) drumbeat=0;

  switch(drumbeat)

  {

    case(0):                                              // raise knee1

    svp[7]=svc[7]+lift;

    break;

 

    case(1):                                              // lower knee1 hard

    svp[7]=svc[7]-thump;

    break;

 

    case(2):

    svp[7]=svc[7];                                        // reset knee1 

    svp[6]=svc[6]+lift;                                   // raise knee2

    break;

 

    case(3):

    svp[6]=svc[6]-thump;                                  // lower knee2 hard

    break;

 

    case(4):

    svp[6]=svc[6];                                        // reset knee2

    svp[5]=svc[5]+lift;                                   // raise knee3

    break;

 

    case(5):

    svp[5]=svc[5]-thump;                                  // lower knee3 hard

    break;

 

    case(6):

    svp[5]=svc[5];                                        // reset knee3

    break;

 

    case(8):

    svp[16]=svc[16]-lift;                                 // raise knee8

    break;

 

    case(9):

    svp[16]=svc[16]+thump;                                // lower knee8 hard

    break;

 

    case(10):

    svp[16]=svc[16];                                      // reset knee8

    svp[17]=svc[17]-lift;                                 // raise knee7

    break;

 

    case(11):

    svp[17]=svc[17]+thump;                                // lower knee7 hard

    break;

 

    case(12):

    svp[17]=svc[17];                                      // reset knee7

    svp[18]=svc[18]-lift;                                 // raise knee6

    break;

 

    case(13):

    svp[18]=svc[18]+thump;                                // lower knee6 hard

    break;

 

    case(14):

    svp[18]=svc[18];                                      // reset knee6

 

    case(16):                                             // raise knee1

    svp[7]=svc[7]+lift;

    break;

 

    case(17):                                             // lower knee1 hard

    svp[7]=svc[7]-thump;

    break;

 

    case(18):

    svp[7]=svc[7];                                        // reset knee1 

    svp[6]=svc[6]+lift;                                   // raise knee2

    break;

 

    case(19):

    svp[6]=svc[6]-thump;                                  // lower knee2 hard

    break;

 

    case(20):

    svp[6]=svc[6];                                        // reset knee2

    svp[5]=svc[5]+lift;                                   // raise knee3

    break;

 

    case(21):

    svp[5]=svc[5]-thump;                                  // lower knee3 hard

    break;

 

    case(22):

    svp[5]=svc[5];                                        // reset knee3

    break;

 

    case(24):

    svp[16]=svc[16]-lift;                                 // raise knee8

    svp[18]=svc[18]-lift;                                 // raise knee6

    break;

 

    case(25):

    svp[16]=svc[16]+thump;                                // lower knee8 hard

    svp[18]=svc[18]+thump;                                // lower knee6 hard

    break;

 

    case(26):

    svp[16]=svc[16];                                      // reset knee8

    svp[18]=svc[18];                                      // reset knee6

    break;

 

    case(28):

    svp[17]=svc[17]-lift;                                 // raise knee7

    svp[19]=svc[19]-lift;                                 // raise knee5

    break;

 

    case(29):

    svp[17]=svc[17]+thump;                                // lower knee7 hard

    svp[19]=svc[19]+thump;                                // lower knee5 hard

    break;

 

    case(30):

    svp[17]=svc[17];                                      // reset knee7

    svp[19]=svc[19];                                      // reset knee5

    break;

  }

  ServoUpdate();

}

 

//------------------------------------------------------sitting and standing------------------------------------------------------------------------------------------------     

void SitStand()                                               

{

  for(int i=0;i<28;i++)                                    // scan through servo positions

  {

    svt[i]=(svc[i+pos]-svp[i])/20;                         // calculate speed and direction required to move the servo to sitting/standing position in 20 steps

    if(svc[i+pos]==0) svt[i]=0;                            // a 0 indicates do not change servo position

 

  }

  for(int j=0;j<20;j++)                                    // move servos over a period of 20 steps to generate a smooth motion

  {

    for(int i=0;i<28;i++)

    {

      svp[i]+=svt[i];                                      // adjust the servos position

      sv[i].writeMicroseconds(svp[i]);                     // update the servos position

    }

    delay(walkspeed);                                      // controls speed of motion

  }

}

//-----------------------------------------------------------------------------------------taze---------------------------------------------------------------------------------------------

//=========================================================== Hide eyes when scared =================================================

 

void HideEyes()

{

  if(pos!=56)                                              // Move into curled up position

  {

    pos=56;

    SitStand();

  }

 

  for(int i=0;i<20;i++)

  {

    svp[11]-=23;                                           // adjust hip1

    svp[12]+=27;                                           // adjust hip8

    svp[3]+=12;                                            // adjust thigh1

    svp[20]-=11;                                           // adjust thigh8

    svp[7]+=68;                                            // adjust knee 1

    svp[16]-=67;                                           // adjust knee 8

 

    sv[11].writeMicroseconds(svp[11]);                     // update the servos position

    sv[12].writeMicroseconds(svp[v12]);                     // update the servos position

    sv[3].writeMicroseconds(svp[3]);                       // update the servos position

    sv[20].writeMicroseconds(svp[20]);                     // update the servos position

    sv[7].writeMicroseconds(svp[7]);                       // update the servos position

    sv[16].writeMicroseconds(svp[16]);                     // update the servos position

    delay(15);

  }

}

 

 

 

 

 

 

 

 

OddBot's picture

Please don't post large chunks of code like this, it messes up the page. Attach your code as a zip file when you post your project.

I do not know why you cannot find the TX and RX pins. All 4 serial ports are together and labelled in the silkscreen RXD0 - RXD3, TXD0 - TXD3 and have the word "communications" next to them.

No one can test your code unless they have your hardware. Even then each robot must have it's servos calibrated.

i forgot to mention that i was going to use putty to send the signals of the wasdqevbnm values
im sorry about that I kept searching on the dagu servo controller thanks