数控电压源的设计
设计并制作一个数控电压源,具体要求:
(1)输出电压范围-5V~+5V;
(2)输出误差≤1%;
(3)显示分辨率满量程的1%以上;
还差一个(4)具有0.1V步进输出功能。
仿真原理图如下(proteus仿真工程文件可到本帖附件中下载)
单片机源程序如下:
- /////////////lcd variable/////////////////
- #include <absacc.h>
- #include <reg51.h>
- #define REG0 XBYTE[0x8000]
- #define REG1 XBYTE[0x8100]
- #define REG2 XBYTE[0x8200]
- #define REG3 XBYTE[0x8300]
- unsigned char bdata busyflag;
- unsigned char dat,datn,count;
- unsigned char str[16] = "Output Vol:0.00V";
- sbit busyflag_7=busyflag^7;
- sbit p10=P1^0;
- sbit p11=P1^1;
- sbit p12=P1^2;
- /////////////////end of lcd variable////////////
- ///////////////start of lcd 1602/////////////////
- void busy()
- {
- do
- {
- busyflag=REG1;
- }while(busyflag_7);
- }
- void wrc(unsigned char wcon)
- {
- busy();
- REG0=wcon;
- }
- void wrd(unsigned char wdat)
- {
- busy();
- REG2=wdat;
- }
- void rdd()
- {
- busy();
- dat=REG3;
- }
- void lcdint()
- {
- wrc(0x38);
- wrc(0x01);
- wrc(0x06);
- wrc(0x0c);
- }
- void wrn(unsigned char word[])
- {
- unsigned char i = 0;
- while(word[i]) {
- wrd(word[i++]);
- }
- }
- sbit PIN_JIA = P1^0;
- sbit PIN_JIAN = P1^1;
- sbit PIN_SMG0 = P2^0;
- sbit PIN_SMG1 = P2^1;
- xdata unsigned char DAC0832DATA _at_ 0x7EFF;
- void main()
- {
- unsigned char out, out1;
- unsigned int v;
- out = out1 = 0;
- lcdint();//初始化液晶
- wrc(0x80);
- wrn(str);
- while(1) {
- if(PIN_JIA == 0) {
- if(out < 0xFF) {
- out++;
- DAC0832DATA = out;
- }
- while(PIN_JIA == 0); //等待按键释放
- } else if(PIN_JIAN == 0) {
- if(out > 0x00) {
- out--;
- DAC0832DATA = out;
- }
- while(PIN_JIAN == 0); //等待按键释放
- }
- ……………………
- …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码
所有资料51hei提供下载:
shukongdianyayuan.rar
(60.05 KB, 下载次数: 91)
|