求高手指导 数控稳压电源要怎么画?proteus仿真,
- #include<reg51.h>
- #define uint unsigned int
- #define uchar unsigned char
- #define DATA_LED P0
- #define DATA_TLC5615 P1
- sbit LED1=P2^1;
- sbit LED2=P2^0;
- sbit JIA1=P2^4;
- sbit JIAN1=P2^5;
- sbit SENT=P2^6;
- sbit OK=P2^7;
- sbit dian=P0^7;
- void mdleay(uint Delaytime);
- uchar a=0,b=1,c=2,n=0,flag;
- float VCC=1.2;
- void mdleay(uint Delaytime)//延时5ms子程序
- {
- uint j=0;
- for(j=0;Delaytime>0;Delaytime–)
- {
- for(j=0;j<130;j++)
- {;}
- }
- }
- void innt0() interrupt 0 using 1
- {
- uchar key;
- mdleay(5);
- key=P2&0xf0;
- switch(key)
- {case(0xe0):if(n==1)
- {if(a==9)
- a=9;
- else
- a++;
- }
- if(n==2)
- {if(b==9)
- b=9;
- else
- b++;
- }
- if(n==3)
- {if(c==9)
- c=9;
- else
- c++;
- }
- break;
- case(0xd0):if(n==1)
- {if(a==0)
- a=0;
- else
- a–;
- }
- if(n==2)
- {if(b==0)
- b=0;
- else
- b–;
- }
- if(n==3)
- {if(c==0)
- c=0;
- else
- c–;
- }
- break;
- case(0xb0):if(n==4)
- n=1;
- else
- n++;
- if(flag==1)
- {
- flag=0;
- a=0;
- b=1;
- c=2;
- DATA_TLC5615=0x00;
- n++;
- }
- break;
- case(0x70):n=0;
- flag=1;
- VCC=a*10+b+0.1*c;
- if(VCC>10)
- {VCC=10;
- a=1;
- b=0;
- c=0;
- }
- if(VCC<12)
- {
- VCC=1.2;
- a=0;
- b=1;
- c=2;
- }
- VCC=(VCC-1.2)/0.04;
- DATA_TLC5615=(int)VCC;
- break;
- default:break;
- }
- }
- main()
- {
- uchar Tab[]={0xc0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0x88,0x83,0xc6,0xA1,0x86,0x8E};
- DATA_TLC5615=0;
- DATA_LED=0xff;
- EA=1;
- EX0=1;
- IT0=1;
- n=0;
- flag=0;
- while(1)
- {
- LED1=1;
- LED2=0;
- DATA_LED=Tab[a];
- mdleay(1);
- DATA_LED=Tab[b]&0x7f;
- LED1=0;
- LED2=1;
- mdleay(1);
- LED2=0;
- }
- }
复制代码