Please help with code for DS18B20


Closed Thread
Results 1 to 40 of 110

Hybrid View

  1. #1
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default

    Hope I am not boring with this subject !
    1. I replace one sensor and now both temperatures are similar.
    2.I write the code for dual thermometer and thermostat ; works verry good !
    If somebody have idea to improve this code, please post here !
    I wish you all the best !
    Attached Files Attached Files

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default

    Hi, Fratello

    What about a nice Bargraph to show what's going on ... ???

    like this one :

    Code:
    '*****************************************************************************
    '*****************************************************************************
    '                              AFFICHAGE
    '*****************************************************************************
    '*****************************************************************************
    
    'Motifs CGRAM
    
          LCDOUT  $FE,$40,$00,$00,$00,$00,$00,$04,$04,$04  ' Cust Char $0 'Small bar
          LCDOUT  $FE,$48,$00,$00,$00,$04,$04,$04,$04,$04  ' Cust Char $1 'Mid bar
          LCDOUT  $FE,$50,$04,$04,$04,$04,$04,$04,$04,$04  ' Cust Char $2 'Big bar 
          LCDOUT  $FE,$58,$04,$04,$0E,$0E,$0E,$1F,$1B,$11  ' Cust Char $3 'Arrow
          LCDOUT  $FE,$60,$11,$1B,$1F,$0E,$0E,$0E,$04,$04  ' Cust Char $4 'Inv Arrow     
          LCDOUT  $FE,$68,$04,$04,$0E,$1F,$1F,$0E,$04,$04  ' Cust Char $5 'Diamond
    
    '*****************************************************************************
    Aff:'Affichage temp
    '*****************************************************************************
    
    'préparation chiffre : sign = 1 = valeur négative
    
    Decal	= ( TempC // 5 ) << 1 
    
    IF NOT sign THEN
    
    	Loscale = ( TempC /5 ) * 5 
    	Hiscale = (( TempC /5 ) + 1) * 5
    	
    	IF Float > 25 AND Float <= 75 then Decal = Decal + 1
    	IF Float > 75 Then Decal = Decal + 2
    	
    ELSE
    
    	Loscale = (( TempC /5 + 1 ) * 5) * -1  
    	Hiscale = ((TempC /5) * 5 )* -1 
    	Decal = 10 - Decal
    	
    	IF Float > 25 AND Float <= 75 then Decal = Decal - 1
    	IF Float > 75 Then Decal = Decal - 2
    	
    		TempC = TempC * -1
    		
    ENDIF
    
    
    'Impression valeurs 1ère ligne
    
    IF Sign THEN
    
      LCDOUT	$FE, $80 ,SDEC2 Loscale,178,Unit," "
      IF TempC = 0 THEN LCDOUT "-" 
      LCDOUT SDEC TempC,".",dec2 Float
      IF ABS TempC < 10 then LCDOUT " "
      LCDOUT $FE,$80 + 11,SDEC2 Hiscale,178,Unit
      
    ELSE
      
      LCDOUT	$FE, $81 ,SDEC2 Loscale,178,Unit," ",SDEC TempC,".",dec2 Float
      IF TempC < 10 then LCDOUT " "
      LCDOUT $FE,$80 + 12,SDEC2 Hiscale,178,Unit 
      
    ENDIF 
      
      
    'Impression échelle 2ème ligne
    
     LCDOUT	$FE,$C0,$01,$00,$02,$00,$01,$00,$01,$00,$01,$00,$01,$00,$02,$00,$01,$00
      
    'Impression index
    
     IF Tempeff < ( Setpoint - 5 ) THEN
     
    	LCDOUT	$FE, $C2 + Decal,$03				'Index Chauffage
    	
     ELSE
     
     	IF Tempeff > ( Setpoint + 5 ) THEN
     	
    		LCDOUT	$FE, $C2 + Decal,$04				' Index Refroidissement
    	
    	ELSE
    	
    		LCDOUT	$FE, $C2 + Decal,$05				' Index Zone neutre
    		
    	ENDIF
    	
    ENDIF
    Better shown on attachment
    Attached Files Attached Files
    Last edited by Acetronics2; - 13th January 2009 at 12:38.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default

    Thanks for reply !
    Sorry, but my LCD is 2 x 16 ; at first line I display "In" and at second "Out" values of temperatures. Otherwise, nice code are You writing .

  4. #4
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default

    New problem :
    -the thermometer PIC 12F675 + DS18B20 + Nokia LCD = 24.5 'C
    -the thermometer LM 35DZ + Fluke 830DM = 24.5 'C
    -the thermometer PIC 16F628A + DS18B20 = 25.5 ' C !!!!!!!!!!!

    I try to write in PIC the same code of themperature conversion like Mr.Novakovic Ivica.
    Check for similarity !!!! Why this diference ? I thing I go crazy, soon ....
    Attached Files Attached Files

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink

    Hi,

    Code:
    count_remain, count_per_c
    DO NOT use that with DS 18B20 ....

    That's a first step.

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  6. #6
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default

    Anything code I write in thermo that I made, the temperatures are NOT similar with those measured with other devices (mentioned). I try to change the sensor (I use three !) but nothing change. I don't know what to believe : which of temperature is - more- accurate ?

  7. #7
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default

    I found this on forum :
    "OSCCON = %01100000 'Internal clock set to 4-MHz (MUST DO THIS!!!)"
    I added in my code, but PBP say "Error : Undefined Symbol 'OSCCON'.
    Maybe this is the error that shows different temperatures ?

Similar Threads

  1. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 21:55
  2. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 21:31
  3. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  4. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  5. Re-Writing IF-THEN-AND-ENDIF code?
    By jessey in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 18th August 2006, 17:23

Members who have read this thread : 3

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts