Documentation Home Page ◇ eHS Toolbox Home Page
Pour la documentation en FRANÇAIS, utilisez l'outil de traduction de votre navigateur Chrome, Edge ou Safari. Voir un exemple.
v2.15 PMSM Field Oriented Control - SPS
Description
This model illustrates the closed-loop control of an eFPGASIM-based Permanent Magnet Synchronous Machine (PMSM), interconnected with a two-level voltage source converter built using the eHS solver. This example is flexible for different real-time simulators, efsChassisSelection drop-down list gives five options in total. This model has CPU and FPGA as two major processing units so the PMSM and the converter are simulated on FPGA and the controller is simulated on CPU in real-time. Two RT-LAB models are provided to illustrate the exchange of information between the controller and plant:
Firmware selection for different platforms
Exchange happening within the software
Exchange through analog and digital I/O cards present on the simulator
A SimPowerSystems equivalent model "PMSM_FOC_ref" is also provided along with these models for the users reference.
SIM POWER SYSTEMS OP4510 OP5607 OP5707
Requirements
The RT-LAB, RT-EVENTS, SimPowerSystems and eFPGASIM toolboxes must be installed on the host and target computers in order to run this example model properly. Please refer to the product documentation for details on version compatibility.
Setup and Connections
This model must be run with both the Hardware Synchronized and XHP modes enabled. The firmware used in this model is generated using the RT-XSG tool, and it can be modified to generate firmware to fit another I/O hardware configuration. The CPU model simulation time step is set to 20 microseconds and all the variables required for eFPGASIM PMSM, eHS power network and controller block are defined in the "ParameterInitialization.m" file that is automatically loaded during simulation.
Model with I/O configured: DB37 pin-based analog and digital loop-back cables and a DB9 pin-based digital RS422 loop-back cable must be connected at the rear of the simulator.
Model without I/O: no cables are required.
Procedure
The following procedure will help the user understand how to work with the eHS solver, and eFPGASIM-based PMSM with field-oriented control (FOC).
Firmware Selection
It supports five options, three for OP4510 (325T with eHSx32 and x64 and 410T with eHSx128) while two for OP5700 (eHSx64 and x128).
RT-LAB model without I/O Configuration [Software-in-the-loop]
Run this demo : efsOpenExample('PMSM_FOC_rtlab');
A software-in-the-loop based RT-LAB model, "PMSM_FOC_rtlab", is provided to illustrate the exchange of information between the controller and plant.
Click on "Run this demo" at the top of this section (if this page is displayed in the MATLAB demo browser ). The RT-LAB model with the eHS solver will open automatically, as will the SimPowerSystems model describing the circuit to be solved.
Verify that the board type is set to TE0741 in the OpCtrl block in the RT-LAB model master subsystem. In the "OpCtrl" block, select the "Board ID" corresponding to the hardware on which eHS is executed. To get this information, select "Tools > Get I/O info" on the target context menu in RT-LAB and find the index for your hardware.
To run this example, users must ensure that the RT-LAB and eHS models are present in the same folder.
The RT-LAB model consists of a master subsystem (i.e. "SM_Controller") and a console subsystem (i.e. "SC_Console").
The master subsystem has a General Framework Machine Mask interface ("PMSM"), converter interface ("eHS CPU Block") and field-oriented control of the machine
The console subsystem is used to control set points, such as magnitude and frequency of source voltages, speed reference, mechanical torque, and control activation during real-time simulation. Users can also monitor voltages, currents, machine torque and speed of the machine at any point during the simulation
The eHS model consists of power network and is solved by eHS solver present in the master subsystem of RT-LAB model. The eHS model "PMSM_eHS_UB" is built by ensuring that sources, switch and measurements conventions are compatible with solver requirements. Out of 5 voltage/current sources needed by eHS circuit, three are generated and mapped via the RT-LAB model (Voltage Source Va,Vb and Vc) and the remaining are received from eFPGASIM PMSM stator terminals (Currents Ia and Ib). The convention to follow in eHS solver "Input Settings" tab is shown below.
Here, the switch configuration is also shown. The user can choose to send the gating pulses from the CPU or configuring Digital In. The converter terminal voltage measurements, namely Y01, Y02 and Y03, are routed to machine terminals internally using the machine interface block. Thus, we ensure a proper loading/coupling between eHS solver and eFPGASIM machine.
When the model is compiled in Simulink, the configuration of the eHS solver will be generated according to the SimPowerSystem circuit characteristics. Elements will be put into matrices and stored in .mat files that will be transferred into the solver when the model is run from the RT-LAB interface. Matrices are generated during model compilation in RT-LAB.
The PMSM available in the eFPGASIM library can solve two motors with hardware. This machine model solves only the electrical side of the system; the mechanical model is computed in the CPU. The converter terminal voltages measured by the eHS solver will feed the machine terminals. Similarly, the machine stator currents are fed back to the converter terminals, as mentioned in point 5. This is the information needed to configure the PMSM.
DataIn Port Number 28
LoadIn Port Number 18
DataOut Port Number 9
Field Oriented Control of PMSM is implemented on the CPU, which runs at a sampling time of 50 microseconds. This has a standard outer loop speed control and inner loop current control implemented. The transformation used is quadrature transformation with d axis aligned to phase A axis (Original Park). The RTE_SPWM block is used to generate PWM pulses for eHS converter upon activation of control from console. The modulating waves are clamped to a value between 0 and 1 using a clamping circuit. The carrier frequency is 9000 Hz and the number of events chosen is 4. Exchange of information between the controller and plant happens within the software model. Machine generated currents, speed and theta information are routed to the controller as an input, and output of the controller that is connected to eHS solver in RTE format.
Note: The "OpWriteFile" block can be used to capture the data during real-time simulation. A .mat file is available in the following folder upon model reset: model_name\model_name_SM_xxxx\OpREDHAWKtarget. This .mat file can be used to more accurately visualize the outputs, or to compare the results of several simulations.
To run simulations that include eHS solver and eFPGASIM machines in real-time, create an RT-LAB project and add the RT-LAB model to the project. The eHS model should not be added to the RT-LAB project, as it does not need to be transferred to the target computer for execution. Compile the model, then assign a target node to run it in real-time, then load the model onto the target.
During real-time execution;
Start the control algorithm: set Start_Control value to 1;
Set the reference speed: set Ref_Speed_rad/s value between 0 and 150;
Add mechanical torque to the machine: set Tmech value between 0 and 10.
RT-LAB model with I/O Configuration [Hardware-in-the-loop]
Run this demo : efsOpenExample('PMSM_FOC_IOs_rtlab');
The following procedure will help the user understand how to work with the eHS solver and eFPGASIM-based PMSM with field oriented control. The Hardware-in-the-loop based RT-LAB model, "PMSM_FOC_IOs_rtlab", is provided to illustrate the exchange of information between the controller and plant.
Click on "Run this demo" at the top of this section (if this page is displayed in the MATLAB demo browser). The RT-LAB model with the eHS solver will open automatically, as will the SimPowerSystems model describing the circuit to be solved.
Repeat steps 2 to 8 from the previous section to ensure proper configuration of the demo.
Unlike the previous model, exchange of information between the controller and plant happens through analog and digital I/O boards present on the simulator, as shown in the figure below.
The "Analog Output Mapping and Rescaling block Control Panel" block in the console subsytem is customised to map measurements from the eHS converter, and signals from the CPU model to the analog out (DAC) board. In this example, analog out channels Ch00 to Ch06 are fixed as the controller expects the inputs in the following order {'PMSM1.Ia', 'PMSM1.Ib', 'PMSM1.Ic', 'PMSM1.Vdc', 'Resolver1.Cosine', 'Resolver1.Sine', 'Resolver1.Excitation'}.
The Resolver and encoder of the machine can be configured from the PMSM block in the master subsystem. Cosine, Sine and Excitation outputs of Resolver1 are mapped to the analog out board. The Encoder are mapped on the RS422 interface.
Machine currents and DC Link voltages are provided to the controller using the simulator's Analog In (ADC).
The "Encoder In" block reads the encoder output and generates speed and angle information of the machine shaft.
Firing pulses generated by controller are sent via the digital out board present on the simulator,and fed back through digital loop-back cable to fire the eHS converter internally.
To run simulations that include eHS solver and eFPGASIM machines in real-time, create an RT-LAB project and add the RT-LAB model to the project. The eHS model should not be added to the RT-LAB project, as it does not need to be transferred to the target computer for execution. Compile the model, then assign a target node to run it in real-time, then load the model onto the target.
During real-time execution;
Start the control algorithm: set the Start_Control value to 1;
Set the reference speed: set the Ref_Speed_rad/s value between 0 and 150;
Add mechanical torque to the machine: set the Tmech value between 0 and 10.
OPAL-RT TECHNOLOGIES, Inc. | 1751, rue Richardson, bureau 1060 | Montréal, Québec Canada H3K 1G6 | opal-rt.com | +1 514-935-2323
Follow OPAL-RT: LinkedIn | Facebook | YouTube | X/Twitter