1 / 15

数码管显示系统设计

任务 3. 数码管显示系统设计. 任务内容. 1 、数码管使用概述 2 、共阳极多位数码管控制系统设计 3 、能自动统计按键次数的显示系统设计. 3 、能自动统计按键次数的显示系统设计. 任务:设计一个可以统计按键次数的系统。 目标:利用 ATmega16 设计一个按键统计的系统; 掌握一个数码管的静态驱动方法,为 多位数码管的动态驱动。 掌握按键的输入处理方法; 掌握数字在数码管的显示系统。. 3.1 系统方案设计. ATmega16. 按键. LED 数码管. 3.2 系统原理设计. 3.3 程序设计.

derex
Download Presentation

数码管显示系统设计

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 任务3 数码管显示系统设计

  2. 任务内容 1、数码管使用概述 2、共阳极多位数码管控制系统设计 3、能自动统计按键次数的显示系统设计

  3. 3、能自动统计按键次数的显示系统设计 任务:设计一个可以统计按键次数的系统。 目标:利用ATmega16设计一个按键统计的系统; 掌握一个数码管的静态驱动方法,为 多位数码管的动态驱动。 掌握按键的输入处理方法; 掌握数字在数码管的显示系统。

  4. 3.1系统方案设计 ATmega16 按键 LED数码管

  5. 3.2系统原理设计

  6. 3.3 程序设计 3.3.1程序要实现个功能: 1)按键操作 2)按键计数 3)统计数字显示 3.3.2程序主要功能模块: 1)按键操作计数模块 2)统计数据处理模块 3)统计数字显示模块

  7. 3.3.3 系统初始化 DDRA = 0xFF; PORTA = 0x00; DDRB = 0xFF; PORTB = 0x00; DDRD = 0xFE; PORTD = 0x01;

  8. 3.3.3 辅助程序模块 1)、延时程序: void Delay_xms(unsignedint xms){unsignedint x,y;for(x=0;x<xms;x++)for(y=0;y<1000;y++) ;} 参数:xms 以毫秒为单位的延时入口参数。

  9. 2)、显示程序: void Display(unsignedchar dis_dat,unsignedchar dis_bit){ PORTB = 1<<dis_bit; PORTA = dis_dat;} 参数:dis_dat 与dis_bit对应的位的显示数据 dis_bit显示数码管位选参数(0~3)对应千、百、 十、个共4位。

  10. 3)、系统显示子程序: void Sys_Display(unsignedint key_dat){ unsignedchar dat_buf; //------------------------------------- dat_buf=key_dat/1000; if(dat_buf==0) dat_buf=0xff;else dat_buf=~digital_code[dat_buf]; Display( dat_buf, 0); //----------------------------------- key_dat=key_dat%1000; dat_buf=key_dat/100; if(dat_buf==0) dat_buf=0xff;else dat_buf=~digital_code[dat_buf]; Display( dat_buf, 1); //----------------------------------- key_dat=key_dat%100; dat_buf=key_dat/10; if(dat_buf==0) dat_buf=0xff;else dat_buf=~digital_code[dat_buf]; Display( dat_buf, 2); //------------------------------------ dat_buf=key_dat%10; dat_buf=~digital_code[dat_buf]; Display( dat_buf, 3);}

  11. 4)、系统显示模块测试 void main(void){ unsignedchar i=0; DDRA = 0xFF; PORTA = 0x00; DDRB = 0xFF; PORTB = 0x00; DDRD = 0xFE; PORTD = 0x01; while(1) { Sys_Display(9876); }}

  12. 5)、按键处理计数模块 unsignedchar key_process(void){unsignedchar key_value=0; key_value=PIND&0x01;if(key_value==0x01) return 0;elseif(key_value==0x00) { Delay_xms(1); key_value=PIND&0x01; if(key_value==0x00) { key_cnt++; if(key_cnt==10000) key_cnt=0;while(1) { Sys_Display(key_cnt); key_value=PIND&0x01;if(key_value==0x01) break; } }else return 0; }}

  13. 5)、系统主函数 void main(void){ unsignedchar i=0; DDRA = 0xFF; PORTA = 0x00; DDRB = 0xFF; PORTB = 0x00; DDRD = 0xFE; PORTD = 0x01; while(1) { key_process(); Sys_Display(key_cnt); }}

  14. 6)、系统仿真结果

  15. 任务3知识总结 1)本任务主要讲述了数码管的驱动方法; 2)数码管的连接方式; 3)数码管显示数据的编码方法; 4)数码管的静态驱动; 5)数码管的动态驱动; 6)按键处理; 7)进一步掌握IO口的使用及开发环境的使用。

More Related