⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bldcti_w.c

📁 直流无刷电机控制程序
💻 C
字号:
/*-----------------------------------------------------------------------------
BLDCTI_W.C       Peripheral independent object for the implementation of
                 current controller for a three phase brushless DC Motor.
-----------------------------------------------------------------------------*/

/*------------------------------------------------------------------------------
 Include header file which defines BLDC Object. This header file has all the
 data necessary for one instance of a BLDC_TI algorithm.
------------------------------------------------------------------------------*/
#include <bldc_ti.h>

/*------------------------------------------------------------------------------
 Notes: 1.  Attributes are conveniently changed here, but this does
            consume cycles twice,
            (a) in the 'C' boot-up, and then
            (b) in the execution of this code. Setting up the needed
                constants the declaration of  PID2 pid2   = PID2_VALUES,
                rather than the defaults is clearly more effecient.
                This method is more intended for runtime changes.
        2.  There is also a code-size associated with these changes.
-----------------------------------------------------------------------------*/

void BLDC_TI_Init(BLDC_TI_handle v)
{
     v->rmp2.out = ALIGN_DUTY;
     v->rmp2.dly = 0x0050;
     v->rmp2.max = 0x7ff0;
     v->rmp2.min = 0x000f;

     v->rmp3.desired = v->cmtn_period_target;
     v->rmp3.dly = v->ramp_delay;
     v->rmp3.out = v->cmtn_period_setpt;
     v->rmp3.min = 0x0050;

     v->cmtn.nw_dynThold = 0x000f;
     v->cmtn.cdnw_delta = 0x0002;
     v->cmtn.noise_windowMax =
                v->cmtn.nw_dynThold - v->cmtn.cdnw_delta;

     v->pid2.max_reg2 = 0x7000;    /* Q15                           */
     v->pid2.min_reg2 = 0x0000;    /* Q15                           */
     v->pid2.k0_reg2  = 0x0080;    /* Q9                            */
     v->pid2.k1_reg2  = 0x0140;    /* Q13                           */
     v->pid2.kc_reg2  = 0x0506;    /* Q13                           */
}  /* End : BLDC_TI_Init() */


void BLDC_TI_Run(BLDC_TI_handle v)
{
   (*v->cmtn.calc)(&v->cmtn);

   if(FALSE == v->sp_up_done_flg) {
        (*v->rmp3.calc)(&v->rmp3);
        v->sp_up_done_flg  = v->rmp3.done_flg;
        v->cmtn_period_setpt = v->rmp3.out;

        v->impl.period = v->rmp3.out;
        (*v->impl.calc)(&v->impl);

        v->mod6.trig_in = v->impl.out;
   } /*if(FALSE == v->sp_up_done_flg)*/

   else
       v->mod6.trig_in = v->cmtn.trig; /* Closed Loop */

   (*v->mod6.calc)(&v->mod6); /* Open Loop */

   v->cmtn.ptr_ct = v->mod6.cntr;    /* Input to COMMUTATION_TRIGGER */

   v->pid2.ref_reg2 = v->current_set;
   (*v->pid2.calc)(&v->pid2);                                             /*
---------------------------------------------------------------------------
   Uses PID result when the flag is set, i.e., I_loop_flg=1
   Implements ramp control of D_func during open current loop
   control, i.e., I_loop_flg=0
---------------------------------------------------------------------------*/
   if(FALSE == v->I_loop_flg){
        v->rmp2.desired = v->D_func_desired;
        (*v->rmp2.calc)(&v->rmp2);
   } /*if(FALSE == v->I_loop_flg) */
} /* BLDC_TI_Run() */


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -