Procedure of creating the vector control system of Permanent Magnet Synchronous Motor (PMSM)

SENSORLESS CONTROL OF SYNCHRONOUS MOTOR

This guide describes creation of control system for the permanent magnet synchronous motor (PMSM) step-by-step. An implementation of the control system using observer in sliding mode, determining the rotation angle of the motor shaft based on the stator voltages and currents feedback signals is shown.

The control system is created on basis of debugger kit Multi-Axis DMS EVM with control module Piccolo F28035 controlCARD produced by Texas Instruments under MexBIOS™Development Studio 2.14 environment for visual programming of digital signal processors (DSP).

The PMSM motor is powered by self-commutated voltage inverter. The control system is realized on processor TMS320F28035, which generates PWM-signals to form sin wave voltage in the stator of the motor. Signals from current and voltage sensors of the DC bus are input into the control system through ADC.

The vector control for a synchronous motor allows controlling the torque and rotor flux linkage vector independently as in a brushed DC motor.

Fig. 1. Functional diagram of the control system

 
 
STEP 1. SETTING-UP PROCEDURES
 
 
Installation of the software
  1. Start the installation package of MexBIOS™Development Studio 2.14 and follow installation instructions. After finishing the installation a shortcut for the software starting appears on desktop or in Start-menu.
  2. Start the installation package of TMS320F2803x library and follow the installation instructions. 

Fig. 2. Exterior view of Multi-Axis DMC EVM board with control module
 
Preparation of the kit hardware
Multi-Axis DMC EVM board should be preliminarily prepared:
  1. Make sure that all switches [M4]-SW1, [M4]-SW2 and [M4]-SW3 are in position «Off».
  2. Make sure that jumper [M4]-J1 is in position «En».
  3. Make sure that jumper block [Main]-J5 has three jumpers and [Main]-J6 has three jumpers.
  4. Make sure that jumper [Main]-J7 is in position «DCbus-FB».
  5. Connect the control module with processor TMS320F28035 to the board.
  6. Connect the motor by power leads (yellow, red, black) to terminals W, V, U of connector [Main]-TB1 respectively.
  7. Power up the connector [M4]-JP1 by supply voltage 24 V. Switches [M4]-SW1, [M4]-SW2 should be in position «Off».
  8. Switch over the [M4]-SW3 into position «On» to apply the supply to microcontroller. An external power source can be connected to connector Axis-12 V, if needed. In microcontroller board under such conditions the light emitting diode LD1 should light up.
  9. Connect USB cable to connector [M1]-JP1. Light emitting diode [M1]-LD1 in the board should start lighting.  The kit is ready for further use.
 

 
Fig. 3. The board wiring 
 
NOTE: If a driver installation dialog box appears, try to wait for the driver’s automatic installation. If the driver will not be found in computer, then the driver CDM20814 WHQL Certified should be installed.
 
 
STEP 2. CREATING STARTUP PROJECT
 
 
In this step the motor is not connected to the power supply ([M4]-SW1 and [M4]-SW2 are in position «Off»). To create the startup project that allows receiving signals from development kit the instructions are given below.
NOTE: All blocks, used in the circuit, are computed in format Q24.
  • Start MexBIOS™Development Studio 2.14.0.8.
  • Under main menu item New create a file - project based on TMS320F2803x library. In appeared dialog box «Save changes?» select «No».

Fig. 4
 
  • In the new empty project for processor TMS320F2803x go to Dataflow inlay.
  • Creation of signaling circuit (by blinking of the LED that is connected to GPIO34 output)
  1. Drag to Workspace a block of square wave generator QG_RECT from Palette Palette→TMS320F2803x→Sources. In the block settings set parameter Offset = 0.5.
  2. Add three IN blocks from the same group in palette, connect them to QG_RECT block to inputs Ampl, Freq, Reset, set 0.5, 10, 0 respectively.
  3. Add a GPIO block from palette Palette→TMS320F2803x→Drivers. In block properties set Type = 1, Pin = GPIO34, Value = 1. Finally we get the circuit shown in Fig. 5.

Fig. 5. Signaling circuit
 
  • Creation of layers
Go to Layers inlay and add four additional outputs to TMS320F2803x Layer1. To Task output background tasks are connected that are not critical to cycling of computing or are computationally intensive. For example, processing of Modbus frames.

Fig. 6. Setting the layers
 
The existing layers are intended for:
  1. ISR_ADC – signal processing in ADC;
  2. ISR_Current – current loop blocks;
  3. ISR_Speed – speed loop blocks. For this layer set parameter Prescaler = 5. The speed loop will be running at frequency 10 kHz/5 = 2 kHz;
  4. ISR_Hint – signaling blocks.
Such division is conditioned by the layer execution order. Firstly main layer Layer1 is executed, then all additional layers starting from the upper layer. Current feedback sensor signals are processed before inputting the signals into control loop.
  • You can create subsystem Hint, place the developed signaling system in it. Move all blocks of the signaling into ISR_Hint layer.
  • Save the project under arbitrary name, for example,  File: PMSM_1.mbs.
  • ADC setting
  1. Add ADC block from palette Palette→TMS320F2803x→Drivers – ADC. 
  2. For first inverter (Motor 1) the settings are as shown in Fig. 7.
  3. Add two GAIN blocks from palette Palette→TMS320F2803x→Math to ADC block outputs to scale the ADC signals. In blocks properties set parameters Gain = 1, Offset = 0.
  4. Add two OUT blocks from palette Palette→TMS320F2803x→Sources to GAIN blocks output for displaying the currents form in Watch Window.
  5. Move the blocks to ISR_ADC layer.
  6. Add the SUBSYSTEM block from palette Palette→Embedded.
  7. Add the CLARKE transform block from palette Palette→TMS320F2803x→Motor Control.
  8. Add two outputs SUBOUT for Subsystem from palette Palette→Embedded.
  9. Place the signal processing blocks with ADC into SUBSYSTEM, as shown in Fig. 8.
  10. In GAIN blocks the necessary parameters Gain и Offset (see further) should be set.

Fig. 7. ADC block setting

Fig. 8. ADC subsystem
 
  • Add the PWM enable control. To do so, you must add blocks IN and GPIO, where set parameters Type = 1, Pin = 32: GPIO32, Value = 1.
  • Add PWM block from palette Palette→TMS320F2803x→Drivers. Set parameters: number of inverter used (Id: 0 – for first motor Motor 1; 1 – for second motor Motor 2), PWM frequency Frequency = 5000 Hz and define property SocPulse 1:True, that is needed for matched operation of PWM and ADC.
Validation of circuit
 
Load the project. To load the project you need to:
  • Connect USB cable to the kit. 
  • After the device identification in the device manager find the  assigned COM-port number. If the port number is greater than 10, assign another number for the port, which should be less than 10.

Fig. 9. Port identification
 
  • In software, in Device inlay, by clicking button Connection settings  select port, to which the device is connected (see Fig. 10). Apply the settings by clicking OK.

Fig. 10. Connection settings
 
  • Click the button  that starts connection to the device. When the connection is successful and there is no configuration file in the microcontroller memory a message: MBS: Configuration is missing or corrupted is displayed. The connection icon for completed connection turns into .
  • Click the button  for project loading into RAM. At first project loading a Save dialog box for *.bin file appears. The loading process will be displayed in progress bar.
  • After successful loading a message: Successful done appears. If all actions were fulfilled correctly, the LED (LD2) in microcontroller board starts blinking with preset frequency.
If the ADC has correct settings and correct voltage offset adjustment the ADC output will have signal that fluctuates near zero.
 
NOTE: The ADC settings are: selection of ADC channels, setting the Prescaler property and number of channels. If PWM driver generates enabling signal in the ADC the source of the enabling signal is set (see above). 
 
Offset choice is carried out by the following technique: 
  • Add GAIN blocks from palette Palette→TMS320F2803x→Math for each channel used;
  • Start the data exchange to the device (click button );
  • Add outputs OUT from ADC to Watch Window, add also add the GAIN blocks to Watch Window (select the blocks, then right-click one of the selected blocks, and choose Add to watch in the drop-menu, or press button [F4] after the blocks are selected);
  • Assign Monitor channels Ch1 and Ch2 to ADC outputs;

Fig. 11. Assigning Monitor channels
 
  • Call the Monitors window by clicking ;
  • Go to TMS320F2803x inlay and add a monitor by clicking ;
  • Set number of points and time between first and last samplings that are needed to be displayed as a graph in monitor;

Fig. 12. Adding monitor
 
  • Mean value, near which the ADC signal is fluctuating, is written to parameter Offset of GAIN block;

Fig. 13. ADC setting
 
  • If output signals from GAIN blocks are fluctuating near zero, the offset is set correctly; you can save the determined gains in parameters of GAIN blocks.
Save the project.

Fig. 14. Result of first and second setting steps
 
 

STEP 3. SCALAR CONTROL SYSTEM

 

In this step the coordinate transformation blocks and PWM driver will be added. The motor will be operating in open loop control mode. 

  • Save the file, which you get in previous step, under another name.
  • Add the inverse Park transformation IPARK from palette Palette→TMS320F2803x→Motor Control (further all blocks are from this group).
  • Add ramp generator RAMPGEN. The block parameters are BaseFreq = 50 Hz, Gain = 1, Offset = 0.
  • Add linear rate generator RMP_CNTL. The block parameters are RampDelayMax = 0, RampLowLimit = -1, RampHighLimit = 1 , DeltStep = 0.0001.
  • Add two IN blocks. Connect them to the blocks inputs RMP_CNTL and IPARK.
  • Add SVGEN_DQ block.
  • Add PWM block from palette Palette→TMS320F2803x→Drivers. Select the inverter used (Id, 0 – for first motor Motor 1; 1 – for second motor Motor 2), set PWM frequency Frequency = 5000 Hz. Define parameter SocPulse 1:True, which is needed for matched operation of PWM and ADC. 

Fig. 15. Setting parameters of PWM driver

  • Place all these blocks into ISR_Current inlay. Set execution order in Layer Inspector according to direction of signal flow from IN block to PWM block.

The resulted circuit looks like the one shown in Fig. 16.

Fig. 16. Circuit of scalar control system

Validation of the circuit

  • Power up the inverter (switches [M4]-SW1 and [M4]-SW2 set in position «On»).
  • Connect the computer to the kit. Start the project.
  • Add PWM enable input PWM_en to Watch Window and set its value equal to «1» (enable PWM). If all is done correctly, then the motor starts rotating. 

NOTE: In scalar control mode high currents are flowing in stator circuit of synchronous motor, therefore big references are not recommended to apply to input of IPARK transformation block (start from 0.1 to get stable rotation of motor and sine wave currents in stator winding). The operation time of motor in scalar mode should not be long.

  • Measure current by means of current clamp. Choose required scaling factors in GAIN blocks.
  • ADC signals after scaling gains should have 120° shift to each other.
  • Signals after inverse Park transform (IPARK) should be 90° shifted, and for positive reference at RAMPGEN block the Alpha component should lead Beta component, as it is shown in fig. 17.

Fig. 17. Alpha component leads Beta component

  • The current Ialpha form should lag behind the voltage Ualpha form for torque angle of synchronous motor.
  • The curent Ibeta form should lag behind the voltage Ubeta form for the same angle.

Fig. 18. Signals Ualpha and Ialpha, Ubeta and Ibeta

If the above mentioned conditions are true, you can go to following step of creation of vector control system.

  • Save file. Set switch [M4]-SW2 in position «Off».

 

STEP 4. VECTOR CONTROL SYSTEM WITH FORCED ORIENTATION OF ROTOR FLUX LINKAGE VECTOR

 

In this step the current sensors polarity will be checked, Park transform and the current PID-regulators will be added and the vector control system with forced orientation of rotor flux linkage vector will be created.

  • Save the file under new name.
  • Add two PID-regulators (PID) from palette Palette→TMS320F2803x→Regulators&Filters.
  • Setting the PID-regulators corresponds to the used motor type. For brushless DC motor BLY172S 24 4000 one of the setting version is shown in fig. 19.

Fig. 19. Setting PID-regulators

 

  • Add the Park transform block (PARK) from palette Palette→TMS320F2803x→Motor Control.
  • Move the added blocks to layer ISR_Current, Set the blocks execution order in Layer Inspector according to direction of signal flow.

Fig. 20. Placing the blocks execution order in layer ISR_Current 

  • The result circuit looks like one shown in fig. 21.

Fig. 21. Control circuit with forced orientation of the rotor flux linkage vector

Validation of circuit

  • Connect the computer to the kit.
  • Set switch [M4]-SW2 in position «On».
  • Load the project into the microcontroller memory.
  • With stalled motor shaft vary the current references for regulators PID1 and PID2. The references will be processed and displayed in outputs oId, oIq.
  • With «0» reference in both current  vector components the motor shaft should be rotated freely by hand.

If the above mentioned conditions are not met, the causes could be the following:

  1. ADC is set incorrectly (incorrect offset and scaling factors were selected);
  2. phases Alpha and Beta were selected incorrectly in previous step;
  3. the current sensors location is set incorrectly (please check connection of SVGEN_DQ to PWM driver).
  4. Save file. Set switch [M4]-SW2 to position «Off».

 

STEP 5. SIMULATION OF VECTOR CONTROL SYSTEM OF SYNCHRONOUS MOTOR

 

In this step the model of synchronous motor will be added, the vector control system will be simulated and the function Smopos of determining the rotation angle of flux linkage vector will be tuned.

 

Current loop

  • Save file under new name.
  • For the circuit compactness place blocks SVGEN_DQ and PWM into subsystem SV_PWM, and after that you need to restore the blocks execution order in Layer inspector.
  • Add the motor model PMSM_ab from palette Palette→Models→Motor Control.
  • Add blocks IQTOF (converters of signal format into Float) and SCALE from palette Palette→Models→Math.
  • Add blocks FTOIQ (converters of signal format into IQ).
  • Assemble the circuit shown in fig. 22.

Fig. 22. Model of closed loop control system of PMSM

  • In blocks SCALE, SCALE1 in parameter Gain set the gain value of the frequency converter for the developed control system. In this case Gain=24.
  • In blocks SCALE2, SCALE3 in parameter Gain set the current feedback gain (Gain=0.1). 
  • Insert parameters of the motor model PMSM_ab, as it is shown in Fig. 23.

Fig. 23. Parameters of motor BLY172S 24 4000

  • Disconnect subsystem ADC from PARK transform.
  • Connect the blocks FTOIQ outputs to corresponding inputs of PARK transform (Alpha ← ia, Beta ← ib).
  • In parameters of the motor model set Brake = 1 – for stalling the motor shaft to check the operation of the current loop.
  • Add square-ware generator QG_RECT  from palette Palette→TMS320F2803x→Sources to check the current loop and add IN blocks to set the reference parameters. In Layer Inspector set the blocks execution order for Layer1.
  • Save file.
  • Open Simulations inlay in the software main menu.
  • Set simulation time. Setting Time = 0 is equivalent to setting the infinite simulation time Time = inf.
  • Add the observable variables to Watch Window.
  • OUT blocks can be used as visual component in plotting mode of the processed value. To do so you need to:
  • Right-click the block. 
  • Select Control in drop-down menu, then select Graph.
  • Start simulation by clicking  button.
  • The result looks like the circuit shown in Fig. 24.

Fig. 24. Tuning the current loop in simulation mode

At simulation starting and changing the reference value Ampl of QG_RECT block the change in output value of current should be observed.

Fig. 25. Transients in current loop during simulation

  • Save file.

 

Speed loop

  • Save file under new name.
  • Add FTOIQ, SCALE blocks from palette Palette→Models→Math. Connect them to output wr of the motor. Set the speed feedback gain (Gain = 0.0025) into parameter Gain of SCALE block.
  • Add FTOIQ block and connect it to input theta of the motor model.
  • Output of FTOIQ block connect to inputs theta of coordinate converters IPARK and PARK.
  • Add PID-regulator PID from palette Palette→TMS320F2803x→Regulators&Filters. Move it into layer ISR_Speed.
  • Set parameters of PID-regulator shown in Fig. 26.

Fig. 26

The assembled circuit is shown in Fig. 27.

Fig. 27. Simulation model of speed loop

  • Start simulation. While changing the reference at input of the speed PID-regulator the motor speed should also change, as the system will work off the reference value, as it is shown in Fig. 27.
  • Save file.

 

SMOPOS function

  • Add SMOPOS block from palette Palette→Models→Motor Control. Place it in layer ISR_Current and set the block parameters as it is shown in Fig. 28.

Fig. 28. The SMOPOS block parameters

  • Connect OUT block to theta output of the motor after FTOIQ block and add it to Watch Window.
  • Connect the SMOPOS block according to the inputs labels, as it is shown in Fig. 29.

Fig. 29. Simulation model of closed loop speed control system with SMOPOS function

  • Start simulation and compare the signals of rotation angle from the motor model and SMOPOS block.

Fig. 30. Rotation angle of the motor shaft from motor model and SMOPOS function at reversing 

As you can see in fig. 30, the computed position angle coincides practically with the position angle from mathematical model of the motor. 

  • Save file.

 

STEP 6. EMULATION OF VECTOR CONTROL SYSTEM OF SYNCHRONOUS MOTOR

 

In this step the motor will start operating with sensorless control system.

 

  • Connect the current feedback to subsystem ADC.
  • Connect theta input of coordinate converters to theta output of SMOPOS block.
  • Add speed estimation block SPEED_EST from palette Palette→TMS320F2803x→Motor Control, place it into layer ISR_Speed.
  • Set the block parameters as it is shown in Fig. 31.

Fig. 31. The SPEED_EST parameters

  • Close the speed feedback through SPEED_EST.
  • Add a linear rate generator RMP_CNTL with parameters shown in Fig. 32.

Fig. 32. RMP_CNTL parameters

  • Connect the computer to the kit.
  • Set switch [M4]-SW2 in position «On».
  • Load the project.
  • Enable PWM generation.
  • The motor starts rotating with speed preset in IN4 block.

Fig. 33. Changing the circuit for emulation

  • The rotor position observer can not operate correctly at slow speed, therefore at reversing the motor shaft sticking, oscillations etc. can occur. When the motor is stuck, you should at zero speed set PWM_en to «1» then reset it to «0».
  • By means of monitor you can observe all main coordinate of the electric drive, for example, Alpha, Beta currents, Theta angle from SMOPOS block, as it is shown in Fig. 34,  35.

Fig. 34. Transients of currents and computated rotor position angle

Fig. 35. Speed transients for sensorless control, the speed is obtained from SPEED_EST block

Let’s convert the ready circuit to more compact one and add visual components, as it is shown in Fig. 36.

Fig. 36. Sensorless control system of PMSM under MexBIOS™Development Studio 2.14 environment

  • Save file.
  • After finishing the work please set switches [M4]-SW1, [M4]-SW2 and [M4]-SW3 into position «Off».