cancel
Showing results for 
Search instead for 
Did you mean: 

Error when generating code with MC Workbench 6.3.0

STMBatu
Associate II

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

 

7 REPLIES 7
cedric H
ST Employee

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

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

Hello @cedric H ,

another unusual thing I noticed.

There seems to be no "esc.c" file for me in the project.

I have seen you reference that file before in other posts.

My project looks like this:

STMBatu_0-1716404748522.png

However I ticked the box for ESC in the MC Workbench:

STMBatu_1-1716404801739.png

Am I missing something?

Best

Batu

Hello @STMBatu,

>Am I missing something?

esc.c file should be located inside Middlewares/MotorControl

 

cedricH_0-1716454020741.png

Cedric

Hello @cedric H ,

thank you for your response. You have been of great help so far.

However my motor still won't turn consistently.

Let me explain.

I'm currently using a MC-Workshop project using the FOC algorithm. I activated the ESC setting to control the motor with external PWM Signal from a Nucleo Board. I successfully profiled my motor and loaded it into the system. The code on the ESC remains the generated code from the MC-Workshop.

When I load the firmware and connect all peripherals and I put a PWM signal of 1060 to arm the motor, then I increase the PWM signal to 1200µs.

I observe the following behaviour:
The motor starts spinning and starts ramping up. Then after 1-5seconds (random) the motor stops spinning.

What could be the issue here?

Thanks in advance.

Batu 

Hello @STMBatu,

If your motor start to spin, then your PWM input sequence is OK., your issue probably comes from your startup parameters.

First, I advise you to test your project without the ESC PWM input pin enabled. Just with the MC Pilot tool by connecting directly your ESC board to a PC with an USB cable.

The MC Pilot will allow you to understand what's going wrong, and to fine tune all your startup parameters.

Once you have a reliable startup sequence, then you can backport it in the Workbench and regenerate a project with the ESC PWM input enabled. Be careful to not use MC Pilot and PWM input at the same time, otherwise target speed will be set by both at the same time with different values...

Regarding the startup parameters, we need to know what error is reported by the MC Pilot when the motor stops to give you relevant tricks, but I can already advise you to have a look at the following FAQ : Frequently asked questions (FAQ) - stm32mcu Even if the screen shot are now outdated, information are still relevant.

Regards

Cedric

 

 

Hello @cedric H ,

thank you for the response, it always helps to get one step closer to the solution.

The error I receive when the ramp up is stopped is called: Speed Feedback Error

I got this error now multiple times when trying to profile my motor. It usually happens with higher RPM, even if the motor is supposed to be able to perform high RPM (>20kRPM).

The motor which is being used is the A2212/6t 2200KV (BLDC).

I have actually looked at the FAQ. To be more precise I looked into 2.10, so far I have tried the first option, with no success and had no time yet to try the second option listed there.

I will definitely try the Motor Pilot again, since that was working consistent but I didnt know I can load parameters directly from the Motor Pilot, I thought it always needs the Profiler to identify.

I will give an update once I know more, since I figured it to be a common error.

Regards
Batu