Skip to main content
Associate II
May 21, 2024
Question

Error when generating code with MC Workbench 6.3.0

  • May 21, 2024
  • 1 reply
  • 3199 views

Hello there,

I am currently working on a project considering the B G431B ESC1 and a BLDC motor.

My goal is to control the motor through a external PWM Signal from a nucleo board.

So far I could only control the BLDC motor through the MC Profiler and only in 6Step mode.

After some research I found out that in order to control the BLDC motor with an external signal the ESC setting must be activated in the "Stage Configuration".

I did that and generated the code for the B G431B ESC1, however I recieve the following error message found in error.txt.

Some variable seems not be declared.

Any tips on how to solve this issue?

Thanks in advance

Batu

 

1 reply

cedric H
Technical Moderator
May 22, 2024

Hello @STMBatu,

Thanks a lot for reporting this issue.

The ESC with PWM input support has been initially developed for the FOC solution, and we missed to check it with the 6-steps algo. We will correct this issue in the next patch release MCSDK 6.3.1.

It sounds weird that you can control your motor in 6Step mode only, because the MC Profiler uses the FOC algo. So, if you profiled your motor successfully, the FOC project created with it should work pretty quickly.

Could you describe the issue you are facing with FOC algo ?

Regards

Cedric

STMBatuAuthor
Associate II
May 22, 2024

Hello @cedric H ,

thanks for your response.

I actually tried the FOC algo aswell. At least here the code that got generated could be build successfully.

After deploying the code to the ESC, I connected the ESC to a power supply and I am trying to control the motor via a PWM signal from a nucleo board.

I wrote some code that changed the duty cycle of the PWM signal from unarmed to armed. I hear a beep noise (I assume its the sound that tells that the motor is ready) but there is no movement on the motor.

 

Here is the relevant code, that I run on the Nucleo board: I measured the PWM Signal with a logical analyzer and confirmed the period/dutyCycles.

void setDutyCycleTIM20(uint8_t dutyCycle){
	// check if param dutyCycle is valid
	if (dutyCycle < 0 || dutyCycle > 100){
		// TODO insert error message
		return;
	}
	// set new dutyCycle and map 0 ... 100 to 1060 ... 1860
	__HAL_TIM_SET_COMPARE(&htim20, TIM_CHANNEL_2, (dutyCycle*800)/100.0 + 1060);
}

...

int main(void)
{
...
 while (1) {
 /* USER CODE END WHILE */

	setDutyCycleTIM20(0);
	HAL_Delay(1000);

	setDutyCycleTIM20(5);
	HAL_Delay(5000);

	setDutyCycleTIM20(10);
	HAL_Delay(5000);

	setDutyCycleTIM20(20);
	HAL_Delay(5000);

	__HAL_TIM_SET_COMPARE(&htim20, TIM_CHANNEL_2, 800);
	HAL_Delay(1000);

 /* USER CODE BEGIN 3 */
 }
}

 I am thankful for any tips.

Best

Batu