Sensored Hall Effect Sensor Based Field Oriented Control of Three Phase BLDC Motor Using dsPIC33CK DS00004064
Sensored Hall Effect Sensor Based Field Oriented Control of Three Phase BLDC Motor Using dsPIC33CK DS00004064
Introduction
The construction of modern BLDC motors allows them to be controlled like permanent magnet synchronous motors.
This means that a sophisticated technique called Field Oriented Control (FOC) is also applicable to BLDC motors. The
FOC algorithm is useful in the applications that require fast dynamic response with independent control of torque and
flux. Sensor-based FOC is advantageous for providing rotor position at slower speeds.
This application note describes the implementation of a Hall effect sensor-based FOC algorithm for three-phase BLDC
motors using Microchip Technology's 16-bit dsPIC33CK DSC’s. The mathematical computations and transformations
are performed by the DSP engine, while the on-chip peripherals, such as PWM, SCCP, op amps, Comparator with DAC,
simplify the implementation and reduce the overall system components. The following figure shows the block diagram
of the solution.
PWM 1
3-Phase
PWM 2 Inverter Motor
Reference ADC17
FIRMWARE Bridge
Speed
PWM 3
Overcurrent Current Ia
Signal
ADC19 ADC0
CMP1
+ - +
OP-AMP1 Current
Temperature Sense Ia
Sensor
-
DAC
Current Ib
+
ADC1 OP-AMP2 Current
VBUS/16 ADC15 Sense Ib
-
Timer Hall A
Count Hall Sensors
State Hall B
SCCP3 GPIO
Hall C
For applications requiring precise control or high torque generation at low motor speeds, sensored control is preferred.
In the sensored FOC implementation, rotor position and speed are determined using an encoder, resolver or Hall effect
sensors. This application note describes the Hall sensor-based implementation with the target application in driving
electric scooter hub motors.
ʘref Iqref Vq Vɲ Ia
+- +- d,q
Inverse 3-Phase
PI PI Clarke Ib Motor
Inverter
Transform
Idref Vd Vɴ and SVM Bridge
+- Ic
ɲ,ɴ
PI
e Inverse
Park
Transform
Iq d,q Iɲ ɲ,ɴ
Id Iɴ
ɲ,ɴ A,B
Electrical
Position Park Clarke
(e) Transform Transform
Hall A
Position and Hall B
Speed (ʘ) Speed
Hall C
Software Hardware
FIGURE 4: FLOWCHART
The process of SVM allows the representation of any resultant vector by the sum of the components of the two adjacent
vectors. In the figure below, UOUT is the desired resultant. It lies in the sector between U60 and U0. If during a given
PWM period T, U0 is output for T1 / T and U60 is output for T2 / T, the resulting voltage for the period T will be UOUT.
T0 represents a time where no effective voltage is applied into the windings; i.e., where a null vector is applied. The
values for T1 and T2 can be extracted with no extra calculations by using a modified Inverse Clarke transformation. If
Vα and Vβ are reversed, a reference axis is generated that is shifted by 30 degrees from the SVM star. As a result, for
each of the six segments, one axis is exactly opposite that segment and the other two axes symmetrically bound that
segment. The timings of the vector components along those two bounding axes are equal to T1 and T2. The null vectors
are applied in the remaining time T0 of the switching period T.
Whenever the motor rotates, there is a Hall state change, which happens every 60 electrical degrees, the Change
Notification ISR (CN_ISR()) is serviced. Within the ISR, the Hall sensor’s state is read, and the rotor sector is calculated.
The interrupt event also measures the timer count of the SCCP Timer between subsequent interrupts.
The following figure illustrates the Hall states and its changes that trigger the interrupt events. The period calculation is
done by measuring the current timer count (ActualCapture) and subtracting it from the previous timer count
(PastCapture). The calculated period is filtered using the moving average filtering method. The moving average filtering
method is optimal for reducing random noise while maintaining a sharp response. It is done by getting multiple period
samples at a time, and taking the average of those to produce a single output point. The average period is used in
calculating the rotor position, while the raw calculated period is passed to the speed calculation routine.
The _90_Degrees_Phase_Offset keeps the stator and rotor flux at 90 degrees from each other. It is equivalent to 16384
and computed from the whole electrical angle rotation of 65536.
The time period measured between subsequent Hall sensor states is inversely proportional to the speed of the motor;
therefore, a proportionality constant is needed. The PHASE_INC_CALC is a constant that is used to compute the phase
increment from the average period.
From the equation above, the constant PHASE_INC_CALC is derived from dividing the SCCP Timer clock by the Timer
Prescaler and PWM switching frequency and multiplying the quotient by the equivalent phase value of 60-electrical
degrees. The phaseInc variable is computed from dividing the PHASE_INC_CALC by the average period. The phaseInc
value is used to increment the transformation angle in every ADC_ISR() cycle. The computed transformation angle
reflects the electrical angle at a distinct moment in time. The process continues until another change notification interrupt
event is serviced, and a new reference value is obtained. For a more elaborate illustration on the relationship among
the sector number, rotor sector phase value and transformation angle, see the diagram in the following figure.
The Period_Summation is a moving average summation that ensures that the calculatedSpeed will always be computed
after every six change notification interrupts. The calculatedSpeed is filtered using the moving average filter to ensure
that the measured speed is smooth and has no random noises.
The final output of the position and speed block are the measured speed and electrical angle that are fed to the PI control
blocks.
8.1 Shoot-through
It is a failure event when two complementary switches in a voltage source inverter are turned on simultaneously,
consequently short-circuiting the supply.
The PWM peripheral has the dead-time generator that is applied in both the rising and falling edges of the PWM signals
to prevent shoot-through. The dead time lasts for 1 µs, ensuring that discharge or turn-off delay time does not falsely
switch ON the complementary switches simultaneously.
Rearranging the previous formula in the previous equation leads to the following equation.
This Vtemp @ 25ºC is used as the reference voltage in which the change in voltage across the diode with the temperature
coefficient of -1.5 mV / ºC will be added or deducted depending on the rise or fall of the temperature. The new Vtemp is
computed using the following equation.
The stopping of the motor is an important consideration in controlling the electric scooter. Regenerative braking is an
additional feature used for speeding up the deceleration and extending the battery life.
1H 2H 3H
0 0 0
+ -
E
- E
+
+ - + E
-
Battery 1L 2L 3L
This switch configuration allows the converted electrical energy from the rotating motor to be boosted to a higher voltage
than the DC bus voltage. The second step in the process is turning off the low side switches, letting the current flow
back to the source through the MOSFET body diode, as shown in the following figure. The boosted voltage is, then,
stored back to the battery.
1H 2H 3H
0 0 0
+ -
E
- E
+
+ - + E
-
Battery 1L 2L 3L
• Microchip believes that its family of products is secure when used in the intended manner and under normal conditions.
• There are dishonest and possibly illegal methods being used in attempts to breach the code protection features of the Microchip
devices. We believe that these methods require using the Microchip products in a manner outside the operating specifications
contained in Microchip's Data Sheets. Attempts to breach these code protection features, most likely, cannot be accomplished
without violating Microchip's intellectual property rights.
• Microchip is willing to work with any customer who is concerned about the integrity of its code.
• Neither Microchip nor any other semiconductor manufacturer can guarantee the security of its code. Code protection does not
mean that we are guaranteeing the product is "unbreakable." Code protection is constantly evolving. We at Microchip are
committed to continuously improving the code protection features of our products. Attempts to break Microchip's code protection
feature may be a violation of the Digital Millennium Copyright Act. If such acts allow unauthorized access to your software or
other copyrighted work, you may have a right to sue for relief under that Act.