How to Design and Simulate Motor Control Algorithms | Field-Oriented Control of PMSM with Simulink, Part 2
In the second video of the series on Field-Oriented Control (FOC) for permanent magnet synchronous motors (PMSMs), we focus on designing and simulating control algorithm for PMSM. We will see how to use Motor Control Blockset™ reference examples as a starting point for implementing FOC algorithms for PMSMs. We will learn how to use desktop simulation to test and verify the algorithm. You can then reuse the same models to generate and deploy embedded code.
In this video, we will see how to use Motor Control Blockset to implement field-oriented control for the brushless PMSM motor that we see here. This model is one of the reference applications from Motor Control Blockset. It’s configured with variants so that we can use this model to both simulate and generate code. This essentially lets us use the same model for simulating our field-oriented control algorithm against inverter and motor model and for generating code to program the microcontroller. Also, this model has been set up to use three different ways to model the inverter. In the first option, we’re using the average value inverter block from Motor Control Blockset for low-fidelity simulation. Another option we can use is Simscape Electrical to model ideal switching in the inverter. And choosing the third option lets us use Simscape Electrical to model multilevel converter.
Let’s quickly take a look through different subsystems that we have in our model. In the serial receive, we’re getting the data that’s sent over the serial port from the host model. The data determines the desired motor speed and if the PWM duty cycles are going to be non-zeros to allow the motor to spin. In the speed control subsystem, we have a PIcontroller that controls the rotor speed. It outputs Iq reference. And Id reference is set to zero because we implement field-oriented control for surface mount PMSM. In the current control subsystem, we’re getting the sensor readings and implementing field-oriented control as well as the PWM writes to the driver. Let’s see what we have under this subsystem. Here, we’re processing current and position and speed measurements. In this subsystem, we’re converting the quadrature encoder readings to position and speed using blocks we see here that are provided by Motor Control Blockset.
In the control system subsystem, we implement field-oriented control algorithm using Clarke, Park, Inverse Park and Space Vector Generator and PIcontrollers for the Id and Iq loops. We’re also using the Sine and Cosine lookup block which implements the lookup efficiently for deployment on microcontroller. Here, we have the driver blocks for PWM writes on the microcontroller. Note that these blocks are from Embedded Coder Support Package for C2000 processor.
Finally, to verify our algorithm and simulation, we have inverter and motor plant model. The three variants that we mentioned before provide us with different options for modeling the motor and inverter. This one is the average-value implementation with Motor Control Blockset. Here we use the Average Inverter and Surface Mount PMSM blocks. Let’s also take a look at the implementation with Simscape Electrical. In the inverter subsystem, this time we’ll look under the second variant where we implement ideal switching. Here, we use the PMSM block from Simscape Electrical as well as the converter that takes the switching pulses from PWM. The block dialog lets us choose the switching device. Here, we use ideal switching but other options are available such as using IGBT or MOSFETs for high-fidelity modeling. Finally, in the third option here, we’re modeling the multilevel converter.
Now that we talked about the model, let’s simulate it and look at some results. To do that, we press run. The model is being compiled and simulated. The results are now available. Before we look at them, let’s also run the simulation using low-fidelity plant model from Motor Control Blockset where we use the average-value inverter. We can now open the data inspector and look at simulation results.
Let's compare the speed, Iq, phase-A voltage and phase-A current seen by the motor and space vector modulation signals for these two runs. On the first plot, we see the speed reference which is in red and doesn't change between the runs. The speed feedback signals in yellow and blue look very close between the two runs. The next plot shows Iq reference and Iq feedback. We see the impact of switching on the Iq feedback that’s shown in yellow. In the third and fourth plots, we respectively see phase-A voltage and phase-A current seen by the motor. Here’s a closeup view of these signals. The signals in yellow show us the effect of switching in the inverter that we modeled and simulated using Simscape Electrical. Finally, these are the well-known duty cycle modulation signals with the characteristic shapes we get with space vector modulation. When we zoom in, we see that the results between the two runs look very similar to each other. Note that you can log any signal of interest in your model and run more simulations to check the performance of your controller by running different test cases. Once you're satisfied with the performance, you can move on to implementing your algorithm on embedded microcontroller. This concludes the video.
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.