FOC中的Clarke变换_TI和ST电机控制库的源码实现
FOC中的PARK变换_TI和ST电机控制库的源码实现
PARK的反变换
此变换将正交旋转坐标系中的矢量投影到两相正交固定框架。
①经过clarke变换将三相电流变换为了固定的“alpha-beta”直角坐标系下。
②因转子是旋转的,又经过PARK变换将固定的直角坐标系下的“alpha-beta”轴,变换为旋转坐标系“D-Q”轴。
③将三相相差120度的正弦信号变换为了线性的ID,IQ信号。
④但是我们得到反馈,计算完后。要将信号变换回去,输出对应的三相电压。
⑤又会经过反PARK变换,而反clarke变化可以使用另一种方式svpwm去完成输出电压。
参考框图:
数学公式
{
I
d
=
I
D
×
cos
θ
+
I
Q
×
sin
θ
I
q
=
I
D
×
sin
θ
+
I
Q
×
cos
θ
\left\{ \begin{array}{l} I_d=I_D\times \cos \theta +I_Q\times \sin \theta\\ I_q=I_D\times \sin \theta +I_Q\times \cos \theta\\ \end{array} \right.
{Id=ID×cosθ+IQ×sinθIq=ID×sinθ+IQ×cosθ
转换后波形:
TI程序:
和park程序一样,cos(theta)和sin(theta)是参数。
typedef struct { _iq Alpha; // Output: stationary d-axis stator variable
_iq Beta; // Output: stationary q-axis stator variable
_iq Angle; // Input: rotating angle (pu)
_iq Ds; // Input: rotating d-axis stator variable
_iq Qs; // Input: rotating q-axis stator variable
_iq Sine; // Input: Sine term
_iq Cosine; // Input: Cosine term
} IPARK;
/*------------------------------------------------------------------------------
Inverse PARK Transformation Macro Definition
------------------------------------------------------------------------------*/
#define IPARK_MACRO(v) \
\
v.Alpha = _IQmpy(v.Ds,v.Cosine) - _IQmpy(v.Qs,v.Sine); \
v.Beta = _IQmpy(v.Qs,v.Cosine) + _IQmpy(v.Ds,v.Sine);
ST的程序:
__weak alphabeta_t MCM_Rev_Park( qd_t Input, int16_t Theta )
{
int32_t alpha_tmp1, alpha_tmp2, beta_tmp1, beta_tmp2;
Trig_Components Local_Vector_Components;
alphabeta_t Output;
// 查表得到cos(theta)和sin(theta)
Local_Vector_Components = MCM_Trig_Functions( Theta );
/*No overflow guaranteed*/
alpha_tmp1 = Input.q * ( int32_t )Local_Vector_Components.hCos;
alpha_tmp2 = Input.d * ( int32_t )Local_Vector_Components.hSin;
#ifdef FULL_MISRA_C_COMPLIANCY
Output.alpha = ( int16_t )( ( ( alpha_tmp1 ) + ( alpha_tmp2 ) ) / 32768 );
#else
/* WARNING: the below instruction is not MISRA compliant, user should verify
that Cortex-M3 assembly instruction ASR (arithmetic shift right) is used by
the compiler to perform the shift (instead of LSR logical shift right) */
// 计算转换后的输出alpha
Output.alpha = ( int16_t )( ( ( alpha_tmp1 ) + ( alpha_tmp2 ) ) >> 15 );
#endif
beta_tmp1 = Input.q * ( int32_t )Local_Vector_Components.hSin;
beta_tmp2 = Input.d * ( int32_t )Local_Vector_Components.hCos;
#ifdef FULL_MISRA_C_COMPLIANCY
Output.beta = ( int16_t )( ( beta_tmp2 - beta_tmp1 ) / 32768 );
#else
/* WARNING: the below instruction is not MISRA compliant, user should verify
that Cortex-M3 assembly instruction ASR (arithmetic shift right) is used by
the compiler to perform the shift (instead of LSR logical shift right) */
// 计算转换后的输出beta
Output.beta = ( int16_t )( ( beta_tmp2 - beta_tmp1 ) >> 15 );
#endif
return ( Output );
}
参考:
TI DMC MATH_13.1pdf
STM32 FOC 软件培训库pdf
被抛弃的写随笔公众号改写技术文章了,感兴趣的可以关注公众号:王崇卫