基于FPGA温度传感器DS18B20的Verilog设计_第1页
基于FPGA温度传感器DS18B20的Verilog设计_第2页
基于FPGA温度传感器DS18B20的Verilog设计_第3页
基于FPGA温度传感器DS18B20的Verilog设计_第4页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、基于FPGA温度传感器DS18B20的Verilog设计赖青松(江西师范大学 南昌 电子信息工程)摘 要: 本文利用数字温度传感器 DS18B20 的数据接口和特点 ,阐述了一种基于现场可编程门阵列( FPGA)控制DS18B20的方法。使用 FPGA 作为控制器 ,严格控制DS18B20 的时序 ,在单总线上实现读写功能 ,完成测量数字温度的功能。将测量的二进制数转换为BCD码 ,并通过数码管显示。系统设计使用 Verilog 语言。由于 DS18B20 是采用一根 I/ O 总线读写数据,因此DS18B20 对读写数据位有严格的时序要求。DS18B20 遵循相应的通信协议从而保证数据传输的

2、正确性和完整性。该通信协议定义了多种信号时序:初始化时序、 写时序、 读时序1、初始化时序:During the initialization sequence the bus master transmits (TX) the reset pulse by pulling the 1-Wire bus low for a minimum of 480us. The bus master then releases the bus and goes into receive mode (RX). When the bus is released, the 5k pullup resistor

3、pulls the 1-Wire bus high.When the DS18B20 detects this rising edge, it waits 15us to 60us and then transmits a presence pulse by pulling the 1-Wire bus low for 60us to 240us.初始化时序中,控制器发送一个480us-960us的低电平的复位信号,然后释放总线,也就是总线为高电平,此时,控制器准备接收DS18B20的反应信号,当总线释放后,如果存在DS18B20,那么DS18B20将在15-60us内发送一个持续60-240

4、us的反应信号。2、写时序:(因为本设计总线上只挂了一个DS18B20,所以不用读取64位序列号,直接发送忽略rom命令skin rom)There are two types of write time slots: “Write 1” time slots and “Write 0” time slots. The bus master uses a Write 1 time slot to write a logic 1 to the DS18B20 and a Write 0 time slot to write a logic 0 to the DS18B20. All write

5、time slots must be a minimum of 60us in duration with a minimum of a 1us recovery time between individual write slots. Both types of write time slots are initiated by the master pulling the 1-Wire bus low写时序有写1和写2时序,首先将总线拉低电平,拉低后15us之内必须把所要向DS18B20写的数据传到总线上,DS18B20将在15us-60us内采样总线上的数据,如果为高则写1,为低则写0;

6、写完一次后释放总线。每两次写数据之间时隙要大于1us3、读时序:All read time slots must be a minimum of 60us in duration with a minimum of a 1us recovery time between slots. A read time slot is initiated by the master device pulling the 1-Wire bus low for a minimum of 1us and then releasing the bus (see Figure 14). After the mast

7、er initiates the read time slot, the DS18B20 will begin transmitting a 1 or 0 on bus. The DS18B20 transmits a 1 by leaving the bus high and transmits a 0 by pulling the bus low. Output data from the DS18B20 is valid for 15us after the falling edge that initiated the read time slot. Therefore, the ma

8、ster must release the bus and then sample the bus state within 15us from the start of the slot.读时序时,总线拉低电平大于1us后,然后释放总线准备接收DS18B20传来的数据,DS18B20将在总线拉低后15us之内将数据传到总线上,因此,控制器必须在拉低电平然后释放总线15us之内采样总线上的数据。每次读取一位数据不小于60us。4、程序流程图FPGA 控制DS18B20 实现温度转换的程序流程如下图所示。本实验采用状态机控制各时序。具体请看源码。5、电源连接DS18B20 可使用寄生电源,可以在

9、 I/ O 引脚处于高电平时 “偷” 些能量,储存在电容中供正常使用,但进行精确转换时需要 I/ O 引脚保持大电流供电,这样对 FPGA 芯片引脚造成很大压力,所以使用 VDD 引脚接外部电源:DS18B20 进行温度转换需要很大电流,工作最大电流可达 1 mA。使用 VDD 引脚接外部电源供电的优点在于I/ O 线上不需要在温度变换期间保持高电平。这样就可以有效的保护 FPGA 芯片,也可在单总线上放置多数目的DS18B20。使用外部电源,通过发出 Skip ROM 跳过命令,然后发出 Convert T变换命令,可以完成温度变换。6、显示:控制器从DS18B20接收的16位温度值为12位(大家懂的),精度为0.0

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论