FOC Modeling with Space Vector PWM using Simplorer
In this video, I'm going to explain how to model and simulate an FOC (Field Oriented Control) for a Permanent Magnet Synchronous Motor (PMSM) using Simplorer.
System Components
- Battery: Modeled for 60 volts.
- Inverter: Includes six transistors with basic parameters defined.
- Output Phases: Current sensors are defined for control and connected to labels.
- PMSM Block: A native component from Simplorer, parameterized for simulation.
Transformations and Feedback
- ABCDQ Transform: Search for "ABC" in the component search to find different types of Park and Clarke transformations.
- Angle Feedback: Measured in watts per second (mechanical) and converted to electrical angle by multiplying by pole pairs.
Control Commands
- D-axis and Q-axis Current Commands: Defined as constants and input to PI blocks.
- PI Blocks: Control current using KP and KI gains, parameterized and normalized with saturation between -1 and 1.
Sampling and Transformation
- Sampling Frequency: Equal to the switching frequency, can be modified as needed.
- DQ Alpha Beta Transformation: Search for "DQ" in the component search to find the block. Inputs are DQ and alpha-beta voltage commands from the PI controller.
Space Vector Modulation
- Space Vector Modulation Block: Search for "SB" in the component search. The gates are internally linked and named using the block name (e.g., SB_PWM1.T1 to T6).
Simulation Setup
- Set D-axis current to 0 and Q-axis current to 250.
- DC bus voltage: 60 volts.
- Load torque: 10 Nm.
- Define PMSM as IPM if D-axis and Q-axis inductances differ, otherwise SPM will cause an error.
- Time steps are a fraction of the switching frequency.
Simulation Results
Once the system is solved, plot the results:
- Currents: Plot the three-phase currents. Initially, they reach close to 250, but amplitude reduces due to inverter reaching maximum voltage.
- RPM Conversion: Convert watts per second to RPM by multiplying by 60 and dividing by 2π.
- Speed Stabilization: The motor stabilizes at approximately 1500 RPM due to inverter voltage limits.
Field Weakening
To achieve higher speeds, apply a negative D-axis current for field weakening:
- With a negative D-axis command, the motor speed increases to nearly 10,000 RPM without changing the inverter voltage.
Conclusion
That's how you can simulate a field weakening algorithm using Simplorer. Thank you for your attention. We hope you found this video useful and encourage you to subscribe to our channel for more content.
In this video, I'm going to explain how to model and simulate an FOC control (Field Oriented Control) for a permanent magnet synchronous motor using Simplorer. In our system, we have modeled our battery for 60 volts, our inverter with six transistors, and basic parameters defined for them.
We'll come back to this one later to see how to determine the gate signals, the activation of the gates. Then we have our output phases, where we defined our current sensors to perform the control. These are connected to some labels.
The permanent magnet synchronous motor block, a native from Simplorer, is parameterized so we can modify the parameters during our simulation. You can see the parameterized variables for PMSM. ABCDQ transformation. You can look for this in the component search.
You can look for ABC and you will get all these different kinds of Park/Clarke transformations. We also have the angle feedback. This angle is in rad/s and it's in mechanical. So we use a gain to convert that to electrical angle by multiplying by pole pairs.
Then we have our D-axis current and Q-axis current commands. Right now defined as constants. They go directly to our PI blocks. So they are the input to our PI blocks. These blocks are used to control the current of the motor.
This PI block uses a Kp and a Ki gains which are now the same for both and they are parameterized. And in this case, we are using a normalized kind of control so we are saturating up to 1 and down to - 1. The sampling frequency is equal to the switching frequency. This is very standard.
Sometimes the sampling time is stored. So we can use this to control the current. Sometimes the sampling time is twice the switching frequency. You can define that here as you wish. Then we go to the DQ αβ transformation. Again you can look for this in the search components.
You can write DQ and you'll find it. You can look in the description to make sure it's what you are looking for. But the input to this block are the DQ and the αβ. The input to this block are the D and Q voltage commands coming from the PI controller.
In this case they are normalized and they are going to our space vector modulation block. Which you can look for also in the component search by typing SVPWM. If you type SVPWM you'll find it. You can see it doesn't have any output pins for the gates. And that's because they are hidden.
They are hidden. And they are hidden because they are not directly connected to the inverter. They are just linked internally. So you can see that the name of this block is SVPWM 1. And for the gates in the inverter block we are using that same name dot the name of the pin.
T1, T2, T3 up to T 6. That way we don't need to make a physical connection in Simplorer. We will make a quick simulation now. Let's make sure D-axis current is 0. Q-axis current 250. These are the commands. Our DC bus voltage 60. Low torque 10 Nm.
And one thing to keep in mind for the PMSM is if you are using IPM kind. You need to define it here in the PMSM. So if your D-axis and Q-axis inductances are different. You need to define it as IPM. If you define it as SPM it will give an error.
Our time steps will be defined as a fraction of the switching frequency. That's what I recommend. Once the system is solved. You can go ahead and plot the results. We go to currents. We'll plot the three currents from the three-phase circuit. The three phases. So we can see these nice curves.
Almost hitting 250 which is our command. But then at some point there. The amplitude is reducing. We'll see why is that happening. You can see the amplitude is going down after a certain moment. We'll see in a moment why is that happening. We are going to plot now the RPM. Okay.
So this measurement is done in rad/s. We will make a conversion to RPM. So we just grab this component. Multiply by 60. Divide by 2π. That will convert to RPM. Create new report. You can see that now the values in this plot are scaled. The motor is reaching about 5000 rad/s, 1500 RPM.
And it's steady at that point. The reason why the current started to drop. And the speed got stabilized. Is because the inverter reached its maximum voltage. So now we have applied a negative D-axis current. To put the motor into field weakening. This will allow us to go higher speeds.
You can see that now with a negative D-axis command. Still keeping the Q-axis command. The speed is much higher. Before we were doing 5500 rad/s. Now the motor is almost 10,000 rad/s. We haven't changed anything else. We didn't modify the inverter voltage.
That's how you can do a field weakening algorithm. Using Simplorer. And now we can see the current voltage. That's it. Thank you for your attention. We hope you enjoyed this video. We hope you found it useful. And we hope you will subscribe to our channel. And we will see you in the next video. Bye.
Bye. Bye. Bye. Bye. Bye. Bye. Bye. Bye. Bye. Bye. Bye. Bye.

