cancel
Showing results for 
Search instead for 
Did you mean: 

PWM input problem with B-G431B-ESC1

elag
Associate

HI, 

I am currently doing a project with the B-G431B-ESC1. I am trying to control a motor with the B-G431B-ESC1. I already have profil my motor with the motor profiler software. I am able to control my motor with the motor pilot software. Now, I am trying to control my motor with an external PWM input. I send a PWM signal at 490Hz with duty cycle value between 1060us and 1860us with a ESP32 (the signal is corect, i have verify with an oscilloscope). The B-G431B-ESC1 detect the PWM and beeping when i switch off the signal. However, I am not able to control the motor with the PWM. My motor start running at constant speed doesn't matter the duty cycle value.

 

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
elag
Associate

Hello @cedric H  and @STMBatu , thank you both for answering

I think, my problem was i never left the arming state even with the pwm at the great duty cycle. So, in order to make the B-G431B-ESC1 work I have simplify the condition which allow to go in armed state (line 112 i think). Now my motor work correctly. My last (little) problem is i can't use debug in real time to see sm_state and ton_value value in real time. I alredy have allow the debug in open loop.

@STMBatu, i think when the motor is beeping that mean the motor is ready to be use (great voltage supply, detect PWM...). however, at the begining your motor is in a arming state and need a pwm below 1060us to pass in armed state. if you don't need a arming_state like me, my advice is to simplify the arming_state condition (line 112 in the esc.c file) and says only if ton_value is over 1060us(pESC_params->Ton_min).

 

Have great day,

elag

View solution in original post

4 REPLIES 4
STMBatu
Associate II

Hello @elag ,

I have the same problem here.

However I got one step closer by activating the ESC in the Stage Configuration.

My motor is beeping but not really doing much.

I hope by commenting this your post gets pushed up and gets some attention.

Batu

cedric H
ST Employee

Hello,

From my past experience, your issue could come from a ground connection missing between your board ESP32 and the B-G431B-ESC1. Could you confirm that the 2 boards shared the same ground?

The variation of the PWM input must be reflected into the global variable ESC_M1.Ton_value, and the state machine ESC1.sm_state must be in ESC_POSITIVE_RUN.

In this state, MCI_ExecSpeedRamp is called with a value computed from Ton_value.

 

The ESC state machine is available in the esc.c file.

Regards

Cedric

elag
Associate

Hello @cedric H  and @STMBatu , thank you both for answering

I think, my problem was i never left the arming state even with the pwm at the great duty cycle. So, in order to make the B-G431B-ESC1 work I have simplify the condition which allow to go in armed state (line 112 i think). Now my motor work correctly. My last (little) problem is i can't use debug in real time to see sm_state and ton_value value in real time. I alredy have allow the debug in open loop.

@STMBatu, i think when the motor is beeping that mean the motor is ready to be use (great voltage supply, detect PWM...). however, at the begining your motor is in a arming state and need a pwm below 1060us to pass in armed state. if you don't need a arming_state like me, my advice is to simplify the arming_state condition (line 112 in the esc.c file) and says only if ton_value is over 1060us(pESC_params->Ton_min).

 

Have great day,

elag

Hello @elag,

Thank you for your feedback.

The idea of ESC_ARMING is to prevent injuries with propeller in case of wrong signal applied at PWM input.

For instance, if you send a signal stuck at 1 by mistake, your propeller will spin full speed directly out of reset.

If you look at the condition :

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

Default parameters are the following:

(from parameters_conversion_g4xx.h)

#define ESC_TON_ARMING ((APB1TIM_FREQ /1000000) * 800 )

#define ESC_TON_MIN (APB1TIM_FREQ / 1000000 * 1060 )

(from mc_parameters.c)

.ARMING_TIME = 200,

Arming condition is then fulfilled if 800 us <= TOn < 1060 us for 200 us. 

This code is provided as an example of implementation, you are completely free to remove this security check if you do not need it. Just take care at your fingers ;) 

Hope it helps

Regards

Cedric