To start making a Drive System, we need to have a piece of good knowledge of the dq frame in order to operate with the motor. In addition, we need to choose the control method. Let's start!

## Control method

We have different control methods for a PMSM. Supposing that we have a motor with an encoder (So the position of the motor is known), this narrow down our strategy: * V/f Control* and

*.*

**FOC**Should the speed needs to be controlled, the V/f control is the simplest method available. This method is also known as scalar control in which the ratio between the voltage and the frequency applied to the machine is maintained constant through the entire range of the motor speed. Having this, the **desired frequency is applied through the inverter in order to have a specific speed in the motor. **But it is not enough for us, as we need to be able to receive a specific amount of torque from the motor at every moment to keep the control over the EV in the driveway.

The Field Oriented Control is focused on the torque that is applied by the motor. This control method is referred to as vector control, having that both the amplitude and phase of the AC excitation are controlled, which makes this method superior when compared with the previous explained V/f control. Moreover, the field orientation refers to the fact that the controllers should maintain a 90º phase angle between the rotor field and stator field components.

In the project, both torque and speed controllers are implemented in a cascaded control loop. ** The generation of torque is only related to the current going through the stator**, which is also required as feedback in the loop. Furthermore, the speed control requires the rotor angular velocity as feedback. The control architecture of combined speed and torque control is shown in the picture:

As you can see in the previous picture, a Speed controller and Torque Controller need to be prepare. This will be shown in the following chapters, but I can assure you that it is not as hard as one could think. We also need to use the SVM (Space Vector Modulation) to configure the triggering signals of our inverter in order to achieve the sinewave we need to set the torque and speed to the motor.

### dq reference frame

Here comes the ugly part, take a break, have a walk, grab a coffee, and read carefully... Let's start!

First, I need to explain a bit about the three different references frames we have in motor drives:

**abc:**The three-phase normal reference frame. This one is well-known for every engineer or electrician. (Also known as u-v-w).With this system, we separate the currents that represent torque and magnetic field of the motor. In this reference frame, we have only 2 currents in two orthogonal axes. The following image shows the abc and alpha-beta reference frame:**Alpha-beta reference frame:**: Allows three-phase steady-state parameters to be expressed as constants in a*dq reference frame***rotating**coordinate system. This is the one which we will be using with the FOC strategy.

There should always be one variable, which is the same for all different reference frames, and this is defined as the zero component (which is zero in symmetrical systems):

Supposing a symmetrical system, then, we have a general approach for abc frame to reference-frame transformation: (If you find it interesting, I can upload another post only to the mathematical explanations on all the equations, step by step).

Now that we want to go from abc to qd0 (or to alpha-beta), let's see how is the previous general approach, with these references:

Now, we just need to combine the expressions and make some vector and spacial calculations to find any transformation in between any reference frame. In our case, we are interested in abc to qd0:

And vice versa:

Finally, we operate with the qd0 reference frame, because in our case we want to align Iq with the stator current of the motor, so we can control the torque of the motor controlling just Iq, letting Id to be zero most of the time. In different cases, the dq0 is the one who will be chosen, everything depends on the application:

Nevertheless, it is important to know that if we are applying all these maths into a microcontroller, it is much more efficient to apply first Clarke (abc to alpha-beta) and then Park (alpha-beta to qd0) transformations, rather than using directly the transformation matrix abc-dq0 shown previously. We will get into those transformations and the code in the following chapters. Just chill a bit, here we are just for learning the deep-knowledge of theory, but afterwards, everything is much simple that it appeared today.

To end up, here an animation for a better explanation of the dq and alpha-beta system (*Thanks to Switchcraft, which also explains all these matters better than I do*):

Everything is made so we can simplify the analysis of the motor as much as possible, converting three-phase signals into two DC constants. Not only is it useful for the simplification of the system, but it also becomes advantageous when it comes to the modelling of the machine inductances.

**To sum up:** Now we know our strategy (FOC) and that we need to operate with the qd0 frame, so our DSP (and code) will need to apply Clarke and Park transformation in real-time, apply two control loops with two PID controllers (speed and torque controls) for controlling just DC variables (not three-phase vectors) and create the triggering signals of our inverter using the SVM technique. In the next episode, we will see how the PMSM Model is calculated.

## Comments