BLDC Sinusoidal Control

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hiy guys, I am trying to understand how to use sinusoidal control.I have codes someone did it. But I couldn't understand somewhere maybe someone have this experience ,maybe can understand the basic points that I can continue.If you need all codes I can send bu very long this is why I am gonna send specific points.

 

int_sine_temp>>=10;  this is interesting.What is it?

 

static void tc_tcc0_ovf_callback(void)
{
	unsigned long long_temp=0;
	pwm_step++;
	switch (pwm_step)
	{
		case 1:
				{
					int_sine_temp=pgm_read_word(&torq_num2[k_a]);
					int_sine_temp*=motor_volt;
					int_sine_temp>>=10;
					
					int_sine_temp+=half_capture_compare;
					TCC0_CCBBUF=int_sine_temp;
					
				int_sine_temp=pgm_read_word(&torq_num2[k_b]);
				int_sine_temp*=motor_volt; ///4;
				int_sine_temp>>=10;
				int_sine_temp+=half_capture_compare;
				TCC0_CCABUF=int_sine_temp;
				
		
				int_sine_temp=pgm_read_word(&torq_num2[k_c]);
				int_sine_temp*=motor_volt; ///4;
				int_sine_temp>>=10;
				int_sine_temp+=half_capture_compare;
				TCC0_CCCBUF=int_sine_temp;

        	motor_amp_temp2+=adc_read(_motor_amp_pin);
			motor_amp_temp2/=2;
			motor_amp_temp=motor_amp_temp2;
		}
		//.
		//.
		//.
	    //Code has more 	
	}

 

This topic has a solution.
Last Edited: Thu. Nov 21, 2019 - 06:27 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
int_sine_temp>>=10;

Is an optimized/efficient equivalent to

int_sine_temp = int_sine_temp / 1024;

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

balisong42  , I need this motor to give more speed so where I can look there.How process I should apply.Still it is not clear .Maybe I should read some article if you know about that.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you are wanting to increase velocity, then you need to create a velocity controller. What I see is mention of torque control from the code:

int_sine_temp = pgm_read_word(&torq_num2[k_a]);

where the variable torq_num is referenced.

 

If you mean a faster response time, then that would have to be dealt with your control equation.

 

I am actually working on a project for BLDC torque control as part of my master's project.

 

Can you please share the code with me and I can see what sense I can make of it? Also, it may help me with my project as well.

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi El_Cuc0 of course I can share , I solved the problem probably there is no any problem but you can check it.But the code that I sent up is not good to understand because the engineer who write this code wrote them to get hard to understand for anyone but I solved it.I am gonna send you my code.

 

 

In timer for 31250 Hz. 8 is FTW to frequency and sin table 10 bit this is why is controlled with 1024.

 

 

void TCD0_Overflow_Callback(void)
{
	
	phaseAccumulator+=8;
	
	if(phaseAccumulator>=1023)
	{
		phaseAccumulator = phaseAccumulator-1023;
	} 
	if(dir)
	{
		tc_write_cc(&TCC0, TC_CCA, (uint16_t)(512+512*sinf(0.017453*phaseAccumulator*0.3515)));
		tc_write_cc(&TCC0, TC_CCB, (uint16_t)(512+512*sinf(0.017453*phaseAccumulator*0.3515+2.094)));
		tc_write_cc(&TCC0, TC_CCC, (uint16_t)(512+512*sinf(0.017453*phaseAccumulator*0.3515+4.189)));
	}
	else if(!dir)
	{
		tc_write_cc(&TCC0, TC_CCB, (uint16_t)(512+512*sinf(0.017453*phaseAccumulator*0.3515)));
		tc_write_cc(&TCC0, TC_CCA, (uint16_t)(512+512*sinf(0.017453*phaseAccumulator*0.3515+2.09)));
		tc_write_cc(&TCC0, TC_CCC, (uint16_t)(512+512*sinf(0.017453*phaseAccumulator*0.3515+4.18)));
	}
	/*
	 U(i) =512 + 512*sin((2*pi/1024)*i);
	 V(i) =512 + 512*sin((2*pi/1024)*i + 2.094);
	 W(i) =512 + 512*sin((2*pi/1024)*i + 4.189);
	*/
	tc_clear_overflow(&TCD0);
}

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

By the way according to you said you worked on it ,maybe you know about "Adaptive PID", I am researching on it .If you know about any nice article or example code to understand it,  I am going to be pleased a lot if you sent it.