로그인회원등록 내글장바구니주문조회현재접속자
 상품 검색








 게시판 검색





 
 
회원등록 비번분실


온라인 입금계좌
ㆍ기업은행
ㆍ219-043192-01-028
ㆍ이건영

      거래은행 바로가기
 
 Sensor Applications
센서 자료실
작성자 leeky        
작성일 2006/02/14
첨부#1 hst11_at89s53.c.zip (0KB) (Down:142)
첨부#2 SHT11_150px_shot.jpg (0KB) (Down:74)
Link#1 sensorSHT11.htm (Down:55)
ㆍ추천: 0  ㆍ조회: 1061   
  SHT11 습도센서 8051 인터페이스

상대습도 센서 SHT11는 첫번째 디지털 습도와 온도센서이다.
SHT11 디지털 습도와 온도 센서는 충분히 교정었으며 장기간 안정도와 매우 저렴한 가격으로 사용하기 쉽다.
디지털 CMOSens 기술은 하나의 칩위에 2개의 센서와 읽기 출력회로로 직접된다.
.
CMOSens 기술은 센서, 증폭기, 보정 메모리 상수 값, A/D 컨버터 그리고 디지털 인터페이스가
단일 silicon chip 위에 구현된 제품으로 표현 될 수 있다.
.SHT11 (14bit ADC for Temperature, 12bit ADC for Humidity)
Temperature(Tc) = -39.60 + 0.01*adc_value
humidity = -4 + 0.0405 * adc_value + (-2.8*10^-6)*(adc_value^2)
Humidity_true = (Tc -25) * (0.01+0.00008*adc_value) + humidity
//
● 습도 계산 루틴.
// calculates temperature [C] and humidity [%RH]
// 입력 : humi [Ticks] (12 bit), temp [Ticks] (14 bit)
// 출력 : humi [%RH], temp [C]

void calc_sth11(float *p_humidity ,float *p_temperature)
{
const float C1=-4.0; // for 12 Bit
const float C2= 0.0405; // for 12 Bit
const float C3=-0.0000028; // for 12 Bit
const float T1=0.01; // for 14 Bit @ 5V
const float T2=0.00008; // for 14 Bit @ 5V
float rh=*p_humidity; // rh: Humidity [Ticks] 12 Bit
float t=*p_temperature; // t: Temperature [Ticks] 14 Bit
float rh_lin; // rh_lin: Humidity linear
float rh_true; // rh_true: Temperature compensated humidity
float t_C; // t_C : Temperature [C]
t_C=t*0.01 ? 40; //calc. Temperature from ticks to [C]
rh_lin=C3*rh*rh + C2*rh + C1; //calc. Humidity from ticks to [%RH]
rh_true=(t_C-25)*(T1+T2*rh)+rh_lin; //calc. Temperature compensated humidity [%RH]
if(rh_true>100)rh_true=100; //cut if the value is outside of
if(rh_true<0.1)rh_true=0.1; //the physical possible range
*p_temperature=t_C; //return temperature [C]
*p_humidity=rh_true; //return humidity[%RH]
}
//
● 이슬점의 계산 루틴
입력 : humidity [%RH], temperature [C]
출력 : output: dew point [C]
float calc_dewpoint(float h,float t)
{
float k,dew_point ;
k = (log10(h)-2)/0.4343 + (17.62*t)/(243.12+t);
dew_point = 243.12*k/(17.62-k);
return dew_point;
}

● SHTxx 습도와 온도 센서 송신용 소스코드
이 용응자료는 다음의 목적을 위한 MPU용 C코드의 예를 제공한다.
기본 오류처리로 SHTxx의 습도 (RH) 혹은 온도 (T) 의 읽기
RH 직선화와 온도보상의 계산
status register의 호출
RH 와 T 를 위한 이슬점 계산
UART 처리 (좋은 데이터를 PC로 전송하는 방법)
.
● 8051 MPU 펌웨어용 KEIL C 소스 (통신속도는 11.0592MHz Xtal에서 9600 BPS 이다)
//***********************************************************************
// 프로젝트 : SHT11 평기 프로그램 (V2.0)
// 파일 이름 : SHT11.c
// MPU : 80C51 시리즈 (AT89S53을 사용 그러나 다른 8051로 변경이 가능)
// 번역기 : Keil Version 6.14
// 저자 : MST (c) Sensirion AG
//***********************************************************************
#include <AT89s53.h> //Microcontroller specific library, e.g. port definitions
#include <intrins.h> //Keil library (is used for _nop()_ operation)
#include <math.h> //Keil library
#include <stdio.h> //Keil library
//
typedef union
{
unsigned int i;
float f;
} value;
//
//***********************************************************************
// modul-var
//***********************************************************************
enum {TEMP,HUMI};
#define DATA P1_1
#define SCK P1_0
#define noACK 0
#define ACK 1
//adr command r/w
#define STATUS_REG_W 0x06 //000 0011 0
#define STATUS_REG_R 0x07 //000 0011 1
#define MEASURE_TEMP 0x03 //000 0001 1
#define MEASURE_HUMI 0x05 //000 0010 1
#define RESET 0x1e //000 1111 0
//
//***********************************************************************
char s_write_byte(unsigned char value)
//***********************************************************************
// writes a byte on the Sensibus and checks the acknowledge
{
unsigned char i,error=0;
for (i=0x80;i>0;i/=2) //shift bit for masking
{
if (i & value) DATA=1; //masking value with i , write to SENSI-BUS
else DATA=0;
SCK=1; //clk for SENSI-BUS
_nop_();_nop_();_nop_(); //pulswith approx. 5 us
SCK=0;
}
DATA=1; //release DATA-line
SCK=1; //clk #9 for ack
error=DATA; //check ack (DATA will be pulled down by SHT11)
SCK=0;
return error; //error=1 in case of no acknowledge
}
//
//***********************************************************************
// char s_read_byte(unsigned char ack)
//***********************************************************************
// reads a byte form the Sensibus and gives an acknowledge in case of "ack=1"
char s_read_byte(unsigned char ack)
{
unsigned char i,val=0;
DATA=1; //release DATA-line
for (i=0x80;i>0;i/=2) //shift bit for masking
{
SCK=1; //clk for SENSI-BUS
if (DATA) val=(val | i); //read bit
SCK=0;
}
DATA=!ack; //in case of "ack==1" pull down DATA-Line
SCK=1; //clk #9 for ack
_nop_();_nop_();_nop_(); //pulswith approx. 5 us
SCK=0;
DATA=1; //release DATA-line
return val;
}
//
//***********************************************************************
// void s_transstart(void)
//***********************************************************************
// generates a transmission start
// _____ ________
// DATA: |_______|
// ___ ___
// SCK : ___| |___| |______
void s_transstart(void)
{
DATA=1; SCK=0; //Initial state
_nop_(); SCK=1;
_nop_(); DATA=0;
_nop_(); SCK=0;
_nop_();_nop_();_nop_(); SCK=1;
_nop_(); DATA=1;
_nop_(); SCK=0;
}
//
//***********************************************************************
// void s_connectionreset(void)
//***********************************************************************
// communication reset: DATA-line=1 and at least 9 SCK cycles followed by transstart
// DATA: ------------------------____------
// SCK : __-_-_-_-_-_-_-_-_-__--__--____
void s_connectionreset(void)
{
unsigned char i;
DATA=1; SCK=0; //Initial state
for(i=0;i<9;i++) //9 SCK cycles
{
SCK=1;
SCK=0;
}
s_transstart(); //transmission start
}
//
//***********************************************************************
// char s_softreset(void)
//***********************************************************************
// resets the sensor by a softreset
char s_softreset(void)
{
unsigned char error=0;
s_connectionreset(); //reset communication
error+=s_write_byte(RESET); //send RESET-command to sensor
return error; //error=1 in case of no response form the sensor
}
//
//***********************************************************************
// char s_read_statusreg(unsigned char *p_value, unsigned char *p_checksum)
//***********************************************************************
// reads the status register with checksum (8-bit)
char s_read_statusreg(unsigned char *p_value, unsigned char *p_checksum)
{
unsigned char error=0;
s_transstart(); //transmission start
error=s_write_byte(STATUS_REG_R); //send command to sensor
*p_value=s_read_byte(ACK); //read status register (8-bit)
*p_checksum=s_read_byte(noACK); //read checksum (8-bit)
return error; //error=1 in case of no response form the sensor
}
//
//***********************************************************************
// char s_write_statusreg(unsigned char *p_value)
//***********************************************************************
// writes the status register with checksum (8-bit)
char s_write_statusreg(unsigned char *p_value)
{
unsigned char error=0;
s_transstart(); //transmission start
error+=s_write_byte(STATUS_REG_W);//send command to sensor
error+=s_write_byte(*p_value); //send value of status register
return error; //error>=1 in case of no response form the sensor
}
//
//***********************************************************************
// char s_measure(unsigned char *p_value, unsigned char *p_checksum, unsigned char mode)
//***********************************************************************
// makes a measurement (humidity/temperature) with checksum
char s_measure(unsigned char *p_value, unsigned char *p_checksum, unsigned char mode)
{
unsigned error=0;
unsigned int i;
s_transstart(); //transmission start
switch(mode)
{
//send command to sensor
case TEMP : error+=s_write_byte(MEASURE_TEMP); break;
case HUMI : error+=s_write_byte(MEASURE_HUMI); break;
default : break;
}

//wait until sensor has finished the measurement
for (i=0;i<65535;i++) if(DATA==0) break;
if(DATA) error+=1; // or timeout (~2 sec.) is reached
*(p_value) =s_read_byte(ACK); //read the first byte (MSB)
*(p_value+1)=s_read_byte(ACK); //read the second byte (LSB)
*p_checksum =s_read_byte(noACK); //read checksum
return error;
}
//
//***********************************************************************
// void init_uart()
//***********************************************************************
// Initializes the UART so the final data can be sent away, e.g. to a PC
//9600 bps @ 11.059 MHz
void init_uart()
{
SCON = 0x52;
TMOD = 0x20;
TCON = 0x69;
TH1 = 0xfd;
}
//
//***********************************************************************
// void calc_sth11(float *p_humidity ,float *p_temperature)
//***********************************************************************
// calculates temperature [C] and humidity [%RH]
// input : humi [Ticks] (12 bit)
// temp [Ticks] (14 bit)
// output: humi [%RH]
// temp [C]
void calc_sth11(float *p_humidity ,float *p_temperature)
{
const float C1=-4.0; // for 12 Bit
const float C2= 0.0405; // for 12 Bit
const float C3=-0.0000028; // for 12 Bit
const float T1=0.01; // for 14 Bit @ 5V
const float T2=0.00008; // for 14 Bit @ 5V
float rh=*p_humidity; // rh: Humidity [Ticks] 12 Bit
float t=*p_temperature; // t: Temperature [Ticks] 14 Bit
float rh_lin; // rh_lin: Humidity linear
float rh_true; // rh_true: Temperature compensated humidity
float t_C; // t_C : Temperature [C]
t_C=t*0.01 ? 40; //calc. Temperature from ticks to [C]
rh_lin=C3*rh*rh + C2*rh + C1; //calc. Humidity from ticks to [%RH]
rh_true=(t_C-25)*(T1+T2*rh)+rh_lin; //calc. Temperature compensated humidity [%RH]
if(rh_true>100)rh_true=100; //cut if the value is outside of
if(rh_true<0.1)rh_true=0.1; //the physical possible range
*p_temperature=t_C; //return temperature [C]
*p_humidity=rh_true; //return humidity[%RH]
}
//
//***********************************************************************
// float calc_dewpoint(float h,float t)
//***********************************************************************
// calculates dew point
// input: humidity [%RH], temperature [C]
// output: dew point [C]
float calc_dewpoint(float h,float t)
{
float k,dew_point ;
k = (log10(h)-2)/0.4343 + (17.62*t)/(243.12+t);
dew_point = 243.12*k/(17.62-k);
return dew_point;
}
//***********************************************************************
// void main()
//***********************************************************************
// sample program that shows how to use SHT11 functions
// 1. connection reset
// 2. measure humidity [ticks](12 bit) and temperature [ticks](14 bit)
// 3. calculate humidity [%RH] and temperature [C]
// 4. calculate dew point [C]
// 5. print temperature, humidity, dew point
void main()
{
value humi_val,temp_val;
float dew_point;
unsigned char error,checksum;
unsigned int i;
init_uart();
s_connectionreset();
//
while(1)
{
error=0;
error+=s_measure((unsigned char*) &humi_val.i,&checksum,HUMI); //measure humidity
error+=s_measure((unsigned char*) &temp_val.i,&checksum,TEMP); //measure temperature
if(error!=0) s_connectionreset(); //in case of an error: connection reset
else
{
humi_val.f=(float)humi_val.i; //converts integer to float
temp_val.f=(float)temp_val.i; //converts integer to float
calc_sth11(&humi_val.f,&temp_val.f); //calculate humidity, temperature
dew_point=calc_dewpoint(humi_val.f,temp_val.f); //calculate dew point
//send final data to serial interface (UART)
printf(“temp:%5.1fC humi:%5.1f%% dew point:%5.1fC
”,temp_val.f,humi_val.f,dew_point);
}
//-----------wait approx. 0.8s to avoid heating up SHTxx---------------
for (i=0;i<40000;i++); //(be sure that the compiler doesn’t eliminate this line!)
}
}

AVRTOOLS™

   
윗글 ENC28J60 Ethernet to SPI Header Board
아래글 SHT11 습도센서 SX18 인터페이스
    N         제목    글쓴이 작성일 조회 추천
74 AT89C2051과 EM4095를 사용한 RFID 장치의 제작 leeky 2006/12/31 (일) 1213 0
73 UserPort for Windows 2000 leeky 2007/11/12 (월) 840 0
72 아날로그 PID 제어 회로 leeky 2007/11/12 (월) 1424 0
71 Windows Scope 2K4 leeky 2007/11/12 (월) 972 0
70 12C508 금속검출기 leeky 2006/02/24 (금) 1137 0
69 16C84 LCD표시 L,C 메터 leeky 2006/02/25 (토) 1181 2
68 89C2051 LCD표시 LC메터의 제작 leeky 2006/02/14 (화) 1193 8
67 12C508A 초음파 거리 측정기 avrtools 2006/02/23 (목) 1074 0
66 Caliper to computer (RS-232) interface leeky 2006/02/23 (목) 1106 4
65 가속도센서 ADXL202의 PIC12C508 인터페이스 leeky 2006/02/20 (월) 1066 2
64 16F84 광학식 심박측정기 leeky 2006/02/27 (월) 1144 6
63 12C508 전자 나침판 leeky 2006/02/27 (월) 741 0
62 ENC28J60 Ethernet to SPI Header Board leeky 2007/03/26 (월) 1009 0
61 SHT11 습도센서 8051 인터페이스 leeky 2006/02/14 (화) 1061 0
60 SHT11 습도센서 SX18 인터페이스 leeky 2006/03/16 (목) 704 2
59 SRF04 초음파 거리센서의 제작 leeky 2006/02/25 (토) 717 0
58 Ambient Light Sensors TSL2550 avrtools 2006/04/06 (목) 518 0
57 PIC16F877A BioSense Physiologic Sensing leeky 2006/04/06 (목) 631 0
56 Electrocardiogram (ECG) Front End leeky 2006/04/06 (목) 702 0
55 Biometric Interface Board leeky 2006/04/06 (목) 820 0
54 MAX2242 802.11b 블루투스 RF증폭기 leeky 2006/04/06 (목) 516 0
53 AX.25 9600BPS 무선모뎀 L2PCX leeky 2006/04/06 (목) 406 0
52 TCS230 색상검출 평가키트 leeky 2006/04/06 (목) 1688 0
51 100V10A 50W 전자부하 leeky 2006/04/06 (목) 600 0
50 FLAME SENSOR UVTRON R2868 leeky 2006/04/06 (목) 586 0
49 Compact Optical Image Scanner leeky 2006/04/06 (목) 525 0
48 지자기 방위계 모듈 CMPS03 leeky 2006/04/06 (목) 675 0
47 0~1.5KV 정전기 측정센서 PKE05A1 leeky 2006/04/06 (목) 364 0
46 Rain Sensor 인터페이스 회로 leeky 2006/04/06 (목) 592 0
45 초음파 감지 센서 leeky 2006/04/06 (목) 597 0
44 HUMIDITY SENSOR HS-1100 leeky 2006/04/06 (목) 463 0
43 Relative Humidity Sensor KSH01, KSH-02 leeky 2006/04/06 (목) 353 0
42 Digital Radar Speedometer leeky 2006/04/06 (목) 522 0
41 Touch Sensitive Switch leeky 2006/04/06 (목) 566 0
40 Economy radar detector leeky 2006/04/06 (목) 400 0
39 Twin Loop metal detector leeky 2006/04/06 (목) 532 0
38 Proximity Detector CS209A/D leeky 2006/04/06 (목) 521 0
37 Lego Sound Sensor leeky 2006/04/06 (목) 471 0
36 12C508 IR Proximity Detector leeky 2006/04/06 (목) 681 0
35 Sharp IR Sensor Hack leeky 2006/04/06 (목) 658 0
34 TIL300 PRECISION LINEAR OPTOCOUPLER leeky 2006/04/06 (목) 414 0
33 Analog Opto Isolator leeky 2006/04/06 (목) 459 0
32 Rich Caudle's capaciflector leeky 2006/04/06 (목) 301 0
31 Geiger Tube leeky 2006/04/06 (목) 410 0
30 Lynxmotion Infrared Proximity Detector leeky 2006/04/06 (목) 388 0
29 Low Power LED Flasher leeky 2006/04/06 (목) 466 0
28 백색 LED BLU 구동회로 leeky 2006/04/06 (목) 498 0
27 저전압 백색 LED 구동회로 leeky 2006/04/06 (목) 534 0
26 IR LED 송신회로 avrtools 2006/04/06 (목) 529 0
25 LED 총방사 광량의 측정 leeky 2006/04/06 (목) 430 0
24 자외선 측정센서의 교정 leeky 2006/04/06 (목) 382 0
23 UV센서 S9050의 데이터 leeky 2006/04/06 (목) 296 0
22 디지털 자외선 메터 leeky 2006/04/06 (목) 345 0
21 Simple Metal Detector leeky 2006/04/06 (목) 538 0
20 DS1820 온도센서 읽기 leeky 2006/04/04 (화) 597 0
19 RC5 적외선 리모콘의 신호처리 leeky 2006/02/17 (금) 687 0
18 NEC 적외선 리모콘의 전송규격 leeky 2006/02/17 (금) 590 0
17 MBI-6001 TRANSLESS LED DRIVER leeky 2006/02/14 (화) 413 0
16 PC로 제어하는 AD9850 DDS 신호발생기 leeky 2006/02/14 (화) 457 0
15 2400 Mhz test oscillator leeky 2006/02/14 (화) 479 0
14 DC BRUSHLESS FANS leeky 2006/02/14 (화) 565 0
13 RF mW Meter for SHF (2300MHz) leeky 2006/02/14 (화) 394 0
12 FET로 만드는 400W SSR leeky 2006/02/14 (화) 628 0
11 Scope2k4 소프트웨어 및 하드웨어 회로 leeky 2006/02/14 (화) 746 0
10 LTC1298를 사용한 PC 병렬포트용 ADC leeky 2006/02/14 (화) 414 0
9 0~14V 가변정전압, 0~2A 가변정전류 전원 avrtools 2006/02/14 (화) 540 0
8 ATV 1240-1300MHz 튜너용 PLL leeky 2006/02/14 (화) 293 0
7 1 Transistor FM Microphone leeky 2006/02/14 (화) 349 0
6 Helical Antenna Design Software leeky 2006/02/13 (월) 451 0
5 IRF510을 사용한 7MHz 출력10W 증폭기, PLL leeky 2006/02/13 (월) 516 0
4 MC34063A 설계용 계산기 avrtools 2006/02/13 (월) 487 0
3 RS232 신호 변환회로 leeky 2006/02/13 (월) 636 0
2 Sound card based multimeter Scope leeky 2006/02/13 (월) 770 0
1 2400MHz Helical Antenna Design leeky 2006/02/08 (수) 414 0
1

바구니 : 0
 보관함 : 0
오늘뷰 : 0
HOME   |   회사소개   |   제휴안내   |   회사위치   |   서비스이용 약관   |   개인정보 보호정책   |   사이트맵
17015 경기도 용인시 기흥구 동백중앙로16번길 16-25, 508호. 전화 : 031-282-3310
사업자 등록번호 : 697-47-00075 / 대표 : 이건영 / 업태 : 제조업 / 종목 : LED조명, LED전원, 제어장치.
개인정보 관리책임자 : 홈페이지 관리자 . Copyright ⓒ2016 아크레즈 (ACLEDS INC.)
HOME TOP PREVNEXT 0 0 0