This application note presents Z16FMC microcontroller used as a three-phase hall sensor brushless DC driver. The microcontroller features an on-chip integrated array of applications using the multi-motor development kit that offers a fast and precise fault control, as well as high system efficiency and easy firmware development for customized applications.
The design involves running the BLDC motor in a closed loop or an open loop, with speed as set by a potentiometer. As shown in the architecture diagram, the design generates PWM voltage via Z16FMC microcontroller PWM module to run the BLDC motor. The state of the three Hall sensors changes base on the rotor position while the monitor is running. Voltage to each of the three phases is switched based on the state of the sensors (commutation). Hall sensor interrupts capture timer ticks every sixty degrees to measure the rotor speed of the motor. Other peripheral functions can be used to protect the system in case of current overload, under- or overvoltage, and over temperature. The hardware is described in the following sections.
- Three-Phase Bridge MOSFET
The three-phase bridge MOSFET consists of six MOSFETs connected in bridge fashion used to drive the three phases of the BLDC motor. The DC bus is maintained at 24 V, which is the same as the voltage rating of the BLDC motor. A separate Hi-Lo gate driver is used for each high- and low-side MOSFET phase pair, making the hardware design simpler and robust. Charging the bootstrap capacitor drives the high-side MOSFET. Reducing it to suitable value using a potential divider monitors the DC bus voltage and putting a shunt in the DC return path monitors the DC bus current. An NTC-type temperature sensor provides an analog voltage output proportional to temperature.
- PWM Module
The Z16FMC microcontroller contains a 6-channel, 12-bit PWM module configured in this application to run in Complementary Mode. The switching frequency is set to 20 kHz. The PWM outputs are controlled according to the inputs from Hall sensors. The inputs from the Hall sensors determine the sequence in which the three-phase bridge MOSFET is switched. The Duty cycle of the PWM is directly proportional to the accelerator potentiometer input. The change in the duty cycle controls the current through the motor winding, thereby controlling motor torque.
- Commutation Logic
The Hall sensors are connected to ports PD3, PD4, and PD5 on the Z16FMC microcontroller. An interrupt is generated when the input state on any pin changes. An interrupt service routine checks the state of all three pins and accordingly switches the voltage for the three phase of the motor. Trapezoidal commutation is used for this application to make implementation simple. In this process of commutation, any two phases are connected across the DC bus by switching the top MOSFET of one phase and bottom MOSFET of another phase ON. The third phase is left un-energized (both top and bottom MOSFET of that phase are switched OFF).
- Speed Measurement
One out of the three Hall sensors is used to capture the Timer0 ticks, which represent the actual Hall period for closed loop calculations.
During implementation of the software, the following actions are performed: Initialization Hardware modules are initialized for the following functions.
- Switch from an internal to an external oscillator for system operation
- Enable alternate functions on the respective pins for the ADC, Comparator, and UART, and to drive the LEDs
- Configure Timer0 to run in Continuous Mode to capture the Hall period timing
- Configure the comparator to shut down the PWM module when an overcurrent results
- Enable the Op-Amp to measure the DC bus current flowing to the motor
- Configure the ADC to read analog values such as DC bus voltage, current, temperature, and acceleration potentiometer (only one channel at a time)
- Configure the PWM module for the individual mode of operation with a 20 kHz switching frequency, control output depending on the values in the PWMOUT Register, and drive the PWMOUT as defaulted to a low off state at Power-On Reset and at any Reset.
The Port D interrupts controls commutation. The Hall sensor output is read on pins PD3:5, the software performs its filtering operation, and the switching sequence of the MOSFET is determined. The PWM timer interrupt is used to time periodically occurring tasks and for the background loop to read analog values from different channels and average these values, update the LED indicator status, and update the read parameters on the UART.