您好,欢迎访问三七文档
当前位置:首页 > 机械/制造/汽车 > 制造加工工艺 > 数控直流稳压电源程序
#includeREGX52.HUnsignedcharled[15]={0x6f,0x7f,0x07,0x7d,0x6d,0x66,0x4f,0x5b,0x06,0x3f,0x39,0x52,0x64,0x37,0x0e};//9876543210-voidmain()//主函数{voidledout(unsignedcharATA,charadd,charj);voiddelays(unsignedchart);unsignedcharodata,key,temp;unsignedintF,f=0x100;//初始频率charadd=0,j=1;odata=155;//电压初值为5vj=1;while(1){for(F=f;F0x110;F++){P3=0xff;key=P3;if(key!=0xff){unsignedchari;for(i=0;i10;i++){ledout(odata,add,j);delays(10);ledout(odata,add,-j);delays(10);}key=P3;if(key==0xff)break;for(i=0;i10;i++){ledout(odata,add,j);delays(10);ledout(odata,add,-j);delays(10);}if(add==0)temp=odata;//记录当前电压值switch(key){case0x7f:if(add==0)if(odata57)odata=odata-2;//电压加0.1Vbreak;case0xbf:if(add==0)if(odata255)odata=odata+2;break;case0xdf:if(add==0){//三角波f=0x100;//1时为频率最高,最大允许256odata=155;add=1;}elseif(add==1){//方波//f=f*200;//频率跟随f=0x100;odata=55;add=200;}elseif(add==-1){//f=f*200;f=0x100;odata=55;add=200;}elseif(add==200){//直流电压add=0;odata=temp;//电压记忆恢复}else{add=0;odata=temp;}break;case0xef:if(add!=0){f=f/2;//频率频率加if(f==1)if(add==1)f=0x100;elsef=0x3200;}break;}}if(odata==255)add=-add;odata=odata+add;if(odata==55)add=-add;P0=odata;//送数据}ledout(odata,add,j);//送显示j=-j;}}voidledout(unsignedcharATA,charadd,charj){unsignedcharDH,DL,temp;switch(add){case0:{temp=((ATA-55)/2)-1;//十进制转换DH=temp/10;DL=temp%10;}break;case1:{DH=11;DL=12;}break;case-1:{DH=11;DL=12;}break;case200:{DH=13;DL=14;}break;case-200:{DH=13;DL=14;}break;}switch(j){case1:{P1=led[DH];//送数码管高位显示P1_7=1;//动态显示}break;case-1:P1=led[DL];//送数码管低位显示break;}}voiddelays(unsignedchart){unsignedchars;for(;t0;t--)for(s=0;s255;s++);}
本文标题:数控直流稳压电源程序
链接地址:https://www.777doc.com/doc-4994832 .html