This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

28035驱动PMSM的问题

我对28035的PMSM程序中的RC_MACRO(v)不理解,

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;              

 

每执行一次MainISR中断就执行一次RC_MACRO(rc1)宏,

RC_MACRO(rc1)宏的初值如下

typedef struct { _iq    TargetValue;     // Input: Target input (pu)

                 Uint32 RampDelayMax;   // Parameter: Maximum delay rate (Q0) - independently with global Q           

                 _iq    RampLowLimit;    // Parameter: Minimum limit (pu)                 

                 _iq    RampHighLimit;   // Parameter: Maximum limit (pu)

                 Uint32 RampDelayCount; // Variable: Incremental delay (Q0) - independently with global Q   

                 _iq    SetpointValue;   // Output: Target output (pu)              

                 Uint32 EqualFlag;      // Output: Flag output (Q0) - independently with global Q

               } RMPCNTL;              

 

#define RMPCNTL_DEFAULTS { 0,        \

                           5,       \

                            _IQ(-1), \

                            _IQ(1),  \

                            0,       \

                            0,       \

                            0,       \

                             }

 

RC_MACRO(rc1)宏的定义如下

#define RC_MACRO(v)                                     \

    rc_tmp = v.TargetValue - v.SetpointValue;           \

/*  0.0000305 is resolution of Q15 */                   \

if (_IQabs(rc_tmp) > _IQ(0.0000305))                    \

{                                                       \

    v.RampDelayCount += 1;                              \

        if (v.RampDelayCount >= v.RampDelayMax)         \

        {                                               \

            if (v.TargetValue >= v.SetpointValue)       \

            {                                           \

                v.SetpointValue += _IQ(0.0000305);      \

                if (v.SetpointValue > v.RampHighLimit)  \

                    v.SetpointValue = v.RampHighLimit;  \

                v.RampDelayCount = 0;                   \

            }                                           \

            else                                        \

            {                                           \

            v.SetpointValue -= _IQ(0.0000305);          \

            if (v.SetpointValue < v.RampLowLimit)       \

                v.SetpointValue = v.RampLowLimit;       \

            v.RampDelayCount = 0;                       \

            }                                           \

        }                                               \

}                                                       \

else v.EqualFlag = 0x7FFFFFFF;

 

buildlevel中,rc1.TargetValue = SpeedRef; SpeedRef=IQ(0);

我理解的是SetpointValue和EqualFlag作为RC_MACRO(rc1)宏的输出,而SetpointValue又作为RG_MACRO(rg1)的输入,有谁可以解释一下RC_MACRO(v)的执行过程和对电机产生的效果吗,谢谢