This code display the DS18B20 unique rom code on the LCD and also the current temperature.

Enjoy

Code:

' FILE: PIC_GCB_16F877A_READ_ROM_DS18B20_and_Temp_with_LCD_Example.gcb' DATE: 26/09/14' VERSION: 0.1a' AUTHOR: Anobium''This program was written using the Great Cow Basic IDE for use with the PIC'16F8777A development board (HCDVBD0003) and a 1602 parallel LCD module'(HCMODU0013 or HCMODU0038) to display the unique 64-BIT LASERED ROM CODE of a DS18B20 sensor.

'Chip Settings. Assumes the development board with with a 16F877A#chip 16F877A,20#include <DS18B20.h>

' READ ROM [33h] ' This command can only be used when there is one slave on the bus. ' It allows the bus master to read the slave’s 64-bit ROM code without using the Search ROM procedure. ' If this command is used when there is more than one slave present on the bus, a data collision will occur when all the slaves attempt to respond at the same time.

Sub OWinRom xpos = 14 ' XPos on the LCD For EightBytes = 1 to 8 For Clocks = 1 to 8 Rotate RxData Right 'The DS18s20 wants data LSB first Dir DQ Out Set DQ Off 'Read time slot wait 4 us Dir DQ In 'Release bus for one wire transmission wait 7 us If DQ On Then Set RxData.7 1 If DQ Off Then Set RxData.7 0 wait 50 us Next locate ypos , xpos Print hex(RxData) xpos = xpos - 2

Next end sub

Fri Sep 26, 2014 5:11 pm

barewires

Joined: Wed Aug 21, 2013 7:38 amPosts: 34

Re: Display the DS18B20 unique rom ID on a LCD & the tempera

Hi, I changed the clock to the actual 4Mhz from 20, the temperature displayed is 60 to 100 deg to high.Could I ask for a text copy of a working <DS18B20.h> being posted?Many thanks,barewires

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum