RG_MACRO宏解析
作者:互联网
typedef struct { _iq Freq; // Input: Ramp frequency (pu) _iq StepAngleMax; // Parameter: Maximum step angle (pu) _iq Angle; // Variable: Step angle (pu) _iq Gain; // Input: Ramp gain (pu) _iq Out; // Output: Ramp signal (pu) _iq Offset; // Input: Ramp offset (pu) } RAMPGEN;
RAMPGEN结构体:
输入变量:Freq(频率:对应RC_MACRO结构体中的SetpointValue输出)
Gain(斜坡增益)
Offset(斜坡偏置)
输出变量:Out(斜坡信号形式)
参数:StepAngleMax(角度步长)
/*------------------------------------------------------------------------------ Object Initializers ------------------------------------------------------------------------------*/ #define RAMPGEN_DEFAULTS {0, \ 0, \ 0, \ _IQ(1), \ 0, \ _IQ(1), \ }
RAMPGEN对象默认初始化
/*------------------------------------------------------------------------------ RAMP(Sawtooh) Generator Macro Definition ------------------------------------------------------------------------------*/ #define RG_MACRO(v) \ \ /* Compute the angle rate */ \ v.Angle += _IQmpy(v.StepAngleMax,v.Freq); \ \ /* Saturate the angle rate within (-1,1) */ \ if (v.Angle>_IQ(1.0)) \ v.Angle -= _IQ(1.0); \ else if (v.Angle<_IQ(-1.0)) \ v.Angle += _IQ(1.0); \ v.Out=v.Angle; 以下代码均被注释 // Use the code snippet below if gain/offset needed. \ /* Compute the ramp output */ \ v.Out = _IQmpy(v.Angle,v.Gain) + v.Offset; \ /* Saturate the ramp output within (-1,1) */ \ if (v.Out>_IQ(1.0)) \ v.Out -= _IQ(1.0); \ else if (v.Out<_IQ(-1.0)) \ v.Out += _IQ(1.0);
RG_MACRO宏:1.角度等于前一次的角度+频率*角度步长
2.输出为饱和限幅后的角度
标签:Angle,pu,iq,MACRO,IQ,----------------------------------------------------------- 来源: https://www.cnblogs.com/xing-2/p/16182093.html