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:
#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
#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.
SCServo.zip (10.1 KB)