(完整版)基于FPGA的温度传感器课程设计

合集下载

(完整版)FPGA温度测量设计毕业设计

(完整版)FPGA温度测量设计毕业设计

毕业论文FPGA温度测量设计摘要温度作为一种最基本的环境参数,与人民的生活有着密切关系。

温度的测量和控制在工业、农业、国防、医疗等各个领域中应用普遍。

温度测量仪是一种常用的检测仪器。

本文首先介绍了DS18B20的工作原理,利用数字温度传感器DS18B20的数据接口特点,展示了FPGA(Field-Programmable Gate Array,即现场可编程逻辑门阵列)的使用方法以及Verilog HDL (HDL:Hardware Discription Language)语言的编程,完成了基本温度测量功能。

给出了硬件电路和软件设计,此设备具有结构简单、转换速度快、精确性高,扩展性好等优点。

关键词:FPGA;DS18B20;测温;Verilog HDL语言Design of temperature measurement based on FPGAAbstractTenperture is one of the most basic environmental parameters, andit industry, agriculture, national defense,medical and other fields, temperature measurement and control was widely used.The temperature measuring instrument is a kind of common testing instrument.In this paper,first we introduces the work principle of DS18B20,andthe characteristics of data interface of digital temperature sensorDS18B20, demonstrated Language)programming language,accomplished the function of temperature measurement. Giventhe .The device .Key Words: FPGA;DS18B20;Temperature measurement;VerilogHDL language目录中文摘要 (1)英文摘要 (2)1绪论 (1)1.1题目背景意义 (1)1.2工作内容 (2)1.2.1技术指标和要求 (2)1.2.2设计的难点重点 (2)2系统方案设计 (4)2.1温度测量原理及方法 (4)2.2系统方案及方框图 (4)2.3FPGA技术 (5)2.4DS18B20温度传感器 (9)2.4.1DS18B20特性介绍 (9)2.4.2DS18B20测温原理 (11)2.4.3DS18B20供电方式 (12)2.4.4DS18B20时序 (13)2.4.5DS18B20操作命令 (15)2.5硬件设计 (17)2.5.1FPGA最小系统硬件原理图 (17)2.5.2DS18B20的连接 (18)2.5.3数码管显示电路 (18)2.5.4电源电路 (19)2.5.5时钟电路 (19)2.5.6复位电路 (20)2.6软件设计流程图 (20)3功能模块建立及仿真 (21)3.1QuartusⅡ及VHDL语言 (21)3.1.1QuartusⅡ介绍 (21)3.1.2Verilog HDL介绍 (16)3.1.3QuartusⅡ的使用 (19)3.2分频 (21)3.3温度信号采集 (22)3.4数码管显示 (23)3.5顶层原理图 (23)4下载调试及实际测量 (25)5设计遇到的问题及误差分析 (27)5.1设计遇到的问题及分析 (27)5.2误差分析 (27)6总结 (29)致谢 (30)参考文献 (31)毕业设计(论文)知识产权声明 (33)毕业设计(论文)独创性声明 (34)1绪论1.1题目背景意义温度是表征物体冷热程度的物理量,是国际单位制七个基本物理量之一,作为一种最基本的环境参数,与人民的日常生活有着密切关系。

基于fpga的智能温度控制系统的设计

基于fpga的智能温度控制系统的设计

基于fpga的智能温度控制系统的设计随着科技的发展,智能控制系统被广泛应用于工业领域和智能家居中,其中智能温度控制系统是其中的一种。

智能温度控制系统能够根据环境温度变化自动控制加热或制冷设备,从而保证环境温度始终在设定值范围内,提高生产效率和舒适度。

本文将介绍一种基于FPGA的智能温度控制系统设计方案。

1. 系统设计该系统由传感器、FPGA、驱动器以及显示器组成。

传感器用于检测环境温度变化,FPGA用于对传感器信号进行处理,驱动器用于控制加热或制冷设备,显示器用于显示系统状态。

系统设计流程如下:1.1 传感器传感器可以选择温度传感器、热敏电阻传感器或热电偶传感器等。

本系统选用温度传感器,将传感器输出的模拟信号转化为FPGA可读的数字信号,从而实现数字信号化。

1.2 数字信号化将模拟信号数字化是实现控制系统的关键所在。

数字信号化是通过模数转换器(ADC)将模拟信号转化为数字信号的过程。

本系统将模拟信号转化为12位数字信号。

1.3 FPGA处理FPGA芯片(Field-Programmable Gate Array)是一种可编程逻辑器件,它能够快速地对数字信号进行处理。

FPGA芯片是本系统的核心处理器,它被用来对传感器信号进行处理,根据环境温度的变化决定加热还是制冷,从而保持环境温度在设定范围内。

具体的处理流程如下:(1)读取温度传感器数据。

(2)将传感器输出的模拟信号转变为数字信号。

(3)将数字信号与设定的环境温度范围进行比较,以决定是否需要进行加热或制冷。

(4)对加热或制冷设备进行控制。

1.4 驱动器设计由于加热或制冷设备的控制电源电平和FPGA的电平不一致,需要通过驱动器进行转换。

本系统使用驱动器将FPGA输出的信号转化成能够控制加热或制冷设备的继电器信号。

1.5 显示器设计本系统使用7段LED数码管作为显示器,用于显示当前环境温度以及系统状态。

系统状态包括温度过高、温度过低、正常等状态,以告知用户系统运行情况。

基于FPGA的温控系统的设计

基于FPGA的温控系统的设计

综合电子系统设计报告实验名称:基于FPGA的温控系统的设计班级:电子1202学号:姓名:__指导教师:前言基于FPGA与温度传感器DS18B20设计实现了单回路水箱温度PID 控制系统。

软件主要包括PID控制算法及PWM波产生模块、DS18B20驱动模块、数码管显示驱动模块等3个模块。

仿真结果验证了设计的正确性。

实验结果说明,系统输出温度到达微小超调的稳定控制要求,表达了该设计方法的有效性和实用性。

基于微处理器的温度控制系统改变了传统模拟温度控制系统参数整定不灵活的问题。

但是常规微处理器无法防止在恶劣环境下程序跑飞的问题。

利用FPGA实现温度控制系统的设计,不仅可以提高系统的运算速度、减小系统的体积,还可以增强系统的可靠性,具有较强的应用前景。

本设计首先针对Altera公司的CycloneII系列FPGA芯片,基于QUARTUSII软件,采用verilogHDL编程设计了主要包括PID控制算法及PWM波产生模块、DS18B20驱动模块、数码管显示驱动模块等功能模块程序。

然后用Modelsim软件仿真验证了各模块的正确性。

最后以水箱为被控对象,以目前市场上性价比拟高的FPGA芯片EP2C8Q208C8为核心器件,结合温度传感器DS18B20、键盘、数码管以及固态继电器等器件设计实现了单回路水温PID控制系统。

在控制温度为30~90℃的实验条件下,误差小于1℃,系统输出温度到达微小超调的稳定控制要求。

关键词:FPGA DS18B20 PID PWM波一、方案设计1、方案设计比拟温度传感器模块设计方案一:采用热敏电阻pt100。

这种电阻输出的是模拟量,所以硬件构造较复杂,需要用到桥式电路将采集到的温度转化为电压输出,而且为了实现AD转化,还要加放大电路。

另外,这种测温系统难以实现多点测温,也要用到复杂的算法,一定程度上也增加了软件实现的难度。

方案二:采用单总线数字温度传感器DS18B20测量温度,直接输出数字信号。

基于FPGA的智能温度控制系统设计

基于FPGA的智能温度控制系统设计

湖南文理学院课程设计报告课程名称:通信系统课程设计专业班级:通信1101班学号(06位)学生姓名:指导教师:***完成时间:2014年11 月21 日报告成绩:基于FPGA的智能温度控制的设计目录1.设计题目 (1)2.设计要求 (1)3.设计作用与目的 (1)4.所用设备(仪器)和软件 (2)5.系统设计方案 (2)5.1 系统总体设计 (2)5.2 工作原理 (3)5.2.1 温度控制系统特性研究 (3)6.智能温度控制器系统硬件设计 (4)6.1 系统方案设计 (4)6.1.1 FPGA与DAC0832结合的目的 (4)6.1.2 系统需求分析 (4)6.1.3系统需求分析 (5)6.2系统结构 (6)6.2.1调试/配置电路 (6)7.智能温度控制系统软件设计 (8)7.1 软件总体设计 (8)7.1.1 设定定义 (8)7.1.2 VHDL实现 (8)7.2 软件程序设计 (9)7.2.1 分频模块 (9)7.2.2 键盘模块 (10)7.2.3 ADC0809 控制模块 (12)7.2.4 三模块连接在一块 (13)7.3 本章小结 (15)8.实验调试结果 (15)8.1 实验条件 (15)8.2 实验结果及分析 (15)8.3 本章小结 (17)9.设计中的问题及解决方法 (18)10.设计心得 (18)11.参考文献 (18)12.附录 (18)1.设计题目基于FPGA的智能温度控制的设计2.设计要求通过前向温度采集电路,采集当前孵化器内部的温度信号,将采集到的模拟信号通过ADC0809模数转换芯片,转变为FPGA可控的数字信号,FPGA芯片根据输入的当前实际温度,控制输出合理的数字信号,再由DAC0832转换为模拟信号,输入到后向加热执行电路,以此来完成对整个孵化器的温度控制。

整个系统中,带有温度传感器的前向温度采集电路作为系统的反馈环节,实时反映当前环境的具体温度。

3.设计作用与目的在空间生命科学试验中,生命培养模拟地面环境要求,主要研究宇空间因素,如失重、宇宙辐射、真空、高温(或低温)等对生命过程的影响。

基于FPGA智能温度传感器监控报警系统的设计

基于FPGA智能温度传感器监控报警系统的设计

基于FPGA智能温度传感器监控报警系统的设计概述本文将详细介绍基于FPGA智能温度传感器监控报警系统的设计。

该系统由FPGA、温度传感器和报警器等组成,可以实时采集环境温度数据并进行处理,同时还可以根据设定的报警阈值进行温度报警。

该系统具有实时性、准确性和灵敏度高等优点,在工业、仓储等领域有广泛应用价值。

设计方案系统硬件设计智能温度传感器智能温度传感器采用DS18B20数字温度传感器,其精度高、体积小、响应速度快、使用方便等优点,能够满足系统的需要。

传感器输出数字量信号,可通过FPGA进行处理并转化为模拟量信号。

FPGAFPGA是本系统的核心部件,负责实现数字信号处理和温度阈值报警功能。

我们选用Xilinx Spartan-6系列FPGA,其具有高速、低功耗、可编程等特点,同时还有丰富的外设资源可以扩展。

报警器为了保证报警的及时和可靠性,我们使用了声光报警器,其能够在温度超出设定阈值时及时报警。

系统软件设计VHDL设计我们采用了VHDL语言对系统进行设计,通过其高级抽象、可移植性强等特点,实现了可适应性强、代码简洁的设计。

其中,数字信号处理主要包含数据的采集、过滤和频率变换等部分;温度阈值报警主要包含数据的计算和闸门控制等。

界面设计为了让用户更加便捷地使用该系统,我们设计了简洁明了的界面,包括温度值显示、报警阈值设置和报警状态等。

系统实现硬件实现按照上述设计方案,我们完成了硬件电路的设计,其中智能温度传感器采用了标准接口,与FPGA连接顺畅稳定。

报警器也能有良好的响应效果。

软件实现通过VHDL语言,我们完成了数字信号处理和温度报警部分的代码编写,在模拟器中进行了仿真和调试,并进行了综合和布局。

最终在FPGA平台上进行了验证,并与界面进行了充分交互。

结果分析经过系统实现,我们完成了一个基于FPGA智能温度传感器监控报警系统的设计。

在实际测试中,该系统具有所需的准确性、灵敏度和实时性等特点,能够实时采集环境温度并进行温度阈值报警。

(完整版)基于FPGA的温度传感器课程设计

(完整版)基于FPGA的温度传感器课程设计

FPGA课程设计论文学生姓名周悦学号20091321018院系电子与信息工程学院专业电子科学与技术指导教师李敏二O一二年5月28 日基于FPGA的温度传感器系统设计1引言温度是一种最基本的环境参数,人们的生活与环境的温度息息相关,在工业生产过程中需要实时测量温度,在农业生产中也离不开温度的测量,因此研究温度的测量方法和装置具有重要的意义。

测量温度的关键是温度传感器,温度传感器的发展经历了三个发展阶段:传统的分立式温度传感器;模拟集成温度传感器;智能集成温度传感器。

目前,国际上新型温度传感器正从模拟式向数字式,从集成化向智能化、网络化的方向飞速发展。

本文将介绍采用智能集成温度传感器DS18B20,并以FPGA为控制器的温度测量装置的硬件组成和软件设计,用液晶来实现温度显示。

2电路分析系统框图如下:第一部分:DS18B20温度传感器美国 Dallas 半导体公司的数字化温度传感器 DS1820 是世界上第一片支持 "一线总线"接口的温度传感器,在其内部使用了在板(ON-B0ARD)专利技术。

全部传感元件及转换电路集成在形如一只三极管的集成电路内。

一线总线独特而且经济的特点,使用户可轻松地组建传感器网络,为测量系统的构建引入全新概念。

现在,新一代的 DS18B20 体积更小、更经济、更灵活。

使你可以充分发挥“一线总线”的优点。

DS18B20 的主要特性:(1)适应电压范围更宽,电压范围:3.0~5.5V,在寄生电源方式下可由数据线供电(2)独特的单线接口方式,DS18B20 在与微处理器连接时仅需要一条口线即可实现微处理器与DS18B20 的双向通讯(3)DS18B20 支持多点组网功能,多个DS18B20 可以并联在唯一的三线上,实现组网多点测(4)DS18B20 在使用中不需要任何外围元件,全部传感元件及转换电路集成在形如一只三极管的集成电路内(5)温范围-55℃~+125℃,在-10~+85℃时精度为±0.5℃(6)可编程的分辨率为 9~12位,对应的可分辨温度分别为 0.5℃、0.25℃、0.125℃和 0.0625℃,可实现高精度测温(7)在 9 位分辨率时最多在93.75ms 内把温度转换为数字,12 位分辨率时最多在 750ms 内把温度值转换为数字,速度更快(8)测量结果直接输出数字温度信号,以"一线总线"串行传送给 CPU,同时可传送 CRC 校验码,具有极强的抗干扰纠错能力(9)负压特性:电源极性接反时,芯片不会因发热而烧毁,但不能正常工作。

基于FPGA的LM75A温度传感器(VHDL)

基于FPGA的LM75A温度传感器(VHDL)

1.编写的程序(一)功能模块:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;--实体--entity at24c08 isport(clk : in std_logic; --时钟信号rst : in std_logic; --复位信号scl : out std_logic; --i2c时钟线sda : inout std_logic; --i2c数据线urv_1 : in std_logic; --上限值1urv_2 : in std_logic; --上限值2sel : out std_logic_vector(3 downto 0);seg : out std_logic_vector(7 downto 0);beep : out std_logic --蜂鸣器输出信号线);end at24c08;--结构体--architecture arch_at24c08 of at24c08 issignal clk_sslow : std_logic;signal counter : std_logic_vector(23 downto 0);signal readdata_reg_buf : std_logic_vector(15 downto 0);signal readdata_ten : integer range 0 to 24564;signal readdata_std : std_logic_vector(15 downto 0);signal qian : std_logic_vector(3 downto 0);signal bai : std_logic_vector(3 downto 0);signal shi : std_logic_vector(3 downto 0);signal ge : std_logic_vector(3 downto 0);signal qian_0 : integer range 0 to 10;signal bai_0 : integer range 0 to 10;signal shi_0 : integer range 0 to 10;signal ge_0 : integer range 0 to 10;--数码管部分信号signal sel_0 : std_logic_vector(3 downto 0);signal seg_0 : std_logic_vector(7 downto 0);signal count : std_logic_vector(13 downto 0);signal clk_slow : std_logic;signal scan_num : std_logic_vector(1 downto 0);signal seg_data_buf : std_logic_vector(3 downto 0);--i2c部分信号signal sda_buf : std_logic; --i2c输入/输出数据寄存器signal link : std_logic; --sda输入输出方向寄存器signal readdata_reg : std_logic_vector(15 downto 0);--i2c读回的数据寄存器signal sda_0 : std_logic; --与sda端口连接信号signal scl_0 : std_logic; --与scl端口连接信号--按键消抖部分信号signal delay_cnt : std_logic_vector(19 downto 0); --消抖延时计数器signal start_delay : std_logic; --按键延时开始--分频部分信号signal clk_div : std_logic_vector(12 downto 0); --分频计数器,5000分频,10khz--蜂鸣器部分信号signal beep_en : std_logic; --蜂鸣器使能信号signal beep_buf : std_logic; --与beep端口连接的信号--时钟部分信号signal level_high : std_logic; --高电平中间值,1249 signal level_low : std_logic; --低电平中间值,3749 signal level_hig_edge : std_logic; --上升沿,4999signal level_low_edge : std_logic; --下降沿,2499--状态机部分信号signal main_state : std_logic_vector(1 downto 0); --状态机主状态signal i2c_state : std_logic_vector(2 downto 0); --i2c状态signal i2c_per_state : std_logic_vector(3 downto 0); --i2c每一步状态--分频部分常量constant div_parameter : std_logic_vector(12 downto 0):="1001110001000";--分频系数,500--状态机部分常量--操作状态常量constant read_init : std_logic_vector(2 downto 0) :="000";--EEPORM 初始化constant read_high : std_logic_vector(2 downto 0) :="001";--读高位数据状态constant read_low : std_logic_vector(2 downto 0) :="010";--读低位数据状态--i2c每一步状态常量constant start : std_logic_vector(3 downto 0) :="0000";--开始位constant first : std_logic_vector(3 downto 0) :="0001";--数据第一位constant second : std_logic_vector(3 downto 0) :="0010";--数据第二位constant third : std_logic_vector(3 downto 0) :="0011";--数据第三位constant fourth : std_logic_vector(3 downto 0) :="0100";--数据第四位constant fifth : std_logic_vector(3 downto 0) :="0101";--数据第五位constant sixth : std_logic_vector(3 downto 0) :="0110";--数据第六位constant seventh : std_logic_vector(3 downto 0) :="0111";--数据第七位constant eighth : std_logic_vector(3 downto 0) :="1000";--数据第八位constant ack : std_logic_vector(3 downto 0) :="1001";--应答位constant stop : std_logic_vector(3 downto 0) :="1010";--停止位--结构体开始beginscl <= scl_0;seg <= seg_0;sda_0 <= sda_buf when (link)='1' else 'Z';sda <= sda_0;sel <= sel_0;beep <= beep_buf;--按键消抖key : process(clk,rst)beginif(not rst='1') thendelay_cnt <= (others => '0');elsif (clk'event and clk='1') thenif start_delay='1' thenif(delay_cnt /= "11110100001001000000") then --20ms延时delay_cnt <= delay_cnt+'1';elsedelay_cnt <= (others => '0');end if;end if;end if;end process key;--分频部分div : process(rst,clk)beginif(not rst='1') thenclk_div <= "0000000000000";level_high <= '0';level_low <= '0';level_hig_edge <= '0';level_low_edge <= '0';elsif(clk'event and clk='1') thenif(clk_div /= div_parameter-'1') then clk_div <= clk_div+'1';elseclk_div <= "0000000000000";end if;if(level_high='1') thenlevel_high <= '0';elseif(clk_div="10011100001") thenlevel_high <= '1';end if;end if;if(level_low_edge='1') thenlevel_low_edge <= '0';elseif(clk_div="100111000011") thenlevel_low_edge <= '1';end if;end if;if(level_low='1') thenlevel_low <= '0';elseif(clk_div="111010100101") thenlevel_low <= '1';end if;end if;if(level_hig_edge='1') thenlevel_hig_edge <= '0';elseif(clk_div="1001110000111") thenlevel_hig_edge <= '1';end if;end if;end if;end process div;--EEPROM操作部分state : process(clk,rst)beginif(not rst='1') thenstart_delay <= '0';scl_0 <= '1';sda_buf <= '1';link <= '0';readdata_reg <= "0000000000000000";main_state <= "00";i2c_state <= read_init;i2c_per_state <= start;elsif(clk'event and clk='1') thencase main_state is--初始化EEPROMwhen "00" =>--等待读写要求scl_0 <= '1';sda_buf <= '1';link <= '0';i2c_state <= read_init;i2c_per_state <= start;main_state <= "10";--读取EEPRO数据when "10" =>if(level_hig_edge='1') thenscl_0 <= '1';elseif(level_low_edge='1') thenscl_0 <= '0';end if;end if;case i2c_state iswhen read_init => --读命令地址case i2c_per_state iswhen start =>if(level_high='1') thensda_buf <= '0';link <= '1';end if;if((level_low and link)='1') thenlink <= '1';sda_buf <= '1';i2c_per_state <= first;end if;when first =>if(level_low='1') thensda_buf <= '0';i2c_per_state <= second;end if;when second =>if(level_low='1') thensda_buf <= '0';link <= '1';i2c_per_state <= third;end if;when third =>if(level_low='1') thensda_buf <= '1';link <= '1';i2c_per_state <= fourth;end if;when fourth =>if(level_low='1') thensda_buf <= '0';link <= '1';i2c_per_state <= fifth;end if;when fifth =>if(level_low='1') thensda_buf <= '0';link <= '1';i2c_per_state <= sixth;end if;when sixth =>if(level_low='1') thensda_buf <= '0';i2c_per_state <= seventh;end if;when seventh =>if(level_low='1') thensda_buf <= '1';link <= '1';i2c_per_state <= eighth;end if;when eighth =>if(level_low='1') thenlink <= '0';i2c_per_state <= ack;end if;when ack =>if(level_hig_edge='1') thensda_buf <= sda;end if;if(level_high='1') thenif(sda_buf='1') thenmain_state <= "00";end if;end if;if(level_low='1') thenlink <= '0';i2c_state <= read_high;i2c_per_state <= first;end if;when others => null;end case;when read_high => --读回数据case i2c_per_state iswhen first =>if(level_hig_edge='1') thensda_buf <= sda;end if;if(level_high='1') thenreaddata_reg(15 downto 9) <= readdata_reg(14 downto 8);readdata_reg(8) <= sda;end if;if(level_low='1') theni2c_per_state <= second;end if;when second =>if(level_hig_edge='1') thensda_buf <= sda;end if;if(level_high='1') thenreaddata_reg(15 downto 9) <= readdata_reg(14 downto 8);readdata_reg(8) <= sda;end if;if(level_low='1') theni2c_per_state <= third;end if;when third =>if(level_hig_edge='1') thensda_buf <= sda;end if;if(level_high='1') thenreaddata_reg(15 downto 9) <= readdata_reg(14 downto 8);readdata_reg(8) <= sda;end if;if(level_low='1') theni2c_per_state <= fourth;end if;when fourth =>if(level_hig_edge='1') thensda_buf <= sda;end if;if(level_high='1') thenreaddata_reg(15 downto 9) <= readdata_reg(14 downto 8);readdata_reg(8) <= sda;end if;if(level_low='1') theni2c_per_state <= fifth;end if;when fifth =>if(level_hig_edge='1') thensda_buf <= sda;end if;if(level_high='1') thenreaddata_reg(15 downto 9) <= readdata_reg(14 downto 8);readdata_reg(8) <= sda;end if;if(level_low='1') theni2c_per_state <= sixth;end if;when sixth =>if(level_hig_edge='1') thensda_buf <= sda;end if;if(level_high='1') thenreaddata_reg(15 downto 9) <= readdata_reg(14 downto 8);readdata_reg(8) <= sda;end if;if(level_low='1') theni2c_per_state <= seventh;end if;when seventh =>if(level_hig_edge='1') thensda_buf <= sda;end if;if(level_high='1') thenreaddata_reg(15 downto 9) <= readdata_reg(14 downto 8);readdata_reg(8) <= sda;end if;if(level_low='1') theni2c_per_state <= eighth;end if;when eighth =>if(level_hig_edge='1') thensda_buf <= sda;end if;if(level_high='1') thenreaddata_reg(15 downto 9) <= readdata_reg(14 downto 8);readdata_reg(8) <= sda;end if;if(level_low='1') theni2c_per_state <= ack;end if;when ack =>if(level_high='1') thenlink <= '1';sda_buf <= '0';i2c_per_state <= first;i2c_state <= read_low;end if;when others => null;end case;when read_low =>case i2c_per_state iswhen first =>if(level_hig_edge='1') thenlink <= '0';sda_buf <= sda;end if;if(level_high='1') thenreaddata_reg(7 downto 1) <= readdata_reg(6 downto 0);readdata_reg(0) <= sda;end if;if(level_low='1') theni2c_per_state <= second;end if;when second =>if(level_hig_edge='1') thenlink <= '0';sda_buf <= sda;end if;if(level_high='1') thenreaddata_reg(7 downto 1) <= readdata_reg(6 downto 0);readdata_reg(0) <= sda;end if;if(level_low='1') theni2c_per_state <= third;end if;when third =>if(level_hig_edge='1') thenlink <= '0';sda_buf <= sda;end if;if(level_high='1') thenreaddata_reg(7 downto 1) <= readdata_reg(6 downto 0);readdata_reg(0) <= sda;end if;if(level_low='1') theni2c_per_state <= fourth;end if;when fourth =>if(level_hig_edge='1') thenlink <= '0';sda_buf <= sda;end if;if(level_high='1') thenreaddata_reg(7 downto 1) <= readdata_reg(6 downto 0);readdata_reg(0) <= sda;end if;if(level_low='1') theni2c_per_state <= fifth;end if;when fifth =>if(level_hig_edge='1') thenlink <= '0';sda_buf <= sda;end if;if(level_high='1') thenreaddata_reg(7 downto 1) <= readdata_reg(6 downto 0);readdata_reg(0) <= sda;end if;if(level_low='1') theni2c_per_state <= sixth;end if;when sixth =>if(level_hig_edge='1') thenlink <= '0';sda_buf <= sda;end if;if(level_high='1') thenreaddata_reg(7 downto 1) <= readdata_reg(6 downto 0);readdata_reg(0) <= sda;end if;if(level_low='1') theni2c_per_state <= seventh;end if;when seventh =>if(level_hig_edge='1') thenlink <= '0';sda_buf <= sda;end if;if(level_high='1') thenreaddata_reg(7 downto 1) <= readdata_reg(6 downto 0);readdata_reg(0) <= sda;end if;if(level_low='1') theni2c_per_state <= eighth;end if;when eighth =>if(level_hig_edge='1') thenlink <= '0';sda_buf <= sda;end if;if(level_high='1') thenreaddata_reg(7 downto 1) <= readdata_reg(6 downto 0);readdata_reg(0) <= sda;end if;if(level_low='1') theni2c_per_state <= ack;end if;when ack =>if(level_high='1') thenlink <= '1';sda_buf <= '1'; --非应答位-- i2c_per_state <= stop;end if;if(level_low='1') thenlink <= '1';sda_buf <= '0';i2c_per_state <= stop;end if;when stop =>if(level_high='1') thenlink <= '1';sda_buf <= '1'; --停止位end if;if(level_low='1') thenmain_state <= "00";end if;when others => null;end case;when others => null;end case;when others => null;end case;end if;end process state;--数据处理部分anly1 : process(readdata_reg_buf)beginreaddata_ten <= conv_integer(readdata_reg_buf)*12;qian_0 <= readdata_ten/1000;bai_0 <= (readdata_ten/100) rem 10;shi_0 <= (readdata_ten/10) rem 10;ge_0 <= readdata_ten rem 10;end process anly1;anly2 : process(qian_0,bai_0,shi_0,ge_0)beginqian <= conv_std_logic_vector(qian_0,4);bai <= conv_std_logic_vector(bai_0,4);shi <= conv_std_logic_vector(shi_0,4);ge <= conv_std_logic_vector(ge_0,4);end process anly2;--数码管显示部分scan : process(rst,clk)beginif(not rst='1') thencount <= (others => '0');clk_slow <= '0';elsif(clk'event and clk='1') thenif(count="11111011011111") thencount <= (others => '0');clk_slow <= not clk_slow;elsecount <= count + '1';end if;end if;end process scan;seg1 : process(clk_slow,rst)beginif(not rst='1') thenscan_num <= "00";elsif(clk_slow'event and clk_slow='1') thenif(scan_num="11") thenscan_num <= "00";elsescan_num <= scan_num + '1';end if;end if;end process seg1;seg2 : process(seg_data_buf)begincase seg_data_buf iswhen "1111" => seg_0 <= "10001110";when "1110" => seg_0 <= "10000110"; when "1101" => seg_0 <= "10100001";when "1100" => seg_0 <= "11000110";when "1011" => seg_0 <= "10000011";when "1010" => seg_0 <= "10011000";when "1001" => seg_0 <= "10010000";when "1000" => seg_0 <= "10000000"; when "0111" => seg_0 <= "11111000"; when "0110" => seg_0 <= "10000010"; when "0101" => seg_0 <= "10010010"; when "0100" => seg_0 <= "10011001"; when "0011" => seg_0 <= "10110000"; when "0010" => seg_0 <= "10100100"; when "0001" => seg_0 <= "11111001"; when "0000" => seg_0 <= "11000000"; when others => seg_0 <= "11111111";end case;end process seg2;seg0 : process(scan_num)begincase scan_num iswhen "00" =>sel_0 <= "1110";seg_data_buf <= ge;when "01" =>sel_0 <= "1101";seg_data_buf <= shi;when "10" =>sel_0 <= "1011";seg_data_buf <= bai;when "11" =>sel_0 <= "0111";seg_data_buf <= qian;when others => null;end case;end process seg0;--数据缓存部分ss : process(clk,rst)beginif(not rst='1') thenclk_sslow <= '0';counter <= (others => '0');elsif(clk'event and clk='1') thenif(counter /= "111111111111111111111110") then counter <= counter + '1';elsecounter <= (others => '0');clk_sslow <= not clk_sslow;end if;end if;end process ss;buf : process(clk_sslow)beginif(clk_sslow'event and clk_sslow='1') thenreaddata_reg_buf <= readdata_reg;elsereaddata_reg_buf <= readdata_reg_buf;end if;end process buf;--蜂鸣器报警部分bep : process(clk,rst)variable count : integer range 0 to 50000; --1KHz方波beginif(not rst='1') thencount := 0;beep_en <= '0';elsif(clk'event and clk='1') thenif(beep_en='1') thencount := count+1;if(count>50000) thencount := 0;beep_buf <= not beep_buf;end if;elseif(not urv_1='1') thenif(readdata_reg>"0000000000000011") thenbeep_en <= '1';end if;elsif(not urv_2='1') thenif(readdata_reg>"1111111111100000") thenbeep_en <= '1';end if;end if;end if;end if;end process bep;end arch_at24c08;(二)测试模块:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity tb is--null;end tb;architecture behv_tb of tb iscomponent at24c08port(clk : in std_logic; --时钟信号rst : in std_logic; --复位信号scl : out std_logic; --i2c时钟线sda : inout std_logic; --i2c数据线urv_1 : in std_logic; --上限值1urv_2 : in std_logic; --上限值2sel : out std_logic_vector(3 downto 0);seg : out std_logic_vector(7 downto 0);beep : out std_logic --蜂鸣器输出信号线);end component;constant clockperiod : time := 20ns;signal clk_tb : std_logic := '0';signal rst_tb : std_logic;signal scl_tb : std_logic;signal sda_tb : std_logic;signal urv_1_tb : std_logic;signal urv_2_tb : std_logic;signal sel_tb : std_logic_vector(3 downto 0);signal seg_tb : std_logic_vector(7 downto 0);signal beep_tb : std_logic;beginmyuit : at24c08 port map(clk => clk_tb,rst => rst_tb,scl => scl_tb,sda => sda_tb,urv_1 => urv_1_tb,urv_2 => urv_2_tb,sel => sel_tb,seg => seg_tb,beep => beep_tb);process(clk_tb)beginclk_tb <= not clk_tb after clockperiod/2;end process;rst_tb <= ‘0',‘1' after 1000ns;end behv_tb;。

基于FPGA的温度传感报警系统设计

基于FPGA的温度传感报警系统设计

基于FPGA的温度传感报警系统设计一、引言温度传感器在许多领域中被广泛使用,用于监测环境或设备的温度变化。

为了及时发现温度异常并采取相应措施,设计一个基于FPGA的温度传感报警系统具有重要意义。

本文将介绍如何利用FPGA实现温度传感器数据采集、处理和报警功能的设计方案。

二、系统结构基于FPGA的温度传感报警系统通常包括温度传感器模块、FPGA开发板、显示模块和报警器。

温度传感器用于采集环境温度数据,将数据传输给FPGA开发板;FPGA开发板负责接收并处理传感器数据,根据预设阈值判断是否触发报警;当温度超过设定阈值时,FPGA会触发报警器进行提示。

三、设计原理1. 数据采集:FPGA通过接口与温度传感器通信,获取实时温度数据。

2. 数据处理:FPGA对采集到的温度数据进行处理,与预设阈值比较,判断是否触发报警。

3. 报警功能:当温度超过设定阈值时,FPGA触发相应报警装置,如LED灯闪烁、蜂鸣器响声等。

四、软件实现1. Verilog/VHDL编程:使用Verilog或VHDL语言编写FPGA的逻辑设计,包括数据采集、阈值比较和报警逻辑。

2. 开发工具:选择适合的FPGA开发工具,如Xilinx ISE、Quartus II 等,进行逻辑综合、布局布线和下载等操作。

3. 调试验证:通过仿真和实验验证系统设计的正确性和稳定性。

五、性能分析通过对基于FPGA的温度传感报警系统进行性能分析,可以评估系统的响应速度、准确性和稳定性等指标。

同时,还可以分析系统的功耗、资源利用情况和可靠性等方面,为系统优化提供依据。

六、总结基于FPGA的温度传感报警系统设计结合了硬件设计和软件编程技朧,具有广泛的应用前景。

通过合理设计系统结构和软硬件实现,可以实现对温度异常的及时监测和报警提示,保障设备和环境的安全。

希望本文的介绍能够为读者深入理解基于FPGA的温度传感报警系统设计提供参考和启发,促进相关领域的技术创新和应用。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

FPGA课程设计论文学生姓名周悦学号20091321018院系电子与信息工程学院专业电子科学与技术指导教师李敏二O一二年5月28 日基于FPGA的温度传感器系统设计1引言温度是一种最基本的环境参数,人们的生活与环境的温度息息相关,在工业生产过程中需要实时测量温度,在农业生产中也离不开温度的测量,因此研究温度的测量方法和装置具有重要的意义。

测量温度的关键是温度传感器,温度传感器的发展经历了三个发展阶段:传统的分立式温度传感器;模拟集成温度传感器;智能集成温度传感器。

目前,国际上新型温度传感器正从模拟式向数字式,从集成化向智能化、网络化的方向飞速发展。

本文将介绍采用智能集成温度传感器DS18B20,并以FPGA为控制器的温度测量装置的硬件组成和软件设计,用液晶来实现温度显示。

2电路分析系统框图如下:第一部分:DS18B20温度传感器美国 Dallas 半导体公司的数字化温度传感器 DS1820 是世界上第一片支持 "一线总线"接口的温度传感器,在其内部使用了在板(ON-B0ARD)专利技术。

全部传感元件及转换电路集成在形如一只三极管的集成电路内。

一线总线独特而且经济的特点,使用户可轻松地组建传感器网络,为测量系统的构建引入全新概念。

现在,新一代的 DS18B20 体积更小、更经济、更灵活。

使你可以充分发挥“一线总线”的优点。

DS18B20 的主要特性:(1)适应电压范围更宽,电压范围:3.0~5.5V,在寄生电源方式下可由数据线供电(2)独特的单线接口方式,DS18B20 在与微处理器连接时仅需要一条口线即可实现微处理器与DS18B20 的双向通讯(3)DS18B20 支持多点组网功能,多个DS18B20 可以并联在唯一的三线上,实现组网多点测(4)DS18B20 在使用中不需要任何外围元件,全部传感元件及转换电路集成在形如一只三极管的集成电路内(5)温范围-55℃~+125℃,在-10~+85℃时精度为±0.5℃(6)可编程的分辨率为 9~12位,对应的可分辨温度分别为 0.5℃、0.25℃、0.125℃和 0.0625℃,可实现高精度测温(7)在 9 位分辨率时最多在93.75ms 内把温度转换为数字,12 位分辨率时最多在 750ms 内把温度值转换为数字,速度更快(8)测量结果直接输出数字温度信号,以"一线总线"串行传送给 CPU,同时可传送 CRC 校验码,具有极强的抗干扰纠错能力(9)负压特性:电源极性接反时,芯片不会因发热而烧毁,但不能正常工作。

DS18B20 引脚定义:(1)DQ 为数字信号输入/输出端;(2)GND 为电源地;(3)VDD 为外接供电电源输入端(在寄生电源接线方式时接地)。

DS18B20 中的温度传感器可完成对温度的测量,以 12 位转化为例:用 16 位符号扩展的二进制补码读数形式提供,以 0.0625℃/LSB 形式表达,其中 S 为符号位。

存储在 18B20 的两个 8 比特的RAM 中,二进制中的前面 5 位是符号位,如果测得的温度大于 0,这 5 位为 0,只要将测到的数值乘于 0.0625 即可得到实际温度;如果温度小于 0,这 5 位为 1,测到的数值需要取反加 1 再乘于 0.0625 即可得到实际温度。

例如+125℃的数字输出为 07D0H,+25.0625℃的数字输出为 0191H,-25.0625℃的数字输出为 FF6FH,-55℃的数字输出为 FC90H。

第二部分 EPM240系列芯片基本参数:CPLD类型:闪存宏单元数:192输入/输出线数:80传播延迟时间:5.9ns整体时钟设定时间:2.7ns频率:201.1MHz电源电压范围:2.375V to 2.625V,3V to 3.6V工作温度范围:0°C to +85°C针脚数:100封装类型:TQFP工作温度最低:0°C工作温度最高:85°C逻辑芯片功能:CPLD逻辑芯片基本号:EPM240T可编程逻辑类型:CPLD输入/输出接口标准:LV TTL, LVCMOS, PCI第三部分:LCD1602液晶显示屏液晶显示器以其微功耗、体积小、显示内容丰富、超薄轻巧的诸多优点,在袖珍式仪表和低功耗应用系统中得到越来越广泛的应用。

1602 采用标准的 16 脚接口,其中:第 1 脚:VSS 为地电源第 2 脚:VDD 接 5V 正电源第 3 脚:V0 为液晶显示器对比度调整端,接正电源时对比度最弱,接地电源时对比度最高,对比度过高时会产生“鬼影”,使用时可以通过一个 10K 的电位器调整对比度第 4 脚:RS 为寄存器选择,高电平时选择数据寄存器、低电平时选择指令寄存器。

第5脚:RW 为读写信号线,高电平时进行读操作,低电平时进行写操作。

当 RS 和 RW 共同为低电平时可以写入指令或者显示地址,当 RS 为低电平 RW 为高电平时可以读忙信号,当 RS 为高电平 RW 为低电平时可以写入数据。

第 6 脚:E 端为使能端,当 E 端由高电平跳变成低电平时,液晶模块执行命令。

第 7~14 脚:D0~D7 为 8 位双向数据线。

它的读写操作、屏幕和光标的操作都是通过指令编程来实现的。

指令 1:清显示,指令码 01H,光标复位到地址 00H 位置指令 2:光标复位,光标返回到地址 00H指令 3:光标和显示模式设置 I/D:光标移动方向,高电平右移,低电平左移 S:屏幕上所有文字是否左移或者右移。

高电平表示有效,低电平则无效指令 4:显示开关控制。

D:控制整体显示的开与关,高电平表示开显示,低电平表示关显示 C:控制光标的开与关,高电平表示有光标,低电平表示无光标 B:控制光标是否闪烁,高电平闪烁,低电平不闪烁指令 5:光标或显示移位 S/C:高电平时移动显示的文字,低电平时移动光标指令 6:功能设置命令 DL:高电平时为 4 位总线,低电平时为 8 位总线N:低电平时为单行显示,高电平时双行显示 F: 低电平时显示 5x7 的点阵字符,高电平时显示 5x10 的点阵字符(有些模块是 DL:高电平时为 8 位总线,低电平时为 4 位总线)指令 7:字符发生器 RAM 地址设置指令 8:DDRAM 地址设置指令 9:读忙信号和光标地址 BF:为忙标志位,高电平表示忙,此时模块不能接收命令或者数据,如果为低电平表示不忙。

指令 10:写数据指令 11:读数据电路连接如图所示~2.2 软件设计1、18b20驱动时序程序采用C语言进行编写,主要完成LCD1602初始化、DS18B20的初始化、从DS18B20读取数据、向DS18B20写数据及温度转化等子程序的编写,此外在进行程序的编写时一定要严格保证读写时序的正确性,否则无法读取测温结果,其初始化时序和写时序的程序分别如下:初始化时序包括一个主机发出的复位脉冲以及从机的应答脉冲这一过程,如图所示复位脉冲是一个480~960us的低电平然后释放总线,将总线拉至高电平,时间持续15~60us之后从机开始向总线发出一个应答脉冲,该脉冲是一个60~240us的低电平信号,表示从机已准备好,在初始化过程中主机接收脉冲的时间最少为480us。

DSl8820的访问步骤为:先进行初始化(Ini—tialization),然后发送ROM命令,最后发送Func—tion功能命令.对DSl8820访问必须通过上述步骤完成.初始化命令使主设备知道从设备是在总线上并可以进行访问.ROM命令可以使主设备知道有多少和什么类型的从设备连接在总线上并且判断是否超过温度报警值.共有5种ROM命令,分别是READROM(33H)、MATCH ROM(55H)、SEARCHROM(FOH)、SKIP ROM(CCH)、ALARM SEARCH命令(ECH).主设备可以通过功能命令来对DSl8820内部存储器进行读写.有6种功能命令,分别是CONVERT(44H)、WRITE SCRA TCHPAD(BEH)、READSCRA TCHPAD(4EH)、COPYSCRATCHPAD(48H)、RECALL E2(B8H)、读电源供电方式(B4H).DSl8820的单线通信功能是分时完成的,它有严格的时隙要求.Library IEEE;Use IEEE.Std_Logic_1164.All;Entity wendu isPort(led : out std_logic_vector(0 to 16);wireout : inout std_logic;clk : in std_logic;rst : in std_logic );End entity b;Architecture init of wendu istype init_states is (s00,s0,s1,s2,s3,s4,s5,s6,s7,w0,w1,w00,w01,read0,read1,read2,read3); signal state : init_states;signal i : integer Range 0 to 1000000;signal reset : std_logic;beginprocess (rst,wireout,clk)--variable i : Integer Range 0 to 1000;variable flag: Integer Range 0 to 200;variable light: Integer Range 0 to 16;beginif rst = '0' thenstate <= s00;wireout <= 'Z';flag:=0;elsif rising_edge(clk) thencase state iswhen s00=> flag:=0;state <=s0;when s0 => --初始化18b20wireout <= '0';--主机拉底总线reset <='1';state <=s1;when s1 =>reset <='0';if (i = 500) then --延时500uswireout <= 'Z'; --释放总线reset <='1';state <=s2;end if;when s2 => reset <='0';if (i = 100) then --等待100usreset <='1';state <=s3;end if;when s3 => if (wireout = '0') then --若18b20拉低总线,初始化成功 state <=s4;led(16)<='1'; --led16灯亮elsif (wireout ='1') then --否则,初始化不成功,返回S0state <= s0;end if;when s4 => reset<='0';if (i = 400) then --再延时400usreset<='1';state <= s5;end if;when s5 => --写数据if (flag = 0 ) then flag:=1;state <=w0; --cchelsif (flag = 1 ) then flag:=2;state <=w0;elsif (flag = 2 ) then flag:=3;state <=w01;wireout<='0';elsif (flag = 3 ) then flag:=4;state <=w01;wireout<='0';elsif (flag = 4 ) then flag:=5;state <=w0;elsif (flag = 5 ) then flag:=6;state <=w0;elsif (flag = 6 ) then flag:=7;state <=w01;wireout<='0';elsif (flag = 7 ) then flag:=8;state <=w01;wireout<='0';--第一次写完,750ms后,跳回s0elsif (flag = 16 ) then flag:=20;state <=s6;wireout<='Z';--再次置数cch和behelsif (flag = 20 ) then flag:=21;state <=w0; --cchelsif (flag = 21 ) then flag:=22;state <=w0;elsif (flag = 22 ) then flag:=23;state <=w01;wireout<='0';elsif (flag = 23 ) then flag:=24;state <=w01;wireout<='0';elsif (flag = 24 ) then flag:=25;state <=w0;elsif (flag = 25 ) then flag:=26;state <=w0;elsif (flag = 26 ) then flag:=27;state <=w01;wireout<='0';elsif (flag = 27 ) then flag:=28;state <=w01;wireout<='0';elsif (flag = 28 ) then flag:=29;state <=w0; --beh 10111110 elsif (flag = 29 ) then flag:=30;state <=w01;wireout<='0';elsif (flag = 30 ) then flag:=31;state <=w01;wireout<='0';elsif (flag = 31 ) then flag:=32;state <=w01;wireout<='0';elsif (flag = 32 ) then flag:=33;state <=w01;wireout<='0';elsif (flag = 33 ) then flag:=34;state <=w01;wireout<='0';elsif (flag = 34 ) then flag:=35;state <=w0;elsif (flag = 35 ) then flag:=36;state <=w01;wireout<='0';--第二次写完,跳到s7,直接开始读数据elsif (flag = 36 ) then flag:=40;state <=s7;end if;when s6 =>reset<='0';if (i = 750000 or wireout='1' ) then --延时750ms!!!!state <= s0;reset<='1'; --跳回s0,再次初始化end if;when s7 => --读数据if (flag = 40 ) then flag:=41;state <=read0;light:=0; wireout<='0';elsif (flag = 41 ) then flag:=42;state <=read0;light:=1; wireout<='0';elsif (flag = 42 ) then flag:=43;state <=read0;light:=2; wireout<='0';elsif (flag = 43 ) then flag:=44;state <=read0;light:=3; wireout<='0';elsif (flag = 44 ) then flag:=45;state <=read0;light:=4; wireout<='0';elsif (flag = 45 ) then flag:=46;state <=read0;light:=5; wireout<='0';elsif (flag = 46 ) then flag:=47;state <=read0;light:=6; wireout<='0';elsif (flag = 47 ) then flag:=48;state <=read0;light:=7; wireout<='0';elsif (flag = 48 ) then flag:=49;state <=read0;light:=8; wireout<='0';elsif (flag = 49 ) then flag:=50;state <=read0;light:=9; wireout<='0';elsif (flag = 50 ) then flag:=51;state <=read0;light:=10;wireout<='0';elsif (flag = 51 ) then flag:=52;state <=read0;light:=11;wireout<='0';elsif (flag = 52 ) then flag:=53;state <=read0;light:=12;wireout<='0';elsif (flag = 53 ) then flag:=54;state <=read0;light:=13;wireout<='0';elsif (flag = 54 ) then flag:=55;state <=read0;light:=14;wireout<='0';elsif (flag = 55 ) then flag:=60;state <=read0;light:=15;wireout<='0';elsif (flag = 60 ) then flag:=0;state<=s0;end if;when w0 => wireout<='0'; --输出0reset<='0';if (i = 80) then --延时80uswireout<='Z'; --释放总线,自动拉高reset<='1';state<=w00;end if;when w00 => state<=s5; --空状态when w01=> state<=w1; --空状态when w1 => wireout<='Z'; --输出1 释放总线,自动拉高 reset<='0';if (i = 80) then --延时80usreset<='1';state<=s5;end if;when read0=> state <= read1; --空延时状态when read1=> wireout <= 'Z'; --释放总线reset<='0';if (i = 10) then --再延时10usreset<='1';state <= read2;end if;when others =>state <=s00;end case;end if;end process;process(clk,reset)beginif (reset='1')theni<=0;elsif rising_edge(clk) then i<=i+1;end if;end process;end architecture init;2、液晶显示程序library ieee;use IEEE.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity lcd1602 isport(clk, reset: in std_logic;LCD_Data: out std_logic_vector(8 downto 0);en: out std_logic;rw: out std_logic);end lcd1602;architecture gongneng of lcd1602 issignal LCD_Clk: std_logic;signal s : integer range 0 to 10000000;begin--50MHz to 5Hzprocess(clk, reset)beginif reset = '0' thenLCD_Clk <= '0';s <= 0;elsif clk'event and clk = '1' thenif s = 10000000 thens <= 0;LCD_Clk <= not LCD_Clk;elses <= s + 1;end if;end if;end process;rw <='0';en <= LCD_Clk;process(LCD_Clk)variable cnt: std_logic_vector(4 downto 0):="00000";beginif Reset='0'thenLCD_Data<="000000001"; -- Reset清屏--LCD_Data[8..0], 其中LCD_Data[8]对应1602的RS,--LCD_Data[7..0]对应1602的八根数据线cnt:="00000"; --计数器清零elsif rising_edge(LCD_Clk) thenif cnt<"01111" then cnt:=cnt+1;else cnt:="00000";end if;--设计计数器,每次计数间隔LCD_CLK定义的一个周期case cnt iswhen "00000"=>LCD_Data<="000111000";--/*设置8位格式,2行,5*7*/ ,顺序2,3的要求when "00001"=>LCD_Data<="000001100"; --/*整体显示,关光标,光标闪烁/ ,顺序4的要求when "00010"=>LCD_Data<="000000001";--清屏,顺序5的要求when "00011"=>LCD_Data<="000000110"; --/*显示移动格式,看最后两位,10表示光标右移,顺序6的要求when "00100"=>LCD_Data<="010000000";--设定显示的位置在00H+80H,即显示屏第一行第一个位置,顺序7的要求when "00101"=>LCD_Data<="101000011"; --顺序8的要求,上一步指定位置处显示字符Cwhen others =>LCD_Data<="101000100";end case;end if;end process;end gongneng;。

相关文档
最新文档