Introduction
The objective of this module is to use the Embedded Target for the C2000, and the Digital Motor Control Library (DMClib) to control a Permanent Magnet Synchronous Motor (PMSM) with an encoder using the Field Oriented Control Technique.
System Overview
The following figure shows the complete application that we will implement step by step during the laboratory.
Variables Description
ias = Phase-a stator current ibs = Phase-b stator current ias = Stationary a-axis stator current ibs = Stationary b-axis stator current ids = Synchronously rotating d-axis stator current iqs = Synchronously rotating q-axis stator current vas = Stationary a-axis stator voltage vbs = Stationary b-axis stator voltage vds = Synchronously rotating d-axis stator voltage vqs = Synchronously rotating q-axis stator voltage vdc = DC-bus voltage qlr = Rotor flux angle qm = Mechanical angle dir = Rotor direction wr = Rotor speed Ta = Phase-a duty cycle ratio of PWM signal Tb = Phase-b duty cycle ratio of PWM signal Tc = Phase-c duty cycle ratio of PWM signal
Related Files
- Powerpoint Presentation - PMSM_control.ppt
- MATLAB script- PMS_Motor_data.m
- Simulink Model for Space vector generation Simulation - PMS_Motor_level1.mdl
- Simulink Model for Open Loop Simulation - PMS_Motor_level2.mdl
- Simulink Model for current loop Simulation - PMS_Motor_level3.mdl
- Simulink Model for Encoder Verification Simulation - PMS_Motor_level4.mdl
- Simulink Model for Closed Loop Simulation - PMS_Motor_level5.mdl
- Simulink Model for Space vector generation - Real Time PMS_Motor_level1eZDSPF2812.mdl
- Simulink Model for Open Loop - Real Time - PMS_Motor_level2eZDSPF2812.mdl
- Simulink Model for current loop - Real Time - PMS_Motor_level3eZDSPF2812.mdl
- Simulink Model for Encoder Verification - Real Time - PMS_Motor_level4eZDSPF2812.mdl
- Simulink Model for Closed Loop - Real Time PMS_Motor_level5eZDSPF2812.mdl
Simulation
The simulation process will be based on a simulation model for the PMS Motor.
Based on this model, the simulation will comprise five steps as follows:
- Implementing the Forward Loop – Space Vector Generation
- Running the PMSM in open loop
- Closing the current loop
- The speed measurement-Encoder
- The Speed Closed Loop
Space vector generation
The diagram below highlights the modules used in the first step. This first incremental step confirms operation of peripheral and target independent modules on forward control path and the code framework.
At this very first stage the goal is to generate a saw–tooth waveform with a varying frequency. This waveform is an emulation of the rotor angle, which is then passed into the Park transformation allowing us to check the correct computation of the Space Vector PWM needed for the Field Oriented Control.
Key Modules
- RMPCNTL (ramp control): this module used by the instantiation of the object rc1, structure for which we can access each variable, controls the acceleration and deceleration rate of the speed command speed_ref .This speed command is passed the input of the RMPCNTL module rc1.target_value. The output of this module is called rc1.setpt_value which represents the frequency of the saw-tooth we want to generate.This frequency information is then passed to the ramp generator module.
- RAMPGEN (ramp generator): to use this module, we instantiate an object rg1. The input of this module is rg1.rmp_freq . The rotating angle we generate (saw-tooth waveform) is rg1.rmp_out. This angle is then used for the Inverse PARK transformation.
- IPARK (Inverse Park Transformation): instance ipark1. Computed rotating angle is passed into the ipark1.ang variable. The d and q inputs to the inverse Park transformation control the command magnitude via the variables ipark1.de and ipark1.qe.
- SVGENDQ (Space Vector Generation): instance svgen_dq1. This module takes the output of the IPARK module and calculates the modulation to be applied on the duty cycle of the three pairs of PWM connected to the three phases inverter bridge (svgen_dq1.Ta, svgen_dq1.Tb and svgen_dq1.Tc).
- PWMGEN (Pulse Width Modulation Generation driver): this modules is the only one linked to the DSP peripherals. Duty-cycles previously calculated are passed into the DSP PWM registers via the instant pw1. PWMGEN takes care of the DSP PWM initialization (timer set-up, PWM polarity and so on).
- Run the PMS_Motor_data M-file. This file initializes the following variables:
%Mechanical system %Electrical part DC_voltage = 200; encoder_resolution = 2000; %PWM freq_max=75e6; %Controller Ts=5e-5;
- Open the PMS_Motor_level1 Simulink® model.
Vd Testing
- Run the model and double-click the “Stator Current” and “Rotor Speed” scopes.
Running the PMSM in open loop
The purpose of this step is to simulate open–loop operation with power-stage and motor connected and to check out current sensing and feedback path.
Key Modules Used for this level
In addition to the modules used in the previous section, we now start to build the feedback loop using:
- ILEG2DCBUSMEAS_VCON (current leg and DC bus measurement): This module initializes the ADC to start automatic conversions of channels selected by the user on timer 1 underflow. ADC conversion results are automatically formatted and stored into dedicated variables.
- CLARKE (Clarke transform module): This module converts the measured current into CLARKE coordinates in the reference frame (α, β).
- PARK (Park Transformation): This module converts the (α, β) coordinates into two DC quantities.
- Open the PMS_Motor_level2 Simulink model.
Figure 8: Open Loop Model
- Run the model and double-click the “Stator Current” and “Rotor Speed” (same as previous section) and “Vd/Vq” scopes.
Figure 9: Current Sensing
- Now you may change the values of Vd and Vq, and check how it influences the graphs above.
Closing the current loop
The purpose of this step is to close the current loop and to set the PI regulators correctly to get a stable system while the motor is still running in speed open-loop.
Key Modules:
In addition to the modules already used, we use the PI module:
- PIDREG3 (Proportional Integrator Derivative regulator): This module regulates the two currents id and iq, generated in the Park module.
- Open the PMS_Motor_level3.mdl Simulink model.
Vd Testing
- Run the model and double-click the “Stator Current” and “Rotor Speed” (same as previous section) and “Vd/Vq” scopes.
For ease of use, the default PID parameters are already tuned. You can still play with them and observe the results. Within the watch windows, the PID coefficients are displayed for both iq and id. Using the following picture will help you to interpret the variables.
The Speed measurement-Encoder
During this step we will check the encoder feedback and we will align the calculated angle with the shaft angle.
KEY MODULES:
In addition to the modules already used, we use:
- QEP (Quadrature encoder pulse module): instance qep1. This module initializes the QEP DSP unit. This involves the associted timer (T2) set-up, the QEP DSP pins set-up and so on. Calling the initialization routine of the QEP module, the dedicated DSP registers are automatically configured with no waste of time for the user in reading through the documentation. This module outputs an electrical angle stored into the qep1.theta_elec variable which is then passed into the speed calculator module. The encoder mounted on the motor is a 2000 lines encoder. In addition to the traditional QEP signals (QEP1 and QEP2), it provides an index pulse, which toggles every complete mechanical round. This index is connected to the capture interrupt 3 of the DSP. In the corresponding served interrupt, we clear the timer 2 counter ensuring to keep it between 0 and 8000: this way we have a precise information on the rotor position. The QEP module also takes care of the capture unit initialization.
- SPEED_MEAS_QEP (Speed measurement based on QEP information): instance speed1. Based on system information (number of poles pairs for instance), this module outputs the motor speed information.
- Open the PMS_Motor_level4 Simulink model.
Figure 16: Figure 16: Using the QEP
- Run the model and double-click the “PWM dutycycles” and “Rotor Speed” scopes.
Align the sensed angle we the motor shaft.
Until now, the magnetic field in the motor was generated without taking care of the shaft position. Even if our motor is a synchronous motor, with no load and at load speed, it was easy to expect the shaft to start and to catch the magnetic field without problem. Now, if we want to close the speed loop, we need to know the shaft angle at every moment. The shaft position is given by the encoder but we still have to align the initial sensed position with the shaft.
For this, we use the Data Log module to display in real time the rmp_out variable (angle we used until now to create the magnetic field) and theta_elec (sensed angle).
Speed Closed Loop
The purpose of this step is to verify the speed regulator, close the speed loop and tune up the gains for the speed regulator if necessary. All the modules previously described are used in this final step.
Real Time
The real-time software will run in the following hardware:
- eZdsp F2812 (DSP control board based on the F2812)
- DMC 550 (power stage board for BLDC and PMSM from Spectrum Digital®)
- PMSM from Applied Motion Product ®
For safety reason it is mandatory that you strictly respect the following picture to connect the DMC 550.
During this build, the speed reference will be given to the DSP through a potentiometer placed on the DMC 550 (R66). To start with, please put the potentiometer around its midle position.
- MAKE SURE that the potentiometer is around its midle position
- Generate the code in Simulink
- Turn ON the PSU and set the voltage to 10V.
The motor should have good response time now thanks to the speed closed loop. As usual the PID controller is already tuned. Using the same graphical display we used during the lab 4 you can see the impact of the PID parameters.
Since all the kits are different, the default settings for the current and speed PID may not be suitable and the maximum command may be instable
Moving the speed potentiometer, you can appreciate the fast and smooth response time!
To Stop the system properly
- Turn OFF the PSU
- Halt the DSP: From the pull-down menu, “Debug” → “Halt”;
- Close the Model
2 comments:
Adaptive PID Speed Control Design for
Permanent Magnet Synchronous Motor Drives
simulation code of Adaptive PID Speed Control Design for
Permanent Magnet Synchronous Motor Drives
Post a Comment