ADT7410 ±0.5℃精度温度传感器
【摘要】
■ 前言
ADT7410是一款基于SOIC封装的高精度数字温度传感器。它内部具有带隙温度参考源以及13位ADC,可以提高0.0625摄氏度的温度精度。这个温度分辨率还可以改变成16位(0...
■ 前言
ADT7410是一款基于SOIC封装的高精度数字温度传感器。它内部具有带隙温度参考源以及13位ADC,可以提高0.0625摄氏度的温度精度。这个温度分辨率还可以改变成16位(0.0075℃)。
ADT7410可以工作在2.7V至5.5V的工作电源。工作在3.3V时,工作电流为210uA。 ADT在Shutdown模式下,耗电量仅为2uA。
ADT7410可以工作在-55℃至150℃。可被广泛 应用在医疗器械、环境监控、计算机温度检测、温度保护、工业过程控制、电源系统监测以及手持设备应用等等。
▲ ADT7410内部功能图
ADT7410通过I2C总线与MCU连接。本文通过制作基于STC8G1K08电路板,来访问四个温度传感器。
01实验电路板设计
1.MCU控制板制作1
○ 原理图设计
▲ MCU原理图
2. ADT7410芯片小板2
▲ ADT7410芯片小板
▲ ADT7410 PCB板
通过温度板的右边四个电阻,来设定温度传感器的I2C地址:A1A0。具体设置如下图所示:
▲ ADT7410地址设置通过RA1234
02MCU软件设计3
控制小板的串口命令:
else IFARG0("rt") {
printf("%f ", ADT7410ReadT(0));
printf("%f ", ADT7410ReadT(1));
printf("%f ", ADT7410ReadT(2));
printf("%f\r\n", ADT7410ReadT(3));
} else IFARG0("rtx") {
printf("%04x ", ADT7410ReadTemp(0));
printf("%04x ", ADT7410ReadTemp(1));
printf("%04x ", ADT7410ReadTemp(2));
printf("%04x\r\n", ADT7410ReadTemp(3));
} else IFARG0("rtb") {
nNumber = ADT7410ReadTemp(0);
SendChar((unsigned char)(nNumber >> 8));
SendChar((unsigned char)(nNumber));
nNumber = ADT7410ReadTemp(1);
SendChar((unsigned char)(nNumber >> 8));
SendChar((unsigned char)(nNumber));
nNumber = ADT7410ReadTemp(2);
SendChar((unsigned char)(nNumber >> 8));
SendChar((unsigned char)(nNumber));
nNumber = ADT7410ReadTemp(3);
SendChar((unsigned char)(nNumber >> 8));
SendChar((unsigned char)(nNumber));
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
▲ 上电后实验电路板
※ 结论
本文构造可以同时访问四路ADT7410温度传感器。 通过串口命令可以获得对应的温度值。
▲ 测量白炽灯泡在点亮后的温度上升
▲ 测量制冷片的温度下降过程
▲ 测量制冷片的温度上升过程
/*
**==============================================================================
** ADT7410.C: -- by Dr. ZhuoQing, 2020-07-08
**
**==============================================================================
*/
//------------------------------------------------------------------------------
#define ADT7410_GLOBALS 1 // Define the global variables
#include "ADT7410.H"
#include "STC8G.H"
//------------------------------------------------------------------------------
//==============================================================================
// INTERFACE FUNCTIONS
//------------------------------------------------------------------------------
void ADT7410SetAdd(unsigned char ucA10) {
g_ucADT7410Add = ADT7410_I2C_ADD + (ucA10 << 1);
}
//------------------------------------------------------------------------------
void ADT7410Init(unsigned char ucAdd) {
ADT7410SetAdd(ucAdd);
ADT7410SetConfiguration(0x80); // Set 16 bits resolution of temperature.
}
//------------------------------------------------------------------------------
float ADT7410ReadT(unsigned char ucAdd) {
ADT7410SetAdd(ucAdd);
ADT7410SetConfiguration(0x80);
return ADT7410ReadTemperature() / 128.0;
}
//------------------------------------------------------------------------------
int ADT7410ReadTemp(unsigned char ucAdd) {
ADT7410SetAdd(ucAdd);
ADT7410SetConfiguration(0x80);
return ADT7410ReadTemperature();
}
//------------------------------------------------------------------------------
float ADT7410Temperature(int nNumber) {
return nNumber / 128.0;
}
//------------------------------------------------------------------------------
void ADT7410WriteByte(unsigned char ucAdd, unsigned char ucByte) {
I2CStart();
I2CSendData(g_ucADT7410Add);
I2CReceiveACK();
I2CSendData(ucAdd);
I2CReceiveACK();
I2CSendData(ucByte);
I2CReceiveACK();
I2CStop();
}
void ADT7410WriteInt(unsigned char ucAdd, unsigned int nNum) {
I2CStart();
I2CSendData(g_ucADT7410Add);
I2CReceiveACK();
I2CSendData(ucAdd);
I2CReceiveACK();
ucAdd = (unsigned char)(nNum >> 8);
I2CSendData(ucAdd);
I2CReceiveACK();
ucAdd = (unsigned char)(nNum);
I2CSendData(ucAdd);
I2CReceiveACK();
I2CStop();
}
//------------------------------------------------------------------------------
unsigned char ADT7410ReadByte(unsigned char ucAdd) {
unsigned char ucByte;
I2CStart();
I2CSendData(g_ucADT7410Add);
I2CReceiveACK();
I2CSendData(ucAdd);
I2CReceiveACK();
I2CStart();
I2CSendData(g_ucADT7410Add + 1);
ucByte= I2CReceiveData();
I2CSendNACK();
I2CStop();
return ucByte;
}
void ADT7410ReadDim(unsigned char ucAdd, unsigned char ucLength, unsigned char * pDim) {
unsigned char ucByte, i;
I2CStart();
I2CSendData(g_ucADT7410Add);
I2CReceiveACK();
I2CSendData(ucAdd);
I2CReceiveACK();
I2CStart();
I2CSendData(g_ucADT7410Add + 1);
I2CReceiveACK();
for(i = 0; i < ucLength; i ++) {
ucByte= I2CReceiveData();
if(i < ucLength - 1)
I2CSendACK();
else I2CSendNACK();
*(pDim + i) = ucByte;
}
I2CStop();
}
//------------------------------------------------------------------------------
int ADT7410ReadTemperature(void) {
unsigned char ucBytes[2];
int nValue;
ADT7410ReadDim(0x0, 2, ucBytes);
// ucBytes[0] = ADT7410ReadByte(0);
// ucBytes[1] = ADT7410ReadByte(1);
nValue = ucBytes[0];
nValue = (nValue << 8) | ucBytes[1];
return nValue;
}
unsigned char ADT7410ReadStatus(void) {
unsigned char ucChar;
ucChar = ADT7410ReadByte(ADT7410_STATUS_ADD);
return ucChar;
}
unsigned char ADT7410ReadConfiguration(void) {
unsigned char ucChar;
ucChar = ADT7410ReadByte(ADT7410_CONFIGURATION_ADD);
return ucChar;
}
void ADT7410SetConfiguration(unsigned char ucConfiguration) {
ADT7410WriteByte(ADT7410_CONFIGURATION_ADD, ucConfiguration);
}
unsigned char ADT7410ReadID(void) {
unsigned char ucChar;
ucChar = ADT7410ReadByte(ADT7410_ID_ADD);
return ucChar;
}
void ADT7410SoftwareReset(void) {
ADT7410WriteByte(ADT7410_RESET_ADD, 0xaa);
}
void ADT7410SetHysteresisTemperature(unsigned char ucHysteresis) {
ADT7410WriteByte(ADT7410_THYST_ADD, ucHysteresis);
}
void ADT7410SetHighTemperature(int nT) {
ADT7410WriteInt(ADT7410_THIGH_ADD, nT);
}
void ADT7410SetLowTemperature(int nT) {
ADT7410WriteInt(ADT7410_TLOW_ADD, nT);
}
void ADT7410SetCriticalTemperature(int nT) {
ADT7410WriteInt(ADT7410_TCRIT_ADD, nT);
}
int ADT7410ReadHighTemperature(void) {
unsigned char ucBytes[2];
int nValue;
ADT7410ReadDim(ADT7410_THIGH_ADD, 2, ucBytes);
nValue = ucBytes[0];
nValue = (nValue << 8) | ucBytes[1];
return nValue;
}
int ADT7410ReadLowTemperature(void) {
unsigned char ucBytes[2];
int nValue;
ADT7410ReadDim(ADT7410_TLOW_ADD, 2, ucBytes);
nValue = ucBytes[0];
nValue = (nValue << 8) | ucBytes[1];
return nValue;
}
int ADT7410ReadCritialTemperature(void) {
unsigned char ucBytes[2];
int nValue;
ADT7410ReadDim(ADT7410_TCRIT_ADD, 2, ucBytes);
nValue = ucBytes[0];
nValue = (nValue << 8) | ucBytes[1];
return nValue;
}
unsigned char ADT7410ReadHysteresisTemperature(void) {
return ADT7410ReadByte(ADT7410_THYST_ADD);
}
//==============================================================================
// END OF THE FILE : ADT7410.C
//------------------------------------------------------------------------------
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 132
- 133
- 134
- 135
- 136
- 137
- 138
- 139
- 140
- 141
- 142
- 143
- 144
- 145
- 146
- 147
- 148
- 149
- 150
- 151
- 152
- 153
- 154
- 155
- 156
- 157
- 158
- 159
- 160
- 161
- 162
- 163
- 164
- 165
- 166
- 167
- 168
- 169
- 170
- 171
- 172
- 173
- 174
- 175
- 176
- 177
- 178
- 179
- 180
- 181
- 182
- 183
- 184
- 185
- 186
- 187
- 188
- 189
- 190
- 191
- 192
- 193
- 194
- 195
- 196
- 197
- 198
- 199
- 200
- 201
- 202
- 203
- 204
- 205
- 206
- 207
- 208
- 209
/*
**==============================================================================
** ADT7410.H: -- by Dr. ZhuoQing, 2020-07-08
**
** Description:
**
**==============================================================================
*/
#ifndef __ADT7410__
#define __ADT7410__
//------------------------------------------------------------------------------
#ifdef ADT7410_GLOBALS
#define ADT7410_EXT
#else
#define ADT7410_EXT extern
#endif // ADT7410_GLOBALS
//------------------------------------------------------------------------------
//==============================================================================
//------------------------------------------------------------------------------
#define ADT7410_I2C_ADD 0x90
ADT7410_EXT unsigned char g_ucADT7410Add;
void ADT7410SetAdd(unsigned char ucA10);
float ADT7410Temperature(int nNumber);
//------------------------------------------------------------------------------
float ADT7410ReadT(unsigned char ucAdd);
int ADT7410ReadTemp(unsigned char ucAdd);
//==============================================================================
// INTERFACE FUNCTIONS
//------------------------------------------------------------------------------
void ADT7410Init(unsigned char ucA10);
void ADT7410WriteByte(unsigned char ucAdd, unsigned char ucByte);
void ADT7410WriteInt(unsigned char ucAdd, unsigned int nNum);
unsigned char ADT7410ReadByte(unsigned char ucAdd);
void ADT7410ReadDim(unsigned char ucAdd, unsigned char ucLength, unsigned char * pDim);
//------------------------------------------------------------------------------
#define ADT7410_TEMPERATURE_ADD 0x0
#define ADT7410_STATUS_ADD 0x2
#define ADT7410_CONFIGURATION_ADD 0x3
#define ADT7410_THIGH_ADD 0x4
#define ADT7410_TLOW_ADD 0x6
#define ADT7410_TCRIT_ADD 0x8
#define ADT7410_THYST_ADD 0xA
#define ADT7410_ID_ADD 0x0B
#define ADT7410_RESET_ADD 0x2F
//------------------------------------------------------------------------------
int ADT7410ReadTemperature(void);
unsigned char ADT7410ReadStatus(void);
unsigned char ADT7410ReadConfiguration(void);
void ADT7410SetConfiguration(unsigned char ucConfiguration);
unsigned char ADT7410ReadID(void);
void ADT7410SoftwareReset(void);
void ADT7410SetHysteresisTemperature(unsigned char ucHysteresis);
void ADT7410SetHighTemperature(int nT);
void ADT7410SetLowTemperature(int nT);
void ADT7410SetCriticalTemperature(int nT);
int ADT7410ReadHighTemperature(void);
int ADT7410ReadLowTemperature(void);
int ADT7410ReadCritialTemperature(void);
unsigned char ADT7410ReadHysteresisTemperature(void);
//==============================================================================
// END OF THE FILE : ADT7410.H
//------------------------------------------------------------------------------
#endif // __ADT7410__
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
文章来源: zhuoqing.blog.csdn.net,作者:卓晴,版权归原作者所有,如需转载,请联系作者。
原文链接:zhuoqing.blog.csdn.net/article/details/107212725
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)