Binary Clock

kevrus

New Member
This is nothing fancy, but I thought i'd post it anyway.

My youngest daughter gave me a picture frame for fathers day a couple of years ago and I never got around to putting a pic (no pun intended) in it, so, to put it to good use, and also to have my first attempt at using surface mount stuff, I decided to make a simple binary clock.

I'm using a 28x1 with a DS1338...only displaying hours, mins and secs (as I didn't want a calender), yellow 5mm flat top leds are used, these have a slightly lower profile and quite a wide viewing angle.

There is two buttons on board for setting the time plus the normal 'reset' button for the 28x.
The PCB material is biege in colour so the front of the clock is the 'non-track' side of the board.
Power comes from an old nokia phone charger.
 

Attachments

kevrus

New Member
Hi Boriz' spot on with the time.
Thanks for the link to the Romanblack clock. It's an excellent way of representing the time, extremely novel.
 

GrandFraganator

New Member
Hi, Just wondering do you have the Circuit diagram PCB layout and code needed to make this clock? I am thinking about making a Binary clock like yours. Thanks From GrandFraganator
 

kevrus

New Member
Hi GrandFraganator

Here's the code I used...usual disclaimer with all of my code...it could do with optimising and tidying up.

Code:
					#picaxe 28x1
'------------------------------------------------------------------------------'

		'first attempt at binary clock using ds1338 and 28x1
					'with multiplexed LEDs

'------------------------------------------------------------------------------'


main:
setfreq m8								'sets operating frequency at power-on
i2cslave %11010000, i2cfast_8, i2cbyte			'initiates and sets DS1307 slave address
i2cslave %11010000, i2cfast_8, i2cbyte			'initiates I2C for ds1307
let dirsc=%11100000						'sets pins 5,6,7 on port c for ouputs

write_time:
if pin2=1 then write_time			      	'loops until button released			
writei2c 0, (b0, b1, b2)					'writes the 'set' hrs,mins,secs into ds1307
low portc 5								'ensure port c o/p 5 is off
low portc 6								'ensure port c o/p 6 is off
low portc 7								'ensure port c o/p 7 is off

readtime:
if pin2=1 then hrs_set						'jump to routine for setting the time
readi2c 0, (b0, b1, b2)						'read secs,mins,hrs and store in variables

'------------------------------------------------------------------------------'
			'Convert BCD to BINARY and display results
'------------------------------------------------------------------------------'


let b6=bcdtobin b0 						'converts bcd secs to binary
low portc 5								'switches off 'hrs' LEDs
let pins=%00000000						'resets outputs to elliminate led blurring
high portc 7							'switches on 'secs' LEDs
let pins = b6							'turns on LEDs to display secs
pause 6								'delay to ensure even 'secs' brilliance 
let b6=bcdtobin b1 						'converts bcd mins to binary
low portc 7								'switches off 'secs' LEDs
let pins=%00000000						'resets outputs to elliminate led blurring
high portc 6 							'switches on 'mins' LEDs
let pins = b6							'turns on LEDs to display mins
pause 4								'delay to ensure even 'mins' brilliance
let b6=bcdtobin b2 						'converts bcd hrs to binary
low portc 6								'switches off 'mins' LEDs
let pins=%00000000						'resets outputs to elliminate led blurring
high portc 5							'switches on 'hrs' LEDs
let pins = b6							'turns on LEDs to display hrs
goto readtime

'------------------------------------------------------------------------------'
			'Routine for pre-setting the HOURS
'------------------------------------------------------------------------------'


hrs_set:
if pin2=1 then hrs_set						'loop until button6 is released
low portc 7								'switches off 'secs' LEDs
low portc 6								'switches off 'mins' LEDs
high portc 5							'switches on 'hrs' LEDs
b8=0									'resets b8(hrs) to zero for hrs setting		

hrs_inc:
if pin2=1 then mins_set						'jump to routine for setting the mins
if pin1=0 then hrs_inc						'loop until button7 is pressed

hrs_loop:
if pin2=1 then mins_set						'jump to routine for setting the mins
if pin1=1 then hrs_loop						'loop until button7 is released
b8=b8+1 			 					'increment hrs variable by 1
let pins=b8								'display hrs on leds in binary
if b8>24 then let b8=0						'resets b8 to zero
end if
let b2=bintobcd b8						'convert to bcd to load into b2 for RTC
if pin2=1 then mins_set						'jump to routine for setting the mins
pause 10
goto hrs_inc

'------------------------------------------------------------------------------'
			'Routine for pre-setting the MINUTES
'------------------------------------------------------------------------------'


mins_set:
if pin2=1 then mins_set						'loop until button6 is released
low portc 5								'switches off 'secs' LEDs
low portc 7								'switches off 'hrs' LEDs
high portc 6							'switches on 'mins' LEDs
b8=0									'resets b8(hrs) to zero for mins setting

mins_inc:
if pin2=1 then secs_set						'jump to routine for setting the secs
if pin1=0 then mins_inc						'loop until button7 is pressed

mins_loop:
if pin2=1 then secs_set						'jump to routine for setting the secs
if pin1=1 then mins_loop					'loop until button7 is released
b8=b8+1 			 					'increment mins variable by 1
let pins=b8								'display mins on leds in binary
if b8> 60 then let b8=0						'resets b8 to zero
end if
let b1=bintobcd b8						'convert to bcd to load into b1 for RTC
if pin2=1 then secs_set						'jump to routine for setting the secs
pause 10
goto mins_inc

'------------------------------------------------------------------------------'
			'routine for pre-setting the SECONDS
'------------------------------------------------------------------------------'


secs_set:
if pin2=1 then secs_set						'loop until button6 is released
low portc 5								'switches off 'mins' LEDs
low portc 6								'switches off 'hrs' LEDs
high portc 7							'switches on 'secs' LEDs
b8=0									'resets b8(hrs) to zero for secs setting

secs_inc:
if pin2=1 then write_time:					'goto write_time: routine for starting the clock
if pin1=0 then secs_inc						'loop until button7 is pressed

secs_loop:
if pin2=1 then write_time:					'goto write_time: routine for starting the clock
if pin1=1 then secs_loop					'loop until button7 is released
b8=b8+1 			 					'increment secs variable by 1
let pins=b8								'display hrs on leds in binary
if b8>60 then let b8=0						'resets b8 to zero
end if
let b0=bintobcd b8						'convert to bcd to load into b0 for RTC
if pin2=1 then write_time:					'goto write_time: routine for starting the clock
pause 10
goto secs_inc
The circuit was breadboarded with 'through-hole' components and then pcb designed for surface mount without a diagram...I have a nasty habit of doing this and relying on memory. Sure to bite me one day!!
I wil try to draw one out if you are stuck
 
Last edited:

QuIcK

Senior Member
i think i have to ask.
how do you solder your smd? silver glue/paste stuff & a heatgun? or are you extremely nifty with an iron?
i ask, cause ive never figured it out. i saw a tutorial of some guy frying a pcb in a pan (on a cooker, like bacon. without oil, tho) in order to solder smd
 

kevrus

New Member
This was my first attempt at surface (and only one to date!). My method was to tin the pads on the PCB and then hold the component with tweezers while quickly applying the iron...fiddly to say the least. The resistors were the hardest as they were the smallest...even harder to keep aligned with adjacent ones.
I didn't destroy anything with excessive heat but will explore other methods when the time arises.
 
Top