Tuesday, December 21, 2010

Permanent Magnet Synchronous Motor Control

Summary: 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.



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.
Figure 1: PMSM Control Block Diagram
Figure 1 (fig1.JPG)

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

Simulation

The simulation process will be based on a simulation model for the PMS Motor.
Figure 2: Permanent Magnet Synchronous Motor (PMSM) Simulink Model
Figure 2 (graphics3.png)
Based on this model, the simulation will comprise five steps as follows:
  1. Implementing the Forward Loop – Space Vector Generation
  2. Running the PMSM in open loop
  3. Closing the current loop
  4. The speed measurement-Encoder
  5. 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.
Figure 3: Space Vector Generation
Figure 3 (fig3.JPG)
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).
  1. 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;
  1. Open the PMS_Motor_level1 Simulink® model.
Figure 4: Space vector generation model
Figure 4 (graphics4.png)
Vd Testing
  1. Run the model and double-click the “Stator Current” and “Rotor Speed” scopes.
Figure 5: Stator Current
Figure 5 (graphics5.png)
Figure 6: Rotor Speed
Figure 6 (fig6.JPG)

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.
Figure 7: Open Loop
Figure 7 (fig7.JPG)
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
Figure 8 (graphics7.png)
Vd Testing
Figure 8: Open Loop Model
  1. Run the model and double-click the “Stator Current” and “Rotor Speed” (same as previous section) and “Vd/Vq” scopes.
Figure 9
Figure 9 (graphics8.png)
Ramp GeneratorVq Testing
Figure 9: Current Sensing
  1. 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.
Figure 10: Current Sensing
Figure 10 (fig10.JPG)
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.
Figure 11: Figure 11: Closing the Loop with the PI
Figure 11 (graphics9.png)
Vd Testing
  1. Run the model and double-click the “Stator Current” and “Rotor Speed” (same as previous section) and “Vd/Vq” scopes.
Figure 12: Stator Current
Figure 12 (fig12.JPG)
Figure 13: Rotor Speed
Figure 13 (Newgraphics11.png)
Ramp GeneratorVq Testing
Figure 14: Vd/Vq
Figure 14 (fig14.JPG)
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.
Figure 15: The Speed Measurement Encoder
Figure 15 (fig15.JPG)
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
    Figure 16 (graphics13.png)
  1. Run the model and double-click the “PWM dutycycles” and “Rotor Speed” scopes.
Figure 17: PWM Duty Cycles
Figure 17 (fig17.JPG)
Figure 18: Rotor Speed
Figure 18 (fig18.JPG)

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

Figure 19: Speed Closed Loop
Figure 19 (fig19.JPG)
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.
Figure 20: Hardware Setup
Figure 20 (fig20.JPG)
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.
  1. MAKE SURE that the potentiometer is around its midle position
  2. Generate the code in Simulink
  3. 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

  1. Turn OFF the PSU
  2. Halt the DSP: From the pull-down menu, “Debug” → “Halt”;
  3. Close the Model

Content actions

GIVE FEEDBACK:

No comments:

Post a Comment