Google Chat: zj734465502@gmail.com
+86-0755-88291180
sales01@spotpear.com
dragon_manager@163.com
services01@spotpear.com
manager01@spotpear.com
WhatsApp:13246739196
As a kind of high-torque programmable serial bus servo, it can control the angle within 180° and can switch to the motor/stepper motor mode that can be rotated continuously through the program. There are two interfaces on each servo, which can be used in series. In theory, 253 bus servos can be controlled at the same time, and each servo can obtain information such as the current angle, load, voltage, mode, and so on. It is suitable for robot projects that require feedback on the angle and load of the steering gear, such as robotic arms, hexapod robots, humanoid robots, wheeled robots, etc.
You can download the relevant open-source robot models in the product documentation for building your own projects.
How to use Arduino IDE:
Each program that controls the steering gear needs to initialize the steering gear before it can be used.
#include <SCServo.h>
SCSCL sc;
void setup(){
Serial1.begin(1000000); //Initialize the serial port, if you use ESP32 and other devices, you can also custom the serial ports
// Serial1.begin(1000000, SERIAL_8N1, RX, TX); // custom serial port
sc.pSerial = &Serial1;
while(!Serial1) {}
}
In the servos connected in series, each ID can only correspond to one servo, or the information fed back by the servos cannot be obtained normally. When changing the servo ID, try to ensure that the driver board is only connected to one servo, and the ID will be permanently saved in the servos:
#include <SCServo.h>
SCSCL sc;
int ID_ChangeFrom = 1; // The original ID of the servo to change the 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); //EPROM-SAFE lock
}
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);
}
}
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 of 1 to rotate to 1000 at a speed of 1500.
delay(754);//[(P1-P0)/V]*1000+100
sc.WritePos(1, 20, 0, 1500); // Control the servo with ID of 1 to rotate to 20 at a speed of 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();
}