Waveshare ST3215 High Precision and Torque User Manual
- June 9, 2024
- WAVESHARE
Table of Contents
Waveshare ST3215 High Precision and Torque
SERVO DRIVER WITH ESP32
HOW TO INSTALL ARDUINO IDE
You can download the Arduino IDE from Arduino. cc.
- Choose the Arduino IDE suitable for your system.
- Run the installation package.
- Click on I Agree.
- Check Install USB driver and Associate. in files, then click Next.
- Select the installation path of Arduino IDE, then click Install.
- Wait for the installation to complete.
- Install the required drivers.
- Click to install.
- Click to install.
- Click to install.
- Arduino IDE installation is complete.
INSTALL ARDUINO CORE FOR THE ESP32
- Run Arduino IDE, and click File.
- Click on Preferences.
- Fill https://dl.espressif.com/dl/package_esp32_index.json in Additional Boards Manager URLs and click OK.
- Restart the IDE, and click Tools > Board > Boards Manager to open the Boards Manager.
- Fill in ESP32 and click Install. [Note: ESP32 version 1.0.6 needs to be installed here.]
- Wait for the installation to complete.
- After installation, you can use Arduino IDE to develop ESP32.
DOWNLOAD PROGRAM & INSTALL DEPENDENCY LIBRARIES
- Please install the following libraries through Manage Libraries: Adafruit SSD1306, Adafruit NeoPixel. Library installed by copying files is SCServo.
- Click Tools > Manage Libraries to open the library manager.
- 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.
- Click Github link to download the program, or you can go to waveshape to download it.
- Copy SCServo to \Documents\Arduino\libraries.
UPLOAD THE PROGRAM TO THE ROBOT
- Double-click to run SERVO DRIVER WITH ESP32 ST/ServoDriverST/ServoDriverST.ino.
- Click Tools > Port to remember the existing COM Port, no need to click it.
- The COM displayed here is different for different computers, remember this COM.
- Connect the driver board and computer.
- Click Tools > Port, and click on this new COM.
- The newly-appearing COM is different for different computers, click it.
- Click Tools > Boards: > ESP32 Arduino > ESP32 Dev Module and select ESP32 Dev Module.
- Other settings are as follows:
- Click “Upload” in the upper left corner to upload the program.
- 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.
- Wait for uploading the program.
- After displaying “Leaving… Hard resetting via RTS pin…”, it means that the upload has been successful.
HOW TO USE THE DRIVER BOARD
- 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.
- Use 6-8.4V DC power supply, the driver board will automatically turn on after plugging in the power supply.
- 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.
- Download and install the Chrome browser on your phone, or other browsers with the same kernel.
- 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.
- In the default program, the WIFI name is ESP32_DEV and the WIFI password is 12345678 .
- 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.
- 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.
- “Middle” button, after pressing the servo, the servo will rotate to the middle position of the servo swing range.
- “Stop” button, the servo will stop turning after pressing it.
- “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).
- “Torque” button, press it to open the torque lock, when receiving external force, the servo will try to keep it in one position.
- “Position+” , the servo position value increases after pressing, the servo starts to rotate clockwise, and the rotation stops when released.
- “Position-” , the servo position value decreases after pressing, the servo starts to rotate counterclockwise, and the rotation stops when released.
- “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.
- “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.
- “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.
- “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.
- “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).
- “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.
- “Normal”, set the current device to Normal, the related functions of ESP-NOW will not be enabled in this mode.
- “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.
- “Follower”, set the current device as Leader, in this mode, the device will receive commands from Leader through ESP-NOW.
- “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.
-
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.
-
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:
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,000
- 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.
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:
- Control the driver board directly by Jetson or Raspberry Pi, we have provided a demo for this method.
- 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”.
- protocol_end is used to select the servo type, 0 for ST series servos and 1 for SC series servos.
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.
References
Read User Manual Online (PDF format)
Read User Manual Online (PDF format) >>