Arduino and Micro Serial 8 Servo Controller

Hi everyone, I’ve been struggling with this for a while now. I have a nicro servo controller connected to an arduino. I’ve been trying to get the servo to move between two predifned positions. I.e. move to position 1, move to position 2 then go back to 1, etc. I have looked at some sample code but am still unable to get it working. Any help would be greatly appreciated.

Hello,

When you say that it is not working, do you mean that the servo is not responding at all, or is it behaving in some other unexpected way?

If you post your Arduino program here (use the [code] tags to format it nicely), we might be able to help you get it working. If it is very long, please try to trim it down to a minimal example first (e.g. a single serial command that should move a servo), and describe what you expect to happen and what actually happens.

Could you also share a picture or diagram of your setup, or at least describe the connections you have made (both logic and power), so that we can make sure there isn’t a problem in your wiring?

- Kevin

Hi Kevin, thank you very much for your reply. The servos are moving, the problem is that the resulting behaviour is unexpected. I suspect it may have something to do with the loop() function and the associated delays. I am using SoftSerial and here is the relevant code:

void loop()
{
put(4,500);
delay(1000);
put(4, 5500);
delay(1000);
}
void put(int servo, int angle)
{//servo is the servo number (typically 0-7)
//angle is the absoltue position from 500 to 5500

   unsigned char buff[6];

   unsigned int temp;
   unsigned char pos_hi,pos_low;
   
   temp=angle&0x1f80;
   pos_hi=temp>>7;
   pos_low=angle & 0x7f;

   buff[0]=0x80;//start byte
   buff[1]=0x01;//device id
   buff[2]=0x04;//command number
   buff[3]=servo;//servo number
   buff[4]=pos_hi;//data1
   buff[5]=pos_low;//data2

   for(int i=0;i<6;i++){
      softSerial.print(buff[i],BYTE);
   }
}

Thanks for your help :smiley:

The code that you posted tells the servo controller to generate the minimum and maximum pulse widths that it can output, which are 0.25 ms and 2.75 ms, and these are beyond the range of what most servos can achieve. (The standard pulse width range is 1 ms to 2 ms, although many servos can go somewhat beyond that range.)

Do your servos behave better if you change 500 and 5500 (0.25 ms and 2.75 ms) to 2000 and 4000 (1 ms and 2 ms)? If they do, you can try gradually increasing the range from there until you reach the physical limits of the servos’ range. There is a risk of damaging a servo by commanding it to go past its physical limit, so be careful and try not to leave it straining for any significant length of time.

- Kevin