Dallas 18B20 example

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Mast
Posts: 65
Joined: Wed Aug 29, 2007 6:24 am
Location: France

Post by Mast » Wed Dec 14, 2011 7:05 am

Jason wrote:Hey Mast,
Where did you get that GLCD_192x94.bas file from?

and what glcd screen are you using with this code?

Thanks in advance

Jason
http://www.sfcompiler.co.uk/wiki/pmwiki ... er.Modules

User avatar
Jason
Posts: 50
Joined: Mon Mar 10, 2008 1:10 pm
Location: Australia

Post by Jason » Wed Dec 14, 2011 7:46 am

I'll dig up the code I used in my 18B20 project when I get home and post it here for you Mast.

User avatar
Jason
Posts: 50
Joined: Mon Mar 10, 2008 1:10 pm
Location: Australia

Post by Jason » Wed Feb 08, 2012 3:16 am

Hi, Sorry about the delay, but here is the code I used and it worked great.
If you had 5, 10 or 20 sensors connected to the bus, they would display each sensors temp on screen along with its hex address in 1 second rolling screen updates.

The resolution was to 3 decimal places I think, or 4 maybe. I haven't used it for a while. The company I work for had a contract to check a heap of incubators, but after about a year, the contract was tendered out to another company who must have undercut our price. Otherwise the thing worked perfect.

Hope it helps you in your project

Code: Select all

Device = 18F252
Clock = 20
#option LCD_DATA = PORTC.4
#option LCD_RS = PORTC.3
#option LCD_EN = PORTC.2
// import modules...
Include "DS18B20.bas"
Include "convert.bas"
Include "lcd.bas"

// on display temperature event...
Event OnDisplayTemp()
   Dim TempA As ShortInt
   Dim TempB As Word
   Dim Index As Byte
   Dim index2 As Byte
   
   RomID = SearchRomID
   GetTemp(TempA, TempB)
   LCD.WriteAt(1,1,DecToStr(TempA),".",DecToStr(TempB,4),"C")
   
   // display ROM ID...
   LCD.WriteAt(2,1,"($")
   Index = 6
   index2 = 3
   Repeat
      LCD.WriteAt(2,index2,HexToStr(SearchRomID(Index),2))
      Dec(Index)
      index2 = (index2)+2
      DelayMS(100)
   Until Index = 0
   LCD.WriteAt(2,16,")")
   DelayMS(500)
End Event
DelayMS(150) 
LCD.Cls  
// program start...

SetPin(PORTC.0)
// if we have some DS1820 devices connected to the bus,
// then display temperature for each one...
If Count > 0 Then
   While true
      ConvertAll               
      FindAll(OnDisplayTemp)
      DelayMS(1000)
   Wend
EndIf

Post Reply