Trouble with LCD 2x8 and sequential display of values


Closed Thread
Results 1 to 31 of 31

Hybrid View

  1. #1
    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

  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

    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...

  3. #3
    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
    Thanks for help ! How can I make this ? The most part of code it's in post #1...
    Can you put the code of your interrupts stuff, because i don't see it in the code of the post #1
    Thanks and Regards;
    Gadelhas

  4. #4
    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 use just :
    "Include "Elapsed.bas"" ; for counting seconds
    without other interrupts...

  5. #5
    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 use just :
    "Include "Elapsed.bas"" ; for counting seconds
    without other interrupts...
    I believe that Elapsed.bas uses Timer 1, maybe Darrel can correct me, if so, do this

    Code:
    @ INT_DISABLE   TMR1_INT
    
     '1 wire stuff
    
    @ INT_ENABLE   TMR1_INT
    Probabily the acurracy of the elapsed.bas would be affected.
    Thanks and Regards;
    Gadelhas

  6. #6
    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 think I made some mistakes ... ...
    Attached Images Attached Images  

  7. #7
    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

    Can you attache the files? ( your code and elapsed.bas)
    Thanks and Regards;
    Gadelhas

  8. #8
    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

    fratello,

    Try this hex file.
    It uses elapsed.bas, adds CRC checking and error correction, while only using 1375 WORDs.
    Yours was 1871 WORDs, so it also saves ~500 WORDs (~1/4 of total memory.)

    It should run on your .dsn, but the voltage will be off because I changed the circuit a little.



    I didn't have your code, so the battery icon is different.
    Attached Files Attached Files
    DT

  9. #9
    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 so much ! I will try soon Your hardware ... I must (re) build the PCB.
    In Proteus I have some messages ... It's something wrong ?
    ...and the temperature on display don't follow the variation of sensor(s)-the new temperature is on display NEXT time when the temperature is show !
    Attached Images Attached Images  
    Last edited by fratello; - 23rd February 2012 at 06:34.

  10. #10
    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

    Oh, OK.
    I din't see that your's kept up with changes during each period.
    I will fix that.

    I wasn't seeing the ADC clock error, but I'll take a look.
    DT

  11. #11
    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 again for helping me !
    The code for batterie is this :
    Code:
    LCDOUT  254,64,4,10,4,0,0,0,0,0          ' Cust Char #0  ; http://www.darreltaylor.com/files/CustChar.htm
    LCDOUT  254,72,10,31,17,17,17,17,31,0    ' Cust Char #1  
    LCDOUT  254,80,10,31,17,17,17,31,31,0    ' Cust Char #2  
    LCDOUT  254,88,10,31,17,17,31,31,31,0    ' Cust Char #3  
    LCDOUT  254,96,10,31,17,31,31,31,31,0    ' Cust Char #4  
    LCDOUT  254,104,10,31,31,31,31,31,31,0   ' Cust Char #5
    LCDOUT  254,112,15,3,5,9,16,16,16,0      ' Cust Char #6  
    LCDOUT  254,120,1,1,1,18,20,24,30,0      ' Cust Char #7
    ...post #16.

  12. #12
    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

    Sorry, sometimes I get carried away ...

    Code:
    '***************************************************************************
    '*  Name    : DT18x20_Fratello.pbp
    '*  Author  : Darrel Taylor
    '*  Date    : 2/19/2012
    '*  Version : 1.1 (2/24/2012)
    '*  Target  : 16F684 @ 4 mhz
    '***************************************************************************
    
    DEFINE  OSC 4
    CLEAR
    ;----[Main Options]---------------------------------------------------------
    TimeToShow CON 5                ; Seconds to show each temperature
    
    ;----[Battery Options]------------------------------------------------------
    Res1   CON 20000                ; Top Resistor of Voltage Divider
    Res2   CON 10000                ; Bottom Resistor of Divider
    VDD    CON 50                   ; VDD voltage
    MaxBat CON 140   ; 14.0V        ; Batt indicator Max
    MinBat CON 98    ;  9.8V        ; Batt indicator Min
    
    ;----[DS1820 Options]----Value----Default-----------------------------------
    DEFINE  DS1820_DECIMALS    1    ; 1
    DEFINE  DS18B20_ONLY       YES  ; NO
    DEFINE  DS1820_VERIFYCRC   YES  ; NO
    DEFINE  DS1820_USETIMEOUT  NO   ; YES
    MaxRetries  CON 4
    INCLUDE "DT18x20.pbp"           ; Include DT18x20 module
    ; --- To get the include file, Register at http://darreltaylor.com/whatsup/
    
    Inside   VAR PORTC.5            ; Pin assigned to Inside Sensor
    Outside  VAR PORTC.4            ; Pin assigned to Outside Sensor
    
    ;----[Elapsed Timer]--------------------------------------------------------
    INCLUDE "Elapsed.bas"
    ; --- To get the include file ... Go to ...
    ; --- http://www.pbpgroup.com/modules/wfsection/article.php?article
    GOSUB ResetTime
    
    ;----[LCD definitions]------------------------------------------------------
    DEFINE LCD_DREG  PORTC          ; LCD Data port
    DEFINE LCD_DBIT  0              ; starting Data bit (0 or 4)
    DEFINE LCD_EREG  PORTA          ; LCD Enable port
    DEFINE LCD_EBIT  2              ;     Enable bit
    DEFINE LCD_RSREG PORTA          ; LCD Register Select port
    DEFINE LCD_RSBIT 1              ;     Register Select bit
    DEFINE LCD_BITS  4              ; LCD bus size (4 or 8 bits)
    DEFINE LCD_LINES 2              ; number of lines on LCD
    DEFINE LCD_COMMANDUS 2000       ; Command delay time in us 
    DEFINE LCD_DATAUS 50            ; Data delay time in us 
    
    ;----[Analog options]-------------------------------------------------------
    DEFINE ADC_BITS  10
    DEFINE ADC_CLOCK  3
    ADCON0.7=1                    ; Right Justify A/D results
    
    ;----[Program Variables]----------------------------------------------------
    BattLevel  VAR BYTE             ; 0 - 10, 0=Empty  10=Full
    RawBattery VAR WORD
    Volts      VAR WORD
    LastVolts  VAR WORD : LastVolts=0
    Sensor     VAR BIT  : Sensor=1
    Char       VAR BYTE
    y          VAR BYTE
    Retries    VAR BYTE
    TempW      VAR WORD
    GIE        VAR INTCON.7
    
    ;----[Initialization]-------------------------------------------------------
    CMCON0=7                      ; disable Comparators
    ANSEL=0                       ; All Digital
    ADCON1=$30                    ; ADC_CLOCK is FRC
    LCDOUT $FE,1:PAUSE 250:LCDOUT $FE,1 ' Initialize LCD
    
    LCDOUT " TERMO- ",$FE,$C0,"  VOLT  "
    GOSUB StartConversions          ; get the first reading started
    PAUSE 4000
    
    GOSUB StartTimer                ; Start the Elapsed Timer
    Seconds=TimeToShow            ; Force 1st display on start-up
    SecondsChanged=1
    
    ;----[Main Program Loop]----------------------------------------------------
    Main:
        IF SecondsChanged THEN
            SecondsChanged=0
            IF Seconds !=0 AND Seconds != TimeToShow THEN GOSUB StartConversions
            IF Seconds=TimeToShow THEN      ; on each period
                Seconds=0
                Sensor=!Sensor              ; Toggle sensors
                LCDOUT $FE,$80
                IF Sensor=0 THEN
                    LCDOUT "I:      "         ; Indicate Inside sensor
                ELSE
                    LCDOUT "O:      "         ; Indicate Outside sensor
                ENDIF
            ENDIF
        ENDIF
      ;---------------------------------
        IF Sensor=0 THEN    
            @  DS1820_Select  _Inside         ; Select Inside DS18x20 pin
        ELSE
            @  DS1820_Select  _Outside        ; Select Outside DS18x20 pin
        ENDIF
        DS1820_Flags=0                      ; clear flags before Stat
        GIE=0                               ; disable interrupts
            @ DS1820_Stat                     ;   get sensor status
        GIE=1                               ; enable interrupts
        IF DS1820_Done THEN                   ; if conversion finished
            @ DS1820_Read                     ; try to read the temp
            Retries=0
          RetryRead:
            IF DS1820_Error=0 THEN          ; if there were no errors
                GOSUB TempToLCD               ; display TempC
            ELSE                              ;--- Error reading Sensor --------    
                IF Retries < MaxRetries THEN
                    Retries=Retries + 1
                    @ DS1820_Read             ; try to read it again (no Conv)
                    GOTO RetryRead
                ENDIF
                LCDOUT $FE,$82,"Error "       
            ENDIF
        ENDIF
        GOSUB ReadVoltage
        PAUSE 100  
    GOTO Main                                
    
    ;----[Start conversion on both sensors]-------------------------------------
    StartConversions:
        @  DS1820_Select  _Inside             ; Select Inside DS18x20 pin
        @  DS1820_Convert                     ; start conversion
        @  DS1820_Select  _Outside            ; Select Outside DS18x20 pin
        @  DS1820_Convert                     ; start conversion
    RETURN
    
    ;----[Display TempC on LCD]-------------------------------------------------
    TempToLCD:
        TempW=TempC
        LCDOUT $FE,$82
        IF ABS(TempW)/DS1820_DIG < 10 THEN LCDOUT " "
        IF TempW.15 THEN 
            LCDOUT "-"                        ; if negative, display minus sign
        ELSE
            LCDOUT "+"
        ENDIF
        TempW=ABS(TempW)                    ; get the positive value
        LCDOUT DEC TempW/DS1820_DIG           ; Display the Integer portion
        LCDOUT "."                            ;   display decimal point
        TempW=TempW//DS1820_DIG             ;   get decimal portion
        LCDOUT  DEC1 TempW DIG 0 
        IF ABS(TempC) < 1000 THEN 
            LCDOUT $DF 
        ENDIF
    RETURN
    
    ;----[Read battery voltage]-------------------------------------------------
    RT     CON Res1 + Res2                    ; Total Divider Resistance
    
    ReadVoltage:
        ADCIN 3, RawBattery
        Volts=RawBattery * Rt
        Volts=DIV32 Res2
        Volts=Volts * VDD
        Volts=DIV32 1023
        IF Volts != LastVolts THEN
            LastVolts=Volts
            LCDOUT $FE,$C1
            IF Volts/10 < 10 THEN LCDOUT " "
            LCDOUT " ",DEC Volts/10,",",DEC1 Volts Dig 0," V"
            IF Volts >= MaxBat THEN
                BattLevel=12
            ELSE
                IF Volts <= MinBat THEN
                    BattLevel=0
                ELSE
                    BattLevel=(Volts - MinBat +1) * 12 / (MaxBat - MinBat +1)
                ENDIF
            ENDIF
            GOSUB ShowBattery
        ENDIF
    RETURN
    
    ;----[Show Battery Icon  0 - 12, 0=Empty  12=Full]--------------------------
    ShowBattery:
        lcdout $FE,$C0,1,$FE,$48,$0A,$1F
        for y=4 to 1 step -1
            if BattLevel >= (y * 3) then
                Char=$1F
            else
                if BattLevel >= (y * 3 - 1) then
                    Char=$17
                else
                    if BattLevel >= (y * 3 - 2) then
                        Char=$13
                    else
                        Char=$11
                    endif
                endif
            endif
            lcdout Char
        next y
        lcdout $1F
    return
    
    
    Attached Files Attached Files
    Last edited by Darrel Taylor; - 24th February 2012 at 08:16.
    DT

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