cancel
Showing results for 
Search instead for 
Did you mean: 

Open Loop Mode in MCSDK

SRedd.5
Senior III

I have seen the following options in the software in MCSDK

 MCI_CMD_SETOPENLOOPCURRENT, /*!< set open loop current .*/

 MCI_CMD_SETOPENLOOPVOLTAGE, /*!< set open loop voltage .*/

in mc_interface.h file, but i don't see any source code related to them does MCSDK support open loop mode? I need them to rectify some of the hardware issues, before i run in closed loop with hall sensors. Please advise.

1 ACCEPTED SOLUTION

Accepted Solutions

Hello,

This is a generation issue that has been fixed on MCSDK 6.1.1, you can download it here : X-CUBE-MCSDK-6.

You can also stick to your 6.1 version, and replace every occurrence of M1_DBG_OPEN_LOOP_ENABLE by DBG_OPEN_LOOP in your .ioc file. Then you can generate the project again via CubeMx. This should fix the problem.

Hope this will help,

Best Regards,

Gaël A.

If you agree with my answer, please consider accepting it by clicking on 'Accept as solution'.

Hope this will help,
Gaël A.

View solution in original post

13 REPLIES 13
Gael A
ST Employee

Hello SRedd.5,

Those two options are for a Motor Pilot feature that can be enabled by checking the "Open Loop" box in the "Stage Configuration" tab while creating your project via workbench :


_legacyfs_online_stmicro_images_0693W00000bjMEsQAM.png 

Using the MotorPilot, the two Open Loop Control Modes now become available :


_legacyfs_online_stmicro_images_0693W00000bjMMMQA2.png 

The Open Loop Voltage Mode is used by varying the Voltage Reference value, and the Open Loop Current Mode by varying the Flux Reference Mode. Both are available by clicking on "Advanced Configuration" on the left of the window. Be sure to set a low target speed to ensure your motor manages to start.

Hope this will help,

Best Regards,

Gaël A.

If you agree with my answer, please consider accepting it by clicking on 'Accept as solution'.

Hope this will help,
Gaël A.
SRedd.5
Senior III

Thank you so much for your replies, it is helping me a lot in the project i could now run the motor in sensorless, now i am trying hall sensor based.

My question is i am using your source code and i downloaded the code from Motor control work bench 6.1.0. When i see the source code mc_interface.c

__weak void MCI_ExecBufferedCommands(MCI_Handle_t *pHandle)

{

#ifdef NULL_PTR_MC_INT

 if (NULL == pHandle)

 {

  /* Nothing to do */

 }

 else

 {

#endif

  if ( pHandle->CommandState == MCI_COMMAND_NOT_ALREADY_EXECUTED )

  {

   bool commandHasBeenExecuted = false;

   switch (pHandle->lastCommand)

   {

    case MCI_CMD_EXECSPEEDRAMP:

    {

     pHandle->pFOCVars->bDriveInput = INTERNAL;

     STC_SetControlMode(pHandle->pSTC, MCM_SPEED_MODE);

     commandHasBeenExecuted = STC_ExecRamp(pHandle->pSTC, pHandle->hFinalSpeed, pHandle->hDurationms);

     break;

    }

    case MCI_CMD_EXECTORQUERAMP:

    {

     pHandle->pFOCVars->bDriveInput = INTERNAL;

     STC_SetControlMode(pHandle->pSTC, MCM_TORQUE_MODE);

     commandHasBeenExecuted = STC_ExecRamp(pHandle->pSTC, pHandle->hFinalTorque, pHandle->hDurationms);

     break;

    }

    case MCI_CMD_SETCURRENTREFERENCES:

    {

     pHandle->pFOCVars->bDriveInput = EXTERNAL;

     pHandle->pFOCVars->Iqdref = pHandle->Iqdref;

     commandHasBeenExecuted = true;

     break;

    }

    default:

     break;

   }

   if (commandHasBeenExecuted)

   {

    pHandle->CommandState = MCI_COMMAND_EXECUTED_SUCCESFULLY;

   }

   else

   {

    pHandle->CommandState = MCI_COMMAND_EXECUTED_UNSUCCESFULLY;

   }

  }

#ifdef NULL_PTR_MC_INT

 }

#endif

}

I don't find the

 MCI_CMD_SETOPENLOOPCURRENT, /*!< set open loop current .*/

 MCI_CMD_SETOPENLOOPVOLTAGE,

commands why is it, where are they present, where is it implemented? Please help.

Hello,

This is a generation issue that has been fixed on MCSDK 6.1.1, you can download it here : X-CUBE-MCSDK-6.

You can also stick to your 6.1 version, and replace every occurrence of M1_DBG_OPEN_LOOP_ENABLE by DBG_OPEN_LOOP in your .ioc file. Then you can generate the project again via CubeMx. This should fix the problem.

Hope this will help,

Best Regards,

Gaël A.

If you agree with my answer, please consider accepting it by clicking on 'Accept as solution'.

Hope this will help,
Gaël A.
SRedd.5
Senior III

Ok I will do that now.​

SRedd.5
Senior III

I have downloaded the software i gave the following command when i receive CAN message

if(g_motormodeselection_u8 == OPENLOOP_VOLTAGEMODE)

    {

    MCI_SetOpenLoopVoltage(&Mci[MOTOR_0]);

    }

but the motor does not run

#define OPEN_LOOP_VOLTAGE_d      2000   /*!< Three Phase voltage amplitude

                           in int16_t format */

#define OPEN_LOOP_SPEED_RPM      100    /*!< Final forced speed in rpm */

#define OPEN_LOOP_SPEED_RAMP_DURATION_MS 1000 /*!< 0-to-Final speed ramp duration */

#define OPEN_LOOP_VF         false   /*!< true to enable V/F mode */

#define OPEN_LOOP_K          44    /*! Slope of V/F curve expressed in int16_t Voltage for

                           each 0.1Hz of mecchanical frequency increment. */

#define OPEN_LOOP_OFF         4400   /*! Offset of V/F curve expressed in int16_t Voltage

                           applied when frequency is zero. */

These are the other settings. I only see i fixed PWM on the phase line.

What is the conversion of 2000 into voltage?

Gael A
ST Employee

Hello SRedd.5,

You need to make a few more steps to make your motor run.

After setting your Open Loop Voltage, you need to set a duty cycle (referred as Voltage Reference in motor pilot) in percentage. Usually you want a low duty cycle otherwise your motor won't start. Something like 10% is generally enough. This is done like that :

OL_UpdateVoltage( &OpenLoop_ParamsM1, ((DUTY_CYCLE * 32767) / 100));

You can find this function by looking at the MC_REG_FOC_VDREF register when handling MotorPilot requests.

Then you have to set a speed ramp for your motor to follow, :

MCI_ExecSpeedRamp(&Mci[MOTOR_0], (int16_t)((SPEED_RPM * SPEED_UNIT) / U_RPM), DURATION_MS);

You need to specify SPEED_RPM as well as DURATION_MS. Be careful not to set a too high speed, as your motor may not catch up and never start properly ; keep in mind that when working in Open Loop, you must have low acceleration.

Finally, there's only to call for a motor start via :

MC_StartMotor1();

I hope this will help you start your motor.

Best regards,

Gaël A.

If you agree with my answer, please consider accepting it by clicking on 'Accept as solution'.

Hope this will help,
Gaël A.
SRedd.5
Senior III

I will try and update

SRedd.5
Senior III

No the motor does not run the voltage dips to 2V from 20V and current increases. I am not sure what to do.​

Hello again,

Could you tell me the values you gave for DUTY_CYCLE, SPEED_RPM and DURATION_MS as well as the reference of the motor you are trying to run ?

Best Regards,

Gaël A.

If you agree with my answer, please consider accepting it by clicking on 'Accept as solution'.

Hope this will help,
Gaël A.