When we want to obtain a specific velocity in our motor, we need to tune the parameters of our controllers to ensure the stability and fast response of our motor, as it will be the main power for the EV. Having this, the security and reliability of our vehicle will depend directly on How good we are tuning these parameters. Here we will explain how to tune them.

Before continue reading, please be sure you have read previous chapters, as it is crucial to understand some of the equations given today.Â

But first, ** let's refresh the FOC architecture**:Â

As you can see, it has two loops. For that reason, we will tune them differently

## Inner Loop

The inner loop will be tuned to have a bandwidth twenty times lower than the switching frequency (As it is recommended for drive systems), which yields an inner loop bandwidth of 1000Hz. First of all, we need to operate with the equation discovered in the last chapter to be able to tune the current:

In order to make a proper control of the current components, the two equations need to be decoupled. This is done by adding and subtracting the cross-coupled terms in the Simulink model. After this decoupling, the transfer functions will be:

However, the inverter time constant should be taken into consideration. For that reason, a reasonable approximation was done, modeling the inverter as a first-order delay, which corresponds to 1.5 the switching period. (Again, as recommended in drives bibliografy). Doing this will ensure that the switching delay of the inverter has been taken into consideration.

We finally ended up with the architecture of the inner loop:

The final control system diagram for id should be similar.Â

The parameters which need to be tuned for the PI controller will be based on cancelling the dominating pole of the current plant, by placing a zero near or at the same location in the imaginary plane. Doing that will result in a faster inner loop response. The plant transfer function should be initially rewritten in order to determine the location of the pole:

Should we need to determine the poles, we have to equal the characteristic equation into 0 and solve it, which give us:

The PI-controller also needs to be rewritten to locate the zero, which needs to cancel the previous pole.

Now, if the pole must be equal as the zero:

Having this in mind, the open-loop transfer function of the system can be obtained:

To obtain the exact gain that is needed in the controller, a root locus using MatLab is done and it can be seen next:

An overshoot of 2% is admissible for the project, resulting in a damping of 0.779 and a gain of 5490. Having this gain, the parameters of the controllers can be calculated:

In order to obtain the final bandwidth our the inner loop, a Bode diagram has been plotted next, which gives the information of 795.77Hz, which should be fine for the inner loop, having that the initial aim was for 1000Hz at the beginning of the article.

Finally, a step response was tested on the controller, having the analytically calculated values of overshoot, damping and time response validated:

The values for the parameters of the id loop were calculated with the same methodology, obtaining the following values:

## Outer Loop

The outer loop is where the speed of the PMSM is controlled: the speed reference is transformed into an iq current. The magnitude of the torque provided by the motor is directly proportional to the iq current, having that the id reference will be forced to be zero.

The outer loop should be at least ten times slower than the inner loop. This has the advantage of the dynamic response of the inner loop will occur at least a decade after the dynamics of this loop. Due to that, the two loops can be consideredÂ decoupled. For that reason, a simplified transfer function can be approximated to be the inner loop:

Where bw = 5000rad/s, the bandwidth of the inner loop. For the outer loop plant transfer function, the ratio of the mechanical angular speed and the q-componentÂ current in the mechanical equation is used.

Finally, the outer diagram:

The outer loop should be designed in a search of stability (We do not want unexpected fluctuations in our speed while driving, Â¿Right?) so it is needed a high phase margin. As said before, if the inner loop has a bandwidth of 5000rad/s, the outer should have 500rad/s to be decoupled. Setting a desirable overshoot of 2% (Same as the inner loop), the phase margin should be obtained with the Addison-Wesley method:

Having the angle, the parameter Kp was chosen using Matlab, increasing its value and checking the Bode plot and the rise time of the seep answer of the system, until the constraints are accomplished. Later, Ki was chosen to finally fit the overshoot required. The following values are reached:

The final bode diagram shows a bandwidth of 492 rad/s with a phase margin of 83Âº and, if the sep answer is analyzed, an overshoot of 2.16%.

**To sum up: **We have calculated all the PI parameters for the two loops: Speed and currents controllers. If we introduce everything in matlab (See next picture), we will be able to change the motor speed easily. So the hard job is almost done! Next chapter will be about triggering signals and the inverter, and what strategy we should apply to ensure that the motor will receive the current we want to apply.Â

Thank for reading

## Comments