Trouble with LCD 2x8 and sequential display of values


Closed Thread
Results 1 to 31 of 31

Hybrid View

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

    Default Trouble with LCD 2x8 and sequential display of values

    Hello !
    I try to build one volt/termometer with 16F684 and 2x8 characters display. I wrote the code, all works ...fine, the "IN" temperature is shown for 8 seconds, the "OUT" temperature for next 8 seconds, and so on, and so on (the voltage is on second line permanent)....
    BUT : sometimes, the value of temperature "jump" to "0.0 'C", especially when the temperature decreases ?! I really don't understand why . I made many changes in "pause", in "Define LCD_COMMANDUS 2000" and "Define LCD_DATAUS 50" , I added/removed " WaitLoop1: While not DQ1 : Wend" , but without results...
    Any clue ? Thanks in advance !
    This is "the big part" of my code :
    Code:
    Main :
    Gosub Get_Vbatt                           ' make a new measure
                TmpW = Vbatt * Vfs                    ' AD * 20480
              TmpW = Div32 1024                     '(AD * 20480) / 1024       
    Gosub char_batt 
            LcdOut $FE, $c0, symb ," ", dec TmpW dig 4,dec TmpW dig 3,",",dec TmpW dig 2, " V" 
    
    Gosub StartTimer
    While seconds =< 8
    Part1:
        ' Start temp.conv.Sensor1
         OWOut DQ1, 1, [$CC, $44] 
         OWOut DQ1, 1, [$CC, $BE]
           OWIn  DQ1, 2, [temperature1.byte0, temperature1.byte1]  
        
            If Temperature1.15 then       
                  Temperature1= ~Temperature1 +1
                  Twist1 = 1
            Endif
     
        Dummy1 = 625 * Temperature1
        TempC1 = DIV32 10 
        TempC1 = (Temperature1 & $7FF) >> 4
        Float1 = ((Temperature1.Lowbyte & $0F ) * 25 )>>2
        Temperature1 = TempC1*100 + Float1
    
            If Twist1 then
                    V1= 10000 - Temperature1                 
                  Twist1 = 0
             else
                  V1= 10000 + Temperature1
            EndIf
    
            If V1 >= 10000 then                           
                  Temperature1=V1-10000                   
             else                                   
                  Temperature1=10000-V1                    
            EndIf
    
        GoSub SelectSign
               If (temperature1/100) =>10 then
                    LcdOut $FE, $80, "I:", Sign1, DEC (Temperature1 / 100), ".", DEC Temperature1 dig 1, 0
                else
                    LcdOut $FE, $80, "I:", Sign1, $14, DEC (Temperature1 / 100), ".", DEC Temperature1 dig 1, 0
                Endif
          Pause 500
    Wend
    '===================================================================================================================
    While seconds >= 9 and seconds =< 17 
    Part2 :    
          ' Start temp.conv.Sensor1
         OWOut DQ2, 1, [$CC, $44] 
         OWOut DQ2, 1, [$CC, $BE]
          OWIn  DQ2, 2, [temperature2.byte0, temperature2.byte1]  
    
            If Temperature2.15 then       
              Temperature2= ~Temperature2 +1
              Twist2 = 1
            Endif
     
        Dummy2 = 625 * Temperature2
        TempC2 = DIV32 10 
        TempC2 = (Temperature2 & $7FF) >> 4
        Float2 = ((Temperature2.Lowbyte & $0F ) * 25 )>>2
        Temperature2 = TempC2*100 + Float2
    
            If Twist2 then
                  V2= 10000 - Temperature2               
                  Twist2 = 0
             else
                  V2= 10000 + Temperature2
            EndIf
    
            If V2 >= 10000 then                           
                  Temperature2=V2-10000                   
             else                                   
                  Temperature2=10000-V2                   
            EndIf
    
        GoSub SelectSign
                If (temperature2/100) =>10 then
                    LcdOut $FE, $80, "O:", Sign2, DEC (Temperature2 / 100), ".", DEC Temperature2 dig 1, 0
                else
                    LcdOut $FE, $80, "O:", Sign2, $14, DEC (Temperature2 / 100), ".", DEC Temperature2 dig 1, 0
                Endif
          Pause 500
    Wend
    Gosub ResetTime
    Goto Main
    I have in code "include elapsed.bas" of course...The internal osc is set to 4 MHz.

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


    Did you find this post helpful? Yes | No

    Default Re: Trouble with LCD 2x8 and sequential display of values

    Even in Proteus I see this trouble, if "Out" temperature decreases verry fast ...
    (Just remove final extension of files)
    Attached Files Attached Files

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


    Did you find this post helpful? Yes | No

    Default Re: Trouble with LCD 2x8 and sequential display of values

    ...or another way to display sequential values of temperature(s), while - on second line- display the voltage ?!
    Have someone another ideea ? Thanks !

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: Trouble with LCD 2x8 and sequential display of values

    Quote Originally Posted by fratello View Post
    ... BUT : sometimes, the value of temperature "jump" to "0.0 'C", ...
    I have in code "include elapsed.bas" ...
    1-Wire and interrupts don't get along very well together.
    1-Wire has some pretty strict timing requirements, and interrupts like to mess that up.

    You can get good readings, but you have to plan on bad data occasionally.
    Which means verifying the CRC, and checking for all 0's in the packet. The CRC will pass (incorrectly) with all 0's
    You can use the CRC routines from Tom Estes ... http://www.picbasic.co.uk/forum/showthread.php?t=1672
    If the CRC fails, just go back and read the temperature again, no need to do another conversion.

    That of course means you need to read the sensor as a Packet, instead of individual variables.

    You also need to wait for the conversion to complete, either by PAUSE'ING the required amount of time, or polling the busy bit.
    Currently, you are not waiting at all after a conversion command.
    DT

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


    Did you find this post helpful? Yes | No

    Default Re: Trouble with LCD 2x8 and sequential display of values

    Thank You for support !
    ...it's another way to do this ?
    I don't think I have enough space for adding something like CRC routines in my code (using 16F684)...

  6. #6
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default Re: Trouble with LCD 2x8 and sequential display of values

    How about just throw away values that are outside of expected ranges? Like take a running average, and if the temp is way off, disregard it. That way, it can still be 0 deg C, but only if its close to the average temp.
    http://www.scalerobotics.com

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


    Did you find this post helpful? Yes | No

    Default Re: Trouble with LCD 2x8 and sequential display of values

    Thank you all for support !
    Since the "timming" it's not so important , I made this change :
    Code:
        ' Start temp.conv.Sensor1      
    OWOut DQ1, 1, [$CC, $44]       
    OWOut DQ1, 1, [$CC, $BE]      
    OWIn  DQ1, 2, [temperature1.byte0, temperature1.byte1]        
    Pause 800 ; because DS18B20 need 750 ms for conversion         
    If Temperature1.15 then                      
    Temperature1= ~Temperature1 +1               
    Twist1 = 1         
    Endif
    ...
    ...and the display works fine now...despite the decrease of speed in display the changes of temperatures.

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


    Did you find this post helpful? Yes | No

    Default Re: Trouble with LCD 2x8 and sequential display of values

    I rushed... still have, from time to time, "0.0 'c" on display, ONLY for sensor on DQ2 (out sensor) .... ....

  9. #9
    Join Date
    Aug 2008
    Location
    Portugal
    Posts
    240


    Did you find this post helpful? Yes | No

    Default Re: Trouble with LCD 2x8 and sequential display of values

    Quote Originally Posted by fratello View Post
    I rushed... still have, from time to time, "0.0 'c" on display, ONLY for sensor on DQ2 (out sensor) .... ....
    Why not you poll the busy bit, instead of the Pause 800 statment?

    I don't know your application, but you can also disable interrupts before the 1-wire stuff, and then enable them again.
    Thanks and Regards;
    Gadelhas

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


    Did you find this post helpful? Yes | No

    Default Re: Trouble with LCD 2x8 and sequential display of values

    Quote Originally Posted by gadelhas View Post
    I don't know your application, but you can also disable interrupts before the 1-wire stuff, and then enable them again.
    Thanks for help ! How can I make this ? The most part of code it's in post #1...

Members who have read this thread : 1

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