The SMS controller board is a 4-layer tiny 20x20mm PCB, that features a STM32G431KB, based on a Arm Cortex-M4 32-bit RISC core operating at 150 MHz.
The SMS controller board also features a Ti DRV8872 3.6-A H-bridge motor driver with fault reporting & current regulation, a shunt resistor (Rsense) and a large bulk capacitor on power supply input.
The SMS board is compatible with any micro and mini servo based on a DC brushed motor (2 leads) and an absolute position sensor based on a potentiometer (3 leads). The position is acquired by the STM32 with a precision of 12 bits (ADC) and the positionnal resolution is less than 1°.
The DRV8872 device is used in the "PWM With Current Regulation" mode. The maximum motor current is set to 1A. The maximum ouput current depends on R1, the shunt resistor, which is 0.33R. This shunt resistor is also used to measure the motor current in FORWARD and REVERSE drive modes (unipolar current sensing). The signal comming from the sense resistor is amplified and sampled by the STM32 with a precision of 12-bits (built-in OP-AMP PGA gain=8 and ADC).
The frequency of motor PWM is set to 20KHz. Servo position, motor current and battery voltage are sampled at 20KHz. The control algorithm (PID) executed by the STM32 firmware is clocked at 1KHz.
The SMS board offers different control algorithms, selectable and parametrable by user :
- Position control mode
- Current-based position control mode (default mode)
- Current-based position control mode with velocity/acceleration profil (most advanced)
- Current control mode
- Direct motor PWM control mode
The SMS board does not offer a velocity control mode because the potentiometer, used as position and velocity sensor, cannot handle multiple turns.
The current-based position control mode (with and w/o profil) use a position PID and a current PI. The goal position is the setpoint for the first PID. The output of the first PID is the setpoint of the second PI. This control loop allow position compliance. This operating mode is designed for legged robot, with fast servo moves and high goal position refresh rate.
The profil takes in account velocity and acceleration limits, and provides real time position, velocity and acceleration setpoints to the position PID with feed forwards. This operating mode is desgined for robot arm for smotth and precise positionning, avoiding vibrations and jerk.
The STM32 firmware is built using STM32CubeIDE. Serial communication is handled by the UART2 and DMA. Motor PWM signals are generated by the TIM4 (two channels). Position, current and voltage are sampled using ADC1 and DMA, when TIM4 ouputs trigger update event. LED is driven by a GPIO (output). DRV8872 fault signal is monitored by a GPIO (input) too.
Average motor current is estimated using only one ADC sample per motor PWM period.
In order to measure motor current during PWM pulse, the TIMER4 is configured in the mode "PWM generation center-aligned", with a trigger ouput event on counter update. The ADC is configured to start conversion on TIMER4 trigger event (rising edge). ADC samples motor current, servo position and battery voltage in a 3-stage scan. A DMA is configred to transfer conversion from peripheral to memory in a target circular buffer. The completed conversion interupt is catched by software. Samples are filtered and scaled according calibration parameters.
A python script for PC allows configuration and monitoring of SMS controller board.
Arduino example sketchs are also provided.
Main forum thread (Fr) : Robot Maker Forum
Development processus (Videos) : MG90s hack playlist
Examples (Videos) : SMS Controller Board