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.

TMS320F280041C: MotorControl SDK Lab07 initial offset calculation problem

Part Number: TMS320F280041C

Tool/software:

Greetings! My project is based on MotorControl SDK 5_03 Lab07. At the beggining I turn on the lab in order to calibrate the offsets of the sensors ->

            motorVars.flagEnableSys=1;
            motorVars.flagRunIdentAndOnLine=1;
            motorVars.flagMotorIdentified=1;

Next I wait until the estimator enters into ONLINE state and I stop the main loop->

EST_State_e curr_est_state=EST_getState(estHandle);
if(curr_est_state==EST_STATE_ONLINE)
{
    motorVars.flagEnableSys=0;
    motorVars.flagRunIdentAndOnLine=0;
    motorVars.flagMotorIdentified=0;
    StartCalibration=calibration_done;
}

The problem is this breaks my program and I receive an error when I try to spin the motor using motorVars.flagEnableSys=1; and 
motorVars.flagRunIdentAndOnLine=1;

If I don`t interrupt the program the motor spins correctly. 

Can you tell me how I should properly stop the program after the offsets are calculated and how should I register that?

Thanks!

  • Can you tell me how I should properly stop the program after the offsets are calculated and how should I register that?

    Are you using your own board? Or the supporting EVM kits? Please follow the lab user's guide to run the lab02~03 to verify the hardware first if you are using your own board.

    You can find the operation steps in the lab01 or lab02 for your question above.

  • Ok! Here is what I have done. I put the 2 loop of lab07 into iternal loop

    while(1)
    {
         while(motorVars.flagEnableSys == false)
         {
         }
     
        //
          // loop while the enable system flag is true
          //
          while(motorVars.flagEnableSys == true)
          {
            //lab routine
          }
          
           //
          // disable the PWM
          //
          HAL_disablePWM(halHandle);
    }

    So I can start the motor by setting motorVars.flagEnableSys=true and           motorVars.flagEnableRunAndIdentify=true. 

    The procedure calculates the offsets and sets  motorVars.flagEnableOffsetCalc = false and after that the motor starts spinning.

    If I set motorVars.flagEnableSys=false the motor stops and the uC exits the lab loop and enters into the waiting loop.

    But this time when I try restarting the motor I receive fault. Do I have to reset somehow the estimator or to do something else in order to be able to spin the motor again?

    Am I doing something wrong?

    Thanks!

  • Any issues if you don't change anything, just run the example lab?

    Are you using your own board? Or the supporting EVM kits?

    What kit are you using?

    motorVars.flagEnableOffsetCalc = false

    Please take a look at the lab user's guide, you don't need to change this flag.

  • I am using my own board. When I run the lab single shot(just enabling the flag motorVars.flagEnableSys=true and motorVars.flagEnableRunAndIdentify=true) everything works correctly. But if I stop the lab(motorVars.flagEnableSys=false) and try to restart the motor (motorVars.flagEnableSys=true) I receive a fault. 

    If I set motorVars.flagEnableOffsetCalc = false this doesn`t change anything just the motor starts spinning directly without recalculating the offsets.

    I assume that some variable or flag is not cleared. I tried to call some of the inital functions before entering again in the lab routine - > no luck...

    Any suggestions?

  • Here comes the problem. It seems MotorControl SDK labs are not written for multistart. Once when the motorVars.flagEnableSys=1 the procedure activates the main loop and the IRS calculation, but If you motorVars.flagEnableSys=0 this breaks the main loop, but doesn`t stop the calculations in the IRS. The calculation part in the IRS depends only on motorVars.flagEnableOffsetCalc==false which is a problem. When you turn off the motor by setting flagEnableSys to 0, the IRS continues to calculate values for the estimator and when you try to reenable the motor by setting flagEnableSys to 1, this causes a problem. If the motor is small almost nothing happens I suppose the estimator quite fast leads the motor to proper condition. But with bigger motor this is not right. So I added an extra variable which indicates when the program is in the turning loop or not:

          __interrupt void mainISR(void)
          {
           
           ....
           if(motorVars.flagEnableOffsetCalc == false && flag_turning==1)
           ....
           }
           

    And I added a reset routine which resets the Clarke module, the estimater, trajectory controller and so on after the turning loop ends. And for now it is working properly. 

    The one thing which causes some of the headacke here is that in the waiting loop the  updateGlobalVariables(estHandle) routine is missing and you can`t see that the irs is calculating even if the turning is inactive. 

    I will be glad if you suggest a better course of action. For now this seems to be working. I have to make more test to be absolutely sure!

    Thanks!