How to Autotune PI controllers for implementing Field-Oriented Control
From the series: Field-Oriented Control of PMSMs with Simulink
In the video, we demonstrate how to automatically tune the gains of the current and the speed loops of the PMSM using the Field Oriented Controller Autotuner block in desktop simulation using reference example from Motor Control Blockset™. You can generate code from this block and run the algorithm to compute accurate PI controller gains by processing motor feedback in real-time on target hardware.
In this video, we will see how you can automatically fine tune controller loop gains for your motor control application using the Field Oriented Control Autotuner block.
In the closed loop simulation model here, we have the plant model, containing the motor and inverter model blocks. Then we have the inner dq axis current PI controller loops and the outer speed PI controller loop.
In traditional tuning methods you would have to tune one loop at a time manually, which tends to be a difficult and time-consuming process.
Field Oriented Control Autotuner simplifies and speeds up this process by automatically tuning d,q axis current and speed loops of your application based on the bandwidth and the phase margin you specify for each loop. This block can be used to tune the field-oriented controller gains in desktop simulation.
Essentially, it runs autotuning experiments for each of the loops by injecting perturbations; recording the output; estimating the plant frequency response and tuning the PI controller parameters.
Let’s see how this model is set up to automatically fine tune the gains using the Field Oriented Control Autotuner block.
First, we set up the speed reference profile for the motor . We will let the motor ramp up its speed to reach a steady state of around 2500RPM using initial controller gains. Then we raise the speed reference to 4500 RPM followed by a reverse in the direction of spin to 4000 RPM to see how the controller performs initially. Then we will bring back the motor speed back to steady state at 2500 RPM and use the Field Oriented Control Autotuner block to run those autotuning experiments for the inner dq current loops and then the outer speed loop. After the block has tuned the gains, we will run the same transients in the motor speed reference and check the controller performance with the fine-tuned gains.
With the speed reference profile set, we will setup the Field Oriented Control Autotuner block and tailor the autotuning experiment settings.
The initial PI gains for the control loops have been set up here using data store memory blocks and the Field Oriented Control Autotuner block is set up in this subsystem named the FOC_AutoTuner. This block in the subsystem, outputs current and speed loop perturbations and measures the resulting controller outputs, motor currents and speed to tune the gains.
To tailor the autotuning experiment settings we will look at the block dialog of the Field Oriented Control Autotuner block.
Under the parameters, we see the loops that will be tuned. As we do not have a flux loop, we have unchecked this. We have this option checked to use the same settings for the dq axis current loops.
Under the Tuning tab, let’s set the controller requirements for the dq-axis current loops. For these loops we will set a target bandwidth of 3000 rad/sec with a phase margin of 80 degrees.
The outer speed loop will run at least 10 times slower than the current loops so we will put in a bandwidth of 100rad/s. Let’s set a target phase margin of 60 degrees.
The Experiment tab lets us choose the amplitude of the perturbations being injected and the duration of the experiments. Based on the speed reference profile we set earlier on, we will set an experiment start time of 6 sec with a duration of 0.5 seconds for the D-axis current loop. Likewise let’s start the second experiment for the Q axis at 7 seconds which allows enough time for the transients from the first experiment to die down. For the duration, again set 0.5 seconds. For the speed loop, let’s set the start to 8 seconds and the duration to be 3 seconds.
Now under the loop experiment settings, for the current loops the plant type is stable with a positive sign. The sinusoidal perturbations here would represent the perturbations of vd and vq . For this we will set a normalized value of 0.15 for this. There is no science to choosing this value. It has to be small enough not to change the operating point of the motor and sufficiently large to excite motor dynamics. For the speed loop, again the plant type and sign are stable and positive respectively. The perturbations for this loop will be perturbations in iq reference current for which we will set the sine amplitude to a normalized value of 0.1.
Under the block tab we have selected the Start/Stop of the autotuning process to output the experiment times, that will allow us to update the PI gains after each experiment. Finally, the entire control runs in single precision datatype so we will match that here. Then click ok
Now that everything is set up, we can just run the model. The experiments will run and field oriented control autotuner block will update the loop gains for all 3 loops. Let us go check how the controller performance has changed
With the initial controller gains, we see the motor response while tracking the speed reference is slow with a significant overshoot and has a large settling time. Then the three experiments for the current and the speed loops were run between 6 and 11 seconds, fine tuning the gains. These gains are automatically updated to the PI blocks. With the tuned gains we see the controller brings about a better reference tracking performance with better rise and settling time
Note that you can still modify these autotuning experiment settings and further finetune these gains for your application.
So in closing, we saw how to use the FOC Autotuner block to tune gains of field-oriented control algorithm in the desktop simulation model. You can also generate code from this block and deploy it to a Speedgoat real-time machine. You can then autotune gains of you field-oriented control algorithms in real-time against motor hardware.
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.