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.

switch between move -> continues running and back to move function agian

Genius 5910 points

Adam,

You give me some advice to how to change lab_13C from move to continues running(lab 13E). That works fine. I can switch between move command to continues running motor. But after continues running when the motor is stopped, the move command doesn't work anymore. I can t find any problem, no error messages. So do you have a hint where I have to look or what the problem maybe?

 Thanks,

  Ernst

 

  • Ernst,

    One thing about the continuous running mode is that you will need to set gMotorVars.RunPositionProfile each time you update the value in gMotorVars.MaxSpeed_krpm.  Otherwise the profile generator doesn't know that there is a new command it needs to generate.  Is it the case where after you switched to continuous running mode that you could no longer update the speed setpoint?

  • Adam,

     I moved the all of the code from ST_runPosMove to my position move and continues move command. and moved     STPOSMOVE_run(stObj->posMoveHandle); to the mainISR.

    This is the code to make the move:

    void Contrl_SetPosMove (INTR_Handle intr,float move,ST_MoveCurveType_e  CurveType)
    {
        ST_Obj *stObj = (ST_Obj *)intr->stHandle;
        float moveF;
        int moveI;

        moveI=(int)move;
        moveF=move - moveI;
        // Run SpinTAC Position Profile Generator
        // If we are not running a profile, and command indicates we should has been modified
        if(STPOSMOVE_getStatus(stObj->posMoveHandle) == ST_MOVE_IDLE) {
            // Get the configuration for SpinTAC Position Move
            STPOSMOVE_setCurveType(stObj->posMoveHandle, CurveType);
            STPOSMOVE_setPositionStep_mrev(stObj->posMoveHandle,moveI, _IQ( moveF));
            // Enable the SpinTAC Position Profile Generator
            STPOSMOVE_setEnable(stObj->posMoveHandle, true);
            // clear the position step command
            intr->Flag_enableFOC=false;
        }

        STPOSMOVE_run(stObj->posMoveHandle);
    }

    void Control_SetFOC (INTR_Handle intr,float speed)
    {
        ST_Obj *stObj = (ST_Obj *)intr->stHandle;
            // Get the configuration for SpinTAC Velocity Profile Generator
            STPOSMOVE_setCurveType(stObj->posMoveHandle, intr->SpinTAC.PosMoveCurveType);
            STPOSMOVE_setProfileType(stObj->posMoveHandle, ST_POS_MOVE_VEL_TYPE);
            STPOSMOVE_setVelocityEnd(stObj->posMoveHandle, _IQ(speed * (float)(ST_SPEED_PU_PER_KRPM)));
            // Enable the SpinTAC Position Profile Generator
            STPOSMOVE_setEnable(stObj->posMoveHandle, true);
            // clear the position step command
        intr->Flag_enableFOC=true;
    }

    edit: This the code in the mainISR for continues move:

            // position control
              if (intr->Flag_enableFOC == false)
              {
                  ST_runPosPlanTick(intr->stHandle);
                  ST_runPosPlan(intr);

              }
              // stop when the end speed and the measured speed are 0.
              else if ((Contrl_GetSpeed_krpm (intr) == 0) && (STPOSMOVE_getVelocityEnd(stObj->posMoveHandle) == 0))
                 intr->Flag_enableFOC = false;

  • Ernst,

    In your code you setting STPOSMOVE_setProfileType(stObj->posMoveHandle, ST_POS_MOVE_VEL_TYPE) when you want to run continuous moves, but you aren't setting STPOSMOVE_setProfileType(stObj->posMoveHandle, ST_POS_MOVE_POS_TYPE) when you want to do point-to-point moves.  I think if you add that call into the Contrl_SetPosMove function this should resolve the issue.