实验7:44 键盘扫描控制器(数电实验报告)


    实验 7 4*4 键盘扫描控制器
    1 实验务说明:
    设计实现 4*4 键盘扫描控制电路判断键数码显示
    键值通蜂鸣器发出键音
    求:
    l 键值采 16 进制编码 16 键分应显示 16 进制数 0~F键
    应关系:面行左右次 0~3第二行左右次 4~7第三行左右次 8~B面行左右次 C~F中 bd 显示写字母写
    l 键时显示前键值保持直键时更新显示
    l 键时蜂鸣器发出键音放开蜂鸣器发声
    l 选做:键应键音

    2 实验设计思路
    实验分4部分分顶层分频器(扫描时钟分频器蜂鸣器提供频率分频器)数码译码电路扫描信号发生电路顶层利状态机实现状态转移s0>s1>s2>s3>s0分应扫描col[0>3>0]时row信号转化时钟信号clock_change键输出1没输出0时钟设计时序逻辑clock_change升更新tempSegin(传递数码输入信号)choose(传递蜂鸣器分频器输入信号)输出sound信号时蜂鸣器输出信号clock_change信号相达次键盘蜂鸣器发声数码显示目
    3 源程序:
    1) 分频器
    扫描时钟分频器:
    LIBRARY IEEE
    USE IEEESTD_LOGIC_1164ALL
    USE IEEESTD_LOGIC_UNSIGNEDALL
    USE IEEESTD_LOGIC_ARITHALL
    entity divide is
    divide the frequency to 1n
    generic( nnatural200)
    port( clk in std_logic
    clk_out out std_logic)
    end divide
    architecture div_arch of divide is
    temporary signal
    signal temp std_logic
    begin
    process( clk )
    count variable count from 0 to n21
    means every n2 period reverse the clk
    variable count integer range 0 to n21
    begin
    if (clk'event and clk'1') then
    if( count n21) then
    temp < not temp
    count 0
    else
    count count + 1
    end if
    end if
    end process
    clk_out < temp
    end div_arch
    蜂鸣器提供频率分频器
    LIBRARY IEEE
    USE IEEESTD_LOGIC_1164ALL
    USE IEEESTD_LOGIC_UNSIGNEDALL
    USE IEEESTD_LOGIC_ARITHALL
    entity divide_sound is
    the origin clk is 50MHz
    divide the frequency to 1n
    generic( n0natural4
    n1natural8
    n2natural12
    n3natural16
    n4natural20
    n5natural24
    n6natural28
    n7natural42
    n8natural46
    n9natural50
    n10natural54
    n11natural58
    n12natural62
    n13natural66
    n14natural70
    n15natural74
    )
    port( clk in std_logic
    choose in integer range 0 to 15
    sound_out out std_logic
    )
    end divide_sound
    architecture div_arch of divide_sound is
    temporary signal
    signal temp std_logic
    begin
    process( clk )
    count variable count from 0 to n21
    means every n2 period reverse the clk
    variable count integer range 0 to 100
    variable ninteger range 0 to 200
    count'max is over the n(max)2 1
    begin
    case choose is
    when 0 >n n0
    when 1 >n n1
    when 2 >n n2
    when 3 >n n3
    when 4 >n n4
    when 5 >n n5
    when 6 >n n6
    when 7 >n n7
    when 8 >n n8
    when 9 >n n9
    when 10 >n n10
    when 11 >n n11
    when 12 >n n12
    when 13 >n n13
    when 14 >n n14
    when 15 >n n15
    when others > n n0
    end case
    if(clk'event and clk'1') then
    if( count n2 1) then
    temp < not temp
    count 0
    else
    count count + 1
    end if
    end if
    end process
    sound_out < temp
    end div_arch

    2) 扫描信号发生电路
    LIBRARY IEEE
    USE IEEESTD_LOGIC_1164ALL
    USE IEEESTD_LOGIC_ARITHALL
    USE IEEESTD_LOGIC_UNSIGNEDALL
    entity scan_seq is
    produce the column scan signal
    port( clkreset in std_logic
    col out std_logic_vector(3 downto 0)
    )
    end scan_seq
    architecture arch of scan_seq is
    begin
    process(clk)
    variable count integer range 0 to 3
    M4 counterevery count output the porper impulse
    begin
    if( reset '1')then
    count 0
    elsif( clk'event and clk'1' )then
    if( count 3)then
    count 0
    else
    count count +1
    end if
    end if
    case count is
    when 0 > col<1110
    when 1 > col<1101
    when 2 > col<1011
    when 3 > col<0111
    end case
    end process
    end arch
    3) 数码译码电路
    LIBRARY IEEE
    USE IEEESTD_LOGIC_1164ALL
    USE IEEESTD_LOGIC_ARITHALL
    USE IEEESTD_LOGIC_UNSIGNEDALL
    ENTITY seg7_1H IS seg7 decoding
    PORT(
    a IN STD_LOGIC_VECTOR(3 DOWNTO 0) input
    b OUT STD_LOGIC_VECTOR(6 DOWNTO 0) output
    cat OUT STD_LOGIC_VECTOR(7 DOWNTO 0) selcect
    )
    END seg7_1H
    ARCHITECTURE aa OF seg7_1H IS
    signal temp std_logic_vector(3 downto 0)
    BEGIN
    process(a)
    begin
    CASE a IS b60 > abcdefg
    WHEN 0000 > b < 1111110 0
    WHEN 0001 > b < 0110000 1
    WHEN 0010 > b < 1101101 2
    WHEN 0011 > b < 1111001 3
    WHEN 0100 > b < 0110011 4
    WHEN 0101 > b < 1011011 5
    WHEN 0110 > b < 1011111 6
    WHEN 0111 > b < 1110000 7
    WHEN 1000 > b < 1111111 8
    WHEN 1001 > b < 1111011 9
    WHEN 1010 > b < 1110111 A
    WHEN 1011 > b < 0011111 b
    WHEN 1100 > b < 1001110 C
    WHEN 1101 > b < 0111101 d
    WHEN 1110 > b < 1001111 E
    WHEN 1111 > b < 1000111 F
    WHEN others > b < 0000000 others
    END CASE
    end process
    cat < 11111110
    END aa
    4) 顶层
    LIBRARY IEEE
    USE IEEESTD_LOGIC_1164ALL
    USE IEEESTD_LOGIC_ARITHALL
    USE IEEESTD_LOGIC_UNSIGNEDALL
    entity scanKeyboard is
    scan the keyboard and display sound at the same time
    port(
    clkreset in std_logic
    row in std_logic_vector(3 downto 0)
    col out std_logic_vector(3 downto 0)
    sound out std_logic
    b out std_logic_vector(6 downto 0)
    cat out std_logic_vector(7 downto 0)
    seeclk out std_logic
    )
    end scanKeyboard
    architecture arch of scanKeyboard is
    component divide_sound is
    the origin clk is 50MHz
    divide the frequency to 1n
    generic( n0natural4
    n1natural8
    n2natural12
    n3natural16
    n4natural20
    n5natural24
    n6natural28
    n7natural42
    n8natural46
    n9natural50
    n10natural54
    n11natural58
    n12natural62
    n13natural66
    n14natural70
    n15natural74
    )
    port( clk in std_logic
    choose in integer range 0 to 15
    sound_out out std_logic
    )
    end component
    component scan_seq is
    produce the column scan signal
    port( clkreset in std_logic
    col out std_logic_vector(3 downto 0)
    )
    end component
    component seg7_1H IS seg7 decoding
    PORT(
    a IN STD_LOGIC_VECTOR(3 DOWNTO 0) input
    b OUT STD_LOGIC_VECTOR(6 DOWNTO 0) output
    cat OUT STD_LOGIC_VECTOR(7 DOWNTO 0) selcect
    )
    END component
    component divide is
    divide the frequency to 1n
    generic( nnatural200)
    port( clk in std_logic
    clk_out out std_logic)
    end component
    clk_scan is the scan signal for column
    tempSound is the output of the sound divider
    tempSegin is the input of the seg7 translate part
    clock_change is disgned to record the row's impulse appear
    choose is the select of the keyboard
    signal clk_scan std_logic
    signal tempSoundstd_logic
    signal tempSeginstd_logic_vector(3 downto 0)
    signal clock_changestd_logic
    signal choose integer range 0 to 15
    type state is (s0s1s2s3)
    signal presentstate nextstate state
    begin
    u0divide_sound port map(clk > clkchoose>choosesound_out>tempSound)
    u1divide port map(clk >clk clk_out>clk_scan)
    u2scan_seq port map(clk>clk_scanreset>resetcol>col)
    u3seg7_1H port map(a>tempSeginb>bcat>cat)
    discrible the register for clk_scan
    p1_regprocess(clk_scanreset)
    begin
    if(reset '1')then
    presentstate< s0
    elsif( clk_scan'event and clk_scan'1' )then
    presentstate< nextstate
    end if
    end process
    discrible the state for clk_scan
    p2_stateChangeprocess(presentstate)
    begin
    case presentstate is
    when s0 > nextstate< s1
    when s1 > nextstate< s2
    when s2 > nextstate< s3
    when s3 > nextstate< s0
    end case
    end process
    discrible the output
    p3_outprocess(presentstaterowclock_change)
    begin
    behave synchronize with the clock_change
    if( clock_change'event and clock_change '1')then
    case presentstate is
    column[0]
    when s0 > case row is
    when 1110>
    choose < 12
    tempSegin < 1100
    when 1101>
    choose < 8
    tempSegin < 1000
    when 1011>
    choose < 4
    tempSegin < 0100
    when 0111>
    choose < 0
    tempSegin < 0000
    when others>
    choose < 0
    tempSegin < tempSegin
    end case
    column[1]
    when s1 > case row is
    when 1110>
    choose < 13
    tempSegin < 1101
    when 1101>
    choose < 9
    tempSegin < 1001
    when 1011>
    choose < 5
    tempSegin < 0101
    when 0111>
    choose < 1
    tempSegin < 0001
    when others >
    choose < 0
    tempSegin < tempSegin
    end case
    column[2]
    when s2 > case row is
    when 1110>
    choose < 14
    tempSegin < 1110
    when 1101>
    choose < 10
    tempSegin < 1010
    when 1011>
    choose < 6
    tempSegin < 0110
    when 0111>
    choose < 2
    tempSegin < 0010
    when others>
    choose < 0
    tempSegin < tempSegin
    end case
    column[3]
    when s3 > case row is
    when 1110>
    choose < 15
    tempSegin < 1111
    when 1101>
    choose < 11
    tempSegin < 1011
    when 1011>
    choose < 7
    tempSegin < 0111
    when 0111>
    choose < 3
    tempSegin < 0011
    when others>
    choose < 0
    tempSegin < tempSegin
    end case
    end case
    end if
    end process
    discrible clkchange
    p3_clkchangeprocess(row)
    begin
    if( row 1111)then
    clock_change <'0'
    else
    clock_change<'1'
    end if
    end process
    output the sound signal
    sound < tempSound and clock_change
    to see the clock_change in waveform
    seeclk < clock_change
    end arch
















    4 仿真波形分析
    1) 分频器1(扫描时钟分频器)

    图11分频器整体

    图12 分频器计数99翻转(高翻低)

    图13 分频器计数99翻转(低翻高)
    实际应采分频50k现仿真时方便仿真取200分频图11整体分频情况图12分频器计数99时高电翻低电图13分频器计数99时低电翻高电
    2) 分频器2(蜂鸣器提供频率分频器)

    图21(a) 分频器整体图

    图21(b)分频器整体图

    图21(c)分频器整体图

    图22(a) 分频器细节图n950

    图22(b) 分频器细节图n950
    仿真时扫描时钟信号200分频时钟信号蜂鸣器提供信号分频系数实际分频系数图21(a)(b)输出信号频率受输入choose信号控制choose增输出信号分频越设计符号先取中状态进行说明choose9nn950应计数器应记24然实现翻转图22(a)计数信号计数001100024实现低电翻高电图22(b)计数信号计数0011000实现高电翻低电完成控分频器
    3) 扫描信号发生电路

    图31扫描信号细节图
    图32 扫描信号reset发生
    图4知红框中序脉周期countcol输出应关系
    count
    col[i]0中i取值
    00
    0
    01
    1
    10
    2
    11
    3
    实现序负脉发生器功时reset信号加入时count重新00开始计数序脉col[0]开始输出低电

    4) 数码译码电路

    图41(a)数码译码波形图

    图42(b)数码译码波形图
    图41(a)译码电路09译码说已较熟悉赘述现选取1015进行说明数码结构图图43示a101010应输出写A应abcefg应点亮d熄灭波形图中见输出b1110111设计相应a101111应输出写b应ab熄灭余点亮波形图中见b0011111设计相应a1100应输出写C应bcg熄灭余点亮波形图见b1001110设计相应
    a1101应输出写d应af熄灭余点亮波形图见b0111101设计相应a1110时应输出写E应bc熄灭波形图见b1001111设计相应a1111时应输出写F应bcd熄灭波形图见b1000111设计相应波形图应译码起表示表1中位选信号catcat[0]显示位数码

    图43 数码部结构图
    表1:
    计数信号
    数码显示控制信号
    0000
    1111110
    0001
    0110000
    0010
    1101101
    0011
    1111001
    0100
    0110011
    0101
    1011011
    0110
    1011111
    0111
    1110000
    1000
    1111111
    1001
    1111011
    1010
    1110111
    1011
    0011111
    1100
    1001110
    1101
    0111101
    1110
    1001111
    1111
    1000111

    5) 综合

    图51 整体波形图

    图52(a)整体波形图细节reset

    图52(b)整体波形图细节(键1)

    图52(c)整体波形图细节(键6)

    图52(d)整体波形图细节(键910数码保持次)

    图52(e)整体波形图细节(键12连续键)
    图51键进行仿真(键0>15)整体出应键应tempSegin保障数码输出前键应值时12连续键波形图中时tempSegin持续12
    图52(b)col[1]0row[3]0时应键1时输出蜂鸣器键相宽度信号时译码电路传入tempSegin1次键前保持tempSegin1时b01100001应译码
    图53(c)col[2]0row[2]0时应键6时输出蜂鸣器键宽度相信号时频率键频率区时译码电路传入tempSegin6次键前保持tempSegin6时b10111116应译码
    图54(d)键9时数码译码电路输入tempSeg9保持次键10
    图54(e)键12连续时直数码译码电路输入 tempSeg12时直蜂鸣器输出相频率信号直键松开输出蜂鸣器信号保持数码显示信号












    实验5点阵载验证图






























    — END —
    文档香网(httpswwwxiangdangnet)户传

    《香当网》用户分享的内容,不代表《香当网》观点或立场,请自行判断内容的真实性和可靠性!
    该内容是文档的文本内容,更好的格式请下载文档

    下载文档到电脑,查找使用更方便

    文档的实际排版效果,会与网站的显示效果略有不同!!

    需要 10 香币 [ 分享文档获得香币 ]

    下载文档

    相关文档

    杭电单片机实验报告一

    单片机原理与应用技术实验报告实验题目: Keil软件使用及汇编语言编程 姓名: * * * 学号:...

    3年前   
    601    0

    C语言实验报告《函数》

    C语言实验报告《函数》  学号:__________    姓名:__________    班级:__________    日期:__________  指导教师:__________  ...

    12年前   
    1379    0

    大工2022年《电力系统继电保护实验》实验报告及答案

    一、实验目的1. 熟悉DL型电流继电器和DY型电压继电器的的实际结构,工作原理、基本特性;2. 学习动作电流、动作电压参数的整定方法。二、实验电路1.过流继电器实验接线图

    2年前   
    2552    0

    基于FPGA的键盘扫描程序的设计毕业设计

    X X 学 院 CHANGSHA UNIVERSITY本科生毕业设计设计(论文)题目: 基于FPGA的键盘扫描程序的设计 ...

    4年前   
    881    0

    非编码键盘的扫描程序设计课程设计

    摘 要 11设计方案 21.1 设计任务 21.2 设计方案 22系统硬件设计 32.1最小应用系统 32.2 8155扩展电路 42.3 矩阵键盘接口电路 62.4 LCD1602...

    2年前   
    377    0

    数电课程设计报告 音乐彩灯控制器

     电子技术课程设计 题目名称: 音乐彩灯控制器 1. 设计任务和要求 (1) ...

    5年前   
    1195    0

    化学实验报告

    化学实验报告  化学是一门以实验为基础的学科。化学上的许多理论和定律都是从实验中发现归纳出来的。同时,化学理论的应用、评价也有赖于实验的探索和检验。虽然到了近代乃至现代,化学的飞速进步已经产生...

    11年前   
    1071    0

    上机实验报告

    上机实验报告  一.     题目1.  建立一个学生档案,内容包括学号,姓名,年龄,性别,数学,物理和英语3门功课成绩。要求实现以下功能:1)        数据输入;2)        查...

    8年前   
    883    0

    教育实验报告

    教育实验报告  教育实验报告  对某种教育现象实验后,要对整个实验过程进行全面总结,提出一个客观的、概括的、能反映全过程及其结果的书面材料,即谓教育实验报告。教育实验报告可分为三部分:①前言。...

    12年前   
    759    0

    **学院实验报告

    实验内容:使用金融数据库查找宏观经济及行业相关数据,使用Excel进行作图分析。根据所得数据以及图形分析相关问题。实验目的:掌握金融数据库软件的相关使用,操作,快捷查找数据,能够制作美观图形,对于数据有效分析。

    3年前   
    691    0

    电路实验报告

    实验一 元件特性的示波测量法一、实验目的1、学习用示波器测量正弦信号的相位差。2、学习用示波器测量电压、电流、磁链、电荷等电路的基本变量3、掌握元件特性的示波测量法,加深对元件特性的理解。二...

    3年前   
    3110    0

    CADCAM实验报告

     二叉树的遍历实验一、实验名称:二叉树的遍历实验。二、实验目的:1、掌握CAD/CAM系统中常用的数据结构二叉树的概念、存储结构以及二叉树遍历技术。2、熟练应用C语言编写二叉树的建...

    4年前   
    965    0

    爱情实验报告

    爱情实验报告  爱情实验报告   这学期要做一周的模块实验,我和欣儿分在一组,欣儿是班里的学习委员,负责收缴每天实验后大家必写的实验报告。    欣儿长的很美,碰到人总是浅浅地笑,不象有些女生...

    12年前   
    764    0

    生物实验报告

    生物实验报告  实验   生物组织中还原糖、脂肪、蛋白质的鉴定  一、实验目的  初步掌握鉴定生物组织中还原糖、脂肪、蛋白质的基本方法。  二、实验原理  1.还原糖的鉴定原理  生物组织中普...

    9年前   
    843    0

    oracle实验报告

    《Oracle数据库设计与 实现》 总结报告 成绩:-------------- ...

    2年前   
    515    0

    GPIO实验报告

    通过实验掌握 ARM 芯片使用 GPIO 端口。掌握 GPIO 端口控制 LED 显示。掌握系统时钟的配置。掌握库开发原理及方法。

    3年前   
    1454    0

    汇编实验报告

    XX大 学 计 算 机 学 院、软 件 学 院实 验 报 告 学号: 姓名:专业:计算机科学与技术 班级: 第X周 课程名称   汇编语言程序设计课程设计(第四次)实验课时30课时...

    1年前   
    490    0

    科技实验报告

    科技实验报告  科技实验报告   一、定义与作用  实验报告,就是在某项科研活动或专业学习中,实验者把实验的目的、方法。步骤、结果等,用简洁的语言写成书面报告。  实验报告必须在科学实验的基础...

    9年前   
    751    0

    物理实验报告

    物理实验报告  物理 实验报告              指导教师    同组者                     实验日期  2003 年9月21日   实验名称 实验一 测量物质的密...

    10年前   
    863    0

    实验报告格式

    实验报告格式实验序号:          实验项目名称:学 号 姓 名 专业、班 实验地点 指导教师 时间 一、实验目的及要求 二、实验设备(环境)及要求 三、实验内容与步骤 四、实验结果与数...

    11年前   
    802    0

    文档贡献者

    花***0

    贡献于2022-04-28

    下载需要 10 香币 [香币充值 ]
    亲,您也可以通过 分享原创文档 来获得香币奖励!
    下载文档

    该用户的其他文档