直流电机调速程序
时间:09-04
来源:互联网
点击:
#includereg52.h>
sbit KEY1 = P3^1; //定义调速按键
sbit PWM = P1^5; //定义调速端口
unsigned char CYCLE; //定义周期T=x*0.1ms
unsigned char PWM_ON ; //定义高电平时间
void delay(unsigned int cnt)
{
while(--cnt);
}
main()
{
unsigned char PWM_Num;
TMOD |=0x01;
TH0=(65536-1000)/256;
TL0=(65536-1000)%256;
IE= 0x82;
TR0=1;
CYCLE = 10;
while(1)
{
if(!KEY1)
{
delay(10000);
if(!KEY1)
{
PWM_Num++;
if(PWM_Num==4)
PWM_Num=0;
switch(PWM_Num)
{
case 0:P0=0x06;PWM_ON=0;break;
case 1:P0=0x5B;PWM_ON=4;break;
case 2:P0=0x4F;PWM_ON=6;break;
case 3:P0=0x66;PWM_ON=8;break;
default:break;
}
}
}
}
}
void tim(void) interrupt 1 using 1
{
static unsigned char count;
TH0=(65536-1000)/256;
TL0=(65536-1000)%256;
if (count==PWM_ON)
{
PWM = 1;
}
count++;
if(count == CYCLE)
{
count=0;
if(PWM_ON!=0)
PWM = 0;
}
}
sbit KEY1 = P3^1; //定义调速按键
sbit PWM = P1^5; //定义调速端口
unsigned char CYCLE; //定义周期T=x*0.1ms
unsigned char PWM_ON ; //定义高电平时间
void delay(unsigned int cnt)
{
while(--cnt);
}
main()
{
unsigned char PWM_Num;
TMOD |=0x01;
TH0=(65536-1000)/256;
TL0=(65536-1000)%256;
IE= 0x82;
TR0=1;
CYCLE = 10;
while(1)
{
if(!KEY1)
{
delay(10000);
if(!KEY1)
{
PWM_Num++;
if(PWM_Num==4)
PWM_Num=0;
switch(PWM_Num)
{
case 0:P0=0x06;PWM_ON=0;break;
case 1:P0=0x5B;PWM_ON=4;break;
case 2:P0=0x4F;PWM_ON=6;break;
case 3:P0=0x66;PWM_ON=8;break;
default:break;
}
}
}
}
}
void tim(void) interrupt 1 using 1
{
static unsigned char count;
TH0=(65536-1000)/256;
TL0=(65536-1000)%256;
if (count==PWM_ON)
{
PWM = 1;
}
count++;
if(count == CYCLE)
{
count=0;
if(PWM_ON!=0)
PWM = 0;
}
}
- 基于DSP的无刷直流电机调速系统(06-01)
- 基于DSP的无刷直流电机伺服系统设计(03-14)
- 基于DSP储能飞轮用无刷直流电机的数字控制系统(06-08)
- 基于TMS320F2812无刷直流电机控制系统设计 (06-27)
- DSP在三相无刷直流电机控制系统的应用(01-10)
- 基于dsPIC30F3010实现无刷直流电机的无传感器控制(05-20)