Go Down

Topic: Serial problem with Arduino Due with Feetech SCS09 smart servos (Read 235 times) previous topic - next topic

Hamulus

I bought Feetech SCS09 smart servos (also known as SCS009 or SCS0009).
The servos communicate with board using Serial connection via device named TTLinked that converts UART to half duplex protocol.
The seller provided me Arduino library to work with the servos.

The simplest testing sketch looks as this:
Quote
#include <SCServo.h>

SCServo SERVO;

void setup() {
   Serial2.begin(1000000);
   SERVO.pSerial = &Serial2;
   delay(500);
   SERVO.EnableTorque(1, 1);
   SERVO.EnableTorque(2, 1);

}

void loop() {
   

   SERVO.WritePos(1, 1023, 4000); // Servo ID:1, rotate to the position:0x2FF

   SERVO.WritePos(2, 1023, 1000); // Servo ID:2, rotate to the position:0x2FF

   delay(4000);
   

   SERVO.WritePos(1, 20, 3000); // Servo ID:1, rotate to the position:0x000

   SERVO.WritePos(2, 20, 1000); // Servo ID:1, rotate to the position:0x000

   delay(3000);
   

   SERVO.WritePos(1, 1023, 2000); // Servo ID:1, rotate to the position:0x2FF

   SERVO.WritePos(2, 1023, 500); // Servo ID:2, rotate to the position:0x2FF
   delay(2000);
   

   SERVO.WritePos(1, 20, 1000); // Servo ID:1, rotate to the position:0x000

   SERVO.WritePos(2, 20, 300); // Servo ID:2, rotate to the position:0x000

   delay(1000);

}

The code works perfectly on Arduino Mega and allows to independently control servos.

But with Due I have problems: not all commands can be performed. So if compile the code for due only servo ID1 works, but ID2 do not work at all.

When I add delays between commands the servos started to work
Quote
#include <SCServo.h>

SCServo SERVO;

void setup() {
   Serial2.begin(1000000);
   SERVO.pSerial = &Serial2;
   delay(500);
   SERVO.EnableTorque(1, 1);
   SERVO.EnableTorque(2, 1);

}

void loop() {
   

   SERVO.WritePos(1, 1023, 4000); // Servo ID:1, rotate to the position:0x2FF
        delay(10);

   SERVO.WritePos(2, 1023, 1000); // Servo ID:2, rotate to the position:0x2FF

   delay(4000);
   

   SERVO.WritePos(1, 20, 3000); // Servo ID:1, rotate to the position:0x000
        delay(10);

   SERVO.WritePos(2, 20, 1000); // Servo ID:1, rotate to the position:0x000

   delay(3000);
   

   SERVO.WritePos(1, 1023, 2000); // Servo ID:1, rotate to the position:0x2FF
        delay(10);

   SERVO.WritePos(2, 1023, 500); // Servo ID:2, rotate to the position:0x2FF
   delay(2000);
   

   SERVO.WritePos(1, 20, 1000); // Servo ID:1, rotate to the position:0x000
        delay(10);

   SERVO.WritePos(2, 20, 300); // Servo ID:2, rotate to the position:0x000

   delay(1000);

}

When I set delays between 1 and 9 the both servos can work but sometimes skip commands. Servos can skip 1-4 actions and then start to work again. The less delay I set the more random skips I get.

So I think here is some specialities regarding Serial connection on Arduino Due. What It can be? Why delays help to make it working?

By the way I read that Arduino Due can have problems with 1000000 baud rate and I tried different, even significntly less baud rates (for example 115200) with Arduino Due: the result is the same.
Also I use level converter for RX2/TX2 pins for Due because it has 3.3v pins but TTLinker device has 5v RX/TX. Maybe the level converter sucks?:) Or maybe I can use 5v serial connection without level conversion? Will it burn my Arduino Due or not?

I attach the library so that someone could figure out the cause of the problem.





ard_newbie


Hamulus

this code is not applicable to my servos, they are smart servos controlled using Serial commands, not by PWM like standard servos, so standard Servo library is not my case

ltheoret

Hi,

I'm no genius but the MEGA is 8-bit running at 16MHz and the DUE is 32-bit running at 84MHz. It makes perfect sense that the delays would make things run better. The serial communications would be the right speed but the timing between would be out by a huge factor, that is why your delays helps, play with the delays till you find something that runs, sounds like you could use more delay.

Luc

Go Up