基于51单片机设计的数控电压源仿真原理图如下(proteus仿真工程文件可到本帖附件中下载)
单片机源程序如下:
- #include<reg52.h>
- #include<absacc.h>
- #define uchar unsigned char
- #define dac0832 XBYTE[0x7fff]
- sbit key1=P1^0;
- sbit key2=P1^1;
- sbit key3=P1^2;
- sbit key4=P1^3;
- sbit wei1=P1^4;
- sbit wei2=P1^5;
- sbit wei3=P1^6;
- sbit wei4=P1^7;
- uchar x;
- uchar code led[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
- uchar code ledx[]={0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10};
- void delay(unsigned int n)
- {
- unsigned int i,j;
- for(i=0;i<n;i++)
- for(j=0;j<120;j++);
- }
- void display(unsigned int num)
- {
- P2=led[num/1000];//显示整数部分
- wei1=0;
- delay(5);
- wei1=1;
- P2=ledx[num%1000/100];//显示小数部分
- wei2=0;
- delay(5);
- wei2=1;
- P2=led[num%100/10];//显示小数部分
- wei3=0;
- delay(5);
- wei3=1;
- P2=led[num%10];//显示小数部分
- wei4=0;
- delay(5);
- wei4=1;
- }
- main()
- {
- unsigned int disp_voltage;
- float i;
- i=0;
- EA=1;
- EX0=1;
- IT0=1;
- while(1)
- ……………………
- …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码 论文预览:
hcm.zip
(381.54 KB, 下载次数: 119)
|