Binary clock problems

LED Maestro

Senior Member
Hi. A while ago i sucessfully built a binary clock using the DS1307 RTC and a pic 28X2. One problem I had whilst compiling the code to run the display is that the seconds, hours and minutes would come on at the same time. I managed to solve this and got the clock working. Now, about 4 months later, I am having the same problem. the seconds work on their own but as soon as i introduce the minutes and hours, it goes to pot. I have included the code and a video to help explain.

Code:
#Picaxe 28x2

symbol secs	= b0
symbol mins	= b1
symbol hour	= b2
symbol control = b7

let dirsb = %01111111

	i2cslave %11010000, i2cslow,i2cbyte	
	
	let secs = bcdtobin secs
	let mins = bcdtobin mins
	let hour = bcdtobin hour				
	
main:
	
	readi2c 0, (secs,mins,hour)
	
	seconds:
      high c.0
	let pinsb = secs
	;switch on secs
	low c.0
	let pinsb = control

	goto main

      minutes:
	high c.1
	let pinsb = mins
	;switch off secs, switch on mins
	low c.1
	let pinsb = control

	

	hours:
	high c.2
	let pinsb = hour
	;switch off mins, switch on hour
	low c.2
	let pinsb = control
	
	goto main
http://www.youtube.com/watch?v=F2q0kriN2fo
 

rossko57

Senior Member
Areas you might think about;
What is the state of the C.x pins at start up?
The Seconds: routine returns to main: - can the code ever get to minutes: or hours:?
The seconds:-to-main: loop is quite tight, C.0 will be toggling on and off very fast - is that a problem for anything to keep up with?
 

LED Maestro

Senior Member
Whoops, sorry i left the goto main bit after the seconds after testing. that is not part of my main code. I will have a look into the state of the pins. thanks
 

StigOfTheDump

Senior Member
Would the

let secs = bcdtobin secs
let mins = bcdtobin mins
let hour = bcdtobin hour

not need to be in the main section after read i2c?

I used serout to an OLED in the simulator and was getting #secs and #mins values larger than 59.
 

hippy

Technical Support
Staff member
high c.0
let pinsb = secs
low c.0
let pinsb = control
Is it simply that this is 'poor quality' multiplexing, everything changing so fast that it all becomes a blur ?

Perhaps try adding some "Pause" after the "Let pinsB=" commands.

It's hard to tell what the code should be doing without a hardware description, impossible to guess what "Let pinsB=control" is meant to achieve.
 

techElder

Well-known member
OT: Sorry

Isn't a binary clock (other than the technical aspects of education, etc.) kind of like a skydiver jumping out of a perfectly working airplane? Why? :D
 

LED Maestro

Senior Member
You see, I thought the bcdtobin had to be in the main code too but it worked fine outside of it. Nevertheless I have fiddled about with the multiplex and added some pauses which seems to have done the trick, thanks hippy. As for what the control does, I honestly don't know, I just took the sample code from the picaxe website and expounded on that.
 

LED Maestro

Senior Member
As a side note, and forgive me if this needs to be in a new thread. I'm eventually wanting to connect my 28x2 to 3 max7221 IC's. I understand the max has 3 I/P, mosi, CS and CLK. My question is are there dedicated O/P pins on the picaxe or can I just designate pins in the code, for example

Symbol mosi = B0
Symbol CS = B1
Symbol CLK = B2

Etc.
 

Paix

Senior Member
As a side note, my question is, can we have a data sheet for the MAX7221 to save half a dozen guys having to go look for one?

Without knowing quite what a MAX7221 is at this point in time, a few words about it and your goal would help jog memories for those that might have done something similar and inspire those that haven't.

Not sure what mosi is?
 

Buzby

Senior Member
... Not sure what mosi is?
MOSI = 'Master Out Slave In', which is what some circuit boards have written on, supposedly to make joining the ins and outs between Slave and Master easier to connect.
 

Paix

Senior Member
Thanks Busby. The MAX7221 datasheet referred to mosi just once on a diagram. I will have to start putting it on my boards to make life easier for me . . . :)
Google was dead helpful, with more than a slack handful of varied suggestions.
MAX7221 is MAX7219 using SPI instead of serial comms. MOSI MISO, ah, that would be TX(out) and RX(in) then.
 

LED Maestro

Senior Member
Thanks e. However, having just spent the past hour and a half looking through those results, I honestly haven't gained much insight into comms between 28x2 and the max. My apologies to all for not being clear in my intentions. I am building an LED clock, using 132 LED's (12 for the hours and 60 each for the minutes and seconds). I don't have a problem setting up the O/P's from the max's to all the LED's. I am using a DS1307 RTC module to provide the time data via SDA and SCL to the 28x2 which is working. What I am having trouble with is how to setup comms between the pic and the max. Am I right in thinking I can use any pin as the mosi, clock and load data lines?
My thanks for all your help so far :)
 
Top