标题: 51单片机万用表制作 实物图+Proteus仿真+C语言程序 [打印本页]

作者: 51黑ele    时间: 2016-5-10 21:11
标题: 51单片机万用表制作 实物图+Proteus仿真+C语言程序
51单片机结合proteus仿真做了一个万用表的仿真



单片机万用表的仿真图,原理图如下:






所有资料下载(包含仿真和源码): 数字万用表.zip (139.9 KB, 下载次数: 206)


还有一个汇编语言版本的51黑电子论坛的万用表:http://www.51hei.com/bbs/dpj-50064-1.html
单片机数字万用表的程序如下:
  1. #include <AT89X52.H>  
  2. unsigned char code dispbitcode[]={0xfe,0xfd,0xfb,0xf7, 0xef,0xdf,0xbf,0x7f};
  3. unsigned char code dispcode[]={0x3f,0x06,0x5b,0x4f,0x66, 0x6d,0x7d,0x07,0x7f,0x6f,0x00};
  4. unsigned char dispbuf[8]={10,10,10,10,10,0,0,0};
  5. unsigned char dispcount;
  6. unsigned char getdata;
  7. unsigned int temp;
  8. long int  i;
  9. unsigned int R1;

  10. sbit ST=P3^0;
  11. sbit OE=P3^1;
  12. sbit EOC=P3^2;
  13. sbit CLK=P3^3;
  14.   
  15. void main(void)
  16. {
  17.   ST=0;
  18.   OE=0;
  19.   ET0=1;
  20.   ET1=1;
  21.   EA=1;
  22.   TMOD=0x12;
  23.   TH0=216;
  24.   TL0=216;
  25.   TH1=(65536-5000)/256;
  26.   TL1=(65536-5000)%256;
  27.   TR1=1;
  28.   TR0=1;
  29.   ST=1;
  30.   ST=0;
  31.   while(1)
  32.     {
  33.       if(EOC==1)
  34.         {
  35.           OE=1;
  36.           getdata=P0;
  37.           OE=0;
  38.                     i=getdata*196;
  39.                         dispbuf[5]=i/10000;
  40.                         i=i%10000;
  41.                         dispbuf[6]=i/1000;
  42.                         i=i%1000;
  43.                         dispbuf[7]=i/100;         
  44.           ST=1;
  45.           ST=0;
  46.         }
  47.     }
  48. }
  49.   
  50. void t0(void) interrupt 1 using 0           //定时器0  中断服务
  51. {
  52.   CLK=~CLK;
  53. }
  54.   
  55. void t1(void) interrupt 3 using 0          //定时器1  中断服务
  56. {
  57.   TH1=(65536-6000)/256;
  58.   TL1=(65536-6000)%256;
  59.   P2=0xff;
  60.   P1=dispcode[dispbuf[dispcount]];
  61.   P2=dispbitcode[dispcount];
  62.   if(dispcount==5)
  63.     {
  64.       P1=P1 | 0x80;
  65.     }
  66.   dispcount++;
  67.   if(dispcount==8)
  68.     {
  69.       dispcount=0;
  70.     }  
  71. }
复制代码




作者: jms209    时间: 2017-2-10 14:14
好东西,收藏了
作者: 越快乐越堕落    时间: 2017-2-11 14:09
74LS74用什么替换
作者: xu37479333    时间: 2017-3-27 10:50
很好很实用谢谢
作者: zqy181818    时间: 2017-3-29 23:32
实用,感谢你的分享
作者: ~IOT夙愿    时间: 2017-4-1 14:32
感谢楼主分享
作者: zhang092413253    时间: 2017-4-19 09:44
感谢分享,和使用
作者: miu    时间: 2017-5-1 07:36

 好东西,收藏了
作者: 4902137    时间: 2017-5-3 15:45
目前正好学习单片机万用表。
作者: 逆风丶蒲公英灬    时间: 2017-5-16 10:45
好东西,支持支持!
作者: zzwk123456    时间: 2017-10-21 12:37
感谢楼主分享
作者: lxh1113460968    时间: 2017-12-3 06:10
很好谢谢楼主
作者: 辉煌仪奇    时间: 2017-12-25 19:46
只能测试电压,没什么用
作者: 206004430    时间: 2017-12-27 21:59
功能能再多一些就更好了
作者: 黑了心的蛆    时间: 2018-4-11 14:43
666,感谢大佬
作者: luckyzhu27    时间: 2018-4-13 08:56
好东西
作者: 沧澜钓翁    时间: 2018-6-5 20:05
好东西!!!
作者: 沧澜钓翁    时间: 2018-6-5 20:06
不错不错,好东西
作者: 1247708705    时间: 2019-10-11 19:43
很好,学习了
作者: 观束_    时间: 2019-10-20 10:08
学习一下




欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1