Google Chat: zj734465502@gmail.com
+86-0755-88291180
sales01@spotpear.com
dragon_manager@163.com
services01@spotpear.com
manager01@spotpear.com
WhatsApp:13246739196
This is a driver board for the DDSM400 direct drive servo hub motor, with 6 DDSM400 motor interfaces on board, integrating ESP32 and hub motor control circuits. We have open source hub motor control demos and JSON communication interface, users can use the host computer to send JSON format instructions to control the hub motor through USB connection, and get JSON format feedback (motor current, speed, temperature and other information).
Users can also redevelop it and use it as a lower computer for robot projects.
Prepare the power supply of the DDSM Driver HAT (B) board, which can be powered by one of the two power supply interfaces of DC5525 or XT60.
The DDSM Driver HAT (B) driver board supports 9~28V DC power supply, and the driver board is suitable for the DDSM400 hub motor with an operating voltage range of 9~28V and a rated voltage of 25.2V.
The current of the power supply should be chosen based on the hub motor's operational requirements. The larger the supported current, the better. In our use tests, a 24V 6A power supply can be used in most scenarios.
The DDSM Driver HAT (B) driver board comes with the hub motor control demo by default at the factory, ensuring that the "UART Control Switch" is in the ESP32 position (as shown below), and the hub motor can receive control commands from the ESP32 at this time. The driver board is powered by two power supply interfaces, DC5525 or XT60, and the ESP32 on the driver board will automatically turn on and establish a hot spot for users to connect at the same time.
Each hub motor has a default ID of 1 at the factory, so you need to set the ID for each hub motor before performing hub motor control.
If you forget the ID set for the hub motor before, or need to check whether the ID setting is successful, you can query the hub motor ID by sending CMD_DDSM_ID_CHECK command in DDSM CTRL. The feedback is as follows:
{"T":20010,"id":6,"typ":210,"spd":-1,"crt":-2,"act":1,"tep":40,"err":0}
After powering on the motor, it defaults to a disabled state, so enabling the motor is required before controlling it in current loop, speed loop, or position loop modes.
Click "INPUT" next to the CMD_CHANGE_Enable command in DDSM CTRL, and you can see that the JSON command in the upper input box showing the motor enabled is: {"T":11002,"id":1}, where:
The Hub motor supports different motor mode switching, but the hub motor after re-powering is in the disabled mode by default. When the motor is enabled, it defaults to current loop mode.
You can use the CMD_CHANGE_MODE command to switch the mode loop, and you can see that the JSON command is displayed as: {"T":10012,"id":1,"mode":2}, where:
Before controlling the rotation of the hub motor, you need to fix the hub motor shaft. If you currently do not have the corresponding structural components to fix the motor shaft, you can set a heartbeat function to automatically stop the hub motor from rotating (in the default speed loop mode).
There are two points to note:
Example: You can set a heartbeat function command with a time value of 1000, enter the JSON command in the input box: {"T ": 11001," time ": 1000}, click SEND to send, so that when you control the hub motor with ID 1, 2, 3, and 4 to rotate, it will automatically stop after rotating for 1 second, so as to prevent the danger caused by sudden rotation of the motor without structural parts to fix the motor shaft.
Before performing speed closed-loop control, ensure that you have enabled the motor and switched the motor mode from current loop to speed loop.
After clicking SEND to send this command, the hub motor will start rotating. If you don't set the heartbeat function (the time value of the heartbeat function is -1) the hub motor will rotate all the time, and then you can use the speed control command above to change the target speed cmd value to 0 to stop the hub motor from rotating.
The basic usage section introduces how to send JSON commands in Web applications and explains JSON commands. This section describes how to send JSON commands via wired connection to control the driver board and hub motors.
You can use a Raspberry Pi, Jetson, PC or other device with a USB port (USB port for serial communication) as the host computer, and connect the driver board and the host computer through the 40PIN serial port or USB port. You can run a Python script on the host computer or send JSON commands to control the hub motor by a tool such as the serial port debugging assistant.
Here introduces the use of a simple serial port debugging assistant to control the hub motor:
You can run the Python script on the host machine to control the hub motor. This script can be used on any device that supports running Python scripts and serial communication, including Windows PC, Raspberry Pi, Jetson Orin, etc. You can change the serial port device name parameter when running the Python script according to actual conditions.
1. Go to Python official website to download the latest version of Python installation package. You can download it according to your operating system, I downloaded it here for Windows, the version is 3.12.0.
2. After downloading, double-click the installation program python-3.12.0-amd64. Remember to check "Add python.exe to PATH", then click "Customize installation" to enter the "Optional Features" interface. Note: If you are installing on a Windows system, make sure to check "Add Python.exe to PATH".
3. In the Optional Features screen, check the box and click "Next" to enter the "Advanced Options" screen.
4. In the "Advanced Options" interface, the installation address can be changed to the address you want to install after clicking "Browse", this is the default installation address, click "Install" to install after setting, and wait for the installation to be completed.
Click to download Python serial communication demo and unzip it, and then enter cmd in the "Start" menu bar to open the Windows command prompt interface, input the cd folder path to enter the ddsm_python project folder.
cd C:\Users\liuwei\Downloads\Ddsm_python\ddsm_python (liuwei needs to be changed into the corresponding user name of your system)
To create a virtual environment for this project in this project folder, and enter the command: python -m venv [virtual environment name, usually called project name-env].
python -m venv ddsm-env
To activate the virtual environment, in the command prompt interface enter: project name- env\Scripts\activate.bat.
ddsm-env\Scripts\activate.bat
After unzipping, you can see that there is a requirements.txt file in the demo, this file is the list of installation packages required for the DDSM_Python project, you can directly install all the necessary packages into the virtual environment by entering the following command:
python -m pip install -r requirement.txt
The virtual environment is already set up, and the installation packages required for this project are installed. Next, we will run the serial communication demo.
The Python demo used for serial communication is serial_simple_ctrl.py. The details of the demo are as follows:
import serial
import argparse
import threading
def read_serial():
while True:
data = ser.readline().decode('utf-8')
if data:
print(f"Received: {data}", end='')
def main():
global ser
parser = argparse.ArgumentParser(description='Serial JSON Communication')
parser.add_argument('port', type=str, help='Serial port name (e.g., COM1 or /dev/ttyUSB0)')
args = parser.parse_args()
ser = serial.Serial(args.port, baudrate=115200, dsrdtr=None)
ser.setRTS(False)
ser.setDTR(False)
serial_recv_thread = threading.Thread(target=read_serial)
serial_recv_thread.daemon = True
serial_recv_thread.start()
try:
while True:
command = input("")
ser.write(command.encode() + b'\n')
except KeyboardInterrupt:
pass
finally:
ser.close()
if __name__ == "__main__":
main()
Connect the hub motor to the driver board, power the driver board, use a USB cable to connect the host computer and the Type-C port marked with ESP32-USB on the driver board, and make sure that the "UART Control Switch" is in the ESP32 position.
After connecting, search for the Device Manager in the "Start" search bar to view the newly inserted port number. Here, the newly inserted is COM67, and the port number varies for different computers. Remember the newly connected port number.
Use the following command to run the serial communication program, and change the serial device name parameter entered when running the Python script according to the actual situation. Replace the COM67 with the port number of the serial device that the driver board inserts into the PC. If you are using a Raspberry Pi, Jeston Orin Nano, etc., change it to the corresponding port name as well.
python serial_simple_ctrl.py COM67
When the run is complete, the terminal will not return any information, and then you can enter the JSON command into the terminal, press Enter, and you can communicate with the DDSM Driver HAT (B). For example, if you need to obtain the ID of the currently connected motor (only one motor can be connected at this time), you can send {"T":10031}, and a message will be fed back after the transmission is successful.
When you upload other demo to the DDSM Driver HAT (B) driver board, it will automatically replace its original factory demo. If you need to quickly restore the driver board to the factory demo, you can use the ESP32 download tool we provide.
The steps are as follows:
1. Click ESP32 download tool to download, unzip it after downloading, and double-click to open the "flash_download_tool_3.9.5.exe" program. After opening, two windows will pop up, we need to operate the UI interface of the download tool, and the other window will act as a terminal to show the working status of the download tool.
2. On the "DOWNLOAD TOOL MODE" screen, select ESP32 for Chip Type and Factory for WorkMode. (With Factory, the relative path will only be used when calling the binary, so the user does not need to manually enter the binary path, click OK after selection.)
3. Enter the download tool software interface, the right side represents the ability to upload programs to 8 drive boards simultaneously. Move the switch on the DDSM Driver HAT (B) driver board to the ESP32 position, connect the ESP32-USB interface on the DDSM Driver HAT (B) driver board to the computer with a USB cable, click on "COM", and select the newly appearing COM (the new COM here is COM67); BAUD is used to set download speed, the higher the speed, the faster. ESP32 can use up to 921600.
4. After selection, click "START" to start uploading the program. Once the upload is complete, "IDLE WAIT" will change to "FINISH COMPLETE". After completion, you can disconnect the driver board from the computer's USB connection, connect the hub motor, and power it on to perform the Basic Usage Control.
Monday-Friday (9:30-6:30) Saturday (9:30-5:30)
Email: services01@spotpear.com