Scrolling thermo


Closed Thread
Page 1 of 2 12 LastLast
Results 1 to 40 of 56
  1. #1
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579

    Default Scrolling thermo

    Hi ! I made this schematic : http://solderslingers.com/cart/index...&products_id=1 and work very fine ! So, since I am "0" in Atmel programming, I try to write my own program for PIC, using PBP (here am I to "1" level and example from this forum- Thanks to Mr.D.J.Welburn !
    But...of course, I need help. Only 4 columns are lighting and the characters are ...strange, non-readable. It's some "moving" on my led matrix, but sure it's something wrong. I need help ! Thanks in advance !
    Code:
    @ DEVICE pic16F628A, intOSC_osc_noclkout, WDT_OFF, PWRT_OFF, BOD_OFF, MCLR_ON
    define osc 4
    INTCON    = 0
    TRISA= %00000000                        
    TRISB= %10000000              
    DQ          var  PortB.7
    CMCON=7                                 ' Disable comparators
    
    
    '***************************************************************************************
    eeprom 0, [%00111110,%01010001,%01001001,%01000101,%00111110] '0
    eeprom 5, [%00000000,%01000010,%01111111,%01000000,%00000000] '1
    eeprom 10,[%01000010,%01100001,%01010001,%01001001,%01000110] '2
    eeprom 15,[%00100001,%01000001,%01000101,%01001011,%00110001] '3
    eeprom 20,[%00011000,%00010100,%00010010,%01111111,%00010000] '4
    eeprom 25,[%00100111,%01000101,%01000101,%01000101,%00111001] '5
    eeprom 30,[%00111100,%01001010,%01001001,%01001001,%00110000] '6
    eeprom 35,[%00000001,%01110001,%00001001,%00000101,%00000011] '7
    eeprom 40,[%00110110,%01001001,%01001001,%01001001,%00110110] '8
    eeprom 45,[%00000110,%01001001,%01001001,%00101001,%00011110] '9
    
    
    
        counter        var    byte
        scan         var    byte
        scroll        var    byte
        leddata        var    byte[36]    'Column Data for display 36 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)
        
    DS18B20_12bit     CON %01111111
    
    START:
        CLEAR        'Clear all varibles
    
    ' Init Sensor 1
     OWOUT DQ, 1, [$CC, $4E, 0, 0, DS18B20_12bit]
     OWOut DQ, 1, [$CC, $48]                   ' Start temperature conversion
     OWOut DQ, 1, [$CC, $B8] 
     OWOut DQ, 1, [$CC, $BE] 
     Pause 50
     OWIn DQ, 2, [temperature.byte0, temperature.byte1]
     Pause 50 
     
        '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
    
        leddata [20] = %11000000    ' DECIMAL POINT
        leddata [21] = %11000000    
    
        leddata [29] = %00000011    ' degrees c
        leddata [30] = %00000011
        leddata [31] = %00111000
        leddata [32] = %01000100    
        leddata [33] = %01000100
        leddata [34] = %01000100
    
    
     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 2
        tempB = temperature DIG 1
        tempC = temperature DIG 0
    
        IF tempA = 0 THEN    ' if 1st digit is 0 then skip so display dosnt display 09.5c
            GOTO skipdigit    ' it will display 9.5c instead
        ENDIF
        FOR counter = 0 TO 4
            READ tempA*5+counter,leddata [counter+8]     'stores 1st digit in leddata locations 8,9,10,11,12    
        NEXT counter
    skipdigit:
        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    
    
    
    
    
    
    LOOP:
    FOR scroll = 0 TO 35
        FOR scan = 0 TO 15
            PORTA = 1
            FOR counter = 0 TO 7
                PORTB = leddata [counter]
                PAUSEUS 1500
                PORTB = 0
                PORTA = PORTA * 2
            NEXT
        NEXT
        FOR counter = 0 TO 34
            leddata [counter] = leddata [counter+1]
        NEXT
    NEXT
    GOTO START
    END
    Attached Images Attached Images  
    Attached Files Attached Files
    Last edited by fratello; - 6th September 2011 at 14:50. Reason: Forgot Proteus file...

  2. #2
    Join Date
    Feb 2005
    Location
    Holmfirth England
    Posts
    116


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo

    Hi,

    Just ran a simulation in isis. First thing I notice is that porta.4 does not seem to be working. Don't know if that is just the simulator though.

    Will take a closer look at your code

  3. #3
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo

    Maybe pull up resistor is missing?

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


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo

    Hi;

    In PIC16F628A the RA4 Pin is open drain, so you wll need a pull up resistor.
    Thanks and Regards;
    Gadelhas

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


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo

    Working soft in simulation !!!
    Attached Files Attached Files

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


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo

    Mr.Arrati say : " PortA.4 is a Schmitt Trigger input and an open drain output. You will need an additional NPN transistor with a pull down resistor to make column 5 working.". So... can I use PortA.5 instead PortA.4 ? How ? Using "MCLR off" and ?!

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


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo

    Quote Originally Posted by fratello View Post
    Mr.Arrati say : " PortA.4 is a Schmitt Trigger input and an open drain output. You will need an additional NPN transistor with a pull down resistor to make column 5 working.". So... can I use PortA.5 instead PortA.4 ? How ? Using "MCLR off" and ?!
    You can only use RA5 as Input with MCLR off
    Thanks and Regards;
    Gadelhas

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


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo

    This is schematic who work fine in Proteus. In "real life" , despite modification of scroll timming (pause 500 to 5000 !), the led's are always ON !!! Any idea ?
    Thanks !
    Attached Images Attached Images  

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


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo

    Hi;

    I cannot compile that source code. What is the "LOOP" for?? This is a reserved word, you cannot compile the code with this word on a label. And i'm always getting illegal opcode.

    What are you using to compile? Mpasm? or PBP?
    Last edited by gadelhas; - 6th September 2011 at 21:06.
    Thanks and Regards;
    Gadelhas

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


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo

    Got it;
    Since I'm using MPASM needed to change the config line;

    Code:
    @ __config _INTOSC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _BODEN_OFF & _MCLRE_ON
    Also like i said before needed to delete the "LOOP" label also, since its a reserved word.
    Thanks and Regards;
    Gadelhas

  11. #11
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo

    LOOP is a reserved word for new version of PBP (2.60 and latter if my memory serves me well) you can replace it with a REPEAT/UNTILL, WHILE/WEND loop.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  12. #12
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo

    Quote Originally Posted by fratello View Post
    This is schematic who work fine in Proteus. In "real life" , despite modification of scroll timming (pause 500 to 5000 !), the led's are always ON !!! Any idea ?
    Thanks !
    Are they FULL ON or dimmed? I feel they will be dimmed, it's a kind of ghost probably you'll need to add some delay after you turn them off, after the PORTB=0 line

    Turn some LED ON, wait a little bit, turn them OFF, wait a little, do it again.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  13. #13
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo

    I will try this code today, later...
    Code:
    ....
    LOOPing:
    FOR scroll = 0 TO 35
        FOR scan = 0 TO 15
            PORTb = 1
            porta=1
            FOR counter = 0 TO 7
                PORTA = leddata [counter]
                PAUSE 10
                PORTb = PORTb * 2
            NEXT
        NEXT
        FOR counter = 0 TO 34
            leddata [counter] = leddata [counter+1]
        NEXT
    NEXT
    GOTO START
    END
    I find another ...mistake (?) : line 2 do not appear on matrix ! What a hell it's going ?!
    Attached Images Attached Images  

  14. #14
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo

    Tens of variants and no result ! Nobody has a clue ?

  15. #15
    Join Date
    Aug 2005
    Posts
    95


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo

    You might have to play with your FOSC setting to enable I/O mode on RA6&RA7.

    Sphere.

  16. #16
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo

    With schematic from post #8 :
    Code:
    ; working variant ; anode to portB, catode to portA
    @ DEVICE pic16F628A, intOSC_osc_noclkout, WDT_OFF, PWRT_OFF, BOD_OFF, MCLR_off
    define osc 4
    INTCON    = 0
    TRISA   = %00000000       
    TRISB   = %10000000
    CMCON   = 7                         ' Disable comparators
    
    DQ     var  PortB.7
    
    '***************************************************************************************
     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[36]    'Column Data for display 36 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
    
    DS18B20_12bit     CON %01111111
    
    START:
     CLEAR        'Clear all varibles
    
    ' Init Sensor 1
     OWOUT DQ, 1, [$CC, $4E, 0, 0, DS18B20_12bit]
     OWOut DQ, 1, [$CC, $48]                   ' Start temperature conversion
     OWOut DQ, 1, [$CC, $B8] 
     OWOut DQ, 1, [$CC, $BE] 
     Pause 50
     OWIn DQ, 2, [temperature.byte0, temperature.byte1]
     Pause 50 
     
    
    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
          
     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] = %11111111
        next                                            ' if 1st digit is 0 then skip so display dosnt display 09.5c
            GOTO skipdigit                                ' it will display 9.5c instead
         ENDIF
        FOR counter = 0 TO 4
            READ tempA*5+counter,leddata [counter+8]     'stores 1st digit in leddata locations 8,9,10,11,12    
        NEXT counter
    
    skipdigit:
        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    
    
    LOOPing:
    FOR scroll = 0 TO 35
        FOR scan = 0 TO 35
            PORTb = 1
            FOR counter = 0 TO 7
                PORTa = leddata [counter]
                PAUSE 1
                PORTb = PORTb * 2
            NEXT
        NEXT
        FOR counter = 0 TO 34
            leddata [counter] = leddata [counter+1]
        NEXT
    NEXT
    GOTO START
    END
    Maybe I put here tomorrow link to video (Y...tube).
    Last edited by fratello; - 8th September 2011 at 20:21.

  17. #17
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo

    How I promise...
    Note : The pullup resistor on RA4 it's 4k7.

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


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo

    Very nice!!!

    fratello,
    This will make a great project for the wiki.
    Dave
    Always wear safety glasses while programming.

  19. #19
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo

    Thanks !
    I need one advice : the leds are not fully OFF when it's nothing to scroll... I try to add "pause" in different places of code, but without results...Please, I need help for one code 100% good ! Thanks in advance !

  20. #20
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo

    Last version of code :
    Code:
    ; working variant ; anode to portB, catode to portA 
    ;   11 september 2011
    ; SCROLLING THERMOMETER 
    ;   By NICULESCU DAN
    
    
    @ DEVICE pic16F628A, intOSC_osc_noclkout, WDT_OFF, PWRT_OFF, BOD_OFF, MCLR_off
    define osc 4
    INTCON    = 0
    TRISA   = %00000000       
    TRISB   = %10000000
    CMCON   = 7                         ' Disable comparators
    DQ     var  PortB.7
    
    '***************************************************************************************
     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[36]    'Column Data for display 36 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
    
    DS18B20_12bit     CON %01111111
    
    START:
     CLEAR        'Clear all varibles
     porta = 1
     portb = 0
     pause 100
    ' Init Sensor 1
     OWOUT DQ, 1, [$CC, $4E, 0, 0, DS18B20_12bit]
     OWOut DQ, 1, [$CC, $48]                   ' Start temperature conversion
     OWOut DQ, 1, [$CC, $B8] 
     OWOut DQ, 1, [$CC, $BE] 
     Pause 50
     OWIn DQ, 2, [temperature.byte0, temperature.byte1]
     Pause 50 
     
    
    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
          
     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        
        tempA = temperature DIG 3
        tempB = temperature DIG 2
        tempC = temperature DIG 1
    
     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    
    
    ;LOOPing:
    FOR scroll = 0 TO 35
        FOR scan = 0 TO 6
            PORTb = 1
            FOR counter = 0 TO 7      
                PORTa = leddata [counter]
                pAUSE 1
                PORTb = PORTb * 2
            NEXT
        NEXT
        FOR counter = 0 TO 34
            leddata [counter] = leddata [counter+1]
        NEXT
    NEXT
    GOTO START
    END
    Work fine... but, in transition, some LEDs (not all) of first column on left are a little dimmed ! I don't know what else I can do ...

  21. #21
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo

    I did it ! Full led on, full led off. Enjoy !
    Code:
    ;               SCROLLING THERMOMETER 
    ;                        FINAL VERSION
    ;                      By NICULESCU DAN
    ;                     SEPTEMBER, 13, 2011
    ;                                                              
    ;                        .oooO                                 
    ;                        (   )   Oooo.                         
    ;                         \ (    (   )
    ;                          \_)    ) /
    ;                                (_/
    ;
    
    @ DEVICE pic16F628A, intOSC_osc_noclkout, WDT_OFF, PWRT_OFF, BOD_OFF, MCLR_off
    define osc 4
    INTCON    = 0
    TRISA   = %00000000                 ' CATODES TO PORTA
    TRISB   = %10000000                 ' ANODES  TO PORTB
    CMCON   = 7                         
    DQ     var  PortB.7
    
    '***************************************************************************************
     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[36]    'Column Data for display 36 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
    
    DS18B20_12bit     CON %01111111
    
    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
    
     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 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
    
    LOOPing:
    FOR scroll = 0 TO 35
        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 34 
            leddata [counter] = leddata [counter+1]
        NEXT
    NEXT
    GOTO START
    END

  22. #22
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo


  23. #23
    Join Date
    Feb 2007
    Posts
    55


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo

    sorry, just saw your private message....looks like you got it going!

    nice one!

  24. #24
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo

    Mr.Wellyboot : Need advice on using RTC DS1307 AND DS18B20 sensor ! How reading/displaying both (temperature and time) ? Please help ! Can I use same (two) pins to driven leds and reading DS1307 ? Any help it's wellcome . Thanks in advance !

  25. #25
    Join Date
    Feb 2007
    Posts
    55


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo

    Im not sure you can use the I2C pins to also connect to your leds, as from my experience the bus can be quite fussy

  26. #26
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo

    Thanks for replay! I can give up at 1x1 line/column for DS1307...but how displaying time & temperature?

  27. #27
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    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  

  28. #28
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


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

  29. #29
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    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.

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

  31. #31
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


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

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

  33. #33
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


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

  34. #34
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    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 !

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

  36. #36
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


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

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

  38. #38
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


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

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

  40. #40
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


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