Free Project - 245 LED Display


Results 1 to 40 of 222

Threaded View

  1. #11
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Smile A new lease on life for my prototype ...

    <img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=1693&stc=1&d=118075962 7">
    <hr/>
    The fact of the matter is, after all of this - I honestly have no use for a scrolling marque display. Primarily, the project was only ever attempted in efforts to add to my collection of published projects in the Silicon Chip magazine. As I've stated before, it won't ever being seeing the light of day inside any magazine. So the question for myself was, what do I do with this bloody thing? I put so much time into it, shame to just give it the "heave-ho" in the trash can. After several moments of considerable thought it dawned on me to yes, you guessed it - turn it into a clock! Why not?, its plenty big enough, at least for a 12hr one that is. Unfortunately, however though, its a couple of columns shy for a 24hr clock, at least for me it is, since I concluded that (5x7) digits are mandatory. Much in between just doesn't quite look right. So here it is, source code and all for those of you who have built this thing and would like to turn it into a clock. I also wrote a simple VB app that is used to set the time. (See screen shot) The VB source and everything else is in the download.
    Code:
       Include "modedefs.bas"    ' Include serial modes
       Define OSC 4              ' 4MHz crystal   
       CMCON      = 7            ' All digital
       OPTION_REG = %10000111    ' TMRO prescale = 256
       TRISA      = %00010000    ' All outputs except RA4
       TRISB      = %00000000    ' All outputs ...
       INTCON.5   = 1            ' Enable TMR0 interrupts   
       INTCON.2   = 0            ' Reset overflow flag
       
       on interrupt goto Clock 
                     
       '// Chrs (0-9) stored in on-chip E²PROM
       data @0,62,65,65,65,62   ' 0
       data @5,64,127,66,0,0    ' 1
       data @10,70,73,81,97,66  ' 2
       data @15,54,73,73,65,34  ' 3
       data @20,16,127,18,20,24 ' 4
       data @25,49,73,73,73,39  ' 5
       data @30,50,73,73,73,62  ' 6
       data @35,3,5,9,113,1     ' 7
       data @40,54,73,73,73,54  ' 8
       data @45,62,73,73,73,38  ' 9
       data @50,0,0,0,0,0       ' Space
       data @55,8,8,8,8,8       ' Colm
    
       Row_Data     VAR BYTE    ' Contains one column worth of a chr at a time 
       Column_Scan  VAR BYTE    ' Current col that's active
       Digit_Pos    Var byte    ' E²PROM address pointing to current col data 
       Digit_Loc    VAR Byte    ' Start E²PROM address for new chr
       Colm         var byte    ' Blinking colm ...
       Counter      VAR Word    ' Time keeping counter               
       Secs_Digit1  var byte    ' Secs (1's)
       Secs_Digit2  var byte    ' Secs (10's)
       Mins_Digit1  var byte    ' Mins (1's)
       Mins_Digit2  var byte    ' Mins (10's)
       Hrs_Digit1   var byte    ' Hrs (1's)
       Hrs_Digit2   var byte    ' Hrs (10's)
     
       Clock_Cols   VAR PORTB.6
       Reset_Cols   VAR PORTB.5
       ROW1         VAR PORTA.2
       ROW2         VAR PORTA.3
       ROW3         VAR PORTB.4
       ROW4         VAR PORTB.3
       ROW5         VAR PORTB.0
       ROW6         VAR PORTB.2
       ROW7         VAR PORTB.1
       Prog_Button  VAR PORTA.4
       TX_To_PC     var PORTB.7
           
       Counter     = $7A12               
       TMR0        = 0                    
       Column_Scan = 0
       Digit_Pos   = 0
       Secs_Digit1 = 0
       Secs_Digit2 = 0
       Mins_Digit1 = 0
       Mins_Digit2 = 0
       Hrs_Digit1  = 2
       Hrs_Digit2  = 1
       Colm        = 0
       Reset_Cols  = 1
       Reset_Cols  = 0
       
    LED_Display:                                         ' Scan cols & output row dat
       @ incf _Column_Scan, 1                            ' Inc col
       @ incf _Digit_Pos, 1                              ' Inc chr pos (0-4)
       Row_Data = 0                                      ' Reset 
       IF Column_Scan = 37 THEN Column_Scan = 1          ' ^     
        
       select case Column_Scan
          case 1                                         ' Secs (1's) 
             Digit_Pos = 0                               ' Reset  
             Digit_Loc = (Secs_Digit1 * 5)               ' Set loc
          case 6                                         ' Space
             Digit_Pos = 0
             Digit_Loc = 50
          case 7                                         ' Secs (10's)
             Digit_Pos = 0
             Digit_Loc = (Secs_Digit2 * 5)
          case 12,13                                     ' Colm
             Digit_Pos = 0
             IF Colm = 2 then                            ' Blink colm
                Digit_Loc = 55 
             else
                Digit_Loc = 50
             endif
          case 14                                        ' Mins (1's)
             Digit_Pos = 0
             Digit_Loc = (Mins_Digit1 * 5)
          case 19
             Digit_Pos = 0                               ' Space
             Digit_Loc = 50
          case 20                                        ' Mins (10's)
             Digit_Pos = 0
             Digit_Loc = (Mins_Digit2 * 5)
          case 25,26                                     ' Colm
             Digit_Pos = 0
             IF Colm = 2 then
                Digit_Loc = 55 
             else
                Digit_Loc = 50
             endif
          case 27                                        ' Hours (1's)
             Digit_Pos = 0
             Digit_Loc = (Hrs_Digit1 * 5)
          case 32                                        ' Space
             Digit_Pos = 0
             Digit_Loc = 50
          case 33                                        ' Hours (10's)
             Digit_Pos = 0
             if Hrs_digit2 = 0 then                      ' Show either 1 or nothing 
                Digit_Loc = 50                           ' (12hr time only)
             else
                Digit_Loc = 5
             endif  
       end select
    
       read Digit_loc + Digit_Pos, Row_Data              ' Fetch portion of digit
                                                         ' One column at a time                
       '// Switch off all rows before advancing the counters
       ROW1 = 0
       ROW2 = 0
       ROW3 = 0
       ROW4 = 0
       ROW5 = 0
       ROW6 = 0
       ROW7 = 0
    
       '// Prog button pressed?
       if Prog_Button = 0 then GOTO Set_Time             
    
       '// Clock cascaded counters
       Clock_Cols = 1 
       Clock_Cols = 0 
    
       '// Logically AND data with row bit values and write to port asynchronously 
       IF Row_Data & 1  THEN ROW1 = 1
       IF Row_Data & 2  THEN ROW2 = 1 
       IF Row_Data & 4  THEN ROW3 = 1
       IF Row_Data & 8  THEN ROW4 = 1       
       IF Row_Data & 16 THEN ROW5 = 1
       IF Row_Data & 32 THEN ROW6 = 1 
       IF Row_Data & 64 THEN ROW7 = 1  
       GOTO LED_Display                                  ' Loop back
    
       disable                                           ' Disable interrupts here
    Clock:                                               ' Time keeping routine   
       INTCON.2 = 0                                      ' Clear TMR0 overflow flag
       Counter = Counter - $1000                         ' Dec      
       IF Counter < $1000 THEN                           ' 0.5 sec elapsed? 
          if colm = 2 then                               ' 1 sec elapsed
             @ incf _Secs_Digit1, 1                      ' Inc secs first digit
             If Secs_digit1 = 10 Then                    ' Secs first digit = 10? 
                @ incf _Secs_Digit2, 1                   ' Inc 10's of secs 
                Secs_digit1 = 0                          ' Reset first digit
                If Secs_digit1 = 0 then                  ' Has one minute elapsed?
                   if Secs_digit2 = 6 Then              
                      @ incf _Mins_Digit1, 1             ' Inc mins first digit
                      Secs_digit2 = 0                    ' Reset secs second digit
                      if Mins_digit1 = 10 then           ' 10 mins elapsed?
                         @ incf _Mins_Digit2, 1          ' Inc 10's of mins
                         Mins_digit1 = 0                 ' Reset first mins digit
                         If mins_digit1 = 0 then         ' 60 mins elapsed?
                            if mins_digit2 = 6 Then      '
                               @ incf _Hrs_Digit1, 1     ' Inc hours first digit
                               mins_digit2 = 0           ' Reset mins second digit
                               if Hrs_digit1 = 10 then   ' 10 hours elapsed?
                                  Hrs_digit1 = 0         ' Set hours digits to show 10
                                  Hrs_Digit2 = 1        
                               EndIf                   
                               if Hrs_digit1 = 3 then    ' 12 hours elapsed?
                                  if hrs_digit2 = 1 then '
                                     Hrs_digit1 = 1      ' Reset hours to 1
                                     Hrs_digit2 = 0      '
                                  endif
                               endif
                            endif
                         endif
                      endif        
                   endif
                endif
             endif      
             Colm = 0                                    ' Colm off ...
          endif                                          '
          Counter = Counter + $7A12                      ' Reset counter with 0.5s            
          @ incf _Colm, 1                                ' Toggle colm every 0.5s
       endif      
       resume
    
    Set_Time:
       low Prog_Button                                   ' Set LED    
       SERIN TX_To_PC, N2400, ["@"], Hrs_Digit2, Hrs_Digit1, Mins_Digit2, Mins_Digit1, Secs_Digit2, Secs_Digit1
       input Prog_Button                                 ' Resume as input for prog but  
       Reset_Cols  = 1                                   ' Reset 4017 counters
       Reset_Cols  = 0                                   '
       Column_Scan = 0                                   ' Reset to start of scan
       goto LED_Display                                  ' Start clock
    Trent Jackson
    <hr/>
    <img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=1694&stc=1&d=118076150 6" align="right">
    Attached Images Attached Images   
    Attached Files Attached Files

Similar Threads

  1. Conway's Game Of Life
    By wellyboot in forum mel PIC BASIC Pro
    Replies: 45
    Last Post: - 28th May 2020, 06:14
  2. Single digit 7 Seg LED clock - PIC16F88
    By thirsty in forum Code Examples
    Replies: 4
    Last Post: - 17th July 2009, 08:42
  3. Replies: 2
    Last Post: - 14th July 2008, 22:11
  4. 245 Led Matrix Display (as constructed by Magu)
    By magu in forum Code Examples
    Replies: 11
    Last Post: - 29th June 2007, 00:07
  5. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30

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