Go Down

Topic: communication breakdown between my arduino & servo (Read 1 time) previous topic - next topic

gr33nhorn

Hi guys, i am currently working on a project that use arduino to control 12servos. I am using the pin 0 and 1(Communication: Multi drop Full Duplex UART serial communication) to send packets of commands to all servos which are connected in daisy chain manner. Initially, everything seems to work fine as all the servos respond according to the commands transmitted from arduino. But after a few weeks later, those packets commands seem to only able to transmit to a few servos and the rest of the servo didnt receive any commands. Can someone tell me what is going on or tell me what can i do? :'(

thanks in advance

AlphaBeta

I, for one, would need to see some code before I can be of any assistance.

http://www.arduino.pastebin.com

:)

gr33nhorn

HI..do you want me to post it down here or on the url?

AlphaBeta

Quote
HI..do you want me to post it down here or on the url?


If it is long (>50 lines) use pastebin. It will make it simpler for me to edit, if there are anything that needs editing. :)

Do as you please.  :)

gr33nhorn

here is my code
Code: [Select]
#include <math.h>
#define Header 0xff  


byte *PosPtr;
byte ZeroPosArray[12]={/* ID 0 ,  1 ,  2 ,  3 ,  4 ,  5 ,  6 ,  7 ,  8 ,   9,  10 ,  11 */
                          132 , 122, 187, 164,  60, 121, 123, 127, 63 , 86 ,  195, 127      //initial positions
                   };                                                                      
                   
byte WalkPosArray[11][12]={/* ID 0 ,  1 ,  2 ,  3 ,  4 ,  5 ,  6 ,  7 ,  8 ,   9,  10 ,  11 */
                             {132 , 116, 188, 161, 58 , 119, 123, 121, 62,  89, 197 , 121},//ViaPoint_0
                             {132 , 115, 166, 190, 64 , 118, 123, 121, 62,  89, 197 , 109},//ViaPoint_1
                             {132 , 116, 182, 154, 45 , 119, 123, 121, 53,  92, 191 , 121},//ViaPoint_2
                             {132 , 122, 180, 157, 46 , 125, 123, 127, 55,  89, 190 , 127},//ViaPoint_3
                             {132 , 129, 183, 158, 50 , 132, 123, 134, 48,  96, 190 , 134},//ViaPoint_4
                             {132 , 129, 188, 161, 58 , 132, 123, 134, 41, 103, 190 , 134},//ViaPoint_5
                             {132 , 129, 180, 161, 58 , 142, 123, 135, 84,  60, 191 , 135},//ViaPoint_6
                             {132 , 129, 197, 158, 64 , 132, 123, 134, 68,  96, 210 , 134},//ViaPoint_7
                             {132 , 122, 195, 161, 65 , 125, 123, 127, 70,  93, 209 , 125},//ViaPoint_8
                             {132 , 116, 202, 154, 65 , 119, 123, 121, 58,  90, 194 , 118},//ViaPoint_9
                            /* {132 , 116, 209, 147, 65 , 114, 123, 121, 68,  96, 210 , 116},//ViaPoint_10 */
                             {132 , 115, 166, 190, 64 , 118, 123, 121, 62,  89, 197 , 109},//ViaPoint_10
                        };
                       
void setup()
 {
   byte i,b;
   Serial.begin(115200);
   byte LastID, Torque;
   LastID=11;
   Torque=0; //0(max)~4(min)
   stop_Post(LastID,Torque);
   b=availableMemory();
   Serial.println(b,DEC);
   delay(1500);
  for(i=0;i<1;i++)
  {
     motionA(LastID,Torque);
  }
   stop_Post(LastID,Torque);
 }
 
void loop()
{
 
 
}

Code: [Select]
void SyncPosSend(byte LastID, byte Torque ,byte *PosPtr)
{
 byte i, Checksum;
 i=0;
 Checksum=0;
 Serial.print(Header,BYTE);
 Serial.print((Torque<<5)|0x1f,BYTE);
 Serial.print(LastID+1,BYTE);
   for(i=0; i<=LastID; i++)
     {
       Serial.print(*(PosPtr+i),BYTE);
       Checksum ^=*(PosPtr+i);
     }
     
 Checksum &=0x7f;
 Serial.print(Checksum,BYTE);
 
}

Code: [Select]
void motionA(byte LastID, byte Torque)
{
   byte ViaPoint;
   ViaPoint=0;
   for (ViaPoint = 0; ViaPoint <= 10; ViaPoint++)      
         {
                PosPtr=&WalkPosArray[ViaPoint][0];
                SyncPosSend(LastID,Torque,PosPtr);
                //Serial.println();
                delay(650);
           }
}

Code: [Select]
void stop_Post(byte LastID, byte Torque)
{
   PosPtr=ZeroPosArray;
   SyncPosSend(LastID,Torque,PosPtr);//initialise
}



i really need helps!!!!!!!!!

mem

you only seem to be calling the following functions once, is that what you intend?
   
motionA(LastID,Torque);
stop_Post(LastID,Torque);

gr33nhorn

yes and no, i'm just testing the respond of the servoes to the packets of commands, but some servoes seem to be unable to hold the torque upon received the codes.

mem

Its always difficult to help debug these things from a distance but it will be easier if you clarify what exactly is the problem.

In your first post you said:
>commands seem to only able to transmit to a few servos and the rest of the servo didnt receive any commands.

Your most recent post says:
>some servos seem to be unable to hold the torque upon received the codes.

Those are quite different symptoms. Perhaps try a very simple sketch that just sends commands to position the servos and see if that works as exected. If so, you can look at the code in your application, if not then it my be a problem with the servos or power source.

Good luck  

Go Up