TI中文支持网
TI专业的中文技术问题搜集分享网站

这段速度估算的 宏 能解释一下吗?

#ifndef __SPEED_EST_H__
#define __SPEED_EST_H__

typedef struct {
_iq EstimatedTheta; // Input: Electrical angle (pu) _iq OldEstimatedTheta; // History: Electrical angle at previous step (pu)
_iq EstimatedSpeed; // Output: Estimated speed in per-unit (pu)
Uint32 BaseRpm; // Parameter: Base speed in rpm (Q0) – independently with global Q
_iq21 K1; // Parameter: Constant for differentiator (Q21) – independently with global Q
_iq K2; // Parameter: Constant for low-pass filter (pu)
_iq K3; // Parameter: Constant for low-pass filter (pu)
int32 EstimatedSpeedRpm; // Output : Estimated speed in rpm (Q0) – independently with global Q
_iq Temp; // Variable : Temp variable
} SPEED_ESTIMATION; // Data type created

/*—————————————————————————–
Default initalizer for the SPEED_ESTIMATION object.
—————————————————————————–*/#define SPEED_ESTIMATION_DEFAULTS { 0, \
0, \
0, \
0, \
0, \
0, \
0, \
0, \
0, \
}

#define SE_DIFF_MAX_LIMIT _IQ(0.85)
#define SE_DIFF_MIN_LIMIT _IQ(0.15)
/*——————————————————————————
SPEED_EST Macro Definition
——————————————————————————*/

#define SE_MACRO(v) \
if ((v.EstimatedTheta < SE_DIFF_MAX_LIMIT)&(v.EstimatedTheta > SE_DIFF_MIN_LIMIT)) \
v.Temp = _IQmpy(v.K1,(v.EstimatedTheta – v.OldEstimatedTheta)); \
/* Q21 = Q21*(GLOBAL_Q-GLOBAL_Q) */ \
else v.Temp = _IQtoIQ21(v.EstimatedSpeed); \
\
/* Low-pass filter */ \
/* Q21 = GLOBAL_Q*Q21 + GLOBAL_Q*Q21 */ \
v.Temp = _IQmpy(v.K2,_IQtoIQ21(v.EstimatedSpeed))+_IQmpy(v.K3,v.Temp); \
\
/* Saturate the output */ \
v.Temp=_IQsat(v.Temp,_IQ21(1),_IQ21(-1)); \
v.EstimatedSpeed = _IQ21toIQ(v.Temp); \
\
/* Update the electrical angle */ \
v.OldEstimatedTheta = v.EstimatedTheta; \
\
/* Change motor speed from pu value to rpm value (GLOBAL_Q -> Q0)*/ \
/* Q0 = Q0*GLOBAL_Q => _IQXmpy(), X = GLOBAL_Q*/ \
v.EstimatedSpeedRpm = _IQmpy(v.BaseRpm,v.EstimatedSpeed);#endif // __SPEED_EST_H__

Igor An:

这段实现的是由角度微分得到速度。

#ifndef __SPEED_EST_H__
#define __SPEED_EST_H__

typedef struct {
_iq EstimatedTheta; // Input: Electrical angle (pu) _iq OldEstimatedTheta; // History: Electrical angle at previous step (pu)
_iq EstimatedSpeed; // Output: Estimated speed in per-unit (pu)
Uint32 BaseRpm; // Parameter: Base speed in rpm (Q0) – independently with global Q
_iq21 K1; // Parameter: Constant for differentiator (Q21) – independently with global Q
_iq K2; // Parameter: Constant for low-pass filter (pu)
_iq K3; // Parameter: Constant for low-pass filter (pu)
int32 EstimatedSpeedRpm; // Output : Estimated speed in rpm (Q0) – independently with global Q
_iq Temp; // Variable : Temp variable
} SPEED_ESTIMATION; // Data type created

/*—————————————————————————–
Default initalizer for the SPEED_ESTIMATION object.
—————————————————————————–*/#define SPEED_ESTIMATION_DEFAULTS { 0, \
0, \
0, \
0, \
0, \
0, \
0, \
0, \
0, \
}

#define SE_DIFF_MAX_LIMIT _IQ(0.85)
#define SE_DIFF_MIN_LIMIT _IQ(0.15)
/*——————————————————————————
SPEED_EST Macro Definition
——————————————————————————*/

#define SE_MACRO(v) \
if ((v.EstimatedTheta < SE_DIFF_MAX_LIMIT)&(v.EstimatedTheta > SE_DIFF_MIN_LIMIT)) \
v.Temp = _IQmpy(v.K1,(v.EstimatedTheta – v.OldEstimatedTheta)); \
/* Q21 = Q21*(GLOBAL_Q-GLOBAL_Q) */ \
else v.Temp = _IQtoIQ21(v.EstimatedSpeed); \
\
/* Low-pass filter */ \
/* Q21 = GLOBAL_Q*Q21 + GLOBAL_Q*Q21 */ \
v.Temp = _IQmpy(v.K2,_IQtoIQ21(v.EstimatedSpeed))+_IQmpy(v.K3,v.Temp); \
\
/* Saturate the output */ \
v.Temp=_IQsat(v.Temp,_IQ21(1),_IQ21(-1)); \
v.EstimatedSpeed = _IQ21toIQ(v.Temp); \
\
/* Update the electrical angle */ \
v.OldEstimatedTheta = v.EstimatedTheta; \
\
/* Change motor speed from pu value to rpm value (GLOBAL_Q -> Q0)*/ \
/* Q0 = Q0*GLOBAL_Q => _IQXmpy(), X = GLOBAL_Q*/ \
v.EstimatedSpeedRpm = _IQmpy(v.BaseRpm,v.EstimatedSpeed);#endif // __SPEED_EST_H__

user1303469:

回复 Igor An:

if ((v.EstimatedTheta < SE_DIFF_MAX_LIMIT)&(v.EstimatedTheta > SE_DIFF_MIN_LIMIT)) \v.Temp = _IQmpy(v.K1,(v.EstimatedTheta – v.OldEstimatedTheta)); \/* Q21 = Q21*(GLOBAL_Q-GLOBAL_Q) */ \else v.Temp = _IQtoIQ21(v.EstimatedSpeed); \

为什么  本次估算角度 不在区间  本次角度 不和上次角度 相减,而直接得到速度?

#ifndef __SPEED_EST_H__
#define __SPEED_EST_H__

typedef struct {
_iq EstimatedTheta; // Input: Electrical angle (pu) _iq OldEstimatedTheta; // History: Electrical angle at previous step (pu)
_iq EstimatedSpeed; // Output: Estimated speed in per-unit (pu)
Uint32 BaseRpm; // Parameter: Base speed in rpm (Q0) – independently with global Q
_iq21 K1; // Parameter: Constant for differentiator (Q21) – independently with global Q
_iq K2; // Parameter: Constant for low-pass filter (pu)
_iq K3; // Parameter: Constant for low-pass filter (pu)
int32 EstimatedSpeedRpm; // Output : Estimated speed in rpm (Q0) – independently with global Q
_iq Temp; // Variable : Temp variable
} SPEED_ESTIMATION; // Data type created

/*—————————————————————————–
Default initalizer for the SPEED_ESTIMATION object.
—————————————————————————–*/#define SPEED_ESTIMATION_DEFAULTS { 0, \
0, \
0, \
0, \
0, \
0, \
0, \
0, \
0, \
}

#define SE_DIFF_MAX_LIMIT _IQ(0.85)
#define SE_DIFF_MIN_LIMIT _IQ(0.15)
/*——————————————————————————
SPEED_EST Macro Definition
——————————————————————————*/

#define SE_MACRO(v) \
if ((v.EstimatedTheta < SE_DIFF_MAX_LIMIT)&(v.EstimatedTheta > SE_DIFF_MIN_LIMIT)) \
v.Temp = _IQmpy(v.K1,(v.EstimatedTheta – v.OldEstimatedTheta)); \
/* Q21 = Q21*(GLOBAL_Q-GLOBAL_Q) */ \
else v.Temp = _IQtoIQ21(v.EstimatedSpeed); \
\
/* Low-pass filter */ \
/* Q21 = GLOBAL_Q*Q21 + GLOBAL_Q*Q21 */ \
v.Temp = _IQmpy(v.K2,_IQtoIQ21(v.EstimatedSpeed))+_IQmpy(v.K3,v.Temp); \
\
/* Saturate the output */ \
v.Temp=_IQsat(v.Temp,_IQ21(1),_IQ21(-1)); \
v.EstimatedSpeed = _IQ21toIQ(v.Temp); \
\
/* Update the electrical angle */ \
v.OldEstimatedTheta = v.EstimatedTheta; \
\
/* Change motor speed from pu value to rpm value (GLOBAL_Q -> Q0)*/ \
/* Q0 = Q0*GLOBAL_Q => _IQXmpy(), X = GLOBAL_Q*/ \
v.EstimatedSpeedRpm = _IQmpy(v.BaseRpm,v.EstimatedSpeed);#endif // __SPEED_EST_H__

Igor An:

回复 user1303469:

这里的意思不是直接得到速度,而是这次不做速度更新,而继续使用上次计算的速度结果。

赞(0)
未经允许不得转载:TI中文支持网 » 这段速度估算的 宏 能解释一下吗?
分享到: 更多 (0)