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 made this schematic and I re-write the code for using DS1307. But ...
    Time it's scrolling "00:00" , without any changes... Please HELP !
    Code:
    ;         test for scroll - clock - thermometer 
    ;               using DS1307 & DS18B20                     
    ;
    
    @ DEVICE pic16F628A, intOSC_osc_noclkout, WDT_OFF, PWRT_OFF, BOD_OFF, MCLR_OFF
    define osc 4
    INTCON    = 0
    TRISA   = %00100000                 ' CATODES TO PORTA
    TRISB   = %10000001                 ' ANODES  TO PORTB
    CMCON   = 7                         
    DQ     var  PortB.7
    
    SDA Var PORTA.5 ' DS1307 SDA pin #5
    SCL Var PORTB.0 ' DS1307 SCL pin #6
    
    DEFINE I2C_SLOW 1                           ;without this nothing work !
    DEFINE I2C_HOLD 1                           ;without this nothing work !
    DEFINE I2C_SCLOUT 1                         ;without this nothing work !
    
    '***************************************************************************************
     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 70 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
    
    DB       Var BYTE[8] ' Data byte array
    RTCSec   Var DB[0]   ' alias individual bytes in array
    RTCMin   Var DB[1]
    RTCHour  Var DB[2]
    RTCDay   Var DB[3]
    RTCDate  Var DB[4]
    RTCMonth Var DB[5]
    RTCYear  Var DB[6]
    RTCCtrl  Var DB[7]
    
        oraa    var byte
        orab    var byte
        minutea var byte
        minuteb var byte
        ttime   var word
        
    DS18B20_12bit     CON %01111111
    gosub write_1307
        
    START:
     CLEAR 
     gosub read_1307   
    ' 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
         
        ; ttime = 2345              ; just for test  
     ;   oraa = ttime dig 3
     ;   orab = ttime dig 2
     ;   minutea = ttime dig 1
     ;   minuteb = ttime dig 0
    
       oraa = ((RTCHour>>4)& $01)        ; ?????????????????????????
       orab =  (RTCHour & $0f)           ; ?????????????????????????
       minutea = ((RTCMin>>4)& $0f)      ; ?????????????????????????
       minuteb =  (RTCMin & $0f)         ; ?????????????????????????
    
       
     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:
        ' Set time & date to  11:59:00, Day 2, Date:Month:Year 30:08:2007
        I2CWRITE SDA,SCL,$D0,$00,[$00,$59,$51,$02,$30,$08,$27,$90] ' Write to DS1307
        pause 10
    RETURN
    
    read_1307:                          ' Read time Secs,Mins,Hours,Day,Date,Month,Year,Control
        I2CREAD SDA,SCL,$D1,$00,[STR DB\8] ' Read 8 bytes from DS1307
    return
    
    end
    Attached Images Attached Images  

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


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo

    I try with this variant of code
    Code:
    read_1307:                             ' Read time Secs,Mins,Hours,Day,Date,Month,Year,Control
       I2CREAD SDA,SCL,$D1,$00,[STR DB\8]  ' Read 8 bytes from DS1307
            pause 50
        If RTCHour.6=1 then           ' Work-Out 12 or 24 hour Display for Hours
            CounterA=(RTCHour>>4)&$01
            else
            CounterA=(RTCHour>>4)&$03
            endif
            
            CounterA=CounterA*10+(RTCHour&$0F)
        If RTCHour.6=1 then            ' Display Hours appropriately for 12 or 24 hour Mode 
            oraa = CounterA
            else
            oraa = CounterA Dig 1 : orab = CounterA Dig 0
            endif
    
        minutea =(RTCMin>>4)&$0F : minuteb = RTCMin&$0F    
    return
    but still "00:00" time I have ...

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


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo

    I made this change
    Code:
    read_1307:                          ' Read time Secs,Mins,Hours,Day,Date,Month,Year,Control
         I2CRead SDA,SCL,$D1,$00,[ RTCSec,RTCMin,RTCHour,RTCDay,RTCDay,RTCMonth,RTCYear,RTCCtrl]
    and now the time is "20:20" ! The clock still don't run ...
    Attached Images Attached Images  
    Last edited by fratello; - 18th October 2011 at 07:46.

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


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo

    You must put a crystal on the DS1307 ( 32.768Khz)
    Thanks and Regards;
    Gadelhas

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


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo

    Thanks...but Proteus dont need him. The clock works fine...just the scroll don't look the "real" time ; it's stuck on "20:20"
    I try many variants, without results. I can't find the way to store real clock in my variables : oraa,orab,minutea & minuteb ...

  6. #6
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo

    I dont think you can have SDA connected to MCLR.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

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


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo

    Thanks cncmachineguy ! Indeed MCLR cannot be SDA.
    Working variant, but just 5 columns ....
    Code:
    ;         Working variant for scroll - clock - thermometer 
    ;               using DS1307 & DS18B20                     
    ;
    
    @ DEVICE pic16F628A, intOSC_osc_noclkout, WDT_OFF, PWRT_OFF, BOD_OFF, MCLR_OFF
    define osc 4
    INTCON    = 0
    TRISA   = 000000                 ' CATODES TO PORTA
    TRISB   = 000000                ' ANODES  TO PORTB
    CMCON   = 7                         
    DQ     var  PortB.7
    
    SDA Var PORTB.6  ' DS1307 SDA pin #5
    SCL Var PORTB.5  ' DS1307 SCL pin #6
    
    '***************************************************************************************
     eeprom 0, [100001,111010,110110,101110,100001]      '0
     eeprom 5, [111111,111101,000000,111111,111111]      '1
     eeprom 10,[111101,111110,101110,110110,111001]      '2
     eeprom 15,[111101,111110,110110,110110,101001]      '3
     eeprom 20,[100111,101011,101101,000000,101111]      '4
     eeprom 25,[111000,111010,111010,111010,100110]      '5
     eeprom 30,[100001,110110,110110,110110,101101]      '6
     eeprom 35,[111110,001110,110110,111010,111100]      '7
     eeprom 40,[001001,110110,110110,110110,001001]      '8
     eeprom 45,[111001,110110,110110,110110,001001]      '9
    
        counter           var      byte
        scan              var      byte
        scroll            var      byte
        leddata           var      byte[75]    'Column Data for display 70 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
    
    DB       Var BYTE[8] ' Data byte array
    RTCSec   Var DB[0]   ' alias individual bytes in array
    RTCMin   Var DB[1]
    RTCHour  Var DB[2]
    RTCDay   Var DB[3]
    RTCDate  Var DB[4]
    RTCMonth Var DB[5]
    RTCYear  Var DB[6]
    RTCCtrl  Var DB[7]
        ore     var word
        minute  var word
        oraa    var byte
        orab    var byte
        minutea var byte
        minuteb var byte
    
        
    DS18B20_12bit     CON 111111
    
    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    
            
        tempA = temperature DIG 3
        tempB = temperature DIG 2
        tempC = temperature DIG 1
       
     if tempA = 0 then
        FOR counter = 0 TO 4
        leddata [counter+8] = 111111
        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   
    
    
       gosub read_1307
        oraa =  ore dig 1
        orab =  ore dig 0
        minutea =  minute dig 1
        minuteb =  minute dig 0
    
        FOR counter = 0 TO 4
            READ oraa*5+counter,leddata [counter+41]        'stores hours digit 1 in leddata locations 
        NEXT 
    
        
        FOR counter = 0 TO 4
            READ orab*5+counter,leddata [counter+47]        'stores hours digit 0 in leddata locations 
        NEXT 
    
    
    
        FOR counter = 0 TO 4
            READ minutea*5+counter,leddata [counter+57]    'stores minutes digit 1 in leddata locations 
        NEXT
        
        FOR counter = 0 TO 4
            READ minuteb*5+counter,leddata [counter+63]    'stores minutes digit 0 in leddata locations 
        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
        'e.t.c.
    ;==========================================================================================================
        
    for n=0 to 7
    leddata [n] = 111111
    next n
        leddata [13] = 111111
        leddata [19] = 111111
        leddata [20] = 111111    ' DECIMAL POINT
        leddata [21] = 111111
        leddata [22] = 111111
        leddata [28] = 111111
        leddata [29] = 111100    ' degrees c
        leddata [30] = 111100
        leddata [31] = 100011
        leddata [32] = 111101    
        leddata [33] = 111101
        leddata [34] = 111101
        leddata [35] = 111111
        leddata [36] = 111111
        leddata [37] = 111111
        leddata [38] = 111111
        leddata [39] = 111111
        leddata [40] = 111111
        leddata [46] = 111111
        leddata [52] = 111111
        leddata [53] = 111111      
        leddata [54] = 111011
        leddata [55] = 111111
        leddata [56] = 111111
        leddata [62] = 111111
        leddata [68] = 111111
        leddata [69] = 111111
        leddata [70] = 111111
        leddata [71] = 111111
        leddata [72] = 111111
        leddata [73] = 111111
        leddata [74] = 111111
        leddata [75] = 111111
    
    LOOPing:
    FOR scroll = 0 TO 70
        FOR scan = 0 TO 10
            PORTA=111111
            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,[$59,$30,$9,$7,$14,$2,$10,$90] ' Write to DS1307
        pause 10
    RETURN
    
    read_1307:                                              ' Read time Secs,Mins,Hours,Day,Date,Month,Year,Control
        I2CREAD SDA,SCL,$D1,$00,[STR DB\8]                  ' Read 8 bytes from DS1307
    ore     = (db[2] & $F )+((db[2]>>4)*10)                 ' Hex to Dec hour
    minute  = (db[1] & $F )+((db[1]>>4)*10)                 ' Hex to Dec minutes
    RETURN
    
    end
    I think I will "upgrade" to 16F886 or 16F57 (more I/O pins) ...

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