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.

Motorware(v1.0.3.03)中rampgen.h文件里的RAMPGEN_run()函数求解

inline void RAMPGEN_run(RAMPGEN_Handle rampgenHandle,float32_t *pOutValue)
{
  RAMPGEN_Obj *rampgen = (RAMPGEN_Obj *)rampgenHandle;
  float32_t Output;
  //rampgen->Freq = Freq;
  //rampgen->Gain = Gain;
  //rampgen->Offset = Offset;

  rampgen->Angle += (rampgen->StepAngleMax * rampgen->Freq); //Compute the angle rate StepAngleMax = 0.005

  if (rampgen->Angle>(1.0) )   //Saturate the angle rate within (-1,1)
    {
      rampgen->Angle -= (1.0);
    }
  else if (rampgen->Angle< (-1.0))
    {
      rampgen->Angle += (1.0);
    }

  Output = (rampgen->Angle * rampgen->Gain) + rampgen->Offset; // Compute the ramp output

  if (Output > (1.0))         // Saturate the ramp output within (-1,1)
    {
      Output -= (1.0);
      rampgen->rampExecutionCount++;
    }
  else if (Output < (-1.0))
    {
      Output += (1.0);
      rampgen->rampExecutionCount++;
    }


  *pOutValue = Output;

  return;
  
}

我想请问

(1)这个StepAngleMax * Freq得出的为什么就是步进的角度了

(2)还有Freq为何是SpedRef这个值

(3)函数名Rampgen_run()中的Ramp斜坡体现在哪里

(4)Output = (rampgen->Angle * rampgen->Gain) + rampgen->Offset这个算式在完成什么作用呢

  • 1)1 / T 就是一个周期的最小步进角度 对吧,乘上 stepAngleMax 并把1/T换成Freq就是最大步进角度

    2)哪里写Freq就是SpedRef了?

    3)角度的增加速度会逐渐变快

    4)完成3)的作用

  • (1)1 / T(=一个周期的最小步进角度) × stepAngleMax = 最大步进角度;最小步进角乘以一个stepAngleMax就是最大步进角了吗?光从字面上就读不通了
    (2)下面if语句里的第一句话就是把SpdRef的值Get过来赋值给句柄rampgenHandle里的Freq变量

     if (obj->commutationMode == RAMP_COMMUTATION_MODE) {
    	  RAMPGEN_setFreq(obj->rampgenHandle, CTRL_get_spd(obj->ctrlHandle));
      	  RAMPGEN_run(obj->rampgenHandle, &obj->elecPos3.ElecTheta);                
    
      	  //Update previous commutation state
      	  obj->prevCommutation = RAMP_COMMUTATION_MODE;
    
      }

    至于(3)、(4)的回答我猜测可能属于个人YY的…⊙﹏⊙‖∣

  • 你好这个函数你现在懂了吗,我也有同样的问题不懂

  •     表示好久没做这些,最近一直在忙别的,不过毕业论文可能还是和这个电机有关,等忙完这阵子再说吧。

    有一个大致的思路,这段代码是实现“I/F开环恒流频比启动”的,你去搜下这方面的论文,或者直接百度先看一下