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 high-torque programmable serial bus servo, it is equipped with a 360° high-precision magnetic encoder, which can realize 360-degree absolute angle control. With the program to control, any angles can be set as the middle of the position, and it can also be switched to the continuously rotating motor or stepper motor mode. The built-in acceleration start-stop function makes the action softer. 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 its current angle, load, voltage, mode, and so on. It is suitable for robot projects, such as robotic arms, hexapod walkers, humanoid robots, wheeled robots and so on, which require real-time feedback for closed-loop control.
At the same time, we provide an open-source 12-DOF robot dog model for this servo. You can download the model and project files of the open-source structure in #Resource.
Generally, we control the ST series servos by compiling and uploading the demo through the Arduino IDE. However, compiling through Arduino requires installing various dependency libraries before use. Therefore, we provide an ESP32 download tool. With this tool, users can download the demo to the driver board without needing to download other dependency libraries or the Arduino IDE software.
https://dl.espressif.com/dl/package_esp32_index.json
Note: If you need to add more than one development board URL, it is not necessary to delete the URL of the ESP32 development board support, you can directly add the other URL to another line, the default display is comma separated URL. For example, if you need to add the URL of the ESP8266 development board, add it directly to another line, it will be displayed as follows:
https://dl.espressif.com/dl/package_esp32_index.json,http://arduino.esp8266.com/stable/package_esp8266com_index.json
C:\Users\username\AppData\Local\Arduino15
The "username" here would vary according to your computer's username, copy the unzipped packages file to the Arduino15 folder.
1. Double-click on ServoDriverST.ino:
2. Click on "Tools" -> "Port", please remember the COM port on your PC, and do not click on this COM port (COM1 is the port on my PC, different computers show different COMs).
3. Connect the serial bus servo with the PC with a USB cable, click on "Tools" -> "Port", and then click on the new COM port (here is COM10):
4. In Arduino IDE, click on "Tools" -> "Board:'ESP32 Dev Module" -> "esp32" -> "ESP32 Dev Module".
5. Click on "Tools", and the other settings as shown below: (it is recommended to set "Huge APP" for "Partition Scheme", and "PSARM" must be enabled).
6. After setting, click to upload, and the demo will be uploaded to the device.
After uploading, "Leaving... Hard resetting via RTS pin..." indicates the successful uploading.
Each program for controlling the servo needs to initialize servo before it can be used.
#include <SCServo.h>
SMS_STS st;
void setup(){
Serial1.begin(1000000); //Initialize the serial port, if you use ESP32 and other devices, you can also choose a custom serial port
// Serial1.begin(1000000, SERIAL_8N1, RX, TX); // custom serial port
st.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>
SMS_STS st;
int ID_ChangeFrom = 1; // Change the original servo ID, and the factory default is 1
int ID_Changeto = 2; // new ID
void setup(){
Serial1.begin(1000000);
st.pSerial = &Serial1;
while(!Serial1) {}
st.unLockEprom(ID_ChangeFrom); //Unlock EPROM-SAFE
st.writeByte(ID_ChangeFrom, SMS_STS_ID, ID_Changeto);//Change ID
st.LockEprom(ID_Changeto); // EPROM-SAFE is locked
}
void loop(){
}
Used to test whether a servo is connected normally.
#include <SCServo.h>
SMS_STS st;
int TEST_ID = 3; // Servo ID to test
void setup()
{
Serial.begin(115200);
Serial1.begin(1000000, SERIAL_8N1, RX, TX); // custom serial port
st.pSerial = &Serial1;
while(!Serial1) {}
}
void loop()
{
int ID = st.Ping(TEST_ID); //Ping the servo with the given ID, and return -1 if it fails
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>
SMS_STS st;
void setup()
{
Serial1.begin(1000000);
st.pSerial = &Serial1;
while(!Serial1) {}
}
void loop()
{
st.WritePos(1, 1000, 1500, 50); // Control the servo with ID 1 to rotate to the position of 1000 at a speed of 1500 and start and stop the acceleration of 50.
delay(754);//[(P1-P0)/V]*1000+100
st.WritePos(1, 20, 1500, 50); // Control the servo with ID 1 to rotate to the position 20 at a speed of 1500 and start and stop the acceleration at 50.
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>
SMS_STS st;
// the uart used to control servos.
// GPIO 18 - S_RXD, GPIO 19 - S_TXD, as default.
#define S_RXD 18 //Custom IO pins of the serial port. If a custom serial port is not used, replace Serial1.begin(1000000, SERIAL_8N1, S_RXD, S_TXD); with Serial1.begin(1000000);
#define S_TXD 19
byte ID[2];
s16 Position[2];
u16 Speed[2];
byte ACC[2];
void setup()
{
Serial1.begin(1000000, SERIAL_8N1, S_RXD, S_TXD);
st.pSerial = &Serial1;
delay(1000);
ID[0] = 1; // Save the IDs of the servos that need to be controlled into the ID[]
ID[1] = 2; // Save the IDs of the servos that need to be controlled into the ID[]
Speed[0] = 3400; // Set the servo speed, Speed[0] should correspond to the servo with ID[0]
Speed[1] = 3400; // Set the servo speed, Speed[1] should correspond to the servo with ID[1]
ACC[0] = 50; // Set the start/stop acceleration. The smaller the value, the lower the acceleration. The maximum value that can be set is 150.
ACC[1] = 50;
}
void loop()
{
Position[0] = 3000; // Set the target position for the servo with ID[0] (which has an ID of 1) to a range of 0-4095
Position[1] = 3000; // Set the target position for the servo with ID[0] (which has an ID of 1) to a range of 0-4095
st.SyncWritePosEx(ID, 2, Position, Speed, ACC);//servo(ID1/ID2) speed=3400,acc=50,move to position=3000.
delay(2000);
Position[0] = 100;
Position[1] = 100;
st.SyncWritePosEx(ID, 2, Position, Speed, ACC);//servo(ID1/ID2) speed=3400,acc=50,move to position=100.
delay(2000);
}
#define S_RXD 18
#define S_TXD 19
#include <SCServo.h>
SMS_STS sms_sts;
void setup()
{
Serial1.begin(1000000, SERIAL_8N1, S_RXD, S_TXD);
Serial.begin(115200);
sms_sts.pSerial = &Serial1;
delay(1000);
}
void loop()
{
int Pos;
int Speed;
int Load;
int Voltage;
int Temper;
int Move;
int Current;
if(sms_sts.FeedBack(1)!=-1){
Pos = sms_sts.ReadPos(-1);
Speed = sms_sts.ReadSpeed(-1);
Load = sms_sts.ReadLoad(-1);
Voltage = sms_sts.ReadVoltage(-1);
Temper = sms_sts.ReadTemper(-1);
Move = sms_sts.ReadMove(-1);
Current = sms_sts.ReadCurrent(-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);
Serial.print("Current:");
Serial.println(Current);
delay(10);
}else{
Serial.println("FeedBack err");
delay(500);
}
Pos = sms_sts.ReadPos(1); // Get the position feedback
if(Pos!=-1){
Serial.print("Servo position:");
Serial.println(Pos, DEC);
delay(10);
}else{
Serial.println("read position err");
delay(500);
}
Voltage = sms_sts.ReadVoltage(1); //Get the voltage feedback
if(Voltage!=-1){
Serial.print("Servo Voltage:");
Serial.println(Voltage, DEC);
delay(10);
}else{
Serial.println("read Voltage err");
delay(500);
}
Temper = sms_sts.ReadTemper(1); //Get the temperature feedback
if(Temper!=-1){
Serial.print("Servo temperature:");
Serial.println(Temper, DEC);
delay(10);
}else{
Serial.println("read temperature err");
delay(500);
}
Speed = sms_sts.ReadSpeed(1); //Get the speed feedback
if(Speed!=-1){
Serial.print("Servo Speed:");
Serial.println(Speed, DEC);
delay(10);
}else{
Serial.println("read Speed err");
delay(500);
}
Load = sms_sts.ReadLoad(1); //Get the load feedback
if(Load!=-1){
Serial.print("Servo Load:");
Serial.println(Load, DEC);
delay(10);
}else{
Serial.println("read Load err");
delay(500);
}
Current = sms_sts.ReadCurrent(1); //Get the current feedback
if(Current!=-1){
Serial.print("Servo Current:");
Serial.println(Current, DEC);
delay(10);
}else{
Serial.println("read Current err");
delay(500);
}
Move = sms_sts.ReadMove(1); //Get the movement feedback
if(Move!=-1){
Serial.print("Servo Move:");
Serial.println(Move, DEC);
delay(10);
}else{
Serial.println("read Move err");
delay(500);
}
Serial.println();
}
Monday-Friday (9:30-6:30) Saturday (9:30-5:30)
Email: services01@spotpear.com