<< Chapter < Page Chapter >> Page >

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.

Current Sensing

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: Closing the Loop with the PI

Vd Testing

  1. Run the model and double-click the “Stator Current” and “Rotor Speed” (same as previous section) and “Vd/Vq” scopes.
Stator Current

Rotor Speed
Ramp GeneratorVq Testing

Vd/Vq

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.

The Speed Measurement Encoder

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: Using the QEP
  1. Run the model and double-click the “PWM dutycycles” and “Rotor Speed” scopes.
PWM Duty Cycles
Rotor Speed

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

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.

Hardware Setup

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

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, From matlab and simulink to real-time with ti dsp's. OpenStax CNX. Jun 08, 2009 Download for free at http://cnx.org/content/col10713/1.1
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'From matlab and simulink to real-time with ti dsp's' conversation and receive update notifications?

Ask