数码管学号滚动显示
- 格式:xls
- 大小:290.00 KB
- 文档页数:2


实验六数码管的动态显示
一、实验目的:
1.学习多位数码动态显示的原理。
2.培养综合运用多种中规模集成器件组合逻辑功能部件的能力及实验技能。
二、实验器材:
74LS139 74LS153 74LS00 74LS74 数字电子线路实验箱
三、实验原理:
数字电路中数据的显示方式有两种,一种为静态显示,一种为动态显示。
前面的实验中数码管的显示方式均为静态显示,数码管动态显示原理与静态显示不同,如果数码管采用共阳极接法一般在阴极接入数据信号,同时在阳极信号接入高电平则该数码管显示数据。
静态显示原理框图:
4路数据输入
数据
选择
2-4译
码器振荡器
秒脉冲
计数
器
七段
译码
4位
数码
管显
示
电路设计图:
测试:。
一、实验目的1. 理解并掌握动态显示技术的基本原理;2. 学习数码管与单片机的连接方法;3. 掌握段代码表的推算及数据表的使用方法;4. 熟悉C语言编程方法,实现动态显示效果。
二、实验原理动态显示技术是一种通过快速切换数码管上的各个段来显示数字或字符的方法。
由于人眼具有视觉暂留效应,当切换速度足够快时,人眼无法分辨出各个段的变化,从而形成连续的显示效果。
三、实验设备与材料1. 计算机;2. 单片机实验箱;3. Proteus软件;4. Keil软件;5. 数码管;6. 电阻;7. 连接线。
四、实验步骤1. 硬件连接:将数码管连接到单片机的P0口,并确保连接正确无误;2. 软件编写:使用Keil软件编写程序,实现动态显示效果;3. 烧写程序:将编写的程序烧写到单片机中;4. 观察现象:打开单片机实验箱,观察数码管上的显示效果。
五、实验内容1. 编写程序,实现数码管上显示数字0-9的动态效果;2. 修改程序,实现数码管上显示特定字符的动态效果;3. 分析程序,了解动态显示的工作原理。
六、实验结果与分析1. 编写程序,实现数码管上显示数字0-9的动态效果(1)程序代码如下:```c#include <reg51.h>#define SEGMENT P0void delay(unsigned int ms) {unsigned int i, j;for (i = 0; i < ms; i++)for (j = 0; j < 120; j++);}void displayNumber(unsigned char num) {switch (num) {case 0: SEGMENT = 0x3F; break;case 1: SEGMENT = 0x06; break;case 2: SEGMENT = 0x5B; break;case 3: SEGMENT = 0x4F; break;case 4: SEGMENT = 0x66; break;case 5: SEGMENT = 0x6D; break;case 6: SEGMENT = 0x7D; break;case 7: SEGMENT = 0x07; break;case 8: SEGMENT = 0x7F; break;case 9: SEGMENT = 0x6F; break;default: SEGMENT = 0x00; break;}}void main() {unsigned char i;while (1) {for (i = 0; i <= 9; i++) {displayNumber(i);delay(500);}}}```(2)程序分析:程序通过定义一个段码表来控制数码管的显示,循环显示数字0-9。
use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity xuehao isport(clk:in std_logic;k:out std_logic_vector(7 downto 0);smgout:out std_logic_vector(7 downto 0));end xuehao;architecture str of xuehao issignal kct:integer range 0 to 7;signal en:std_logic;function smg(xh:integer range 0 to 9) return std_logic_vector is variable smg7:std_logic_vector(7 downto 0);begincase xh isWHEN 0 => smg7:="00111111";WHEN 1 => smg7:="00000110";WHEN 2 => smg7:="01011011";WHEN 3 => smg7:="01001111";WHEN 4 => smg7:="01100110";WHEN 5 => smg7:="01101101";WHEN 6 => smg7:="01111101";WHEN 7 => smg7:="00000111";WHEN 8 => smg7:="01111111";WHEN 9 => smg7:="01101111";end case;return smg7;end smg;beginprocess(clk)variable clkct:std_logic_vector(13 downto 0);beginif clk'event and clk='1' thenif clkct<10000 thenclkct:=clkct+'1';en<='0';elseclkct:=(others=>'0');en<='1';end if;end if;end process;process(en)if en'event and en='1' thenif kct<7 thenkct<=kct+1;elsekct<=0;end if;end if;case kct iswhen 0 => k<= not "01111111";smgout<=smg(9);when 1 => k<= not "10111111";smgout<=smg(1);when 2 => k<= not "11011111";smgout<=smg(0);when 3 => k<= not "11101111";smgout<=smg(0);when 4 => k<= not "11110111";smgout<=smg(3);when 5 => k<= not "11111011";smgout<=smg(0);when 6 => k<= not "11111101";smgout<=smg(2);when 7 => k<= not "11111110";smgout<=smg(3);when others=>null;end case;end process;end str;。