Google Chat: zj734465502@gmail.com
+86-0755-88291180
sales01@spotpear.com
dragon_manager@163.com
services01@spotpear.com
manager01@spotpear.com
WhatsApp:13246739196
SC09 Servo is a mini and compact dual-shaft serial bus servo, which can control within a range of 300° and can be programmed to switch to continuous rotation motor/stepper motor mode. There is an interface on the servo, which can be used in series to control 253 bus servos at the same time and each servo can get its current angle, load, voltage, mode, and other information. It is suitable for the robotic arm, hexapod robot, a humanoid robot, wheeled robot, and other robotic projects that require feedback on servo angle and load.
Serial bus servo drive circuit schematic.
Arduino IDE usage guide:
You can refer to the demo in \examples\arduinoIDE\SCSCL to learn how to control the servo and get feedback information from the servo. The functions described below are provided in the Serial bus servo driver board with GUI demos that are newbie friendly.
Each program for controlling the servo needs to initialize the servo before it can be used.
#include <SCServo.h>
SCSCL sc;
void setup(){
Serial1.begin(1000000); //initialize the serial port, you can also choose to customize the serial port if you use a device such as ESP32
// Serial1.begin(1000000, SERIAL_8N1, RX, TX); // Customized serial port
sc.pSerial = &Serial1;
while(!Serial1) {}
}
In the servos connected in series, each ID corresponds to only one servo, otherwise, the information fed back by the servos cannot be obtained normally. When changing the servo ID, please try to ensure that the driver board is connected to only one servo, and the ID will be permanently saved in the servo.
#include <SCServo.h>
SCSCL sc;
int ID_ChangeFrom = 1; //The original ID of the servo to change ID, the factory default is 1.
int ID_Changeto = 2; // New ID
void setup(){
Serial1.begin(1000000);
sc.pSerial = &Serial1;
while(!Serial1) {}
sc.unLockEprom(ID_ChangeFrom); //Unlock EPROM-SAFE
sc.writeByte(ID_ChangeFrom, SCSCL_ID, ID_Changeto);//Change ID
sc.LockEprom(ID_Changeto); // Lock EPROM-SAFE
}
void loop(){
}
Used to test whether a servo is connected normally.
#include <SCServo.h>
SCSCL sc;
int TEST_ID = 3; //Servo ID to test
void setup()
{
Serial.begin(115200);
Serial1.begin(1000000, SERIAL_8N1, RX, TX); // custom serial port
sc.pSerial = &Serial1;
while(!Serial1) {}
}
void loop()
{
int ID = sc.Ping(TEST_ID);
if(ID!=-1){
Serial.print("Servo ID:");
Serial.println(ID, DEC);
delay(100);
}else{
Serial.println("Ping servo ID error!");
delay(2000);
}
}
sc.pSerial = &Serial1;
while(!Serial1) {}
}
Can be used to control the rotation of individual servos.
#include <SCServo.h>
SCSCL sc;
void setup()
{
Serial1.begin(1000000);
sc.pSerial = &Serial1;
while(!Serial1) {}
}
void loop()
{
sc.WritePos(1, 1000, 0, 1500); //Control the servo with ID 1 to rotate at 1500 to the position of 1000.
delay(754);//[(P1-P0)/V]*1000+100
sc.WritePos(1, 20, 0, 1500); //Control the servo with ID 1 to rotate to position 20 at 1500.
delay(754);//[(P1-P0)/V]*1000+100
}
Can be used to control multiple servos at the same time (turn to different positions and different speeds).
#include <SCServo.h>
SCSCL sc;
byte ID[2];
u16 Position[2];
u16 Speed[2];
void setup()
{
Serial1.begin(1000000);
sc.pSerial = &Serial1;
delay(1000);
ID[0] = 1;
ID[1] = 2;
}
void loop()
{
Position[0] = 1000;
Position[1] = 1000;
Speed[0] = 1500;
Speed[1] = 1500;
sc.SyncWritePos(ID, 2, Position, 0, Speed);//Servo((ID1/ID2)) moves at max speed=1500, moves to position=1000.
delay(754);//[(P1-P0)/V]*1000+100
Position[0] = 20;
Position[1] = 20;
Speed[0] = 1500;
Speed[1] = 1500;
sc.SyncWritePos(ID, 2, Position, 0, Speed);//Servo((ID1/ID2)) moves at max speed=1500, moves to position=20.
delay(754);//[(P1-P0)/V]*1000+100
}
#include <SCServo.h>
SCSCL sc;
int ID_input = 1;
void setup()
{
Serial1.begin(1000000, SERIAL_8N1, S_RXD, S_TXD);
Serial.begin(115200);
sc.pSerial = &Serial1;
delay(1000);
}
void loop()
{
int Pos;
int Speed;
int Load;
int Voltage;
int Temper;
int Move;
if(sc.FeedBack(ID_input)!=-1){
Pos = sc.ReadPos(-1);
Speed = sc.ReadSpeed(-1);
Load = sc.ReadLoad(-1);
Voltage = sc.ReadVoltage(-1);
Temper = sc.ReadTemper(-1);
Move = sc.ReadMove(-1);
Serial.print("Position:");
Serial.println(Pos);
Serial.print("Speed:");
Serial.println(Speed);
Serial.print("Load:");
Serial.println(Load);
Serial.print("Voltage:");
Serial.println(Voltage);
Serial.print("Temper:");
Serial.println(Temper);
Serial.print("Move:");
Serial.println(Move);
delay(10);
}else{
Serial.println("FeedBack err");
delay(500);
}
Pos = sc.ReadPos(1);
if(Pos!=-1){
Serial.print("Servo position:");
Serial.println(Pos, DEC);
delay(10);
}else{
Serial.println("read position err");
delay(500);
}
Voltage = sc.ReadVoltage(1);
if(Voltage!=-1){
Serial.print("Servo Voltage:");
Serial.println(Voltage, DEC);
delay(10);
}else{
Serial.println("read Voltage err");
delay(500);
}
Temper = sc.ReadTemper(1);
if(Temper!=-1){
Serial.print("Servo temperature:");
Serial.println(Temper, DEC);
delay(10);
}else{
Serial.println("read temperature err");
delay(500);
}
Speed = sc.ReadSpeed(1);
if(Speed!=-1){
Serial.print("Servo Speed:");
Serial.println(Speed, DEC);
delay(10);
}else{
Serial.println("read Speed err");
delay(500);
}
Load = sc.ReadLoad(1);
if(Load!=-1){
Serial.print("Servo Load:");
Serial.println(Load, DEC);
delay(10);
}else{
Serial.println("read Load err");
delay(500);
}
Move = sc.ReadMove(1);
if(Move!=-1){
Serial.print("Servo Move:");
Serial.println(Move, DEC);
delay(10);
}else{
Serial.println("read Move err");
delay(500);
}
Serial.println();
}