因为刚刚开始自学无刷电机,所以程序还有许多不懂的地方,希望能够得到解答,十分感谢!
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar code duojishu[]= {11,12,13,14,15,16,17,19,20,21,22,23,24};/*?70us????????????***/
/* 0 1 2 3 4 5 6 7 8 9 10 11 12*/
sbit Sevro_moto_pwm = P1^5;
sbit Sevro_moto_pwm2 = P1^4;
uchar pwm_val_left = 0;
uchar push_val_left = 0;
uchar AD_CHANNEL;
void delay1ms(uchar z)
{
uchar a,b,c;
for(c = z ;c > 0 ;c--)
for(b = 142 ; b > 0 ;b--)
for(a = 2 ;a > 0 ;a--);
}
void pwm_Servomoto(void)
{
if(pwm_val_left <= push_val_left)
{
Sevro_moto_pwm = 1;
Sevro_moto_pwm2 = 1;
}
else
{
Sevro_moto_pwm = 0;
Sevro_moto_pwm2 = 0;
}
if(pwm_val_left >= 215)
pwm_val_left = 0;
}
time1() interrupt 1
{
TH0 = (65536 - 70)/256;
TL0 = (65536 - 70)%256;
pwm_val_left++;
pwm_Servomoto();
}
void main()
{
TMOD = 0x01;
TH0 = (65536 - 70)/256;
TL0 = (65536 - 70)%256;
TR0 = 1;
ET0 = 1;
EA = 1;
push_val_left = duojishu[0]; //???????
delay1ms(5000);delay1ms(5000);delay1ms(5000);
delay1ms(5000);delay1ms(5000);delay1ms(5000);
delay1ms(5000);delay1ms(5000);delay1ms(5000);
delay1ms(5000);delay1ms(5000);delay1ms(5000);
delay1ms(5000);delay1ms(5000);delay1ms(5000);//?????????????????/??0?(????5???)
while(1)
{
for( AD_CHANNEL = 0; AD_CHANNEL < 9; AD_CHANNEL++) //??????????!(??/???1)????9?
{ push_val_left = duojishu[AD_CHANNEL];
delay1ms(5000);
delay1ms(5000);
}
for( AD_CHANNEL = 9; AD_CHANNEL > 1; AD_CHANNEL--) //?9????????!(??/???1)????1?
{ push_val_left = duojishu[AD_CHANNEL];
delay1ms(5000);
delay1ms(5000);
}
push_val_left = duojishu[0];
while(1)
;
}
}
已经用程序将电机驱动转动起来,但是注释的部分不知为何变成了问号。
可是我还有许多不懂的地方,希望有大神能帮我注释一下。不胜感激!
|