cancel
Showing results for 
Search instead for 
Did you mean: 

How to control sensored motor via B-G431B-ESC1 PWM input ?

timco
Associate II

Hi all!

I am trying to control a motor with integrated hall sensors using the B-G431B-ESC1. I've had a lot of problems, getting all kinds of errors while setting up the firmware, but I managed to control it through the motor pilot.

Now I would like to control it with a PWM-input onto the board pin but as soon as I configure the hall sensors in the example project it stops working correctly

All in all I'm a bit baffled at how hard it is to get anything to work the way you want even with fresh installs of all the software.

Anyway I'm using:

MC Workbench SDK 5.4.8

CubeMX 6.3.0

CubeIDE 1.12.0

CubeProgrammer 2.13.0

If anyone could help me out here I would be very thankful!

7 REPLIES 7
Zied b.
ST Employee

Hello,

Have you tried with MCSDK 6.1.1 ?

You will be able to activate the ESC on the workbench and control the speed of your motor with a PWM input.

The electronic speed control (ESC) feature allows to control the motor speed with a PWM signal in input, for example on the B-G431B-ESC1 boards it is possible to use this feature to control the motors of a drone sending a PWM signal with a different duty cycle to switch the motor to armed, armed with a minimum speed, armed with a maximum speed and unarmed state.

0693W00000Y9oRLQAZ.png 

You can find more details on this example on this link : click here

on the chapter "Connection and first execution of the electronic speed controller (ESC) program".

If you agree with my answer, please accept it by clicking on "Accept as solution".
timco
Associate II

Hi!

Thanks for your reply!

So I am now using MCSDK 6.1.1 and I can see that all the pins are programmed correctly. However, the duty cycle of the input PWM does not impact the speed of the motor. If I have a 0% or 100% duty cylce PWM it doesn't spin and in all other cases it just spins at the same random speed. Do you know what the problem could be ?

Also I am unable to use the motor profiler or even the motor pilot when using firmware generated with MCSDK 6.1.1.

If I upload the old firmware I can again use the motor pilot on MCSDK 5.4.8 but not on 6.1.1.

Is this a known problem perhaps ?

Zied b.
ST Employee

Hello @timco​ ,

To control the motor, you must first put it in unarmed state and then increase the duty cycle.

You can use a debugger and follow pHandle->sm_state variable that indicate the state of your ESC.

The state should begin to ESC_ARMING then ESC_ARMED and finally ESC_POSITIVE_RUN.

You can find more information in the file esc.c

Then it's normal that  you cannot use a 5.4.8 firmware with the motor Pilot included in version 6.1.1 because the communication protocol used is not compatible.

If you agree with my answer, please accept it by clicking on "Accept as solution".
timco
Associate II

Where exactly can I see this variable ? Also the esc.c file ?

What I was trying to say is that firmware generated with SDK 6.1.1 doesn't allow me to use the motor pilot in the same version. The motor profiler also gets hung up on "checking st-link connection" even after erasing the firmware.

Zied b.
ST Employee

Hello @timco​ 

Yes, this variable is updated in the esc.c file.

It seems strange to me that the Motor Pilot and the Motor Profiler do not work.

What tool do you use to flash the Firemware on the board?

If you agree with my answer, please accept it by clicking on "Accept as solution".
timco
Associate II

So I got the speed control working now with a potentiometer, so thanks for the tip there!

I load the firmware with the CubeIDE 1.12.0 or erase with CubeProgrammer 2.13.0 and it doesn't let me connect to the motor profiler or pilot, even with a completely new board.

Zied b.
ST Employee

for Motor profiler, can you get the file "B-G431B-ESC1#B-G431B-ESC1 3Sh#(6.1.1).hex" which is in the directory : \MC_SDK_6.1.1\Utilities\PC_SoftwareSTMotorPilotSTM32CubeProgrammer\Fw and flash it manually with Stm32CubeProgrammer and disconnect CubeProgrammer.

then try to connect manually with the profiler.

If you have the possibility to make a video screen capture so that I can understand where the problem comes from?

If you agree with my answer, please accept it by clicking on "Accept as solution".