You are on page 1of 22

Contents

1. Overview of OWP
y OWP : copyright by MAXIM y Features: y Bi-directional y Serial signal, half-duplex y Power auto charge(by the internal capacitor in slaves) y One Master controls many slaves (different IDs) in single line

1. Overview of OWP

1. Overview of OWP

2.Working
y Communication with time slots y Slave self-clocked from master edge (high to low pulse) y Time slot: +bit 1: pull bus low in short Tx > 1-2us

+bit 0: pull bus low in long Tx=60-120us y Slaves sample in 15-60us y Master sample at 15us

2.Working

ex: The transaction sequence for accessing the DS18B20 is as follows: Step 1.Reset bus Step 2. ROM Command Step 3. Function Command

3.TEMPERATURE SENSORS DS18B20 vs. LM35

3.1 DS18B20 -DIGITAL SIGNAL


Unique 1-Wire Interface Requires Only One Multi-drop Capability Simplifies Distributed Temperature-Sensing Applications Requires No External Components Can Be Powered from Data Line; Power Supply Range is 3.0V to 5.5V Measures Temperatures from -55C to +125C (-67F to +257F) 0.5C Accuracy from -10C to +85C y Thermometer Resolution is User Selectable from 9 to 12 Bits y Converts Temperature to 12-Bit Digital Word in 750ms (Max) (Reference :DS18B20 datasheet)
y y y y y y y

3.1 DS18B20:RESET

//************************************************************* //ham onewire_reset() reset va xac nhan co ngoai vi tren mach //tra ve bit presence_pulse :0->co device ket noi va nguoc lai //------------------------------------------------------------void onewire_reset() { onewire_pin_tris=0; //set_output_pin onewire_pin=0; __delay_us(250); __delay_us(230); onewire_pin_tris=1; //set_input_pin realease bus __delay_us(70); //sample presence pulse presence_pulse=onewire_pin; //return 1:no device;0:device(s) __delay_us(410); }

3.1 DS18B20:READ BIT

//master keo xuong low bus >1us roi realease bus lay mau trong khoang 15us //delay them khoang 60us la lay mau xong 1 bit onewire_read_bit() { onewire_pin_tris=0; onewire_pin=0; __delay_us(6); onewire_pin_tris=1; //realease bus __delay_us(8); DQ=onewire_pin; //sample in less than 15us after pull low the line //return value to bit DQ }

3.1 DS18B20:WRITE BIT

//ghi bit 1: ghi 0 trong >1us(chon 6us) sau do release bus trong >60us //ghi bit 0: ghi 0 trong 60-120us( chon 65us) sau do realese bus >1us(chon 5us ) void onewire_write_bit1() { //pull low the line onewire_pin_tris=0; onewire_pin=0; __delay_us(6); onewire_pin_tris=1; //realease bus __delay_us(64); } void onewire_write_bit0() { onewire_pin_tris=0; onewire_pin=0; //at least 60us __delay_us(65); onewire_pin_tris=1; //realease bus;recovery time __delay_us(5); //recovery time }

DS18B20 Memory Map

3.1 DS18B20: LCD DISPLAY TEMP


Step1
Initialization MCU , LCD Reset and detect any 1-wire device connected on the bus If (no device) reset again

Step2

Write Rom command :Skip Rom (only one slave on the bus) Write Function Command: Convert T Wait for 750ms Write Function Command: Read Scratchpad

Step3

Convert 2 first data bytes in Scratchpad to ASCII Display temperature on LCD Return step1

3.2 LM35-ANALOG SIGNAL


y Calibrated directly in Celsius (Centigrade) y Linear + 10.0 mV/ C scale factor y 0.5 C accuracy guarantee able (at +25 C) y Low cost due to wafer-level trimming y Vs from 4 to 30 volts y Low self-heating, 0.08 C in still air y Nonlinearity only 1 4 C typical y Low impedance output, 0.1

for 1 mA load (Reference :DS18B20 datasheet)

3.2 LM35: LCD DISPLAY TEMP


Step1
Initialization MCU , LCD Adc_init();

Step2

Read_adc();

Step3

Convert adc to temperature(Vadc=t(C )* 10(mvolt)) Display temperature on LCD Return step1

Simulation Result:

Temperature Sensors Signal transmit Data Process

DS18B20 -digital signal -1-wire protocol (1 master + many slaves) -0.0625 C

LM35 -analog signal -analog digital conversion

Resolution

-10mv/C + ADC 10bit 0.5C

Price(Tme_30/5/2011)

-27000VND

-22000VND

Source code: (tested on board)


y Onewire.c ; onewire.h y MPLAB project:PIC_DS18B20 ;PIC_temp_sensor y Proteus file

References:
-All about OWP -1-Wire Overview -DS18B20 datasheet -LM35 datasheet -PIC16F887 datasheet