cancel
Showing results for 
Search instead for 
Did you mean: 

Hello to every, In the lib of St foc v2.0, it seems something wrong with its Svpwm module

970253146
Associate II
Posted on September 05, 2017 at 07:05

Let's see how ST does to calculate the duty time of Svpwm in the foc sdk v2.0

in Um0492 doc, taking one sector as example, it says Ta=(Ts+wX-wZ)/2,

then Ta can be rewrited as  T/4 + ((T/2)+wX-wZ)/2, that's ok I think.

But when it comes to program, it is 

hTimePhA = (T/8) + ((((T + wX) - wZ)/2)/131072);

hTimePhB = hTimePhA + wZ/131072;

hTimePhC = hTimePhB - wX/131072; 

Here T is defined as 4*Pwm_Period, Pwm_Period is the overflow value of the timer, this timer works under TIM_CounterMode_CenterAligned1.

wX wY wZ are values of the operational time of each phase, and it is in Q15 format.   

why T/4 in the document will become T/8 when programing?

Maybe  I can explain it myself,

it's because T in the document is the pwm period Ts at theory level, while in programing T is 4*Pwm_period. There are different.In the case of CenterAligned mode, the real period is 2*Pwn_period.

So Ts/4 -> 2*Period/4 -> Period/2, T=4*Pwm_Period-> Pwm_Period=T/4, Finally, we could see this value T/8 in the source file.  

But I can't figue out how  the second term of hTimePhA( ((((T + wX) - wZ)/2)/131072); ) comes. T is in Q0 format actually, why T/2/131072 ???

According to what I analyzed above, value T=4*Pwm_period in programing is not the real pwm period while the real value is 2*Pwm_period, or rather, T_real=T/2.

Basing on the theory of 7-Svpwm, we can get XYZ with T*Usb,T*(1/2)*sqrt(3)*Sum(Usa, Usb).  So ((T/2)+wX-wZ)/2 could be rewrited as ((2*Pwm_Period/2)+wX-wZ)/2 -> ((Pwm_Period)+wX-wZ)/2 -> ((T/4)+(wX/2)-(wZ/2))/2| wX=T_real*Usb=2*Pwm_Period*Usb=(T*Usb)/2.

Then I have no way to go, the result I calculated is quite different from that given in the progarm. 

Could anyone help me to solve it ? I don't dare to say St is wrong because this Foc library could run the sonsorless motor normally. I read TI's Svpwm approach before, it is the same as the theory analysis, that is to say ,we could get the same value from both from the TI's svpwm application document and its C program when using TI's foc lib.

Here is part of the source file

void SVPWM_3ShuntCalcDutyCycles (Volt_Components Stat_Volt_Input)

          s32 wX, wY, wZ, wUAlpha, wUBeta;   

          u16  hTimePhA=0, hTimePhB=0, hTimePhC=0, hTimePhD=0; 

          u16  hDeltaDuty;     

          wUAlpha = Stat_Volt_Input.qV_Component1 * T_SQRT3 ;                                 wUBeta = -(Stat_Volt_Input.qV_Component2 * T);

          wX = wUBeta; 

          wY = (wUBeta + wUAlpha)/2;   

          wZ = (wUBeta - wUAlpha)/2;

           ...... ?Sector Calculation?.....  

          switch(bSector) 

        {      case SECTOR_1:        hTimePhA = (T/8) + ((((T + wX) -                                                                        wZ)/2)/131072);

                               hTimePhB = hTimePhA + wZ/131072;

                               hTimePhC = hTimePhB - wX/131072;  

#foc-2.0 #motor-control #foc-4.2
1 REPLY 1
Laurent Ca...
Lead II

The question has been moved from the "Motor Control Hardware" section to the "STM32 Motor Control" section (the question is about the STM32 MC SDK). 

Best regards