Professional Documents
Culture Documents
DS18B20
DS18B20
Lu :
Config
: cu hnh.
1. Tng quan
DS18B20 l IC cm bin nhit , ch bao gm 3 chn, ng gi
dng TO-92 3 chn nh gn.
chuyn i khng qu 200 ms, trong thi gian ang chuyn i nu thc
hin lnh c th cc gi tr c ra u bng 0.
- READ POWER SUPPLY (B4h)
Mt lnh c tip sau lnh ny s cho bit DS1820 ang s dng ch
cp ngun nh th no, gi tr c c bng 0 nu cp ngun bng
chnh ng dn d liu v bng 1 nu cp ngun qua mt ng dn
ring.
b. Cch config phn gii cho ds18b20
d. c nhit
Khi bt u chuyn i nhit th chn DQ s c ko xung mc
thp v khi chuyn i xong th mc cao.Nh vy ta s cn c vo
hin tng ny xc nh khi no chuyn i xong nhit . Lu
lun phi dng mt in tr tm 4.7k tr ln vo chn DQ treo ln
ngun nh s mc.
Di y l mt v d mu o nhit bng ds18b20 hin th LCD cc
bn tham kho s hiu r hn v s dng cm bin ny nh th no.
ng thi tham kho thm datasheet ca ds18b20.
Hm c nhit :
M:
float ds18b20_read() {
int8 busy=0, temp1, temp2;
signed int16 temp3;
float result;
onewire_reset();
onewire_write(0xCC);
//Skip ROM, address all devices
onewire_write(0x44);
//Start temperature conversion
while(busy == 0)
//Wait while busy (bus is low)
busy = onewire_read();
onewire_reset();
onewire_write(0xCC);
//Skip ROM, address all devices
onewire_write(0xBE);
//Read scratchpad
temp1 = onewire_read();
temp2 = onewire_read();
temp3 = make16(temp2, temp1);
result = (float) temp3 / 16.0;
delay_ms(200); //
return(result);
}
Kt qu:
Hin th LCD