cancel
Showing results for 
Search instead for 
Did you mean: 

PWM Electronic speed control issue, B-G431B-ESC1

Labrey
Associate II

Hello everyone,

I recently worked with a B-G431B-ESC1 discovery kit with STM32G431CB MCU, and I find a mistake in the code generated by Motor Control Workbench 6.1.2, that made the Electronic speed control feature (

the one used in the example of the same name) not usable, the symptoms were that the motor never leaves the arming state, said otherwise it was spinning when a PWM signal between 1060µs and 1860µs of on time, was sent to the board, but the speed was not controllable by the PWM signal.

(if you didn't manage to make the motor run I advise you to check if the motor run in sensorless mode, you can do this in the motor profiler, if it is the case, you should verify your sensor settings

To solve the issue, first generate the project in MC workbench with your settings,

then you should open the project with your IDE, STM32CubeIDE for example,

look for the esc.c file, this file is located located in the path described in the picture attached : your_project_name\Middlewares\MotorControl\esc.c

And modify the code line number 112

if((pHandle->Ton_value >= pESC_params->Ton_arming) && (pHandle->Ton_value < pESC_params->Ton_min))

by 

if((pHandle->Ton_value >= pESC_params->Ton_arming) && (pHandle->Ton_value > pESC_params->Ton_min))

 

Next you can save this file, build the project and send it on your board with the run button. And It should work.

The second inequality made the expression always invalid, the inequality was in the wrong direction since Ton_arming<Ton_min, to arm the ESC we want that Ton_value  which represents the value read from the PWM input verify Ton_min<Ton_value to make the motor armed, making the first inequality useless.

Keep in mind that you have to make this modification each time that you generate the project in MC workbench. Since no parameters are stored in the esc.c, you and keep this file that you modified saved in another location on your computer and paste it to replace the new version that has been generated with the mistake when you are modifying the parameters of MC workbench. I also linked the esc.c file corrected to this thread.

I hope that this can help some people.

I also tried to modify the esc file to make the motor run clockwise and anti clockwise depending on the PWM input (below 50% anti-clockwise and clockwise in the other case) but the speed reference wasn't working.

My final goal is to create a torque control system with torque that can be positive and negative with a low Kv motor and a incremental encoder.

If anyone has managed to do something similar, I'd love to talk about it !

 

2 REPLIES 2
RhSilicon
Lead

Is this also required for SDK v6?

Yes, it is. I tested this with SDK 6.1.2, sorry for the mistake it is not 1.6.2 but 6.1.2. It is now corrected.