How to Deploy Control Algorithm to a Microcontroller | Field-Oriented Control of PMSM with Simulink | Part 3
From the series: Field-Oriented Control of PMSMs with Simulink
In the third video of the series on Field-Oriented Control (FOC) for permanent magnet synchronous motors (PMSMs), we will explore how to deploy the algorithm and control your PMSM from your host computer. We will see how to use Motor Control Blockset™ reference examples to implement FOC algorithm for PMSMs and generate optimized embedded code from the model. Using these reference examples, you'll be able to control and monitor your motor's signal to verify the implemented motor control algorithm.
In this video, we’re going to implement the field-oriented control algorithm on the embedded microcontroller. We’ll spin this brushless PMSM motor which we’ll control using the Texas Instruments LaunchPad processor and DRV8305 inverter module. We will use the same model that we used to run simulations. On the right-hand side, we see the different sample rates we have in our model. The current loop is running at 50 microseconds and the speed loop is running ten times slower. Then we also have the serial receive subsystem that gets the data from the host model running at 10 Hz. Now, we’ll go to the hardware tab and click on the settings. We see that we have configured the model to generate code for the Texas Instruments F28379D processor and we’re using Embedded Coder to generate code.
If we look under the current control subsystem, we see that this model contains algorithmic blocks from Motor Control Blockset such as Park and Clarke blocks and also the driver blocks from C2000 support package. When we generate code from this model, Embedded Coder generates both the algorithmic and driver code. All the code is then automatically compiled, and target application is downloaded to the processor. Let’s go ahead and do this by pressing “build, deploy and start” button. This starts the code generation process. We can see the progress in the diagnostic viewer. We see that the code is being generated and a project is automatically created in the Code Composer Studio IDE. By clicking here, we can open the project and debug from the IDE. We can now see that the application has been downloaded to the target and we’re ready to spin our motor.
Now that we programmed the microcontroller, let’s open the host model which runs on my laptop. This model lets us set the desired speed for the motor shaft using this knob where we specify speed reference in rpm. Through this on/off switch, it also lets us specify when the motor should start spinning. The model receives signals such as speed and currents listed here over serial port from the target application and we plot per-unit, normalized values in this scope. To start the execution on the host, we go to the simulation tab and press run. We see the measurements in the scope on the right. Let’s start spinning the motor by turning the switch on. We see how the motor speed starts tracking the reference. Let’s try setting the reference speed to a set of different values and observe the motor response. We go up to 0.8 of the motor baseline speed. And now let’s try a step change from 0.8 of the baseline speed to a much lower speed value. And here’s another step change to higher speed. After checking the performance of speed tracking, let’s look at the currents. From this menu, we choose Id current. To better see the current waveform, let’s open scope settings and change the time span to 0.1 second. We see that Id current is kept at zero. Next, let’s look at Iq. Finally, we can take a look at the phase-A and phase-B currents.
In this video we showed how you can use Motor Control Blockset and Embedded Coder to generate code that is running at 20 kHz on the target microcontroller and controlling a brushless PMSM motor. This concludes the demo.
Puoi anche selezionare un sito web dal seguente elenco:
Come ottenere le migliori prestazioni del sito
Per ottenere le migliori prestazioni del sito, seleziona il sito cinese (in cinese o in inglese). I siti MathWorks per gli altri paesi non sono ottimizzati per essere visitati dalla tua area geografica.