ST3215-HS Servo Motor

From Waveshare Wiki
Jump to: navigation, search
ST3215-HS Servo Motor
ST3215-HS Servo Motor.jpg

TTL Serial Bus Servo Interface
{{{name2}}}

{{{name3}}}

{{{name4}}}

{{{name5}}}

{{{name6}}}

Overview

Introduction

This product is a high-torque programmable serial bus servo motor with a 360° high-precision magnetic encoder, enabling angle control within a 360° range, with a maximum speed of up to 106 RPM. It can be controlled programmatically to set any angle as the servo motor's middle position. It can also be switched to operate as a continuous rotation motor (speed closed-loop control) or stepper motor mode. The motor has a built-in acceleration and deceleration function, ensuring smoother motion.

Each servo motor has two interfaces, allowing for multiple motors connected in series. Theoretically, it can simultaneously control 253 bus servo motors, and each one can provide information about its current angle, load, voltage, and mode. It is suitable for robotic projects that require closed-loop control, such as robotic arms, hexapod robots, humanoid robots, and wheeled robots.

Additionally, we offer an open-source 12-degree-of-freedom robotic dog model specifically designed for this type of servo motor. You can download the model and engineering files of this open-source structure from the information section at the bottom.

Specification

  • Input Voltage: 6-12.6V
  • Mechanical Limited Angle: No Limit
  • Rotating Angle: 360° (servo mode angle control)/motor mode continuous rotation
  • Baudrate: 1Mbps
  • Gear: high-precision metal gear
  • Idling Speed: 0.094sec/60° (106RPM)@12V
  • Position Sensor Resolution: 360°/4096
  • ID Range: 0-253
  • Feedback: Position, Load, Speed, Input Voltage
  • Load Current: 240mAA
  • Locked-rotor Current: 2.4A
  • Dimension: 45.22mm x 35mm x 24.72mm

Features

  • High speed, with a maximum speed of up to 106 RPM.
  • Support connecting in series, simultaneously controlling up to 253 servo motors (provided that there is sufficient power) and obtaining feedback information from each motor.
  • 360° magnetic encoder, allowing for a wider angle control range.
  • High precision, with an angle control accuracy of 360°/4096.
  • Any angle can be set as the motor's midpoint, facilitating assembly.
  • Acceleration and deceleration function for smoother motion effects.
  • Compact structural design for a more aesthetically pleasing product appearance.
  • Wide voltage input range of 6-12.6V, capable of direct power supply from 2s or 3s lithium batteries.
  • High torque, up to 20kg.cm@12V.
  • Programmable work modes: Servo mode for angle control / Motor mode for continuous rotation.

Hardware Usage

Software Usage

ESP32 Flash Download Tool

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.

  • Click here to download ESP32 Flash Download Tool. Once downloaded, extract the files and double-click on the "flash_download_tool_3.9.5.exe" program. After opening, two windows will appear. The UI interface of the download tool is the one you need to operate, while the other window serves as a terminal to display the working status of the download tool.
  • In the "DOWNLOAD TOOL MODE" interface, select Chip Type as ESP32 and WorkMode as Factory. When using Factory to call the binary file, it will use a relative path, eliminating the need for users to manually input the binary file path. After making these selections, click OK.

ST3020 SERVO esp.png

  • In this software interface, keep the "LockSettings" option checked. On the right side, you can simultaneously upload demos to 8 driver boards. Next, connect the servo driver board to the computer using a USB cable. Click on "COM" and select the newly appeared COM port (in my case, it's COM3). BAUD is used to set the download speed, higher values result in faster speeds, with the ESP32 supporting speeds up to 921600.

ST3020 SERVO esp2.png

  • After selecting, click START to begin uploading the demo. Once the upload is complete, "IDLE" will change to "FINISH". After completing this process, you can disconnect the USB connection between the servo driver board and the computer. Then, connect the servos to the servo driver board, provide power to the driver board, and start controlling the ST series servos.

ST3020 SERVO esp4.pngST3020 SERVO esp3.png

Compile Arduino IDE

Install Arduino IDE

  • You can directly click this link to download the Arduino IDE from Arduino.cc.
  1. Download the latest Arduino IDE 2.1.0 package from Arduino website. The official IDE supports different operating systems, just download it according to your operating system. The one I downloaded here is for Windows. (If you have already installed it, just skip to the second step) The installation process is very simple, just keep clicking next step.
    Arduino IDE 2.1.0.png
    Note: It will prompt you to install the driver during installation, you can click to install.
  1. Open Arduino IDE, click the File on the left corner and choose "Preferences".
    RoArm-M1 Manual01.png
  2. Add the following link in the additional development board manager URL, then click OK.
    https://dl.espressif.com/dl/package_esp32_index.json

    RoArm-M1 Manual02.png
    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
    

    RoArm-M1 Manual03.png
    RoArm-M1 Manual04.png

  3. Download the package, and copy the unzipped packages files to the following path:
    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.
    L76K GPS Module ESP32204.jpg

Download the Program & Install Dependency Libraries

  • Please install the following libraries through Manage Libraries:
    • Adafruit SSD1306
    • Adafruit NeoPixel
  • Click Tools > Manage Libraries to open the library manager.

QQ screenshot 20211130115318.png

  • Enter the libraries that need to be installed through the library manager in the search box, and install:
    • Adafruit SSD1306
    • Adafruit NeoPixel
  • Click "Update", and if there is no "Update", please click "Install" for the newest version.

QQ screenshot 20211130135130.png QQ screenshot 20211130135223.png

  • Download the bus servo library and the Arduino program for the servo driver board:
  • ServoDriverST Open Source Program (Arduino)
  • After downloading, unzip it, and you can get two file folders:
    • "ServoDriverST": control ST series servo demo
    • "SCServo": control servo library
  • Copy the SCServo folder to \Documents\Arduino\libraries after decompression, and install them for controlling the servo.

Upload Demo

1. Double-click on ServoDriverST.ino:
Upload Servo demo01.png
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).
Upload Servo demo02.png
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):
Upload Servo demo03.png
4. In Arduino IDE, click on "Tools" -> "Board:'ESP32 Dev Module" -> "esp32" -> "ESP32 Dev Module".
Upload Servo demo04.png
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).
Upload Servo demo05.png
6. After setting, click to upload, and the demo will be uploaded to the device.
Upload Servo demo06.png
After uploading, "Leaving... Hard resetting via RTS pin..." indicates the successful uploading.

Product Usage Tutorial

  • The following tutorial uses servo driver by default to explain how to use the servo, if you need to use it in your own project, you can refer to the sample program and the bus servo drive circuit schematic for secondary development.
  • The factory default ID of the servo is 1. Among the servos connected to the same servo drive board, the same ID can only correspond to one servo, and there cannot be more than one servo with the same ID in the one control circuit. When you set the ID for the servo, try to ensure that only one servo whose ID is to be changed is connected to the driver board. After the ID is changed, it will be permanently saved in the servo and will not be lost even if the power is off.
  • First of all, you need to set an independent ID for each servo. When setting an ID for one servo, the driver board should not be connected to other servos.
  • If you use the ST3020 servo, after connecting it to the driver board, you need to provide 6-12.6V (12V is recommended) via the DC port (5.5*2.1mm) on the board, and the port will directly power the servo. If you use a large number of servos, you need to provide enough currents for the port.
  • After the driver board is powered on, a WiFi hotspot will be created by default. The default hotspot name is ESP32_DEV, and its password is 12345678. Please connect to this hotspot with your phone.
  • After connecting to the hotspot issued by the servo driver board, it is recommended to use Google Chrome to access the address 192.168.4.1. Noted that the phone will fail to verify the server with ping after connecting the WiFi, so it may automatically switch to the other known WiFi. In this case, you should connect ESP32_DEV again, and the phone will not connect to other WiFi automatically after the reconnection is successful.
  • The driver board will automatically scan the servo ID (0-20) when it is powered on (in order to save the boot time). If your servo ID is more than 20, you must change the MAX_ID value in ServoDriverST.ino and upload it to the driver board again.

ST3215-Servo-details-023.jpg

  • If the servo is connected after the driver board is powered on, you need to click Start Searchingon the mobile browser page to scan again.
  • Active IDis the currently selected servo ID number, ID to Setis the new ID number to be set, adjust the value of ID to Setthrough ID to Set+andID to Set-, and press the Set New ID button to set the servo ID Active ID as ID to Set.
  • When the IDs of all servos are set, you can connect them all. If you do not restart the device, you need to clickStart Searchingto scan all servos.
  • ID: shows all ID numbers of servos currently connected to the servo driver board.
  • Active ID The currently selected servo ID number, and the subsequent operations are all controlling thisActive ID servo.
  • You can select the Active ID servo via the ID to Set+ and ID to Set- buttons.
  • Middlekey, you can turn the servo to the middle position, the position range of the servo is 0-4095, and the middle position is 2047.
  • Stopkey, the default program will not let the servo move all the time. If the servo cannot be stopped after the secondary development, you can press the Stop key to hault the servo movement.
  • Releasekey, press it and the servo will close torque lock (Torque Off), then you can turn the servo by hand.
  • Torquekey, after pressing the servo, the servo will turn on the torque lock (Torque On), at this time, the servo will maintain the specified position with force.
  • Position+key, after pressing the servo, the servo will start to rotate clockwise. When the servo is in the servo mode, it will not continue to rotate after turning to the 4095 position.
  • Position-key, after pressing the servo, the servo will start to rotate counterclockwise. When the servo is in the servo mode, it will not continue to rotate after turning to the 0 position.
  • Speed+ and Speed- are used to set the speed of the servo. The maximum setting for ST series servos is about 3073. The speed is the number of steps per second, 50 steps/sec≈0.732RPM.
  • Set Middle Positionkey, no matter what position the current servo is in, when this key is pressed, the servo will set the current position to the middle position (2047).
  • Set Servo Modekey, set the servo to servo mode, 360° absolute angle control can be performed in the servo mode, the setting will be permanently saved and will not be lost even if the power is turned off.
  • Set Motor Modekey, set the servo to stepper motor mode, the servo can rotate continuously 30,000 steps. If you press it continuously, the motor will keep rotating. This mode can control the relative angle within ±7 circles and the number of circles will not be saved when power is off, but the stepper motor mode settings will be permanently saved even if power is off.
  • Start Serial Forwardingbutton, set the servo driver board to serial forwarding mode, you can directly control the servo and get the feedback of the servo with the type C interface on the board. This function is used to debug the servo.
  • Normalkey, set the servo driver board to normal mode, in this mode, it will not send or receive any information via ESP-NOW.
  • Leaderkey, set the servo driver board as the host, in this mode, the driver board continuously sends the ID, position, and speed of the current Active ID servo to the driver board of the controlled slave through the ESP-NOW protocol. After the servo driver board is turned on, the MAC:on the first line of the screen is the MAC address of this development board, which is unique, such as MAC: 08 3A F2 93 5F A8. The premise of ESP-NOW communication is to get the MAC address of the slave, please write down the address, and fill it in the broadcastAddress[] = {0x08, 0x3A, 0xF2, 0x93, 0x5F, 0xA8} of ServoDriverST.ino, then upload it to the driver of the host and the function is enabled.
  • Followerkey, set the servo drive board as the slave, after changing the MAC address of the slave in the program of the host, it can act under the remote control of the host.
  • RainbowONand RainbowOFFkeys are used to turn on and off the rainbow effect of RGB lights.

Secondary Development Tutorial

  • Servo Initialization

Each demo that controls the servo needs to initialize the servo, and the initialization is done before it can be used.

#include <SCServo.h>
SMS_STS st;
void setup(){
	Serial1.begin(1000000);  //Serial port initialization, and if using devices like ESP32, custom serial ports can also be selected.
	// Serial1.begin(1000000, SERIAL_8N1, RX, TX);  // Custom serial ports
	st.pSerial = &Serial1;
	while(!Serial1) {}
}
  • Change servo ID

Among the servos connected in series, each ID should only correspond to one servo. Otherwise, the servo feedback information cannot be obtained properly.
When changing the servo ID, it is advisable to ensure that the driver board is only connected to one servo. The ID will be permanently stored in the servo.

#include <SCServo.h>
SMS_STS st;
int ID_ChangeFrom = 1;   // The original ID of the servo whose ID is to be changed is factory defaulted to 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); // Lock EPROM-SAFE
}

void loop(){
}
  • Ping

Used to test whether a particular servo is properly connected.

#include <SCServo.h>
SMS_STS st;
int TEST_ID = 3;  // Servo ID to be tested
void setup()
{
  Serial.begin(115200);
  Serial1.begin(1000000, SERIAL_8N1, RX, TX); // Custom serial ports
  st.pSerial = &Serial1;
  while(!Serial1) {}
}

void loop()
{
  int ID = st.Ping(TEST_ID);  //If you ping the servo with that ID and receive no response, it will return -1.
  if(ID!=-1){
    Serial.print("Servo ID:");
    Serial.println(ID, DEC);
    delay(100);
  }else{
    Serial.println("Ping servo ID error!");
    delay(2000);
  }
}
  • Write position

Can be used to control individual servo rotation.

#include <SCServo.h>
SMS_STS st;
void setup()
{
  Serial1.begin(1000000); 
  st.pSerial = &Serial1;
  while(!Serial1) {}
}

void loop()
{
  st.WritePos(1, 1000, 1500, 50); //To control the servo with ID 1, rotate it to position 1000 at a speed of 1500, with a start-stop acceleration of 50.
  delay(754);//[(P1-P0)/V]*1000+100

  st.WritePos(1, 20, 1500, 50); // To control the servo with ID 1, rotate it to position 20 at a speed of 1500, with a start-stop acceleration of 50.
  delay(754);//[(P1-P0)/V]*1000+100
}
  • Synchronous writing

Can be used to control multiple servos at the same time (rotating to different positions and at 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    //Customize the IO of the serial port, if you don't use the custom serial port below Serial1.begin(1000000, SERIAL_8N1, S_RXD, S_TXD); you need to change to 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 servo ID to be controlled to ID[].
  ID[1] = 2;   //Save the servo ID to be controlled to ID[].
  Speed[0] = 3400;  // Set the servo speed, Speed[0] corresponds to the servo with ID[0] above.
  Speed[1] = 3400;  // Set the servo speed, Speed[1] corresponds to the servo with ID[1] above.
  ACC[0] = 50;   // Set the start/stop acceleration, the lower the value the lower the acceleration, and the maximum can be set to 150.
  ACC[1] = 50;
}

void loop()
{
  Position[0] = 3000;  // Set the target position of the servo with ID[0] (in this case ID 1) in the range 0-4095
  Position[1] = 3000;  // Set the target position of the servo with ID[1] (here with ID 2) in the range 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);
}
  • Get servo feedback
#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 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 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 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 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 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 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);   // Getting 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();
}

Resource

3D Model

2D Drawing

Document

Demo

Software

Open-source Structure

ST Robot dog.png

FAQ

 Answer:

You can check the attached st3215 serial servo memory table.
memory table

{{{5}}}


Support



Technical Support

If you need technical support or have any feedback/review, please click the Submit Now button to submit a ticket, Our support team will check and reply to you within 1 to 2 working days. Please be patient as we make every effort to help you to resolve the issue.
Working Time: 9 AM - 6 PM GMT+8 (Monday to Friday)