Test robot
Mainboard
Functionality
-
Closed loop speed control of 3 brushless DC motors.
-
Designed for Pololu 37D Metal Gearmotors with quadrature encoders.
-
Motor driver current limited to 3.0 A.
-
Motor driver supply voltage up to around 16.8V (maximum voltage of 4S LiPo batteries). Limited by ceramic capacitors that are rated to 25 V.
-
-
Reverse voltage protection MOSFET on the motor driver supply side.
-
Two 5 V small hobby servo outputs with 50 Hz PWM signals.
-
One BLDC ESC (Electronic Speed Controller) signal output using DShot300 protocol.
-
Reverse voltage protected motor power output for thrower ESC.
-
Isolation between microcontroller and motor drivers.
-
STM32G441KBT6 microcontroller.
-
Powered through USB connector.
-
-
Micro-USB socket for communicating with a computer over virtual COM port.
-
Two ball detector inputs.
-
10-pin SWD (Serial Wire Debug) connector.
-
One UART interface with solderable pads.
-
Two M2 mounting holes.
Firmware
Binary firmware file
Connect STLINK programmer to the mainboard and to a computer with USB. Drag or copy the *.bin file to the STLINK drive.
Sending commands to mainboard
Struct in firmware
typedef struct __attribute__((packed)) Command {
int16_t speed1;
int16_t speed2;
int16_t speed3;
uint16_t throwerSpeed;
uint16_t servo1;
uint16_t servo2;
uint8_t disableFailsafe; // 1 to disable failsafe, anything else to enable
uint16_t delimiter;
} Command;
Using with python’s struct library
disable_failsafe = 0
struct.pack('<hhhHHHBH', speed1, speed2, speed3, thrower_speed, servo1, servo2, disable_failsafe, 0xAAAA)
Using HTerm
-
Download HTerm.
-
Connect a micro USB cable to the mainboard.
-
Open HTerm.
-
Select the correct port.
-
On Windows the ports are listed in the Device Manager.
-
On Linux running
dmesg
can list recently connected devices.
-
-
Leave other settings to defaults.
-
Press Connect.
-
In
HTerm
underInput control
changeType
toHEX
. -
Send
0A 00 0A 00 0A 00 00 00 00 00 00 00 00 AA AA
to set all the motors to rotate at the speed of 10.-
Byte order is little endian, which means that least significant byte is first.
-
-
Send
F6 FF F6 FF F6 FF 00 00 00 00 00 00 00 AA AA
to set all the motors to rotate at the speed of -10.-
Negative values are two’s complement of the positive value.
-
-
10 is relatively low speed, so if any of the motors is rotating fast, the motor power wires might need to be reversed (because the encoder values need to count in a positive direction if the speed is set to a positive value) or the encoder signal connections might be faulty.
Receiving data from mainboard
Struct in firmware
typedef struct __attribute__((packed)) Feedback {
int16_t speed1;
int16_t speed2;
int16_t speed3;
int16_t position1;
int16_t position2;
int16_t position3;
uint8_t sensors;
uint16_t delimiter;
} Feedback;
Using with python’s struct library
actual_speed1, actual_speed2, actual_speed3, motor1_position, motor2_position, motor3_position, sensors, feedback_delimiter = struct.unpack('<hhhhhhBH', received_data)
Thrower speeds
Thrower speeds are sent to thrower motor controller using DShot protocol. Speed values are between 48 - 2047 for 0 to 100% speed.