"angle_el" calculation clarifications

Maybe I’m getting confused, but I don’t understand the angle_el calculation in the function setPhaseVoltage. There is a difference between the foc_modulation:

  1. For the SinePWM,
    angle_el = normalizeAngle(angle_el + zero_electric_angle)

  2. For the SpaceVectorPWM,
    angle_el = normalizeAngle(angle_el + zero_electric_angle + _PI_2).

I think that _PI_2 is needed to get the electrical angle starting from the current rotor position (taking into account the -90 deg between rotor and stator), but why does _PI_2 appear in SpaceVectorPWM and not in SinePWM?



I suspect we’d have to read up on the inverse Park and Clarke transform algorithm to fully understand. I’m guessing it’s taken into account by this. The Cos function leads a Sine by 90 degrees so you could probably add 90 deg and change the Park and Clarke slightly and get the same result.

Yes, we should better understand Clarke and Park’s transforms. What I remember from my college studies, Park’s inverse equations are:

Vα = Vd ∙ cos(𝜃) – Vq ∙ sin(𝜃)

Vβ = Vq ∙ cos(𝜃) + Vd ∙ sin(𝜃)

Approaching the motor as purely resistive, I can confuse voltage with current.

id = is ∙ cos(𝜀)

iq = is ∙ sin(𝜀)

𝜀 is the angle subtended between the stator current and the flux of the magnet.
The maximum current, therefore the maximum torque, is obtained for the 𝜀 of π/2 (here is 90 degrees):

id = 0

and so:

Vα = – Vq ∙ sin(𝜃)

Vβ = Vq ∙ cos(𝜃)

Ultimately, then I believe that the angle_el calculation does not require π/2 because it is intrinsic to the Clarke and Park transforms and the id = 0 control strategy for the Field Oriented Control.

Hey @DomenicoGiampetruzzi,
I like it how deep you are going with analyzing this library :smiley:

You are absolutely right, I dont like it that I had to calculate the values differently but the sinusoidal transformations already take it in consideration and Space vector doesn’t.
As @Owen_Williams said, we could easily transform the equations to avoid this but that might just make things more complicated for someone trying to understand the equations.

These equations are heart of the FOC algorithm so I wanted them to stay in its pure form. But this might be subject to change in future. :smiley:

1 Like