🛠 BLDC Motor Control with HPM5100
Objectives
This tutorial aims to configure the HPM5100 to generate three-phase PWM signals for brushless DC (BLDC) motor control. We will leverage the microcontroller's native ability to integrate analog conversion and power protection, reducing the need for external components. The goal is to understand the interaction between the PWM generator and dedicated analog inputs.
Required Hardware
- HPM5100 development board (QFN or LQFP package).
- A three-phase BLDC motor (or equivalent resistive load for initial tests).
- A compatible three-phase power bridge (MOSFETs or IGBTs).
- An oscilloscope to visualize signals.
- External power supply for the motor (voltage compliant with the motor).
- Power and control wiring.
Steps
- Environment Setup: Ensure the HPMicro SDK (version 1.13.0+) is installed and the RISC-V compiler is accessible.
- PWM Module Initialization: In your code, configure the 6 main PWM channels required for a three-phase bridge (H1, H2, H3, L1, L2, L3). The HPM5100 offers 32 channels, providing great flexibility. Configure the switching frequency (e.g., 20 kHz) and waveform generation mode (center-aligned or edge). Use low-level commands from the SDK's PWM driver to set the period register and compare registers.
- Commutation Setup: Implement a logical commutation sequence (sector jump) to power the phases in the correct order. You can use the input capture feature if Hall sensors are present, or generate sensorless control based on back-EMF (BEMF).
- Use of Analog Peripherals: Configure one of the four 16-bit SAR ADCs to read phase current or DC bus voltage. The HPM5100 allows sampling at 2 MSPS, sufficient for fast control loops. Enable one of the PGA op-amps to amplify the current shunt signal before the ADC, eliminating the need for an external amplifier.
- Protection and Safety: Configure the integrated analog comparators to monitor overcurrents. If the voltage across the shunt exceeds a threshold, the comparator can trigger an interrupt or disable PWM via the hardware protection module, ensuring motor safety.
- Compilation and Flashing: Compile the project and transfer the binary to the HPM5100 board via USB OTG or JTAG interface.
Verification
Open an oscilloscope and connect probes to the MOSFET command outputs (H1 to L3). You should observe PWM signals at 50% duty cycle (or according to your configuration) with automatic dead-time inserted if configured. Verify that signals do not overlap. Measure the PGA output voltage on the ADC input to confirm that the signal is properly amplified and centered. If the motor spins, measure current with a clamp meter to confirm regulation.
Further Learning
Explore the use of CAN FD (8 Mbps) to send motor telemetry data to a PC. Integrate FreeRTOS to manage the real-time control task alongside USB communication. Test the high-performance mode (480 MHz) to increase the current control loop frequency.