2025-04-28 7:29 AM
Hello,
I am currently designing an ESC for a small vehicle (around 300g). I made a first proto board and I use the 6-steps algorithm with an hall sensored motor. I would like to be able to brake. I firstly thought to short all the phases directly to the ground with a PWM in order to brake more or less but it seems that there is no dedicated function for braking in the generated project.
Here are the availabe functions in mc_api.h :
/* Starts Motor 1 */
bool MC_StartMotor1(void);
/* Stops Motor 1 */
bool MC_StopMotor1(void);
/* Programs a Speed ramp for Motor 1 */
void MC_ProgramSpeedRampMotor1(int16_t hFinalSpeed, uint16_t hDurationms);
/* Returns the current PWM duty cycle reference for Motor 1 */
int16_t MCI_GetDutyCycleRefMotor1(void);
/* Returns the state of the last submited command for Motor 1 */
MCI_CommandState_t MC_GetCommandStateMotor1(void);
/* Stops the execution of the current speed ramp for Motor 1 if any */
bool MC_StopSpeedRampMotor1(void);
/* Stops the execution of the on going ramp for Motor 1 if any.
Note: this function is deprecated and should not be used anymore. It will be removed in a future version. */
void MC_StopRampMotor1(void);
/* Returns true if the last submited ramp for Motor 1 has completed, false otherwise */
bool MC_HasRampCompletedMotor1(void);
/* Returns the current mechanical rotor speed reference set for Motor 1, expressed in the unit defined by #SPEED_UNIT */
int16_t MC_GetMecSpeedReferenceMotor1(void);
/* Returns the current mechanical rotor speed reference set for Motor 1, expressed in rpm */
float_t MC_GetMecSpeedReferenceMotor1_F(void);
/* Returns the last computed average mechanical rotor speed for Motor 1, expressed in the unit defined by #SPEED_UNIT */
int16_t MC_GetMecSpeedAverageMotor1(void);
/* Returns the last computed average mechanical rotor speed for Motor 1, expressed in rpm */
float_t MC_GetAverageMecSpeedMotor1_F(void);
/* Returns the final speed of the last ramp programmed for Motor 1, if this ramp was a speed ramp */
int16_t MC_GetLastRampFinalSpeedMotor1(void);
/* Returns the final speed of the last ramp programmed for Motor 1, if this ramp was a speed ramp */
float_t MC_GetLastRampFinalSpeedM1_F(void);
/* Returns the current Control Mode for Motor 1 (either Speed or Torque) */
MC_ControlMode_t MC_GetControlModeMotor1(void);
/* Returns the direction imposed by the last command on Motor 1 */
int16_t MC_GetImposedDirectionMotor1(void);
/* Returns the current reliability of the speed sensor used for Motor 1 */
bool MC_GetSpeedSensorReliabilityMotor1(void);
/* Acknowledge a Motor Control fault on Motor 1 */
bool MC_AcknowledgeFaultMotor1(void);
/* Returns a bitfiled showing faults that occured since the State Machine of Motor 1 was moved to FAULT_NOW state */
uint16_t MC_GetOccurredFaultsMotor1(void);
/* Returns a bitfield showing all current faults on Motor 1 */
uint16_t MC_GetCurrentFaultsMotor1(void);
/* returns the current state of Motor 1 state machine */
MCI_State_t MC_GetSTMStateMotor1(void);
/* Call the Profiler command */
uint8_t MC_ProfilerCommand (uint16_t rxLength, uint8_t *rxBuffer, int16_t txSyncFreeSpace, uint16_t *txLength, uint8_t *txBuffer);
What is the best way to brake ? Is it mandatory to add the load resistor ? In the commercial ESC for RC cars, there is a brake function but it doesn't seem to have a load resistor.
If I make a negative speed ramp, is it going to brake ? Or it is just decelerate with the inertia ?
Thanks for your help.
Xavier
Solved! Go to Solution.
2025-05-20 7:14 AM
Hi Xavier, you will find attached two updated files to add into your MCSDK 6.3.2 project to make the "turn on low side feature" of the over voltage compile.
In addition, as an example, the stop action has been updated with the same brake feature by calling the PWMC_TurnOnLowSides.
Best regards.
Fabrice
2025-04-29 7:56 AM
Hello I tried to activate the following function :
But unfortunatly I have the following error when compiling :
.st_workbench/projects/6_step_config_hall/Src/mc_tasks.c:440:(.text.TSK_SafetyTask_LSON+0xc): undefined reference to `PWMC_GetTurnOnLowSidesAction'
Any help ?
Thanks
2025-05-19 8:15 AM
Hi Xavier75, unfortunately, this over voltage configuration does not work into the current 6step implementation. Sorry for the inconvenience of this compilation issue. A correction is scheduled for MCSDK6.4.0 version.
however, the function used to brake the motor if the over voltage error occurs in "turn on low side feature" is the following: PWMC_TurnOnLowSides that switches on the PWN Low Side to generate a brake.
Witch version of the MCSDK are you using? MCSDK6.3.2?
Best regards.
Fabrice
2025-05-19 9:01 AM
Hello,
Yes I am using MCSDK 6.3.2.
Regards,
Xavier
2025-05-20 7:14 AM
Hi Xavier, you will find attached two updated files to add into your MCSDK 6.3.2 project to make the "turn on low side feature" of the over voltage compile.
In addition, as an example, the stop action has been updated with the same brake feature by calling the PWMC_TurnOnLowSides.
Best regards.
Fabrice
2025-05-20 8:55 AM
Thank you very much Fabrice !
Merci
Xavier