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
- 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.
- Start the installation package of TMS320F2803x library and follow the installation instructions.
- Make sure that all switches [M4]-SW1, [M4]-SW2 and [M4]-SW3 are in position «Off».
- Make sure that jumper [M4]-J1 is in position «En».
- Make sure that jumper block [Main]-J5 has three jumpers and [Main]-J6 has three jumpers.
- Make sure that jumper [Main]-J7 is in position «DCbus-FB».
- Connect the control module with processor TMS320F28035 to the board.
- Connect the motor by power leads (yellow, red, black) to terminals W, V, U of connector [Main]-TB1 respectively.
- Power up the connector [M4]-JP1 by supply voltage 24 V. Switches [M4]-SW1, [M4]-SW2 should be in position «Off».
- 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.
- 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.
- Start MexBIOS™Development Studio 126.96.36.199.
- Under main menu item New create a file - project based on TMS320F2803x library. In appeared dialog box «Save changes?» select «No».
- 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)
- 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.
- 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.
- 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.
- Creation of layers
- ISR_ADC – signal processing in ADC;
- ISR_Current – current loop blocks;
- 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;
- ISR_Hint – signaling blocks.
- 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
- Add ADC block from palette Palette→TMS320F2803x→Drivers – ADC.
- For first inverter (Motor 1) the settings are as shown in Fig. 7.
- 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.
- Add two OUT blocks from palette Palette→TMS320F2803x→Sources to GAIN blocks output for displaying the currents form in Watch Window.
- Move the blocks to ISR_ADC layer.
- Add the SUBSYSTEM block from palette Palette→Embedded.
- Add the CLARKE transform block from palette Palette→TMS320F2803x→Motor Control.
- Add two outputs SUBOUT for Subsystem from palette Palette→Embedded.
- Place the signal processing blocks with ADC into SUBSYSTEM, as shown in Fig. 8.
- In GAIN blocks the necessary parameters Gain и Offset (see further) should be set.
- 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.
- 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.
- 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.
- 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.
- 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;
- 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;
- Mean value, near which the ADC signal is fluctuating, is written to parameter Offset of GAIN block;
- 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.
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:
- ADC is set incorrectly (incorrect offset and scaling factors were selected);
- phases Alpha and Beta were selected incorrectly in previous step;
- the current sensors location is set incorrectly (please check connection of SVGEN_DQ to PWM driver).
- 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.
- 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.
- 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.
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.
- 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».