LED点阵屏上文字显示实验.docx

上传人:b****4 文档编号:6169403 上传时间:2023-05-09 格式:DOCX 页数:15 大小:50.83KB
下载 相关 举报
LED点阵屏上文字显示实验.docx_第1页
第1页 / 共15页
LED点阵屏上文字显示实验.docx_第2页
第2页 / 共15页
LED点阵屏上文字显示实验.docx_第3页
第3页 / 共15页
LED点阵屏上文字显示实验.docx_第4页
第4页 / 共15页
LED点阵屏上文字显示实验.docx_第5页
第5页 / 共15页
LED点阵屏上文字显示实验.docx_第6页
第6页 / 共15页
LED点阵屏上文字显示实验.docx_第7页
第7页 / 共15页
LED点阵屏上文字显示实验.docx_第8页
第8页 / 共15页
LED点阵屏上文字显示实验.docx_第9页
第9页 / 共15页
LED点阵屏上文字显示实验.docx_第10页
第10页 / 共15页
LED点阵屏上文字显示实验.docx_第11页
第11页 / 共15页
LED点阵屏上文字显示实验.docx_第12页
第12页 / 共15页
LED点阵屏上文字显示实验.docx_第13页
第13页 / 共15页
LED点阵屏上文字显示实验.docx_第14页
第14页 / 共15页
LED点阵屏上文字显示实验.docx_第15页
第15页 / 共15页
亲,该文档总共15页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

LED点阵屏上文字显示实验.docx

《LED点阵屏上文字显示实验.docx》由会员分享,可在线阅读,更多相关《LED点阵屏上文字显示实验.docx(15页珍藏版)》请在冰点文库上搜索。

LED点阵屏上文字显示实验.docx

LED点阵屏上文字显示实验

LED点阵屏上文字显示实验

李宇pb09013011

实验要求:

在试验板的8×8的LED点阵屏上分别显示“PLD电子技术”。

编程思想:

1.首先定义控制LED点阵屏的端口组a,b,及时钟和复位端口

Port(a:

inoutSTD_LOGIC_VECTOR(7downto0;

b:

inoutSTD_LOGIC_VECTOR(7downto0;

clk:

inSTD_LOGIC;

reset:

inSTD_LOGIC;

2.字的跳变显示是通过改变整型变量m的值来选择扫描的程序段

3.对LED点阵屏的工作方式清楚,XUP板子上采用的是共阴极8x8点阵LED。

8X8点阵LED结构如下图所示

从图中可以看出,8X8点阵共需要64个发光二极管组成,且每个发光二极管是放

置在行线和列线的交叉点上,当对应的某一列置0电平,某一行置0电平,则相应

的二极管就亮;本程序中是通过对行扫描,并对当前行中需要亮灯的列置0来实

现显示过程。

示例程序段如下:

if(count=N/8then

a<="11111111";

b<="01111111";

count<=count+1;

elsif(count=N/4then

a<="11101111";

b<="10111111";

count<=count+1;

elsif(count=3*N/8then

a<="11101111";

b<="11011111";

count<=count+1;

elsif(count=N/2then

a<="11101111";

b<="11101111";

count<=count+1;

elsif(count=N*5/8then

a<="11101111";

b<="11110111";

count<=count+1;

elsif(count=N*3/4then

a<="11101111";

b<="11111011";

count<=count+1;

elsif(count=7*N/8then

a<="11101111";

b<="11111101";

count<=count+1;

elsif(count=Nthen

a<="11100011";

b<="11111110";

count<=0;

VHDL代码:

----------------------------------------------------------------------------------

--Company:

--Engineer:

--

--CreateDate:

10:

09:

5805/24/2012

--DesignName:

--ModuleName:

expp8-Behavioral

--ProjectName:

--TargetDevices:

--Toolversions:

--Description:

--Dependencies:

--Revision:

--Revision0.01-FileCreated

--AdditionalComments:

--

----------------------------------------------------------------------------------

libraryIEEE;

 

----Uncommentthefollowinglibrarydeclarationifinstantiating

----anyXilinxprimitivesinthiscode.

--libraryUNISIM;

entityexpp8is

generic(N:

integer:

=16000;

Port(a:

inoutSTD_LOGIC_VECTOR(7downto0;

b:

inoutSTD_LOGIC_VECTOR(7downto0;

clk:

inSTD_LOGIC;

reset:

inSTD_LOGIC;

endexpp8;

architectureBehavioralofexpp8is

signalcount:

INTEGERRANGE0toN:

=0;--count用来对LED扫描分频用--count1用来产生1HZ的分频信号

signalcount1:

INTEGERRANGE0to49999999:

=0;

signalm:

integer:

=0;--用m的数值来选择该扫描显示那个字

begin

process(reset,clk

begin

--复位时的表现为屏上的灯全部点亮

if(reset='0'then

a<="00000000";

b<="00000000";

count<=0;

m<=0;

count1<=0;

else

if(rising_edge(clkthen

ifcount1=49999999then--一赫兹的分频信号产生

m<=m+1;

count1<=0;

elsecount1<=count1+1;

endif;

--m=0时采用扫描的方式显示第一个字母“P”

ifm=0then

--所选行中点亮的灯的时间为N/8个周期if(count=N/8then

a<="11111111";

b<="01111111";

count<=count+1;

elsif(count=N/4then

a<="11100111";

b<="10111111";

count<=count+1;

elsif(count=3*N/8then

a<="11101011";

b<="11011111";

count<=count+1;

elsif(count=N/2then

a<="11101011";

b<="11101111";

count<=count+1;

elsif(count=N*5/8then

a<="11100111";

b<="11110111";

count<=count+1;

elsif(count=N*3/4then

a<="11101111";

b<="11111011";

count<=count+1;

elsif(count=7*N/8then

a<="11101111";

b<="11111101";

count<=count+1;

elsif(count=Nthen

a<="11101111";

b<="11111110";

count<=0;

else

count<=count+1;

endif;

--m=1时显示“L”,时长同样为1秒

elsifm=1then

if(count=N/8then

a<="11111111";

b<="01111111";

count<=count+1;

elsif(count=N/4then

a<="11101111";

b<="10111111";

count<=count+1;

elsif(count=3*N/8then

a<="11101111";

b<="11011111";

count<=count+1;

elsif(count=N/2then

a<="11101111";

b<="11101111";

count<=count+1;

elsif(count=N*5/8then

a<="11101111";

b<="11110111";

count<=count+1;

elsif(count=N*3/4then

a<="11101111";

b<="11111011";

count<=count+1;

elsif(count=7*N/8then

a<="11101111";

b<="11111101";

count<=count+1;

elsif(count=Nthen

a<="11100011";

b<="11111110";

count<=0;

else

count<=count+1;

endif;

--m=2显示“D”,时长为一秒elsifm=2then

if(count=N/8then

a<="11111111";

b<="01111111";

count<=count+1;

elsif(count=N/4then

a<="11100111";

b<="10111111";

count<=count+1;

elsif(count=3*N/8then

a<="11101011";

b<="11011111";

count<=count+1;

elsif(count=N/2then

a<="11101101";

b<="11101111";

count<=count+1;

elsif(count=N*5/8then

a<="11101101";

b<="11110111";

count<=count+1;

elsif(count=N*3/4then

a<="11101101";

b<="11111011";

count<=count+1;

elsif(count=7*N/8then

a<="11101011";

b<="11111101";

count<=count+1;

elsif(count=Nthen

a<="11100111";

b<="11111110";

count<=0;

else

count<=count+1;

endif;

--m=3显示“电”,时长为一秒elsifm=3then

if(count=N/8then

a<="11111111";

b<="01111111";

count<=count+1;

elsif(count=N/4then

a<="11101111";

b<="10111111";

count<=count+1;

elsif(count=3*N/8then

a<="10000011";

b<="11011111";

count<=count+1;

elsif(count=N/2then

a<="10000011";

b<="11101111";

count<=count+1;

elsif(count=N*5/8then

a<="10000011";

b<="11110111";

count<=count+1;

elsif(count=N*3/4then

a<="11101111";

b<="11111011";

count<=count+1;

elsif(count=7*N/8then

a<="11101011";

b<="11111101";

count<=count+1;

elsif(count=Nthen

a<="11100011";

b<="11111110";

count<=0;

else

count<=count+1;

endif;

--m=4显示“子”,时长为一秒elsifm=4then

if(count=N/8then

a<="11111111";

b<="01111111";

count<=count+1;

elsif(count=N/4then

a<="11100011";

b<="10111111";

count<=count+1;

elsif(count=3*N/8then

a<="11111011";

b<="11011111";

count<=count+1;

elsif(count=N/2then

a<="11000001";

b<="11101111";

count<=count+1;

elsif(count=N*5/8then

a<="11110111";

b<="11110111";

count<=count+1;

elsif(count=N*3/4then

a<="11110111";

b<="11111011";

count<=count+1;

elsif(count=7*N/8then

a<="11100111";

b<="11111101";

count<=count+1;

elsif(count=Nthen

a<="11110111";

b<="11111110";

count<=0;

else

count<=count+1;

endif;

--m=5显示“技”,时长为一秒elsifm=5then

if(count=N/8then

a<="11111111";

b<="01111111";

count<=count+1;

elsif(count=N/4then

a<="11011011";

b<="10111111";

count<=count+1;

elsif(count=3*N/8then

a<="10000001";

b<="11011111";

count<=count+1;

elsif(count=N/2then

a<="11000001";

b<="11101111";

count<=count+1;

elsif(count=N*5/8then

a<="11010101";

b<="11110111";

count<=count+1;

elsif(count=N*3/4then

a<="10011111";

b<="11111011";

count<=count+1;

elsif(count=7*N/8then

a<="10011011";

b<="11111101";

count<=count+1;

elsif(count=Nthen

a<="11010101";

b<="11111110";

count<=0;

else

count<=count+1;

endif;

--m=6显示“术”,时长为一秒

elsifm=6then

if(count=N/8then

a<="11111111";

b<="01111111";

count<=count+1;

elsif(count=N/4then

a<="11110011";

b<="10111111";

count<=count+1;

elsif(count=3*N/8then

a<="11000001";

b<="11011111";

count<=count+1;

elsif(count=N/2then

a<="11110111";

b<="11101111";

count<=count+1;

elsif(count=N*5/8then

a<="11100011";

b<="11110111";

count<=count+1;

elsif(count=N*3/4then

a<="11110111";

b<="11111011";

count<=count+1;

elsif(count=7*N/8then

a<="11010101";

b<="11111101";

count<=count+1;

elsif(count=Nthen

a<="10110110";

b<="11111110";

count<=0;

m<=0;--一次循环完成,循环计数变量m归零else

count<=count+1;

endif;

endif;

endif;

endif;

endprocess;

endBehavioral;

设计思路:

本实验的目的是要在LED点阵屏上显示字符,基本思想是用扫描的方式使整个屏上需要的灯点亮,并通过计数整型变量m使LED屏上的字每秒钟变换一次,其中扫描频率和m的变化频率都是通过分频实现的。

LED屏的具体扫描方式是这样的:

用向量b每次选通一行,再通过设定向量a选通列,使当前行需要点亮的列被点亮,以合适的频率扫描就可以使需要的字符在LED屏上滚动显示。

心得与收获:

本实验总体上完成的比较顺利,因为对LED的扫描过程在前几个实验都有涉及,但在实验过程中还是遇到了问题,第一次测试时,LED点阵屏在滚动显示完“PLD电子技术”后会有一秒钟在屏上随机显示一个字符,之后才回到对设定字符的循环显示。

经过对代码的反复阅读,终于在计数整型变量m控制的程序段中发现了不妥之处:

原始程序中是在检测到m等于7(即第八个计数时才将m归零,这样导致了LED屏有一秒空闲的时间,并随机点亮屏上的灯。

之后我在扫描显示完“术”之后就将m置零(之前m=6,这样就可以按实验要求完成显示。

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 自然科学 > 物理

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2