Scrolling thermo


Closed Thread
Results 1 to 40 of 56

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo

    I found in my boxes one piece of PIC16F877A. So, because this have a lot of I/O, I try to migrate the code.
    But...of course, I have problems ! What's up now ?
    Code:
    @ DEVICE pic16F877A, intOSC_osc_noclkout, WDT_ON, PWRT_ON, BOD_ON, MCLR_OFF
    DEFINE OSC 4
    
    OPTION_REG.7 = 0
    ADCON0 = %110000000
    ADCON1 = %000000111 
    CMCON=7
    CVRCON=0
    
    PORTA = %00000001 'Set all INPUTS to 0 except RA0 = DQ
    TRISA = %00000001 'Set PORTA RA0-RA5
    PORTB = %00000000 'Set all outputs to 0 (off)
    TRISB = %00000000 'Set PORTB to all output
    PORTC = %00000000 'Set all outputs to 0 (off)
    TRISC = %00000000 'Set PORTC to all output
                    
    DQ     var  PortA.0
    
    SDA Var PORTC.4 ' DS1307 SDA pin #5
    SCL Var PORTC.3 ' DS1307 SCL pin #6
    
    '***************************************************************************************
     eeprom 0, [%10100001,%01111010,%01110110,%01101110,%10100001]      '0
     eeprom 5, [%11111111,%01111101,%00000000,%01111111,%11111111]      '1
     eeprom 10,[%01111101,%00111110,%01101110,%01110110,%01111001]      '2
     eeprom 15,[%10111101,%01111110,%01110110,%01110110,%10101001]      '3
     eeprom 20,[%11100111,%11101011,%11101101,%00000000,%11101111]      '4
     eeprom 25,[%10111000,%01111010,%01111010,%01111010,%10100110]      '5
     eeprom 30,[%10100001,%01110110,%01110110,%01110110,%10101101]      '6
     eeprom 35,[%11111110,%00001110,%11110110,%11111010,%11111100]      '7
     eeprom 40,[%10001001,%01110110,%01110110,%01110110,%10001001]      '8
     eeprom 45,[%11111001,%01110110,%01110110,%01110110,%10001001]      '9
    
        counter           var      byte
        scan              var      byte
        scroll            var      byte
        leddata           var      byte[75]    'Column Data for display 75 columns
        temperature       var      Word        'reading from sensor
        Sign              var      BIT
        tempA             var      byte        'Stores First digit (High)
        tempB             var      byte        'stores Second digit (Mid)
        tempC             var      byte        'stores Third digit (low)
        n                 var      byte
    
    RTCSec   Var byte   ' alias individual bytes in array
    RTCMin   Var byte
    RTCHour  Var byte
    RTCDay   Var byte
    RTCDate  Var byte
    RTCMonth Var byte
    RTCYear  Var byte
    RTCCtrl  Var byte
    
        oraa    var byte
        orab    var byte
        minutea var byte
        minuteb var byte
    
        
    DS18B20_12bit     CON %01111111
    gosub write_1307
        
    START:
     CLEAR 
    ' Init Sensor 
     OWOUT DQ, 1, [$CC, $4E, 0, 0, DS18B20_12bit]
     OWOut DQ, 1, [$CC, $48]                   
     OWOut DQ, 1, [$CC, $B8] 
     OWOut DQ, 1, [$CC, $BE] 
     Pause 50
     OWIn DQ, 2, [temperature.byte0, temperature.byte1]
     Pause 50 
                     
     OWOut DQ, 1, [$CC, $44] 
     OWOut DQ, 1, [$CC, $BE]
     OWIn DQ, 2, [temperature.byte0, temperature.byte1]         
        Sign = temperature.15
        temperature= ABS(temperature)
        temperature=((temperature >> 4)*100) + ((temperature & $F) * 100 >> 4)
        if sign then temperature= -temperature
        ; temperature=2340         ; UNCOMMENT FOR DISPLAY TEST        
            
        tempA = temperature DIG 3
        tempB = temperature DIG 2
        tempC = temperature DIG 1
         
    
    gosub read_1307
                          
    if tempA = 0 then
        FOR counter = 0 TO 4
        leddata [counter+8] = %11111111
        next
        else
        for counter = 0 to 4
            READ tempA*5+counter,leddata [counter+8]     'stores 1st digit in leddata locations 8,9,10,11,12    
        NEXT 
    endif    
        FOR counter = 0 TO 4
            READ tempB*5+counter,leddata [counter+14]    'stores 2nd digit in leddata locations 14,15,16,17,18
        NEXT
        
        FOR counter = 0 TO 4
            READ tempC*5+counter,leddata [counter+23]    'stores 3rd digit in leddata locations 23,24,25,26,27
        NEXT   
    
     
        FOR counter = 0 TO 4
            READ oraa*5+counter,leddata [counter+41]    
        NEXT 
        
        FOR counter = 0 TO 4
            READ orab*5+counter,leddata [counter+47]    
        NEXT 
    
    
    
        FOR counter = 0 TO 4
            READ minutea*5+counter,leddata [counter+57]    'stores minut digit in leddata locations 41,42,43,44,45 
        NEXT
        
        FOR counter = 0 TO 4
            READ minuteb*5+counter,leddata [counter+63]    'stores minut digit in leddata locations 41,42,43,44,45 
        NEXT 
    
    ;==========================================================================================================
        'leddata locations 0-7 are blank so that data scrolls onto display
        'leddata locations 8-12 1st digit (leading digit)
        'leddata location  13 blank column between digits
        'leddata locations 14-18 2nd digit
        'leddata location  19 blank column between digits
        'leddata locations 20 & 21 Decimal Point
        'leddata locations 23 - 27 3rd digit (last digit)
        'leddata locations 28 blank column between digits
        'leddata locations 29 - 34 Degrees C symbol
        'leddata location  35 is a blank column at end to clear display as it scrolls
    ;==========================================================================================================
        
    for n=0 to 7
    leddata [n] = %11111111
    next n
        leddata [13] = %11111111
        leddata [19] = %11111111
        leddata [20] = %00111111    ' DECIMAL POINT
        leddata [21] = %00111111
        leddata [22] = %11111111
        leddata [28] = %11111111
        leddata [29] = %11111100    ' degrees c
        leddata [30] = %11111100
        leddata [31] = %11100011
        leddata [32] = %10111101    
        leddata [33] = %10111101
        leddata [34] = %10111101
        leddata [35] = %11111111
        leddata [36] = %11111111
        leddata [37] = %11111111
        leddata [38] = %11111111
        leddata [39] = %11111111
        leddata [40] = %11111111
            leddata [46] = %11111111
            leddata [52] = %11111111
            leddata [53] = %11111111      
            leddata [54] = %10111011
            leddata [55] = %11111111
            leddata [56] = %11111111
            leddata [62] = %11111111
            leddata [68] = %11111111
            leddata [69] = %11111111
            leddata [70] = %11111111
            leddata [71] = %11111111
            leddata [72] = %11111111
            leddata [73] = %11111111
            leddata [74] = %11111111
            leddata [75] = %11111111
             
    LOOPing:
    FOR scroll = 0 TO 70
        FOR scan = 0 TO 10
            PORTA=%11111111
            PAUSE 1
            PORTb = 1
            FOR counter = 0 TO 7
                PORTa = leddata [counter]          
                PAUSE 1          
                PORTb = PORTb * 2
            NEXT
        NEXT
        FOR counter = 0 TO 70
            leddata [counter] = leddata [counter+1]
        NEXT
    NEXT
    GOTO START
    
    Write_1307:
        I2CWRITE SDA,SCL,$D0,$00,[$00,$55,$15,$2,$6,$7,$4,$90] ' Write to DS1307
        pause 10
    RETURN
    
    read_1307:                          ' Read time Secs,Mins,Hours,Day,Date,Month,Year,Control
         I2CRead SDA,SCL,$D0,$00,[ RTCSec,RTCMin,RTCHour,RTCDay,RTCDate,RTCMonth,RTCYear,RTCCtrl]
    RETURN
    
    END
    And I've got many errors :
    Code:
    FATAL ERROR: Too many errors. (21)
    ERROR Line 4: Redefiniton of LABEL OPTION_REG. (16F877A.bas)
    ERROR Line 5: Redefiniton of LABEL ADCON0. (16F877A.bas)
    ERROR Line 6: Redefiniton of LABEL ADCON1. (16F877A.bas)
    ERROR Line 7: Redefiniton of LABEL CMCON. (16F877A.bas)
    ERROR Line 8: Redefiniton of LABEL CVRCON. (16F877A.bas)
    ERROR Line 10: Redefiniton of LABEL PORTA. (16F877A.bas)
    ERROR Line 11: Redefiniton of LABEL TRISA. (16F877A.bas)
    ERROR Line 12: Redefiniton of LABEL PORTB. (16F877A.bas)
    ERROR Line 13: Redefiniton of LABEL TRISB. (16F877A.bas)
    ERROR Line 14: Redefiniton of LABEL PORTC. (16F877A.bas)
    ERROR Line 15: Redefiniton of LABEL TRISC. (16F877A.bas)
    ERROR Line 17: Redefinition of VAR. (16F877A.bas)
    ERROR Line 19: Redefinition of VAR. (16F877A.bas)
    ERROR Line 20: Redefinition of VAR. (16F877A.bas)
    ERROR Line 34: Redefinition of VAR. (16F877A.bas)
    ERROR Line 35: Redefinition of VAR. (16F877A.bas)
    ERROR Line 36: Redefinition of VAR. (16F877A.bas)
    ERROR Line 179: Redefiniton of LABEL PORTA. (16F877A.bas)
    ERROR Line 181: Redefiniton of LABEL PORTB. (16F877A.bas)
    ERROR Line 183: Redefiniton of LABEL PORTA. (16F877A.bas)
    ERROR Line 185: Redefiniton of LABEL PORTB. (16F877A.bas)
    Please, help ! Thanks !

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo

    DATA sheets are your friend.
    Please read the chips DATA sheet and make it happy


    intOSC_osc_noclkout

    First problem
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo

    I allready check this :
    "@ DEVICE pic16F877A, XT_OSC, LVP_OFF, WDT_ON, PWRT_ON, BOD_ON, MCLR_OFF"
    Of course, the messages it's still there ...

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo

    What do you want the ADC to do? Did you adjust for the new part?
    Did you select the correct chip in the compiler?
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo

    I am so DUMB !!! The file I wrote and I try to compile has the name "16F877A.bas" ! So idiot !!!
    Works fine...now ! Thank You all ! Sorry for my stupidity .
    Code:
    '****************************************************************
    '*  Name    : test scroll-clock-thermometer-16F877A
    '****************************************************************
    @ DEVICE pic16F877A, XT_OSC, WDT_ON, PWRT_ON, BOD_ON
    DEFINE OSC 4
    
    OPTION_REG.7 = 0
    ADCON1 = 7
    CMCON=7
    
    PORTA = %00000001 'Set all INPUTS to 0 except RA0 = DQ
    TRISA = %00000001 'Set PORTA RA0-RA5
    PORTB = %00000000 'Set all outputs to 0 (off)
    TRISB = %00000000 'Set PORTB to all output
    PORTC = %00000000 'Set all outputs to 0 (off)
    TRISC = %00000000 'Set PORTC to all output
    PORTD = %00000000
    TRISD = %00000000                
    DQ     var  PortA.0
    
    SDA Var PORTC.1 ' DS1307 SDA pin #5
    SCL Var PORTC.0 ' DS1307 SCL pin #6
    ...etc...

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo

    $_hit happens...
    Do not be so hard on yourself.
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo

    Still need help...I try to write code for setting clock ; I use parts from the great code of Melanie's (Thanks !). In Proteus I see what happens but... In real-life I need to display each digit of clock-time ; if set hour I need to see, first tens hour digit, then hour digit, tens minutes, minutes.
    How can I display on this matrix static number ? Please, give me a clue !

Members who have read this thread : 0

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