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)
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.