Waveshare ST3215 High Precision and Torque User Manual

June 9, 2024
WAVESHARE

Waveshare ST3215 High Precision and Torque

SERVO DRIVER WITH ESP32

HOW TO INSTALL ARDUINO IDE

You can download the Arduino IDE from Arduino. cc.

  1. Choose the Arduino IDE suitable for your system.
  2. Run the installation package.
  3. Click on I Agree.
  4. Check Install USB driver and Associate. in files, then click Next.
  5. Select the installation path of Arduino IDE, then click Install.
  6. Wait for the installation to complete.
  7. Install the required drivers.
  8. Click to install.
  9. Click to install.Waveshare-ST3215-High-Precision-and-Torque-fig-6
  10. Click to install.Waveshare-ST3215-High-Precision-and-Torque-fig-7
  11. Arduino IDE installation is complete.Waveshare-ST3215-High-Precision-and-Torque-fig-8

INSTALL ARDUINO CORE FOR THE ESP32

  1. Run Arduino IDE, and click File.Waveshare-ST3215-High-Precision-and-Torque-fig-9
  2. Click on Preferences.Waveshare-ST3215-High-Precision-and-Torque-fig-10
  3. Fill https://dl.espressif.com/dl/package_esp32_index.json in Additional Boards Manager URLs and click OK.Waveshare-ST3215-High-Precision-and-Torque-fig-11
  4. Restart the IDE, and click Tools > Board > Boards Manager to open the Boards Manager.
  5. Fill in ESP32 and click Install. [Note: ESP32 version 1.0.6 needs to be installed here.]Waveshare-ST3215-High-Precision-and-Torque-fig-12
  6. Wait for the installation to complete.Waveshare-ST3215-High-Precision-and-Torque-fig-13
  7. After installation, you can use Arduino IDE to develop ESP32.

DOWNLOAD PROGRAM & INSTALL DEPENDENCY LIBRARIES

  1. Please install the following libraries through Manage Libraries: Adafruit SSD1306, Adafruit NeoPixel. Library installed by copying files is SCServo.Waveshare-ST3215-High-Precision-and-Torque-fig-14
  2. Click Tools > Manage Libraries to open the library manager.Waveshare-ST3215-High-Precision-and-Torque-fig-15
  3. Enter the libraries that need to be installed through the library manager in the search box, and install: Adafruit SSD1306, Adafruit NeoPixel
  4. Click “Update”, and if there is no “Update”, please click “Install” for the newest version.
  5. Click Github link to download the program, or you can go to waveshape to download it.
  6. Copy SCServo to \Documents\Arduino\libraries.Waveshare-ST3215-High-Precision-and-Torque-fig-16

UPLOAD THE PROGRAM TO THE ROBOT

  1. Double-click to run SERVO DRIVER WITH ESP32 ST/ServoDriverST/ServoDriverST.ino.Waveshare-ST3215-High-Precision-and-Torque-fig-17
  2. Click Tools > Port to remember the existing COM Port, no need to click it.
  3. The COM displayed here is different for different computers, remember this COM.Waveshare-ST3215-High-Precision-and-Torque-fig-18
  4. Connect the driver board and computer.
  5. Click Tools > Port, and click on this new COM.
  6. The newly-appearing COM is different for different computers, click it.Waveshare-ST3215-High-Precision-and-Torque-fig-19
  7. Click Tools > Boards: > ESP32 Arduino > ESP32 Dev Module and select ESP32 Dev Module.
  8. Other settings are as follows:Waveshare-ST3215-High-Precision-and-Torque-fig-20
  9. Click “Upload” in the upper left corner to upload the program.Waveshare-ST3215-High-Precision-and-Torque-fig-21
  10. Note that the automatic downloading circuit will fail when WAVEGO uses the serial port to connect with the Raspberry Pi. You need to disconnect the serial port from the Raspberry Pi before uploading the program to WAVEGO.Waveshare-ST3215-High-Precision-and-Torque-fig-22
  11. Wait for uploading the program.Waveshare-ST3215-High-Precision-and-Torque-fig-23
  12. After displaying “Leaving… Hard resetting via RTS pin…”, it means that the upload has been successful.Waveshare-ST3215-High-Precision-and-Torque-fig-24

HOW TO USE THE DRIVER BOARD

  1. Connect the SC15 Servo to the driver board. There are two 3pin servo ports on the driver board, which are connected, so you can press any one of them.
  2. Use 6-8.4V DC power supply, the driver board will automatically turn on after plugging in the power supply.Waveshare-ST3215-High-Precision-and-Torque-fig-25
    • When powered on, the RGB blue light indicates that the driver board starts to initialize WIFI and establish a WebServer. After completion, the driver board will automatically scan the connected servos. The RGB light is green during scanning, and then the RGB will turn off.
    • After power on, the first line of the OLED is the MAC address of the device, which is unique and used for ESP-NOW communication.
    • The second row V: is the measured voltage. After the next is the device IP address.
    • The third line MODE: is the role of the device, N is Normal, ESP-NOW related functions are turned off; L is Leader, ESP-NOW will send the current Active Servo ID and location information to the Follower, and control the servo with the same ID connected to the Follower. F is Follower, the device will receive commands from Leader through ESP-NOW.
    • The role of the device is followed by AP or STA. In AP mode, the device will establish a WIFI hotspot; in STA mode, the device will connect to a known WIFI.
    • In AP mode, the AP is followed by the SSID of the device; in STA mode, the STA is followed by the signal strength RSSI.
    • The first line N: is Number, which shows the number of servos connected in the last scan; ID: is the currently selected servo (Active Servo), the -0 behind the servo indicates that the servo is in servo mode; – 3 Indicates that the servo is in motor mode. POS: is the current position of the servo.
  3. Download and install the Chrome browser on your phone, or other browsers with the same kernel.
  4.  In the default program, after the driver board is powered on, a WIFI hotspot will be created automatically, and the mobile phone will be used to search for the WIFI hotspot.
  5. In the default program, the WIFI name is ESP32_DEV and the WIFI password is 12345678 .
  6. After the connection is successful, open the browser and enter 192.168.4.1 in the address bar to open the ESP32 web interface.
    • Generally, if the servo is connected first and then powered on, the driver board will scan the connected servo. If you turn on the servo first and then connect to the servo, you need to manually click Start Searching on the WEB interface of the mobile phone, and then wait for a while for the servo to scan, including re-scanning the servo after resetting the servo ID.Waveshare-ST3215-High-Precision-and-Torque-fig-26
  7. If you only connect one servo, the ID Select+ and ID Select- buttons have no effect; if you connect multiple servos with different IDs, you can use these two buttons to select the servo, the currently selected servo ID is displayed after ID. If you connect multiple servos with the same ID, it is very likely that the ping will fail, resulting in no servo ID to choose from the driver board. Hence, you need to disconnect the redundant connections. Only connect one servo, after changing the ID, connect it in series with the servos with other IDs.
  8. “Middle” button, after pressing the servo, the servo will rotate to the middle position of the servo swing range.
  9. “Stop” button, the servo will stop turning after pressing it.
  10. “Release” button, press the servo to turn off the torque lock, and people can turn the servo by hand (due to the existence of multi-stage reduction gears, it may be very ifficult to rotate the servo between them, and a lever arm can be used to rotate).
  11. “Torque” button, press it to open the torque lock, when receiving external force, the servo will try to keep it in one position.
  12. “Position+” , the servo position value increases after pressing, the servo starts to rotate clockwise, and the rotation stops when released.
  13. “Position-” , the servo position value decreases after pressing, the servo starts to rotate counterclockwise, and the rotation stops when released.
  14. “Speed+ Speed-” , press to increase/decrease the speed of the servo, the changed speed is displayed after “Speed Set”, the moving speed of the servo will use this speed.
  15. “ID to Set+ ID to Set- Set New ID”, used to select the servo ID to be changed, displayed after ID to Set:. For example, when you need to change the servo with ID 3 to the servo with ID 9, you need to click “ID to Select” first to change the display area.ID: to 3 (provided that the scanned servo has an ID of 3), and then use the ID to Set button to change the number behind to 9, then click Set New ID, click OK in the pop-up dialog box, so that the ID3 servo is set to ID9 Right, now you need to click Start Searching again to find the servos.
  16. “Set Middle Position”, dedicated to ST series, SC series servos do not have this function, this button is used to set the currently selected servo position as the middle position of the servo.
  17. “Set Servo Mode”, set the current servo as the servo mode, which is also the initial default mode of the servo and can be rotated to an absolute position.
  18. “Set Motor Mode”, set the current servo to motor mode. In this mode, the servo can rotate continuously and control the relative position of each rotation. It can be used as a geared motor (SC series servo) or a stepper motor (ST series steering gear).
  19. “Start Serial Forwarding”, after the servo is turned on, the servo will start the serial port forwarding, and forward the data of the Type-C UART0 and the UART1 used to control the servo, so that the FD tool on the computer can be used to debug the servo. The default baud rate of UART0 is 115200.
  20. “Normal”, set the current device to Normal, the related functions of ESP-NOW will not be enabled in this mode.
  21. “Leader”, set the current device as Leader , in this mode, the device will send the current Active Servo’s ID and Position to Follower through ESP-NOW.
  22. “Follower”, set the current device as Leader, in this mode, the device will receive commands from Leader through ESP-NOW.
  23. “RainbowON RainbowOFF”, used to turn on and off the RGB rainbow light, you can expand more WS2812 RGB LEDs on the RGB light interface.

AT COMMAND SET

SET THE LARGEST SERVO ID

The method of scanning the currently connected servos each time is to ping each ID. Ping through a certain ID means that the servo with this ID is connected to the driver board, so if the number of IDs to Ping is too many, it will take a long time. The maximum ID of the scanning servo, MAX_ID, is defined in ServoDriver.ino. If you control many servos or the servo ID value is relatively large, you can adjust the number of IDs to be pinged in each scan by changing this value. The maximum is 253, the default is 20.

SET MAC ADDRESS

  • ESP-NOW is used to communicate among the driver boards and the default program supports one-to-one control. You can follow the tutorials later in this section.
    One-to-many or many-to-one communication.

  • The premise of ESP-NOW communication is to get the MAC address of the receiver. After the driver board is powered on, it will automatically obtain the MAC address of the device and display it in the first row of the OLED screen.

  • The working mode of the driver board can be set to Normal Leader Follower, when you use one driver board to control another, the control terminal of the driver board is the Leader, and the other controlled driver board is the Follower. The specific operation steps are as follows:

  • Connect the Follower to the computer and note the Follower’s MAC address.

  • Open ServoDriver.ino, change DEFAULT_ROLE to 2, and upload it to the Follower driver board.

  • It is not necessary to change the DEFAULT_ROLE. After changing this, the driver board will automatically be in the corresponding working mode after booting. If you do not change this, you need to manually set it on the WEB page. When the driver boards with the same SSID are running in AP mode at the same time, you may not be able to distinguish which name corresponds to the driver board. For WIFI settings, please refer to the WIFI: AP and STA Mode chapter.

  • Connect the Leader driver board to the computer, open ServoDriver.ino , change broadcastAddress[] to Follower’s MAC address, and remember to add 0x before each value.Waveshare-ST3215-High-Precision-and-Torque-fig-30

  • The above is an example, in practice the MAC address of each device is different.

  • Change DEFAULT_ROLE to 1 and upload it to the Follower driver board.Waveshare-ST3215-High-Precision-and-Torque-fig-31

  • After the two devices are connected to the servos with the same ID, the ID and Position of the Leader’s Active Servo will be sent to the Followers to control the rotation of the servos connected to them.

  • The demo is only suitable for the servo to work in the servo mode. If it works in the motor mode, it does not work. The SC series servo cannot control the angle in the continuous rotation mode.

  • When connecting the mobile phone to the driver board, pay attention to whether the SSIDs of the two driver boards have the same name. If they are the same name, it may lead to the connection to the wrong driver board.

  • You can refer to the WIFI: AP and STA Mode section to change the SSID.

  • Related links for ESP-NOW:

  • ESP-NOW Two-Way Communication Between ESP32 Boards

  • ESP-NOW with ESP32: Send Data to Multiple Boards (one-to-many)

  • ESP-NOW with ESP32: Receive Data from Multiple Boards (many to one)

SERVO TYPES

The driver board can control the servo of the SC and ST series. The main differences between the two series of servo parameters are as follows:

| SC| ST
---|---|---
Digital Signal Range| 0-1023| 0-4095
Servo Rotation Angle| 200°| 360°
Voltage Range| 6-8.4V| 6-12V

  • For other differences, please refer to the Datasheet on the servo sales page. The voltage is determined by the power supply of the DC port, and the DC port directly supplies power to the servo.
  • In the program, you need to adjust the program according to your own servo type. The original program is suitable for SC series servos. If you are using SC series servos, you do not need to change. The relevant code is in STSCTRL.h, and SC is supported by default. The program of the series servo is as follows:
  • If you need to control ST series servos, you need to comment out the part of SC servos and uncomment the part of ST series servos. The changed code is as follows:Waveshare-ST3215-High-Precision-and-Torque-fig-32

WIFI: AP & STA MODE

  • In AP mode, the device will establish a WIFI hotspot, which can be connected through the mobile phone to control/debug the servo.
  • In STA mode, the device will connect to a known WIFI hotspot.
  • You can customize the SSID and password of the WIFI hotspot established by the driver board in AP mode by changing the code in ServoDriver.in:
  • You can customize the SSID and password of the WIFI that the driver board will connect to in STA mode by changing the code in ServoDriver.in:
  • Set AP mode, the default is AP mode in device code, change DEFAULT_WIFI_ROLE in ServoDriver.ino to 1.
  • To set STA mode, change DEFAULT_WIFI_ROLE in ServoDriver.ino to 2 .

EXPAND MORE RGB-LED

There is a PH1.25-3P main seat on the back of the driver board, and there are silkscreens next to the three pins to mark the function of each pin, respectively 5V GND OUT. OUT is connected with other WS2812 5V IN, which is used to expand more RGB-LED lamp beads.
There are two on-board RGB LEDs on the driver board, and the code that controls them is in RGB_CTRL.h, numbered 0 and 1 respectively, if you expand more lamp beads, you need to modify the value of NUMPIXELS in ServoDriver.h.

ESP32 PIN FUNCTION

  • GPIO 23 is used to control RGB LEDs.
  • The GPIO 18 acts as RX and the GPIO 19 acts as TX, communicating with the servo control circuit.
  • The baud rate for the UART controlled by the servo is 1,000,000Waveshare-ST3215-High-Precision-and-Torque-fig-41
  • The baud rate of the UART used for the download circuit and host computer communication is 115200.
  • Used GPIO 21 as SDA, and GPIO 22 as SCL for controlling OLED screens.Waveshare-ST3215-High-Precision-and-Torque-fig-42Waveshare-ST3215-High-Precision-and-Torque-fig-44

SECOND DEVELOPMENT

  • The Example folder contains the demos for Arduino IDE, Jetson (Python language), and Raspberry Pi (Python language).
  • You can use the Arduino IDE demo for secondary development directly on the driver board.
  • If you want to use Jetson or Raspberry Pi to control the driver board, you have two options:
  1. Control the driver board directly by Jetson or Raspberry Pi, we have provided a demo for this method.
  2. Use the driver board as a lower computer, in which the inverse solution of the connecting rod is performed, and the upper computer is responsible for decision-making operations. We will provide relevant demos in specific products in the future.

ARDUINO IDE DEMO

  • The demos for the Arduino IDE are in examples\arduinoIDE\ , all tested on SERVO DRIVER with ESP32, no need to change any code.
  • The power supply of the servo is from the DC interface, so the DC interface should be connected to the power supply during the test.
  • The demos of SC series servos are in the SCSCL folder.
  • The demos of ST series servos are in the STSCL folder.
  • SCSCL\Broadcast: broadcast to control all the servos. During the test, the servos will swing in a wide range at the maximum speed. Do not connect the servos with other structures.
  • SCSCL\Ping: used to test whether the servo is ready, set the servo ID to be viewed by changing TEST_ID, and open the serial monitor to check the servo status during the test.
  • SCSCL\ProgramEprom: Used to change the ID of the servo, change ID_ChangeFrom to ID_Changeto.
  • SCSCL\RegWritePos: A demo for asynchronous writing, first set the target position and speed of each servo, and then call the following functions to start the movement uniformly.
  • SCSCL\SyncWritePos: A demo for synchronous writing to control multiple servos to move together.
  • SCSCL\WritePos: Used to control the movement of a single servo.
  • SCSCL\FeedBack: used to obtain the position, speed, load, voltage, temperature, and movement status of the servo.
  • STSCL\CalibrationOfs: The demo used to set the center position of the servo. After calling the following function, the current position of the servo will be used as the center position of the servo.
  • STSCL\FeedBack: Used to obtain the position, speed, load, voltage, temperature, and movement status of the servo.
  • STSCL\Ping: Used to test whether the servo is ready, set the servo ID to be viewed by changing TEST_ID, and open the serial monitor to check the servo status during the test.
  • STSCL\ProgramEprom: Used to change the ID of the servo, change ID_ChangeFrom to ID_Changeto.
  • STSCL\RegWritePos: A demo for asynchronous writing, first set the target position and speed of each servo, and then call the following functions to start the movement uniformly.
  • STSCL\SyncWritePos: A demo for synchronous writing to control multiple servos to move together.
  • STSCL\WritePos: Used to control the movement of a single servo.

RASPBERRY PI/JETSON/PC HOST COMPUTER DEMO(PYTHON)

  • Servo control demos in Python are in examples\python\.
  • When you use this demo to directly control the servos, you need to enable the serial port transparent transmission mode of the driver board. You can operate through the
  • WEB terminal and click the Start Serial Forwarding button to enable serial port transparent transmission. For convenience, you can also change the serial port in ServoDriver.ino. The SERIAL_FORWARDING is true, so the driver board will automatically enter the serial port transparent transmission mode after booting.
  • When the driver board is in the serial port transparent transmission mode, use the baud rate of 115200 to communicate with the driver board.
  • ping.py: ping command example
  • read_write.py: common read and write example
  • sync_write.py: Synchronous write example
  • sync_read_write.py: Example of synchronous write and synchronous read
  • When using the demo, you need to rewrite some codes according to your actual situation, such as the USB device name. For example Windows: “COM1”, Linux: “/dev/ttyUSB0”.Waveshare-ST3215-High-Precision-and-Torque-fig-52
  • protocol_end is used to select the servo type, 0 for ST series servos and 1 for SC series servos.Waveshare-ST3215-High-Precision-and-Torque-fig-53

FUNCTION TEST

  • Double click to run ServoDriver.ino .

  • Connect the driver board and click the arrow in the upper left corner of the Arduino IDE to upload the program to the driver board.

  • After the upload is successful, disconnect the driver board, connect a servo, and use the DC port for power supply (power supply in the range of 6-8.4V can be used).

  • The screen lights up, and the RGB lights emit light green light while scanning the servos.

  • Use your phone to search for WIFI, name ESP32_DEV , password 12345678 .

  • Open the Chrome browser on your phone (or other browsers with Chrome kernel) and visit 192.168.4.1 .

  • Press Position+ or Position- to rotate the servo, if the servo rotates, the test is successful.

  • *The content tested in the above steps includes: power supply, communication, steering gear control, OLED, RGB LED, and automatic download circuit.
    It is necessary to ensure that only one driver board is turned on near the mobile phone, otherwise it is not easy to determine which driver board is connected with the same WIFI name.

  • www.waveshare.com/wiki

References

Read User Manual Online (PDF format)

Loading......

Download This Manual (PDF format)

Download this manual  >>

WAVESHARE User Manuals

Related Manuals