Servos Won't Respond after initial commands

Hi,
I have a weird issue and have been stuck on it for two days now.
I can use lynxterm with no problem communicating to the ssc-32 controller but running the commands from my program it won’t respond after a couple of commands.

I am just trying to move arm sideways from position 1500 to 2000 and back to 1500 in an infinite loop. There is a time gap of about 11 seconds between the 2 commands ( 1500 ->(1 sec) 2000 ->(11 sec) 1500 )

Default position: #00P1500#01P1500#02P1500#16P1500#17P1500
Second Command: #00P2250T10000

Here is the troubleshooting I have done so far.
I have used hyper terminal to look at the output from the com1 and its coming perfect( Above commands from hyper terminal) .
Checked the Voltage on SSC32 = 5.21
Used Lynxterm to communicate by typing commands from hyper terminal and ssc-32 responds and servo moves.
Changed Baud rate from 9600 ( had the same problem ) to 2400
I can see Green light blinking on the ssc-32 but the servos won’t respond and after a while port 0 servo just goes to 500. :frowning:
TIA

Perhaps you can post info and the code that does not work.

Some of the comments are not right(as I still developing it ), but I am using code warrior along with c.

[code]#include <hidef.h> /* for EnableInterrupts macro /
#include “derivative.h” /
include peripheral declarations */

// DEFINE General
#define ON 0 // LED ON
#define OFF 1 // LED OFF
#define UP 1 // Switch off
#define DOWN 0 // Switch on

// DEFINE LED’s
#define LED1 PTFD_PTFD0 // LED1
#define LED1_DDR PTFDD_PTFDD0 // DATA DIRECTION FOR LED1

// vars
int i = 0; // this is for the for loop
int j = 0;

int xposition;
int leastxposition = 1100;
int maxxposition = 2000;

char temp[4];
/*
char PinNumber[3];
char Position[5];
char Time[6];
*/
byte EndCommand = 0x0d; // Carriage Return

// wait loop that lets you wait between the commands
void waitloop(int seconds){
// 25 = 1 second
for ( j = 0; j < seconds; j++ ) {

    // 29000 = 40 ms   
    for (i = 0; i < 29000; i++ ) {
       __RESET_WATCHDOG();
    }
      
}

}

void SetRobotNumber(char *PinNumber, char *Position ) {
__RESET_WATCHDOG();

   while(SCI2S1_TDRE == 0);
   SCI2D = '#';
   
   while(SCI2S1_TDRE == 0);
   SCI2D = *PinNumber;

   while(SCI2S1_TDRE == 0);
   SCI2D = *(PinNumber+1); 
    
   while(SCI2S1_TDRE == 0);
   SCI2D = 'P';
   
   while(SCI2S1_TDRE == 0);
   SCI2D = *Position;
   
   while(SCI2S1_TDRE == 0);
   SCI2D = *(Position+1);
   
   while(SCI2S1_TDRE == 0);
   SCI2D = *(Position+2);
   
   while(SCI2S1_TDRE == 0);
   SCI2D = *(Position+3); 

}

// #0P1600T1000 1000 = 1 second

void MoveX(char* Time) {

   __RESET_WATCHDOG();
    
   while(SCI2S1_TDRE == 0);
   SCI2D = 'T';                
   
   while(SCI2S1_TDRE == 0);
   SCI2D = *(Time);
   
   while(SCI2S1_TDRE == 0);
   SCI2D = *(Time+1);
   
   while(SCI2S1_TDRE == 0);
   SCI2D = *(Time+2);
   
   while(SCI2S1_TDRE == 0);
   SCI2D = *(Time+3);
   
   while(SCI2S1_TDRE == 0);
   SCI2D = *(Time+4);

}

int SetArmDefault(){

  SetRobotNumber("00","1500");
  SetRobotNumber("01","1500");
  SetRobotNumber("02","1500");
  SetRobotNumber("16","1890");
  SetRobotNumber("17","2100");
  SetRobotNumber("18","1500");
  SetRobotNumber("19","1500");

  
  while(SCI2S1_TDRE == 0);
  SCI2D = EndCommand;
 
  return 1500;

}

int MoveArmx(){

  SetRobotNumber("00","2250");
  MoveX ("1000");            // move x in 10 seconds
  
    
  while(SCI2S1_TDRE == 0);
  SCI2D = EndCommand; 

  return 2250;

}

void main(void) { // main

EnableInterrupts; // enable interrupts

LED1_DDR = 1; // sets up led1 as the output

// DEFINE SCI2
// BAUD RATE MODULO

SCI2BDH = 0; // SCIBDH DOESN’T CHANGE UNTILL SCIBDL IS WRITTEN
SCI2BDL = 28; // 4 MHZ /(16 * 26) = 9600 baud rate 00001101 BAUDRATE = BUSRATE / (SCI2BDL X 16 ) 29 = 9600 116 =2400
SCI2C2_TE = 1; // TRANSMITTER IS ENABLED

for(;:wink: {

        __RESET_WATCHDOG();
                    
        xposition = SetArmDefault(); 
        waitloop(25);               // waits for one second            
       
        xposition = MoveArmx();
        
        waitloop(100);              // waits for 4 seconds
       
      } 
                                                                     // Loop forever

}[/code]

Just for someone else having this problem.
I think I found the problem, after extensive study I figured out my baud rate was off by more than 1.5%. I had to change my number from 29 to 30 and that solved the problem. I am sure I will be back with more questions :slight_smile: