Let's Make Robots!

How to contol servo speed from serial

Hello all

I have  renbotics ServoShield and I have made a code on arduino where from serialport I can send commads to servos and it happens with that way... S01P1200,S14P2300etc..I mean that  Servo 1 to 1200 posion and servo 14 to 2300 posion

NowI have one problem.How can I control the servo's  speed from serial port? For example S01P1200F.... 1 SERVO, 1200 POSION, F = SPEED...Is  there any code for controlling  servos speed so that I  can take it and include it into my code? As I know  servoshield 1.5 library I use , can't support any speed control.

My code that moves servo is this , but how can I contol the speed?o you have any clue?



case 's':  
     char servoid[extractedCommand.substring(1,3).length() + 1];
     char servopos[extractedCommand.substring(4,8).length() + 1];
     extractedCommand.substring(1,3).toCharArray(servoid, sizeof(servoid));
     extractedCommand.substring(4,8).toCharArray(servopos, sizeof(servopos));
     // Convert extracted strings to integers
     int sid = atoi(servoid);
     int spos = atoi(servopos);
     //Print some debug info
     char debugMsg[256];
     sprintf(debugMsg,"command string: %s   Servo Id: %d   Servo Position: %d", command, sid, spos);
     // Move the
     shieldServos.setposition(sid , spos);


Comment viewing options

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

Move the servos in little steps, the delay between them will determine the servo speed. I think that's the only way to control the speed with this shield.