数字电压表设计与制作报告(编辑修改稿)内容摘要:

6 / W R16P 3 .5 /T 115P 2 .7 /A 1 528P 2 .0 / A 821P 2 .1 / A 922P 2 .2 /A 1 023P 2 .3 /A 1 124P 2 .4 /A 1 225P 2 .5 /A 1 326P 2 .6 /A 1 427U2A T 8 9 C 5 2X1C R Y S T A LC12 2 p FC22 2 p FC31 0 u F 键盘与显示电路设计 应用系统中,设计要求不同,使用的 LED 显示器的位数也不同,因此就生产了位数,尺寸,型号不同的 LED 显示器供选择,在本设计中,选择 4 位一体的数码型 LED 显示器,简称“ 4LED”。 本系统中前一位显示电压的整数位,即个位,后两位显示电压的小数位。 4LED 显示器引脚如图所示,是一个共阴极接 法的 4位 LED 数码显示管,其中 a, b, c, e, f, g为 4位 LED各段的公共输出端, 4分别是每一位的位数选端, dp 是小数点引出端, 4位一体 LED数码显示管的内部结构是由 4 个单独的 LED 组成,每个 LED 的段输出引脚在内部都并联后,引出到器件的外部。 7 4位 LED引脚 对于这种结构的 LED 显示器,它的体积和结构都符合设计要求,由于 4 位LED阴极的各段已经在内部连接在一起,所以必须使用动态扫描方式(将所有数码管的段选线并联在一起,用一个 I/O 接口控制)显示。 8 9 第四章 软件设计 软件组成框图 开始 初始化 调用 A / D 转换子程序 调用显示子程序 结束 软件流程图设计 启动转换 A / D 转换结束。 输出转换结果 数值转换 显示 结束 开始 10 主要程序设计 include include typedef unsigned int uint。 typedef unsigned char uchar。 /*****************端口定义 **************/ sbit CS=P3^4。 sbit CLK=P3^5。 //定义时钟信号 sbit DI=P3^6。 sbit DO=P3^6。 uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}。 // 共阴段码表 void delay(uint xms) // 延时函数 { uint i,j。 for(i=xms。 i0。 i) for(j=110。 j0。 j)。 } void display(uchar add,uchar dat) { uchar aa=0x80。 P0=table[dat]。 //送段码 if(add==1) P0|=0x80。 P2=~(aaadd)。 //送位码 delay(1)。 P2=0xff。 } uchar AD0832(bit channel) { uchar AdcByte0,AdcByte1,i。 CLK=0。 _nop_()。 _nop_()。 DI=1。 _nop_()。 _nop_()。 CS=0。 _nop_()。 _nop_()。 CLK=1。 _nop_()。 _nop_()。 11 CLK=0。 _nop_()。 _nop_()。 DI=1。 _nop_()。 _nop_()。 CLK=1。 _nop_()。 _nop_()。 CLK=0。 _nop_()。 _nop_()。 DI=channel。 _nop_()。 _nop_()。 CLK=1。 _nop_()。 _nop_()。 CLK=0。 DI=1。 for(i=0。 i8。 i++) { AdcByte0=1。 CLK=1。 _nop_()。 _nop_()。 CLK=0。 _nop_()。 AdcByte0|=DO。 } if(DO) AdcByte1|=0x80。 for(i=0。 i7。 i++) { AdcByte1=1。 CLK=1。 _nop_()。 _nop_()。 CLK=0。 _nop_()。 if(DO) AdcByte1|=0x80。 } CS=1。 return(AdcByte0==AdcByte1?AdcByte0:0)。 } 12 void main() { uint date。 uchar AdcByte,bit0,bit1,bit2,bit3,i。 while(1) { AdcByte=AD0832(0)。 date=(AdcByte/)*5*100。 bit0=date%10。 bit1=date%100/10。 bit2=date%1000/100。 bit3=date/1000。 for(i=0。 i100。 i++) { display(3,bit0)。 display(2,bit1)。 display(1,bit2)。 display(0,bit3)。 } } } 第五章 系统调试 13 调试的方法与工具 用 keil 软件编写程序,编好程序后再进行编译,编译完成后检查程序有无错误,然后修改程序直到没有错为止,然后再与硬件联调,直到仿真出结果。 Proteus 仿真调试及效果 P 2 . 7P 2 . 6P 2 . 5P 2 . 4P2.7P2.6P2.5P2.4A02B018A13B117A24B216A35B315A46B414A57B513A68B612A79B711CE19A B / B A1U17 4 L S 2 4 512345678161514131211109R N 11kX T A L 218X T A L 119A L E30EA31P S E N29RS T9P 0 .0 /A D 039P 0 .1 /A D 138P 0 .2 /A D 237P 0 .3 /A D 336P 0 .4 /A D 435P 0 .5 /A D 534P 0 .6 /A D 633P 0 .7 /A D 732P 1 .0 /T 21P 1 .1 /T 2 E X2P 1 . 23P 1 . 34P 1 . 45P 1。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。