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.

Query regarding controll of Iq_ref in insta-spin FOC algorithm.

Other Parts Discussed in Thread: TMS320F28069F

Dear Chris,

I am using TMS320F28069F controller and motorware13 example.

Can i control the input (Iq_ref) of Iq PI controller. How can I control regenerative current limit (lower limit of speed PI)? This is require like pump jack application. If we can not control the regenerative current limit than AC drive will trip in OVER DC BUS VOLTAGE.

-Suprit

  • You can do that by setting positive and negative limits independently in ctrl.h, under function CTRL_runOnLine_User(). So from this code:

     // when appropriate, run the PID speed controller
     if(CTRL_doSpeedCtrl(handle))
       {
         _iq refValue = TRAJ_getIntValue(obj->trajHandle_spd);
         _iq fbackValue = EST_getFm_pu(obj->estHandle);
         _iq outMax = TRAJ_getIntValue(obj->trajHandle_spdMax);
         _iq outMin = -outMax;

         // reset the speed count
         CTRL_resetCounter_speed(handle);

         PID_setMinMax(obj->pidHandle_spd,outMin,outMax);

         PID_run_spd(obj->pidHandle_spd,refValue,fbackValue,CTRL_getSpd_out_addr(handle));
       }

    For example if you want to set a hard limit of -2.0 Amperes, then you can do this:

     // when appropriate, run the PID speed controller
     if(CTRL_doSpeedCtrl(handle))
       {
         _iq refValue = TRAJ_getIntValue(obj->trajHandle_spd);
         _iq fbackValue = EST_getFm_pu(obj->estHandle);
         _iq outMax = TRAJ_getIntValue(obj->trajHandle_spdMax);
         _iq outMin = -_IQ(2.0 / USER_IQ_FULL_SCALE_CURRENT_A);

         // reset the speed count
         CTRL_resetCounter_speed(handle);

         PID_setMinMax(obj->pidHandle_spd,outMin,outMax);

         PID_run_spd(obj->pidHandle_spd,refValue,fbackValue,CTRL_getSpd_out_addr(handle));
       }

    -Jorge

  • Thank you jorge.

    I try this but I can not able to change value min, max of pidHandle_spd. I try below trail.

    1. I follow same as you mention, but when I get value (for debug purpose) PID_getOutMax(obj->pidHandle_spd) using this function I shown that value is default value. Not modified value.

    2.Then I increment one global variable in CTRL_runOnLine_User() and CTRL_runOnLine() these function, but this variable can not increment any value in online state (Ctrlstate and Eststate). So I think these function can not call from main_ISR().

    3.Then I put below code in updateGlobalVariables_motor() function.

    if(one_time_flag == 0)

    {

    one_time_flag = 1;

    CTRL_Obj *obj1 = (CTRL_Obj *)ctrlHandle;

    _iq outMax = _IQ(0.50);

    _iq outMin = _IQ(-0.50);

    PID_setMinMax(obj1->pidHandle_spd,outMin,outMax);

    }

    so I see, value of min, max of pidHandle_spd change to new value but when I set gMotorVars.Flag_Run_Identify = 1 (Ctrlstate and Eststate = online) than min, max of pidHandle_spd value will change to default value not modified value.

    General information:

    I am using TMS320F28069F controller and motorware13 example lab2a implementation in my custom board for AC induction motor 415V/50Hz system.

    Waiting for your reply.

    Thanks

  • Any update!!!

  • For what you want to do you need to use lab 2b. This is because lab 2a uses ctrl.c/h from ROM, and the following is done in ROM when you call CTRL_run()

     // when appropriate, run the PID speed controller
     if(CTRL_doSpeedCtrl(handle))
       {
         _iq refValue = TRAJ_getIntValue(obj->trajHandle_spd);
         _iq fbackValue = EST_getFm_pu(obj->estHandle);
         _iq outMax = TRAJ_getIntValue(obj->trajHandle_spdMax);
         _iq outMin = -outMax;

         // reset the speed count
         CTRL_resetCounter_speed(handle);

         PID_setMinMax(obj->pidHandle_spd,outMin,outMax);

         PID_run_spd(obj->pidHandle_spd,refValue,fbackValue,CTRL_getSpd_out_addr(handle));
       }

    So it overwrites the Min Max values you write outside of ROM.

    What you need to do then is use lab 2b, which uses ctrl.c/h outside of ROM, have you code as you mention in your post, and remove the highlighted code in ctrl.h, function CTRL_runOnLine_User():

     // when appropriate, run the PID speed controller
     if(CTRL_doSpeedCtrl(handle))
       {
         _iq refValue = TRAJ_getIntValue(obj->trajHandle_spd);
         _iq fbackValue = EST_getFm_pu(obj->estHandle);
         _iq outMax = TRAJ_getIntValue(obj->trajHandle_spdMax);
         _iq outMin = -outMax;

         // reset the speed count
         CTRL_resetCounter_speed(handle);

         //PID_setMinMax(obj->pidHandle_spd,outMin,outMax);

         PID_run_spd(obj->pidHandle_spd,refValue,fbackValue,CTRL_getSpd_out_addr(handle));
       }

  • Dear jorge,

    Thank you.

    I added these .C file(clarke, ctrl, filter_fo, ipark, offset, park, pid, svgen, traj) and .H file(dlog4ch

    ) to convert lab 2a example to lab 2b example (as per lab pdf) .

    Is there any other things to do?

  • Dear jorge,

    Also I change in main_ISR() as per below.

    interrupt void mainISR(void)
    {
    // HAL_PwmData_t negPwmData = {_IQ(0.0), _IQ(0.0), _IQ(0.0)};

    // run the controller

    // CTRL_run(ctrlHandle,halHandle,&gAdcData,&negPwmData);

    CTRL_run(ctrlHandle,halHandle,&gAdcData,&gPwmData);

    /* // negate PwmData generated by SVGEN module in ROM

    gPwmData.Tabc.value[0] = _IQmpy(negPwmData.Tabc.value[0], _IQ(-1.0));

    gPwmData.Tabc.value[1] = _IQmpy(negPwmData.Tabc.value[1], _IQ(-1.0));

    gPwmData.Tabc.value[2] = _IQmpy(negPwmData.Tabc.value[2], _IQ(-1.0));

    */
    …..............
    …..........

    return;
    } // end of mainISR() function

    but when I see cmpA value using below function, I got last pending value of cmpr, it can not set half value of period.

    act.plc_panal8 = HAL_readPwmCmpA(halHandle, PWM_Number_3);

    and because of this when I run again, high current gone in starting pulse.

    Any idea? Is there any missing or other things to do? Or I have to put

    HAL_PwmData_t gPwmData = {_IQ(0.0), _IQ(0.0), _IQ(0.0)}; in mainISR()?

    Thanks

  • That's really all you need to do. Take a look at this post that talks about an initial pulse. I think that will take care of the initial pulse you are seeing:

    http://e2e.ti.com/support/microcontrollers/c2000/f/902/t/300135.aspx?pi310980=2

    -Jorge

  • I just realized you are the author of the other forum post :)

    Anyways, give it a try and let me know if it helped.