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

    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.

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


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo

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

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

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


    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 !

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


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

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


    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

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


    Did you find this post helpful? Yes | No

    Default Re: Scrolling thermo


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