当前位置:网站首页>ATH10 sensor reads temperature and humidity
ATH10 sensor reads temperature and humidity
2022-08-10 06:50:00 【do whatever you want】
一、分析AHT10 技术手册
(一)Temperature and humidity sensor information(不太重要)
1.简介
2.应用范围
3.传感器性能
(二)Temperature and humidity sensor information(重要)
1.接口
2.串行时钟线SCL
3.串行数据线SDA
4.I2C时序
5.AHT10指令
6.状态位说明
7.Read the temperature and humidity process
(1)Trigger on measurement data
(2)读取温湿度
8.采集数据处理
二、思路
(类似于I2C读写EEPROM,So the whole frame diagram is very similar)
(Power on first and wait40ms,Then enter the idle state,Then a read operation is performed,Depending on the status bytes are returnedbit[3]to determine whether initialization is required.如果bit[3]=0则需要进行初始化(Send a write control byte,0xE1命令,初始化参数0x08,0x00)如果是bit[3]=1则不需要初始化,Triggered measurements can be started directly(发送控制字节,0xAC命令,触发参数0x33,0x00),Wait after the measurement is complete80ms(The read operation should have been performed again,Judging the status bytebit[7]Check whether the measurement has been completed and the device is idle.But it feels cumbersome,延迟80ms应该够了,Therefore, this read status operation is not performed),Then read the temperature and humidity operation(Send a read control byte))
(一)The frame diagram of the temperature and humidity acquisition system
模块说明:
1.顶层模块–aht10
aht10(
input clk ,
input rst_n ,
output i2c_scl,
inout i2c_sda,
output tx
);
2.控制模块–controller
controller(
input clk ,
input rst_n ,
input busy ,
output i2c_scl ,
inout i2c_sda ,
output [7:0] data_tx,
output data_tx_vld
);
控制aht10_rw和i2c_interface数据传输,接收uart_tx模块的busy信号,输出data_tx和data_tx_vld给uart_tx模块,传输i2c时钟和数据.
3.AHT10读写模块–aht10_rw
aht10_rw(
input clk ,
input rst_n ,
input busy ,
output req ,
output [3:0] cmd ,
output [7:0] wr_data ,
input [7:0] rd_data ,
output reg [7:0] dout ,
output reg dout_vld ,
input done ,
input slave_ack
);
According to the status pairi2cThe interface module sends the request、命令(读、写、起始、停止)、发送数据.实现控制i2cInterface module pairaht10The sensor performs read and write operations.Handles receiving data and sending ituart_tx模块.
数据处理
(I worked with the data directly in this module)
思路:
(1)Store data in bytes[19:0]RH和[19:0]TP中,Filter out status bytes,Place the back of the THM byte before2.5字节存入[19:0]RH,后2.5字节存入[19:0]TP.
//数据处理
//RH、TP
[email protected](posedge clk or negedge rst_n)begin
if(!rst_n)begin
RH <= 1'b0;
TP <= 1'b0;
end
else if(state_c == READ_WAIT && cnt_byte == 2) begin
RH[19:12] <= rd_data;
TP <= 1'b0;
end
else if(state_c == READ_WAIT && cnt_byte == 3) begin
RH[11:4] <= rd_data;
TP <= 1'b0;
end
else if(state_c == READ_WAIT && cnt_byte == 4) begin
RH[3:0] <= rd_data[7:4];
TP[19:16] <= rd_data[3:0];
end
else if(state_c == READ_WAIT && cnt_byte == 5) begin
RH <= RH;
TP[15:8] <= rd_data;
end
else if(state_c == READ_WAIT && cnt_byte == 6) begin
RH <= RH;
TP[7:0] <= rd_data;
end
end
(2)Process data by formula
wire [39:0] RH_r;
wire [39:0] TP_r;
assign RH_r = (RH * 10000)>>20;
assign TP_r = ((TP * 20000)>>20) - 5000;
(3)将数据转换为ASCII码
wire [7:0] data_r [15:0];//Register humidity、Tens of thousands of temperature
assign data_r [0] = 8'b01010010 ;//R
assign data_r [1] = 8'b01001000 ;//H
assign data_r [2] = 8'b00111010 ;//:
assign data_r [3] = RH_r /1000 + 8'b0011_0000;//Humidity in thousands
assign data_r [4] = RH_r /100 %10 + 8'b0011_0000;//Humidity in the hundreds
assign data_r [5] = 8'b00101110 ;//.
assign data_r [6] = RH_r /10 %10 + 8'b0011_0000;//Tens of humidity
assign data_r [7] = RH_r %10 + 8'b0011_0000;//Humidity bits
assign data_r [8] = 8'b01010100 ;//T
assign data_r [9] = 8'b01010000 ;//P
assign data_r [10] = 8'b00111010 ;//:
assign data_r [11] = TP_r /1000 + 8'b0011_0000;//Temperature in thousands
assign data_r [12] = TP_r /100 %10 + 8'b0011_0000;//温度百位
assign data_r [13] = 8'b00101110 ;//.
assign data_r [14] = TP_r /10 %10 + 8'b0011_0000;//温度十位
assign data_r [15] = TP_r %10 + 8'b0011_0000;//温度个位
4.I2C接口模块–i2c_interface
i2c_interface(
input clk ,
input rst_n ,
//主机发送数据
input req ,//请求
input [3:0] cmd ,//i2c接口指令,控制状态
input [7:0] din ,//i2cThe data that the interface needs to send
//主机接收数据
output [7:0] dout ,//i2c接口接收的数据
output done ,//完成一次读/写指令
output slave_ack ,//The response from the master to the slave
//从机接收数据
output i2c_scl ,//i2c时钟
input i2c_sda_i , //i2cSend data to the host
output i2c_sda_o ,//The master sends data to the slave
output i2c_sda_oe
);
根据aht10_rw模块的请求、command for read and write operations,满足i2c读写时序,产生i2c时钟,控制i2cThe clock line and the data line are used for data transmission.
(二)状态转移图
1.AHT10_RWModule state transition diagram
(1)状态说明:
WAIT:上电等待40ms
IDLE:空闲状态
STATU、STATU_WAIT:Read the status byte status and its wait states
INIT、INIT_WAIT:The initialization state and its wait states
START、START_WAIT:Trigger state and its wait state
READ、READ_WAIT:Read the temperature and humidity data status and its waiting status
DONE:结束状态
(2)The number of individual status bytes:
读状态 读控制字节(8’b0111_0001) Read the status byte 共两字节
初始化 写控制字节(8’b0111_0000) 写命令(8’b11100001) 写两个参数(8’b00001000、8’b00000000) 共四字节
触发测量 写控制字节(8’b0111_0000) 写命令(8’b10101100) 写两个参数(8’b00110011、8’b00000000) 共四字节
读数据 读控制字节(8’b0111_0001) read six bytes 共七字节
(3)状态转移条件:
2.I2C_interfaceModule state transition diagram
状态跳转条件:
三、实验结果
(一)实验效果
(二)仿真
1、State jump simulation
(1)读状态、初始化状态
(2)读状态、Trigger measurement state
(3)Read the temperature and humidity status
2、Data processing simulation
3.RTL视图
边栏推荐
- Grammar Basics (Judgment Statements)
- oracle业务表的数据发生增删改,该表的索引会写redo,undo吗?
- order by injection and limit injection, and wide byte injection
- 调试ZYNQ的u-boot 2017.3 不能正常启动,记录调试过程
- 结构体初阶
- 第12章 数据库其它调优策略【2.索引及调优篇】【MySQL高级】
- Nude speech - lying flat - brushing questions - big factory (several tips for Android interviews)
- 神经网络可视化有3D版本了,美到沦陷 已开源
- 强化学习_08_Datawhale针对连续动作的深度Q网络
- 数据库学习之数据类型
猜你喜欢
语法基础(判断语句)
第12章 数据库其它调优策略【2.索引及调优篇】【MySQL高级】
The constraints of the database learning table
Elementary Structure
DGIOT三千万电表集抄压测
【Event Preview on August 9】Prometheus Summit
High quality WordPress download station 5 play theme template
Fiddler(八) - 抓取手机APP的流量-插件Fiddler Orchestra Beta安装&配置
About MongoDb query Decimal128 to BigDecimal problem
DGIOT支持工业设备租赁以及远程管控
随机推荐
MVCC详解
The constraints of the database learning table
幂函数 指数函数 对数函数
delta method 介绍
关于MongoDb查询Decimal128转BigDecimal问题
.NET-8.我的思想笔记
2022河南萌新联赛第(五)场:信息工程大学 K - 矩阵生成
Complex AB experiment
2022 Henan Mengxin League Game (5): University of Information Engineering C - Throwing a Handkerchief
MySQL事务隔离级别
高级测试:如何使用Flink对Strom任务的逻辑功能进行复现测试?
SCS【2】单细胞转录组 之 cellranger
【愚公系列】2022年08月 Go教学课程 034-接口和多态
SQL建表问题,帮我看看好吗朋友们~大家人。!
语法基础(判断语句)
请问为什么sqlserver cdc,任务启动过了一天,会报这个错误,明明已经开启cdc了。
1413. 逐步求和得到正数的最小值
mysql数据库定时备份(保留近7天的备份)
order by注入与limit注入,以及宽字节注入
【MySQL】SQL语句