Skip to main content
Lzhiy.1
Associate II
November 26, 2021
Solved

can FOC Frequency be very low?

  • November 26, 2021
  • 2 replies
  • 1623 views

I've designed an FOC board.First of all,I want to realize the SVPWM without using other transformation in order to make the motor rotate first.

PWMC_SetPhaseVoltage(pwmcHandle, Valphabeta);

so I generate an array about Valphabeta as the code below:

#define PIDIV180 0.017453292519943
#define MAX 25000
int main()
{
 double cnt=0,angle;
 int a,b;
 printf("int16_t test1[][2]=\n{\n");
 for(cnt = 0;cnt<90;cnt+=0.05)
 {
 angle = cnt * PIDIV180;
 a = MAX*cos(angle);
 b = MAX*sin(angle);
 printf("{%d,%d},\n",a,b);
 }
 printf("};");
 return 0;
}

and the FOC code is changed to below:

	cnt = (cnt+1)%1800;
	if(!cnt)
	{
		cnt1 = (cnt1+1)%4;
	}
	
	switch(cnt1)
	{
		case 0:// 4 quadrand
			a = test1[cnt][0];
			b = test1[cnt][1];
			break;
		case 1:// 3 quadrand
			a = -test1[cnt][1];
			b = test1[cnt][0];
			break;
		case 2:// 2 quadrand
			a = -test1[cnt][0];
			b = -test1[cnt][1];
			break;
		case 3:// 1 quadrand
			a = test1[cnt][1];
			b = -test1[cnt][0];
			break;
	}
 
	Valphabeta.alpha = a;
	Valphabeta.beta = b;
 hCodeError = PWMC_SetPhaseVoltage(pwmcHandle, Valphabeta);

when PWM_FREQUENCY is above 10k,the motor rotates,but when PWM_FREQUENCY is slow like 5k,the motor rotates back and forth at a small angle.

Where is the problem?FOC frequency can't be too low or my test method is wrong.

This topic has been closed for replies.
Best answer by Lzhiy.1

Solved.It depends on the ADV_TIM_CLK_MHz.

#define ADV_TIM_CLK_MHz 128
#define PWM_FREQUENCY 5000
#define PWM_PERIOD_CYCLES (uint16_t)((ADV_TIM_CLK_MHz*(uint32_t)1000000u/((uint32_t)(PWM_FREQUENCY)))&0xFFFE)
 
and the variable:
 .hT_Sqrt3 = (PWM_PERIOD_CYCLES*SQRT3FACTOR)/16384u,
is out of bound.

2 replies

Saurabh SONA
Visitor II
November 26, 2021

The X-CUBE-MCSDK standard code works well at frequencies lower than 10kHz. The lowest supported PWM frequency is in fact 2kHz. The optimal PWM frequency depends on the motor parameters.

Lzhiy.1
Lzhiy.1AuthorBest answer
Associate II
November 27, 2021

Solved.It depends on the ADV_TIM_CLK_MHz.

#define ADV_TIM_CLK_MHz 128
#define PWM_FREQUENCY 5000
#define PWM_PERIOD_CYCLES (uint16_t)((ADV_TIM_CLK_MHz*(uint32_t)1000000u/((uint32_t)(PWM_FREQUENCY)))&0xFFFE)
 
and the variable:
 .hT_Sqrt3 = (PWM_PERIOD_CYCLES*SQRT3FACTOR)/16384u,
is out of bound.