20X2 4 digit 7 segment Countdown timer

marks

Senior Member
At the moment just a simple 10 minute countdown timer (10.00)
push the button to start stop and reset.
will add more features later lol.
Code:
	'             -- --   -- --   -- --   -- --
	' B0-A       |     | |     | |     | |     |
	' B1-B	
	' B2-C       |     | |     | |     | |     |
	' B3-D        -- --   -- --   -- --   -- --         MarkS
	' B4-E       |     | |     | |     | |     |
	' B5-F
	' B6-G       |     | |     | |     | |     |
	' B7-dp       -- --   -- -- o -- --   -- --   
	'
	'Display        1       2       3       4
	'Common anode  C.3     C.2     C.1     c.0
	
 SETFREQ M16
eeprom 0,(192,249,164,176,153,146,130,248,128,144,255)     'Display (0,1,2,3,4,5,6,7,8,9,blank)
 
	SYMBOL pushbutton    = PINC.6
	SYMBOL display1      = C.3     
	SYMBOL display2      = C.2
	SYMBOL display3      = C.1
	SYMBOL display4      = C.0
	SYMBOL output1       = A.0

	SYMBOL push          = B9
	SYMBOL mins          = B10
	SYMBOL secs          = B11
	SYMBOL number        = B12
	SYMBOL time          = W7 'b14,b15
Main:
let dirsb = %11111111
let dirsc = %10111111

Zero: push=0
SETTIMER T1S_16
TIMER = 0
time = 600                                      ' time = 10.00 mins (600 secs)

Start:

 mins=Time-timer/60                                               
 
 secs=Time-timer//60
                                                             
Stop1:
          
 number = 10 :  IF mins < 10 THEN dig1                                  'Display1 Zero blanking	
      LET number = mins DIG 1                                       
    Dig1:  READ number,pinsb :                   LOW display1 : PAUSE 1 : HIGH display1      
 
                IF mins < 1  THEN dig2                                  'Display2 Zero blanking
	LET number = mins DIG 0 	                                          
    Dig2:  READ number,pinsb : pinsb=pinsb-128 : LOW display2 : PAUSE 1 : HIGH display2  	
	
	LET number = secs DIG 1			
    Dig3:  READ number,pinsb :                   LOW display3 : PAUSE 1 : HIGH display3  
		
	LET number = secs DIG 0 	                                                              
    Dig4:  READ number,pinsb :                   LOW display4 : PAUSE 1 : HIGH display4  
    
      if pushbutton = 1 then selection 	          
 	           	                                                                                     
if mins=0 and secs=0 then zero                   'once .00 is reached  stops and resets to 10.00 mins 
                                        
on push goto zero,start,stop1 
                              
Selection:
  inc push :pause 1000
 if pushbutton = 1  then selection                                       
 on push goto zero,start,stop1
 if push > 2 then zero
Have been playing with Diptrace my first schematic for Westy lol
although designing a pcb withit is a bit beyond me at the moment
will stick with veroboard lol
 

Attachments

Last edited:

westaust55

Moderator
@Marks,

At the top of your schematic you have -5V. That should be "0V" or "Gnd".


To avoid having a flow through in the ON///GOSUB line newr the botton, try:

Code:
Selection:
  push = push // 3  ; 0,1 or 2 are the result
pause 1000
 if pushbutton = 1  then selection                                       
 on push goto zero,start,stop1
which also saves 4 bytes in program size

you may then not even need "push = 0 at the label "zero:",
just the label which saves a couple more bytes (have not checked full program to ascertain this is possible)
 
Last edited:

marks

Senior Member
Another clever 1 from westaus55, ive reposted the working code so i dont forget that 1 lol
the overflow was there on purpose so when you hold the button continously it will zero.
Code:
		'             -- --   -- --   -- --   -- --
	' B0-A       |     | |     | |     | |     |
	' B1-B	
	' B2-C       |     | |     | |     | |     |
	' B3-D        -- --   -- --   -- --   -- --         MarkS
	' B4-E       |     | |     | |     | |     |
	' B5-F
	' B6-G       |     | |     | |     | |     |
	' B7-dp       -- --   -- -- o -- --   -- --   
	'
	'Display        1       2       3       4
	'Common anode  C.3     C.2     C.1     c.0
	
 SETFREQ M16
eeprom 0,(192,249,164,176,153,146,130,248,128,144,255)     'Display (0,1,2,3,4,5,6,7,8,9,blank)
 
	SYMBOL pushbutton    = PINC.6
	SYMBOL display1      = C.3     
	SYMBOL display2      = C.2
	SYMBOL display3      = C.1
	SYMBOL display4      = C.0
	SYMBOL output1       = A.0

	SYMBOL push          = B9
	SYMBOL mins          = B10
	SYMBOL secs          = B11
	SYMBOL number        = B12
	SYMBOL time          = W7 'b14,b15
Main:
let dirsb = %11111111
let dirsc = %10111111

Zero:
push=0                                               
SETTIMER T1S_16
TIMER = 0
time = 600                                      ' time = 10.00 mins (600 secs)

Start:

 mins=Time-timer/60                                               
 
 secs=Time-timer//60
                                                             
Stop1:
          
 number = 10 :  IF mins < 10 THEN dig1                                  'Display1 Zero blanking	
      LET number = mins DIG 1                                       
    Dig1:  READ number,pinsb :                   LOW display1 : PAUSE 1 : HIGH display1      
 
                IF mins < 1  THEN dig2                                  'Display2 Zero blanking
	LET number = mins DIG 0 	                                          
    Dig2:  READ number,pinsb : pinsb=pinsb-128 : LOW display2 : PAUSE 1 : HIGH display2  	
	
	LET number = secs DIG 1			
    Dig3:  READ number,pinsb :                   LOW display3 : PAUSE 1 : HIGH display3  
		
	LET number = secs DIG 0 	                                                              
    Dig4:  READ number,pinsb :                   LOW display4 : PAUSE 1 : HIGH display4  
    
      if pushbutton = 1 then selection 	          
 	           	                                                                                     
if mins=0 and secs=0 then zero                   'once .00 is reached  stops and resets to 10.00 mins 
                                        
on push goto zero,start,stop1 
                              
Selection:  
if pushbutton = 1  then selection
pause 100
push=push+1//3                                                
                                                                                                   
on push goto zero,start,stop1
 
Last edited:

marks

Senior Member
When power first turned on output A.0 goes high will display ( on )
when pushbutton pressed will start timer (180) minutes will count down.
Off when (0) is reached A.0 goes low and will display ( --)

To program new time hold button for 5 secs when in countdown mode
(9 ) hold on each digit (99 ) (999) ie 0-999 minutes can be programmed
it will then display and countdown from (999) until it turns off ( --)
new time will be saved in eeprom
power off then on to start again. (display 4 not used)

Code:
	'             -- --   -- --   -- --   -- --
	' B0-A       |     | |     | |     | |     |
	' B1-B	
	' B2-C       |     | |     | |     | |     |
	' B3-D        -- --   -- --   -- --   -- --         MarkS
	' B4-E       |     | |     | |     | |     |
	' B5-F
	' B6-G       |     | |     | |     | |     |
	' B7-dp       -- --   -- --   -- --   -- --   
	'
	'Display        1       2       3       4
	'Common anode  C.3     C.2     C.1     c.0
	
 SETFREQ M16
eeprom 0,(192,249,164,176,153,146,130,248,128,144,255)     'Display (0,1,2,3,4,5,6,7,8,9,blank)
eeprom 22,(180,0)                                          '180 minutes 
	SYMBOL pushbutton    = PINC.6
	SYMBOL display1      = C.3     
	SYMBOL display2      = C.2
	SYMBOL display3      = C.1
	SYMBOL display4      = C.0
	SYMBOL output1       = A.0
	
	SYMBOL number        = B8
	SYMBOL minutes       = W9
	SYMBOL recall        = W10 'b21,b22
	SYMBOL time          = W11 'b23,b24
	SYMBOL hold          = W12 'b25,b26
Main:
let dirsb = %11111111
let dirsc = %10111111

Auto:Do : HIGH display1 : HIGH display4
    LOW display2 : LET pinsb = 163 : PAUSE 1 : LET pinsb = 255 : PAUSE 1 : HIGH display2 ' Display o
    LOW display3 : LET pinsb = 171 : PAUSE 1 : LET pinsb = 255 : PAUSE 1 : HIGH display3 ' Display n
     HIGH output1
     loop until pushbutton = 1  
         
Start:
IF pushbutton = 1 then start 
SETTIMER T1S_16
TIMER = 0
read 22,word minutes                                 

Run1:hold = 0
Prog:
 time=minutes*60+59-timer/60                                               
          
 number = 10 :  IF time < 100 THEN dig1                                  'Display1 Zero blanking	
      LET number = time DIG 2                                       
    Dig1:  READ number,pinsb :                   LOW display1 : PAUSE 1 : HIGH display1      
 
                IF time < 10  THEN dig2                                  'Display2 Zero blanking
	LET number = time DIG 1 	                                          
    Dig2:  READ number,pinsb :                   LOW display2 : PAUSE 1 : HIGH display2  	
	
	LET number = time DIG 0			
    Dig3:  READ number,pinsb :                   LOW display3 : PAUSE 1 : HIGH display3  
		
	LET number = 10 	                                                              
    Dig4:  READ number,pinsb :                   LOW display4 : PAUSE 1 : HIGH display4 'Not used
     
      if time=0  then  finish
      if hold > 500 then mselect                                         ' Hold pushbutton to program
      if pushbutton = 1 then inc hold :endif goto prog 	          
 	         
  goto run1                                      

	
     mselect: IF pushbutton = 1 THEN mselect
             minutes = 0  
      mselec: hold = 0  	         
                  LET number = minutes DIG 2	                                          
              READ number,pinsb : LOW display1 : PAUSE 1 : HIGH display1            
           IF pushbutton=0 THEN mselec
                                                                    
       msele:low display1 : IF hold > 700 then mslect                    
              INC hold  :  high display1
            IF pushbutton = 1 THEN msele
      
         minutes = minutes + 100                                        
       IF number = 9  THEN  mselect                              
      GOTO mselec
      
      
                    mslect:let recall = minutes high display1 :IF pushbutton = 1 THEN mslect
                                
                     mslec:hold = 0                                  
                            LET number = minutes DIG 2	            
                        READ number,pinsb  : LOW display1 : PAUSE 1 : HIGH display1  
          
                            LET number = recall  DIG 1 			
                        READ number,pinsb  : LOW display2 : PAUSE 1 : HIGH display2        
                     IF pushbutton=0 THEN mslec
                                                                
                      msle:low display2 : IF hold > 700 then mmselect          
                             INC hold  :  high display2
                           IF pushbutton = 1 THEN msle   
                       recall = recall + 10
                    IF number = 9  THEN  mslect                              
                   GOTO mslec
                   
 	
    mmselect: let minutes = recall : HIGH display2 : IF pushbutton = 1 THEN mmselect
                
     mmselec: hold = 0
                  LET number = minutes DIG 2	                                          
              READ number,pinsb  : LOW display1 : PAUSE 1 : HIGH display1  
          
                  LET number = minutes DIG 1 			
              READ number,pinsb  : LOW display2 : PAUSE 1 : HIGH display2        
            	         
                  LET number = minutes DIG 0	                                          
              READ number,pinsb  : LOW display3 : PAUSE 1 : HIGH display3            
           IF pushbutton=0 THEN mmselec
                                                                    
      mmsele:low display3 : IF hold > 700 then program                     
              INC hold  :  high display3
            IF pushbutton = 1 THEN mmsele
      
        INC minutes                                            
      IF number = 9  THEN mmselect                              
     GOTO mmselec
  
  program:high display3 : write 22, word minutes : goto start            ' write minutes to eeprom
  
  Finish: Low output1 : pinsb= 191 : LOW Display2,Display3                   ' Off Display --
 
Last edited:
Hello Marks. Thanks for the circuit and code.

I'm wondering if this code can be used with the 20x2 4 digit clock/temp circuit.

Main difference is the use of BC557 transistor in the clock circuit versus
2N3906 in the countdown circuit.

Forgive me, I'm not that familiar with transisitor specifications.

Thanks,
 

marks

Senior Member
Hi Aviatorbjai ,
that will work no worries most project examples basically the same hardware
bc557 was all i had at the time in later drawings no use 2n3904 and 2n3906
makes little or no difference
 

dbarry722

Member
Hi Marks.

Just looking at your circuit. Am I right in saying that your seven segment displays are 'Common Anode'?

If so, what changes would I need to use 'Common Cathode' 7 segment displays as sold by 'Techsupplies'

Many thanks

Declan
 

marks

Senior Member
Hi dbarry722,
yes thats correct i only use Common Anode ,i dont have any common cathode displays.
Ive reworked the code and drawing from post 1 hopefully this is correct LOL!

Code:
	'             -- --   -- --   -- --   -- --
	' B0-A       |     | |     | |     | |     |
	' B1-B	
	' B2-C       |     | |     | |     | |     |
	' B3-D        -- --   -- --   -- --   -- --         MarkS
	' B4-E       |     | |     | |     | |     |
	' B5-F
	' B6-G       |     | |     | |     | |     |
	' B7-dp       -- --   -- -- o -- --   -- --   
	'
	'Display        1       2       3       4
    'Common Cathode   C.3     C.2     C.1     c.0
	
 SETFREQ M16

eeprom 0,( 63,  6, 91, 79,102,109,125,  7,127,111,  0)     'Display (0,1,2,3,4,5,6,7,8,9,blank) 
	SYMBOL pushbutton    = PINC.6
	SYMBOL display1      = C.3     
	SYMBOL display2      = C.2
	SYMBOL display3      = C.1
	SYMBOL display4      = C.0
	SYMBOL output1       = A.0

	SYMBOL push          = B9
	SYMBOL mins          = B10
	SYMBOL secs          = B11
	SYMBOL number        = B12
	SYMBOL time          = W7 'b14,b15
Main:
let dirsb = %11111111
let dirsc = %10111111

Zero: push=0
SETTIMER T1S_16
TIMER = 0
time = 600                                      ' time = 10.00 mins (600 secs)

Start:

 mins=Time-timer/60                                               
 
 secs=Time-timer//60
                                                             
Stop1:
          
 number = 10 :  IF mins < 10 THEN dig1                                  'Display1 Zero blanking	
      LET number = mins DIG 1                                       
    Dig1:  READ number,pinsb :                   HIGH display1 : PAUSE 1 : LOW display1      
 
                IF mins < 1  THEN dig2                                  'Display2 Zero blanking
	LET number = mins DIG 0 	                                          
    Dig2:  READ number,pinsb : pinsb=pinsb+128 : HIGH display2 : PAUSE 1 : LOW display2  	
	
	LET number = secs DIG 1			
    Dig3:  READ number,pinsb :                   HIGH display3 : PAUSE 1 : LOW display3  
		
	LET number = secs DIG 0 	                                                              
    Dig4:  READ number,pinsb :                   HIGH display4 : PAUSE 1 : LOW display4  
    
      if pushbutton = 1 then selection 	          
 	           	                                                                                     
if mins=0 and secs=0 then zero                   'once .00 is reached  stops and resets to 10.00 mins 
                                        
on push goto zero,start,stop1 
                              
Selection:
  inc push :pause 1000
 if pushbutton = 1  then selection                                       
 on push goto zero,start,stop1
 if push > 2 then zero
 

Attachments

Last edited:

dbarry722

Member
Hi Marks.

Cheers for that. Will give it a go tomorrow. Are the transistors critical. I think I only have BC109's & BCX38C transistors but I suppose a quick trip up to maplins will fix that.

Declan
 

dbarry722

Member
Hi dbarry722,
yes thats correct i only use Common Anode ,i dont have any common cathode displays.
Ive reworked the code and drawing from post 1 hopefully this is correct LOL!

Code:
	'             -- --   -- --   -- --   -- --
	' B0-A       |     | |     | |     | |     |
	' B1-B	
	' B2-C       |     | |     | |     | |     |
	' B3-D        -- --   -- --   -- --   -- --         MarkS
	' B4-E       |     | |     | |     | |     |
	' B5-F
	' B6-G       |     | |     | |     | |     |
	' B7-dp       -- --   -- -- o -- --   -- --   
	'
	'Display        1       2       3       4
    'Common Cathode   C.3     C.2     C.1     c.0
	
 SETFREQ M16

eeprom 0,( 63,  6, 91, 79,102,109,125,  7,127,111,  0)     'Display (0,1,2,3,4,5,6,7,8,9,blank) 
	SYMBOL pushbutton    = PINC.6
	SYMBOL display1      = C.3     
	SYMBOL display2      = C.2
	SYMBOL display3      = C.1
	SYMBOL display4      = C.0
	SYMBOL output1       = A.0

	SYMBOL push          = B9
	SYMBOL mins          = B10
	SYMBOL secs          = B11
	SYMBOL number        = B12
	SYMBOL time          = W7 'b14,b15
Main:
let dirsb = %11111111
let dirsc = %10111111

Zero: push=0
SETTIMER T1S_16
TIMER = 0
time = 600                                      ' time = 10.00 mins (600 secs)

Start:

 mins=Time-timer/60                                               
 
 secs=Time-timer//60
                                                             
Stop1:
          
 number = 10 :  IF mins < 10 THEN dig1                                  'Display1 Zero blanking	
      LET number = mins DIG 1                                       
    Dig1:  READ number,pinsb :                   HIGH display1 : PAUSE 1 : LOW display1      
 
                IF mins < 1  THEN dig2                                  'Display2 Zero blanking
	LET number = mins DIG 0 	                                          
    Dig2:  READ number,pinsb : pinsb=pinsb+128 : HIGH display2 : PAUSE 1 : LOW display2  	
	
	LET number = secs DIG 1			
    Dig3:  READ number,pinsb :                   HIGH display3 : PAUSE 1 : LOW display3  
		
	LET number = secs DIG 0 	                                                              
    Dig4:  READ number,pinsb :                   HIGH display4 : PAUSE 1 : LOW display4  
    
      if pushbutton = 1 then selection 	          
 	           	                                                                                     
if mins=0 and secs=0 then zero                   'once .00 is reached  stops and resets to 10.00 mins 
                                        
on push goto zero,start,stop1 
                              
Selection:
  inc push :pause 1000
 if pushbutton = 1  then selection                                       
 on push goto zero,start,stop1
 if push > 2 then zero
Cheers Marks.

Circuit Works fine. (after I put the correct 7 segment displays in :rolleyes: )

Have been able to change timing to suit what I wish (15 Mins). the only thing I don't really need is the 'pause' bit when the button is pressed. How would I take that out?

I'm also going to attempt to integrate a piezo buzzer into the circuit to give the crew a bit of audio when counter reaches zero. Might have to alter the code not to go back to initial start value.

On my 20x2 board from Techsupplies, the A.0 tap-off is a bit fiddly to get a wire connected to it for the piezo so will probably make up a new purpose built board.

Many thanks

Declan
 

marks

Senior Member
Hi dbarry722,
I'm not familiar with the board from techsupplies perhaps use say c.7 as an output.

Not exactly sure what you after lol!
its always up to your imagination how you want things to work.

Here's another example
Starts in standbymode with decimalpoint1 flashing output1 low
hold the button for 3 seconds it
displays on and countsdown from 15 mins
you can return to standbymode at any time just hold button for 3 secs.

When zero is reached output1 is high and zero's will flash
it will time out after 60 seconds and return to standbymode or
if we push the button too cancel will countdown again.
hope you give it a try!
Code:
	'             -- --   -- --   -- --   -- --
	' B0-A       |     | |     | |     | |     |
	' B1-B	
	' B2-C       |     | |     | |     | |     |
	' B3-D        -- --   -- --   -- --   -- --         MarkS
	' B4-E       |     | |     | |     | |     |
	' B5-F
	' B6-G       |     | |     | |     | |     |
	' B7-dp       -- --   -- -- o -- --   -- --   
	'
	'Display        1       2       3       4
    'Common Cathode  C.3     C.2     C.1     c.0
	
 SETFREQ M16

EEPROM 0,(63,6,91,79,102,109,125,7,127,111,0)     'Display (0,1,2,3,4,5,6,7,8,9,blank) 
	SYMBOL pushbutton    = PINC.6
	SYMBOL display1      = C.3     
	SYMBOL display2      = C.2
	SYMBOL display3      = C.1
	SYMBOL display4      = C.0
	SYMBOL output1       = C.7

	SYMBOL mins          = B10
	SYMBOL secs          = B11
	SYMBOL number        = B12
	SYMBOL time          = W7 'b14,b15
	SYMBOL push          = W8 'b16,b17
Main:
LET dirsb = %11111111
LET dirsc = %10111111

Standbymode:
Low output1
push = 0

Standby:
LOW display1 : PAUSE 1500 
IF push > 3 THEN Displayon 
IF pushbutton = 1 THEN INC push : ENDIF 
pinsb = 128 : HIGH  display1 : PAUSE 50             'Standby (Flash decimal point)                         
GOTO Standby

DisplayOn:
FOR  push = 1 to 200
pinsb = 92 : HIGH display2 : PAUSE 1 : LOW display2 : PAUSE 1
pinsb = 84 : HIGH display3 : PAUSE 1 : LOW display3 : PAUSE 1 
NEXT push

Zero: 
Low output1

SETTIMER T1S_16
TIMER = 0
time = 900                                        'time = 15.00 mins (900 secs)

Start:
IF pushbutton = 0 THEN : push=0: ENDIF
 mins = Time - timer / 60                                                
 secs = Time - timer // 60
          
 number = 10 :  IF mins < 10 THEN dig1            'Display1 Zero blanking	
      LET number = mins DIG 1                                       
    Dig1:  READ number,pinsb :                   HIGH display1 : PAUSE 1 : LOW display1      
 
                IF mins < 1  THEN dig2            'Display2 Zero blanking
	LET number = mins DIG 0 	                                          
    Dig2:  READ number,pinsb : pinsb=pinsb+128 : HIGH display2 : PAUSE 1 : LOW display2  	
	
	LET number = secs DIG 1			
    Dig3:  READ number,pinsb :                   HIGH display3 : PAUSE 1 : LOW display3  
		
	LET number = secs DIG 0 	                                                              
    Dig4:  READ number,pinsb :                   HIGH display4 : PAUSE 1 : LOW display4  
     	           	                                                                                     
IF mins = 0 AND secs = 0 THEN Alarm                    
IF push > 300 THEN Standbymode
IF pushbutton = 1 THEN INC push : ENDIF
 GOTO start
                                        
Alarm:
HIGH output1
TIMER = 0

Alarm1: 
 pinsb = 63                                       'Flash zero's                            
HIGH display1 : PAUSE 30 : LOW display1 
HIGH display2 : PAUSE 30 : LOW display2 
HIGH display3 : PAUSE 30 : LOW display3 
HIGH display4 : PAUSE 30 : LOW display4 
IF timer > 60 THEN Standbymode                    'Alarmtime  60 seconds
IF pushbutton = 1 THEN Zero                       'Startcountdown
PAUSE 300 
GOTO Alarm1
 
Last edited:

dbarry722

Member
Hi dbarry722,
I think NPN BC109's would be fine to use to drive common cathode displays.
Counter appears to be working fine but one small issue I'm having is that the 7 segment displays are not bright. Reducing the 100 ohm resistors made no difference. neither did reducing the 1k resistor to base of NPN transistors (actually BC108's - not BC109's).

Could it be that the transistors are not sinking enough for the 7 segment displays?

I'm working down the code to understand how things operate but could you explain what 'DIG 1' and 'DIG 0' are (or doing). I understand dig1, dig2 etc.

Declan
 
Last edited:

MPep

Senior Member
Have you measured the voltage across Collector and Emitter when the LED is ON? Should be about 100mV or so, if conducting fully.
Also, Base to Emitter voltage? Should be about 700mV.

The BC109 has higher gain than a BC108. Both should be suitable for the job at hand though.
 

marks

Senior Member
Hi dbarry722,
There are many others better able to comment I guess its my thread so will have to try lol!

If displays are extremely dull it could be that your transistors are connected around the wrong way
try turning around swapping the emiter and colector it still works just has little gain when reversed.

Unfortunately with different types of displays different results will be achieved
selecting high intensity leds (Brighter ones's are becoming much more popular to use.)
I'm still a novice too maybe ive been lucky with my selection lol.

A Bit about the code lol!
*Each display is turned ON for a period of a PAUSE1 and OFF for other code,
having the same time should give each display similiar brightness.
*Example if our seconds = 59
our number DIG1 will equal 5 and
our number DIG0 will equal 9

Things we can try.
*Increase supply to 5.5volts
*Seperate supply for our picaxe and a higher supply for our display if necessary.
*Recode our program to give more On time (hopefully this works for you give the new code a try lol!)
-*-note when making major changes best to check our picaxe remains within our operating current usually about 90ma

Now our other code becomes part of the On time
this does make the code a bit harder to follow .
this option sometimes makes it hard to keep display brightness uniform
we can also finetune and use pauseus 100 and vary value slightly
Now we have more On time we could also try reducing the 100 ohm resistors .
Also added Stop to the code .
hopefully this will be helpfull!! LOL
Code:
	'             -- --   -- --   -- --   -- --
	' B0-A       |     | |     | |     | |     |
	' B1-B	
	' B2-C       |     | |     | |     | |     |
	' B3-D        -- --   -- --   -- --   -- --         MarkS
	' B4-E       |     | |     | |     | |     |
	' B5-F
	' B6-G       |     | |     | |     | |     |
	' B7-dp       -- --   -- -- o -- --   -- --   
	'
	'Display        1       2       3       4
    'Common Cathode  C.3     C.2     C.1     c.0
	
 SETFREQ M16

EEPROM 0,(63,6,91,79,102,109,125,7,127,111,0)     'Display (0,1,2,3,4,5,6,7,8,9,blank) 
	SYMBOL pushbutton    = PINC.6
	SYMBOL display1      = C.3     
	SYMBOL display2      = C.2
	SYMBOL display3      = C.1
	SYMBOL display4      = C.0
	SYMBOL output1       = C.7

	SYMBOL mins          = B10
	SYMBOL secs          = B11
	SYMBOL number        = B12
	SYMBOL time          = W7 'b14,b15
	SYMBOL push          = W8 'b16,b17
Main:
SETTIMER T1S_16
LET dirsb = %11111111
LET dirsc = %10111111

Standbymode:
LOW display3
Low output1
push = 0
pinsb = 128                                      'decimalpoint
Standby:
PAUSE 1500 
HIGH  display1 : PAUSE 50                        'Flash decimal point
IF pushbutton = 1 THEN INC push : ENDIF 
LOW display1
IF push > 2 THEN Displayon                           
GOTO Standby

DisplayOn:
FOR  push = 1 to 300                               'displayontime
pinsb = 92 : HIGH display2 : PAUSE 1 : LOW display2'o 
pinsb = 84 : HIGH display3 : PAUSE 1 : LOW display3'n 
NEXT push

Zero: 
Low output1
PAUSE 500
time = 900                                        'time = 15.00 mins (900 secs)
TIMER = 0                                         'reset to  0
Start:
 mins = Time - TIMER / 60                                                
           
 number = 10 :  IF mins < 10 THEN dig1            'Display1 Zero blanking	
      LET number = mins DIG 1                                       
    Dig1: LOW display4                         : READ number,pinsb : HIGH display1 : PAUSEus 100      
  
 secs = Time - TIMER // 60
  
                IF mins < 1  THEN dig2            'Display2 Zero blanking
	LET number = mins DIG 0 	                                          
    Dig2: LOW display1                         : READ number,pinsb : pinsb = pinsb + 128 : HIGH display2 : PAUSEus 100   	

IF pushbutton = 0 THEN : push=0: ENDIF
IF mins = 0 AND secs = 0 THEN Alarm 
	
	LET number = secs DIG 1			
    Dig3: LOW display2                         : READ number,pinsb : HIGH display3 : PAUSEus 100   

IF push > 300 THEN Standbymode
IF pushbutton = 1 THEN INC push : ENDIF
		
	LET number = secs DIG 0 	                                                              
    Dig4: LOW display3                         : READ number,pinsb : HIGH display4 : PAUSEus 100    
 GOTO start
                                        
Alarm:
LOW display2
HIGH output1
TIMER = 0
pinsb = 63                                        'zero
Alarm1:                                           'Flash zero's                            
HIGH display1 : PAUSE 30 : LOW display1 
HIGH display2 : PAUSE 30 : LOW display2 
HIGH display3 : PAUSE 30 : LOW display3 
HIGH display4 : PAUSE 30 : LOW display4
PAUSE 300  
IF timer > 60 THEN Standbymode                    'Alarmtime  60 seconds
IF pushbutton = 1 THEN STOP1                      'Change to THEN ZERO to remove Stop function.
GOTO Alarm1

Stop1:
Low output1
IF pushbutton = 1 THEN STOP1 
Stop2:
HIGH display1,display2,display3,display4
PAUSE 1
LOW  display1,display2,display3,display4
IF pushbutton = 1 THEN Zero                       'Startcountdown again
PAUSE 2
GOTO Stop2
 
Last edited:

dbarry722

Member
Hi dbarry722,
There are many others better able to comment I guess its my thread so will have to try
*Example if our seconds = 59
our number DIG1 will equal 5 and
our number DIG0 will equal 9

[/code]
Ahhh!! See now what DIG1 & DIG0 do. I'll measure the voltages on the transistors later and see how that progresses.

Other than the brightness, everything appears to be working fine. Incidentally, where did the command 'DIG' come from? Didn't see it in the list of command.

Declan
 
Last edited:

sodeaf

Senior Member
Hey Marks.. I Must say.. Nice work.. I have read over all your different clock displays.. and this one if very nice.. Although I still don't understand it all 100%... but I am getting there.. I am in the process of building something similar.. and I have learned 100 new tricks.. after reading your posts.. Thanks a million.. us newbies really appreciate it.. It you didn't share.. we wouldn't learn..

I seem to learn better by studying someone Else's code and figuring it out from there.. The manuals help with explanation of commands and such.. but I would be no where if it wasn't for you guys posting your code and ideas.. not to mention answering all my basic questions.. haha no pun intended..

Thanks

I look forward to reading more..
 

dbarry722

Member
Hi folks

Just looking at the possibility of adding an additional section to the counter which works well at moment. Rather than building multiple units with different times, is there a way of adding some form of hex unit to allow a user to 'program' required countdown time.

Declan
 

marks

Senior Member
Hi dbarry722,
i think ones imagination can be endless to how we want things to work.
post #4 of this thread
has a timer project preset to 180 minutes we can
enter a new time between 0 - 999 minutes which can be saved in EEprom.
 
Top