Tutorial V: ST3215 Serial Bus Servo Control Demo

From Waveshare Wiki
Jump to: navigation, search

Modules Usage Tutorial

ST3215 Serial Bus Servo

ST3215 is a serial bus servo with large torque, and you can refer to the link to view it. The demo about how to easily control the servo is provided as follows.

Demo

Upload Demo

Firstly, you need to download the dependency library. After downloading, you need to extract it to the path of C:\Users\username\AppData\Local\Arduino15\libraries.
ST3215 Serial Bus servo demo.png
After downloading the zip package, open Servo.ino, connect the multifunctional driver board to the computer with a USB cable (here the Type-C port of the USB of the multifunctional driver board is plugged in), click "Tools" -> "Ports", and then click the new COM (COM26 in my case). Click on "Tools" → "Ports", and then click on the new COM.
In Arduino IDE, click "Tools" → "Development Board" → "ESP32" → "ESP32 Dev Module". Upload the demo after selecting the development board and the port. After uploading the demo, connect the serial bus servo to the ST3215 serial bus servo interface on the driver board, connect the XH2.54 power supply interface to the power supply, and run the demo, you can see the servo will swing back and forth.

Demo Analysis

#include <SCServo.h>

SMS_STS st;

#define S_RXD 18
#define S_TXD 19

void setup()
{
  Serial.begin(115200);
  Serial1.begin(1000000, SERIAL_8N1, S_RXD, S_TXD);
  st.pSerial = &Serial1;
  delay(1000);
}

void loop()
{
  st.WritePosEx(1, 4095, 3400, 50);
  delay(2000);
  
  st.WritePosEx(1, 2000, 1500, 50);
  delay(2000);
}

Resources