欢迎来到天天文库
浏览记录
ID:42675656
大小:27.50 KB
页数:3页
时间:2019-09-19
《直流电机可控硅程序》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、#include#defineucharunsignedchar#defineuintunsignedintucharzhishi[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};/*显示码*/uinta,b;bitmod=1;uchari,j;voidjianpan(void)/*键盘扫描程序*/{if(P2_1==0)/*P21为加速键*/if(a<49900)a=a+100;if(P2_5==0)/*P25为减速键*/if(a>100)a=a-100;
2、}voidwaite(void)/*显示用延时程序*/{for(i=0;i<3;i++)for(j=0;j<10;j++);}voidxianshiqi(void)/*显示程序*/{if(a>=45000)P0=zhishi[9];waite();if(a>=40000&&a<45000)P0=zhishi[8];waite();if(a>=35000&&a<40000)P0=zhishi[7];waite();if(a>=30000&&a<35000)P0=zhishi[6];waite();if(a>=25000&&a<30000)P
3、0=zhishi[5];waite();if(a>=20000&&a<25000)P0=zhishi[4];waite();if(a>=15000&&a<20000)P0=zhishi[3];waite();if(a>=10000&&a<15000)P0=zhishi[2];waite();if(a>=5000&&a<10000)P0=zhishi[1];waite();if(a<5000)P0=zhishi[0];waite();}voidintie0(void)interrupt0/*用于测试停止开关*/{mod=0;}voidint
4、t0(void)interrupt1/*T0中断服务,用于输出占空比可调的脉冲*/{b=50000-a;if(P1_0==1){TH0=(65536-a)/256;TL0=(65536-a)%256;P1_0=0;P1_3=0;}else{TH0=(65536-b)/256;TL0=(65536-b)%256;P1_0=1;P1_3=1;}}voidintie1(void)interrupt2/*用于可控硅关断*/{P3_1=0;waite();for(i=0;i<150;i++)for(j=0;j<3;j++);P3_1=1;}void
5、main(void){TMOD=0x01;TH0=0xff;TL0=0xff;TCON=0x05;IE=0x87;cx:while(P2_6);while(P2_6==0);a=100;TR0=1;while(mod){jianpan();xianshiqi();}TR0=0;P1_0=1;P1_3=1;P3_1=0;waite();P3_1=1;P0=0xff;if(mod==0)mod=1;gotocx;}
此文档下载收益归作者所有