🛠 Automated Motor Control with HPM5100
Objectifs
This advanced tutorial aims to configure the HPM5100 for closed-loop BLDC motor control. You will learn to leverage the 32 synchronized PWM channels and 4 SAR ADCs at 2 MSPS for precise regulation. The goal is to achieve minimal latency using the 400 MHz RISC-V core and 416 KB SRAM.
Matériel nécessaire
- HPM5100 development board (HPM5151)
- Tri-phase BLDC motor driver compatible with 3.3 V/5 V
- BLDC motor with Hall sensors or current shunts
- Oscilloscope for PWM and ADC signal analysis
- HPM SDK v1.13.0 and RISC-V toolchain
- Wiring adapted to QFN/LQFP package pins
Étapes
- Configure system clocks to reach 400 MHz via the SDK configuration file. Ensure thermal conditions meet specifications to avoid throttling if attempting 480 MHz.
- Initialize the PWM module. Select one of the 32 channels to generate three complementary signals with dead-time for the power driver. Enable channel synchronization to ensure coherent switching.
- Configure the 16-bit SAR ADCs. Select two channels for phase current reading and one for bus voltage. Set the sampling frequency to 2 MSPS for high temporal resolution.
- Implement the ISR triggered by ADC conversion completion. In this routine, read raw values, apply digital filtering, and calculate the error relative to the setpoint.
- Apply a PI (Proportional-Integral) controller calculated in floating-point or optimized fixed-point for the RISC-V core. Update PWM comparison registers in real-time.
- Enable secure boot via the hardware security interface to protect firmware against copying, essential in industrial applications.
Vérification
Use an oscilloscope to observe PWM signals on output pins. Verify that dead-time is correct and transitions are sharp. On the PC, connect the UART interface (1 of 5 available) to print current and speed values. Ensure latency between ADC read and PWM update remains below 10 µs.
Pour aller plus loin
Integrate CAN FD communication at 8 Mbps for remote control via an industrial bus. Leverage USB 2.0 OTG for firmware updates (DFU) or advanced debugging. Finally, explore the XPI interface to add external Flash memory if control code exceeds internal capacity.