ST意法半导体
直播中

赖治添

7年用户 212经验值
私信 关注
[问答]

如何开始使用PMSM编写FOC?

我下载了PMSM电机示例。我想修复自己的程序,但不知道。

我只想询问ia,ib的外部输入,通过FOC算法,三相电压的输出值到示波器的测量,

FOC算法只要我调用以下程序范例即可?


PWMC_GetPhaseCurrents(oCurrSensor [bMotor],& Iab);

Ialphabeta = MCM_Clarke(Iab);

Iqd = MCM_Park(Ialphabeta,hElAngledpp);


hElAngledpp = SPD_GetElAngle(oSPD [MC_NUM]);

Vqd.qV_Component1 = PI_Controller(oPIDIq [MC_NUM],

(int32_t)(FOCVars [MC_NUM] .Iqdref.qI_Component1) - Iqd.qI_Component1);

Vqd.qV_Component2 = PI_Controller(oPIDId [MC_NUM],

(int32_t)(FOCVars [MC_NUM] .Iqdref.qI_Component2) - Iqd.qI_Component2);

Valphabeta = MCM_Rev_Park(Vqd,hElAngledpp);


hCodeError = PWMC_SetPhaseVoltage(oCurrSensor [MC_NUM],Valphabeta);


该功能是三相电压值的最终输出?

谢谢!

以上来自于谷歌翻译


以下为原文




I downloaded the PMSM Motor Example. I want to fix my own programs, but has no idea .

I just wanted to ask if the external input from ia, ib, via FOC algorithm, the output value of the three-phase voltage to the oscilloscope measurement,

The FOC algorithm as long as I call following below program paradigm can be ?


PWMC_GetPhaseCurrents(oCurrSensor[bMotor], &Iab);

  Ialphabeta = MCM_Clarke(Iab);

  Iqd = MCM_Park(Ialphabeta, hElAngledpp);


  hElAngledpp = SPD_GetElAngle(oSPD[MC_NUM]);   

  Vqd.qV_Component1 = PI_Controller(oPIDIq[MC_NUM],

             (int32_t)(FOCVars[MC_NUM].Iqdref.qI_Component1) - Iqd.qI_Component1);

  Vqd.qV_Component2 = PI_Controller(oPIDId[MC_NUM],

             (int32_t)(FOCVars[MC_NUM].Iqdref.qI_Component2) - Iqd.qI_Component2);

  Valphabeta = MCM_Rev_Park(Vqd, hElAngledpp);  


  hCodeError = PWMC_SetPhaseVoltage(oCurrSensor[MC_NUM], Valphabeta);


This function is the final output of the three-phase voltage values ?

Thanks!

回帖(3)

张秀兰

2019-3-8 16:32:05
Ciao Sapphira
 
 
 是的,这些是高频任务中存在的步骤,执行当前规则以实现FOC。
 
 最后的功能
 
PWMC_SetPhaseVoltage(oCurrSensor [MC_NUM],Valphabeta);
 
 
 将Valpha和Vbeta转换为三个占空比值(施加到电机的电压)并将其设置为PWM定时器以生成输出。中间值Va,Vb和Vc不是经过精确计算和存储的,因此Va,Vb和Vc变量不能以这种方式直接发送到DAC输出。您可以进入代码并查找为三个任务计算的变量并将其发送到DAC(但您需要lib的机密或受保护版本。)
 
 返回值hCodeError它只是一个错误代码,如果在定时器的更新事件(计算出的三个占空比变为实际的那一刻)之前更新了三个占空比,则返回null。
 
 再见
 梁咏琪

以上来自于谷歌翻译


以下为原文





Ciao Sapphira


Yes, these are the steps present inside the High Frequency Task that performs the current regulation to achieve the FOC.

The final function

PWMC_SetPhaseVoltage(oCurrSensor[MC_NUM], Valphabeta);


Transform the Valpha and Vbeta into the three duty cycle values (voltage applied to the motor) and set it into the PWM timer to generate the output. Intermediate value Va, Vb and Vc is not reaqlly computed and stored and for this reason the Va, Vb and Vc variables can't directly sent to the DAC output in this way. You can go inside the code and find the variables computed for the three duty and send it to the DAC (but you require confidential or protected version of the lib.)

The return value hCodeError it is only a error code or null if the three duty cycle has been updated before the update event of the timer (the moment in which the three duty cycle computed become actual).

Ciao
Gigi
举报

赖治添

2019-3-8 16:48:41
亲爱的吉吉,
 
 感谢你的信息。
 但我在功能方面遇到了一些问题
 PWMC_GetPhaseCurrents(oCurrSensor [bMotor],& Iab);
 
 当我调用这个函数时,这段代码变成了无限循环。
 
void HardFault_Handler(void)
{
 / *发生硬故障异常时进入无限循环* /
 而(1)
 {
 }
}
 
 我从函数发生器发送3.3v到Ia和Ib,但我不能
 从这个函数得到Ia,Ib。
 所以我的代码可能有问题。
 我怎么能正确使用这个功能?
 谢谢!

以上来自于谷歌翻译


以下为原文





Dear Gigi,

     Thanks for your information.
     But I had some problems about function
     PWMC_GetPhaseCurrents(oCurrSensor[bMotor], &Iab);

     When I call this function, this code into an infinite loop.

void HardFault_Handler(void)
{
  /* Go to infinite loop when Hard Fault exception occurs */
  while (1)
  {
  }
}

     I send 3.3v to Ia and Ib from function generator, but I couldn't  
     get Ia, Ib from this function.
     So maybe something wrong with my code.
     How could I use this function correctly?
     Thanks!
举报

张秀兰

2019-3-8 17:05:46
Ciao Sapphira
 
 
 如果使用MCTaks.c中的MC Boot功能未正确实例化所有对象,则会发生这种情况
 
 这是因为某些指向数据或函数的指针可能为NULL,这会在无效的内存范围内产生跳转。
 
 然后调用PWMC_GetPhaseCurrents
 
 
 在正常操作中(我的意思是正确配置FW并执行MC Boot)并且在Hghfrequency taks内每个PWM周期执行一次,通常不会发生硬故障。
 
 再见
 梁咏琪

以上来自于谷歌翻译


以下为原文





Ciao Sapphira


This can occur if all the object are not correctly instantiated using the MC Boot function in MCTaks.c

This due to the fact that some pointer to data or functions can be NULL and this generate a jump in a not valid range of the memory.

Calling then PWMC_GetPhaseCurrents


in normal operation (I mean with FW correctly configured and MC Boot executed) and done one time each PWM period inside the Hghfrequency taks, the hard fault normally doesn't occur.

Ciao
Gigi
举报

更多回帖

发帖
×
20
完善资料,
赚取积分