Your Motor Controller Customization Service Specialist

86-18157453060 bobo@hf-motion.com

# Square wave control principle of brushless motor

## 1.Theoretical basis of square wave control

Square wave control is also called six-step control. In an electrical cycle, the motor has only six states, or the stator current has six states (three-phase bridge arm has six switching states). Each current state can be regarded as a vector torque in one direction, and the six vectors are regularly converted step by step. The rotation direction of the vector determines the rotation direction of the motor (clockwise or counterclockwise), and the rotor of the motor will rotate synchronously.

In square wave control, two variables are mainly controlled, one is the open tube state corresponding to the motor rotor position. When there is Hall, the rotor position is obtained by Hall information, and when there is no sensor, the rotor position is obtained by back electromotive force information, thus determining the open tube state; The second is PWM duty ratio control, which controls the current by controlling the duty ratio, thus controlling the torque and speed.

## 2.Implementation steps of square wave algorithm

Hall square wave control:

1. Read the AD value of bus current sampling and calculate the bus current
2. The current loop calculates the PWM duty cycle that should be given, and controls the current to a given current size
3. Read hall state, and according to the relation array between hall state and three-phase bridge arm opening state, get the corresponding opening state, each jump edge of Hall state and the time point (also called commutation point) for three-phase bridge arm state switching.
4. The sector between the adjacent states of Hall is one sixth of an electrical cycle, that is, 60. The timer can record the time taken by the 60 sector, so as to calculate the current frequency and obtain the motor speed.
5. Take the current loop as the inner loop and the speed loop as the outer loop, and control the motor in closed loop, as shown in Hall square wave control block diagram. For hall square wave control, when the motor is started, the rotor position of the motor is already known, and the motor can be started by directly pulling the motor with the vector torque of Hall state pair, and can be directly controlled in closed loop.

BEMF square wave control:

1. Read the AD value of bus current sampling and calculate the bus current.
2. The current loop calculates the PWM duty cycle that should be given, and controls the current to a given current size
3. Keep a pipe opening state (i.e. keep a direction vector positioning), and then change the pipe opening state according to a certain frequency, and increase and change the frequency according to the law. Reach the switching electrical frequency, and then switch to the back electromotive force mode.
4. Use a timer with higher frequency to interrupt and read the output state of the phase comparator. If the output level of the phase comparator turns over, it means that the counter electromotive force generates zero crossing. At this time, read the time base count value of timer D, save it, then clear the timer D, configure the comparison value of the comparison register 0 of timer D, start the timer D to start timing until PWMD0 interrupt occurs, and change the switching tube state in the interrupt, that is, find the zero crossing point and delay the phase change by 30 electrical angle.
5. With the current loop as the inner loop and the speed loop as the outer loop, the motor performs closed-loop control. For BEMF square wave control, when the motor starts, the position of the motor rotor is unknown, so it is necessary to start the motor in an external synchronous way, so that the stator current can drive the motor rotor to run according to a given size and frequency, and then the motor can switch to the back electromotive force mode to run the motor, and run the closed-loop control of speed and current.