Sensorless Field-Oriented Control of PMSM Using DC Shunt Current Sensing
This example shows how to implement sensorless field-oriented control (FOC) using only a single DC bus-based current measurement to run a permanent magnet synchronous motor (PMSM).
The Field-Oriented Control (FOC) algorithm needs precise position and three-phase current feedback to follow a motor reference speed accurately. Accurate current sensing helps minimize torque ripple, and therefore, enhances dynamic performance of the motor with minimum audible noise.
You can measure the three-phase currents of a motor using the following three methods:
Inline current sensing
Inverter leg current sensing
DC bus (single shunt) current sensing
The following image shows the current sensing regions in an inverter circuit for each of these methods.
The example uses the sensorless Extended EMF Observer block to estimate the motor position. Instead of using inline current sensing or inverter leg sensing, this example utilizes DC bus (single shunt) current sensing to determine the three-phase motor currents.
The example uses only one shunt resistance for measuring motor currents (instead of two or three resistances used by the other techniques). Therefore, it uses only a single analog to digital converter (ADC) for current measurement, and thereby, reduces production costs effectively by reducing the number of hardware peripherals.
DC Bus Current Sensing
The FOC current controller uses the computed rotor position as well as measured motor currents to compute the three-phase voltages required for the motor to follow a given reference speed. The controller converts these three-phase voltages into pulse width modulation (PWM) duty cycles that operate the six inverter switches.
To generate PWM duty cycles, the current controller in the example model uses a 20 kHz triangular carrier waveform (with sampling time of 50 microseconds) and generates three pulse trains that operate the inverter switches as shown in the following figure.
The controller operates the inverter in a complementary mode. The pulse that controls the lower transistor in an inverter leg is always opposite to the one controlling the upper transistor.
Therefore, the upper-transistors of a three-phase inverter can have eight switching states (for space vector modulation PWM) described in the following table.
By operating the switches, the PWM pulses energize the three motor phases appropriately to generate the three-phase voltages.
Based on the sequence of duty pulse duration of three motor phases, you can define six sectors. For example, the following figure shows a sector (phase a duty duration > phase b duty duration > phase c duty duration). It shows how during a PWM cycle, these three duties for the three motor phases, switch ON the three inverter leg switches for different durations.
In the preceding example of PWM cycle, the three inverter leg switches show the following states.
For switching state 1 in the above figure, the switches operate as following:
Switch A1 is ON.
Switch B1 is OFF.
Switch C1 is OFF.
The DC bus or single shunt current measurement method only measures the current in the DC shunt.
From the preceding figure, you can infer that the DC shunt current is equal to +Ia during this switching state.
Similarly, for switching state 2, the switches operate as following:
Switch A1 is ON.
Switch B1 is ON.
Switch C1 is OFF.
From the preceding figure, you can infer that the DC shunt current is equal to -Ic during this switching state.
Therefore, for this PWM cycle, by measuring DC shunt current during two relevant switching states (state 1 and 2), you can determine currents for two motor phases (in this example, you determined Ia and Ic). Because the example assumes a balanced system, the algorithm computes the third phase current mathematically for each PWM cycle.
Ib = - (Ia + Ic)
Similarly, other sectors have a different sequence of switching states. You can determine the motor phase currents from the measured value using the following table.
For each PWM cycle, the example samples thrice (at each falling edge of three PWM pulses corresponding to each motor phase). Based on the two relevant switching states identified for the applicable sector, the example selects the two values that help determine two of the phase currents.
Note: The example uses measurements at falling edge switching states. However, you can measure DC shunt current at both rising and falling edge switching states.
The algorithm then mathematically calculates the third phase current.
PWM Phase Shift Compensation
During some PWM cycles, any two phases may have identical duty ratios (or duty values that are close to each other). In such scenarios, the example can determine only one of the motor phase currents and cannot determine all three phase currents. The following figure shows such a PWM cycle.
To overcome this limitation, the current measurement algorithm shifts the PWM pulses. Using this compensation, the example algorithm can determine two phase currents using which it eventually determines the third phase current mathematically.
The following figure shows an example of the applied compensation.
Model
This example includes the PMSMFocSensorlessDCShuntCurrentSenseF28069m Simulink® model.
You can use this model for both simulation and code generation.
Required MathWorks Products
To simulate model:
Motor Control Blockset™
Simscape Electrical™
To generate code and deploy model:
Motor Control Blockset
Embedded Coder®
C2000™ Microcontroller Blockset
Prerequisites
1. Obtain the motor parameters. The Simulink model uses default motor parameters that you can replace with the values from either the motor datasheet or other sources.
However, if you have the motor control hardware, you can estimate the parameters for the motor that you want to use, by using the Motor Control Blockset parameter estimation tool. For instructions, see Estimate PMSM Parameters Using Recommended Hardware.
The parameter estimation tool updates the motorParam
variable (in the MATLAB® workspace) with the estimated motor parameters.
2. If you obtain the motor parameters from the datasheet or other sources, update the motor parameters and inverter parameters in the model initialization script PMSMFocSensorlessDCShuntCurrentSenseF28069mData associated with the Simulink models. For instructions, see Estimate Control Gains and Use Utility Functions.
If you use the parameter estimation tool, you can update the inverter parameters, but do not update the motor parameters in the model initialization script. The script automatically extracts motor parameters from the updated motorParam workspace variable.
Simulate Model
This example supports simulation. Follow these steps to simulate the model.
1. Open a target model included with this example.
2. To simulate the model, click Run on the Simulation tab.
3. To view and analyze the simulation results, click Data Inspector on the Simulation tab.
Generate Code and Deploy Model to Target Hardware
This section instructs you on how to generate code and run the sensorless extended EMF observer based FOC algorithm on the target hardware.
This example uses a host and a target model. The host model is a user interface to the controller hardware board. You can run the host model on the host computer. The prerequisite to use the host model is to deploy the target model to the controller hardware board. The host model uses serial communication to command the target Simulink model and run the motor in closed-loop control.
Required Hardware
This example supports the following hardware configuration.
F28069M controller card + DRV8312-69M-KIT inverter: PMSMFocSensorlessDCShuntCurrentSenseF28069m
For connections related to the preceding hardware configuration, see F28069 control card configuration.
Generate Code and Run Model on Target Hardware
1. Simulate the target model and observe the simulation results.
2. Complete the hardware connections.
3. The model automatically computes the ADC or current offset value. To disable this functionality (enabled by default), update the value 0
to the variable inverter.ADCOffsetCalibEnable
in the model initialization script.
4. Open the target model for the hardware configuration that you want to use. If you want to change the default hardware configuration settings for the model, see Model Configuration Parameters.
5. Click Build, Deploy & Start on the Hardware tab to deploy the target model to the hardware.
6. In the target model, click the host model hyperlink to open the associated host model.
For more information on serial communication between the host and target models, see Host-Target Communication.
7. In the model initialization script PMSMFocSensorlessDCShuntCurrentSenseF28069mData associated with the target model, specify the communication port using the variable target.comport
. The example uses this variable to update the Port parameter of the Host Serial Setup, Host Serial Receive, and Host Serial Transmit blocks available in the host model.
8. Update the Reference Speed value in the host model.
Note
* Before you run the motor at the required Reference Speed, start running the motor at 0.1
x pmsm.N_base speed by using open-loop control. Then transition to closed-loop control by increasing the speed to 0.25
x pmsm.N_base (where, pmsm.N_base is the MATLAB workspace variable for the base speed of the motor).
* High acceleration and deceleration may affect the sensorless position computation.
9. Click Run on the Simulation tab to run the host model.
10. Change the position of the Motor switch to On, to start running the motor in the open-loop condition (by default, the motor spins at 10% of base speed).
Note: Do not run the motor (using this example) in the open-loop condition for a long time. The motor may draw high currents and produce excessive heat.
The open-loop control algorithm used in this example runs the motor with Reference Speed that is less than or equal to 10% of the base speed.
When you run this example on the hardware at low Reference Speed, due to a known issue, the PMSM may not follow the low Reference Speed.
11. Increase the motor Reference Speed beyond 10% of the base speed to switch from open-loop to closed-loop control.
Note: To change the direction of rotation of the motor, reduce the motor Reference Speed to a value less than 10% of the base speed. This brings the motor back to the open-loop condition. Change the direction of rotation by providing a negative Reference Speed (keeping the Reference Speed magnitude identical). Then, transition to the closed-loop condition.
12. Observe the debug signals from the Serial Communication subsystem in the scope available in the host model.