Pic 18x and BCD 4511 clock

rabag

New Member
hi,

Thanks for your help guys, but I still have a problem with getting time to run fast without it being 10 or 20 minutes fast. If anyone could help me to get this program to run slightly fast over 24 hours so that I can use a pause to get accurate time. Or if anyone has an idea of getting a picaxe 18x working with a BCD 4511 chip to read a more accurate time than I have. Here is my program. Thanks once again for your help, very much appreciated.

main:
let b0= 31 ' %00011111
let b1= 47 ' %00101111
let b2= 79 ' %01001111
let b3= 143 ' %10001111
label_3A: for b6= 1 to 75
for b5= 1 to 75
pause 2
let pins =b3
let pins =b0
let pins =b1
let pins =b2
let pins =b1
let pins =b2
let pins =b3
let pins =b0
let pins =b2
let pins =b3
let pins =b0
let pins =b1
let pins =b3
let pins =b2
let pins =b0
let pins =b1
let pins =b0
let pins =b2
let pins =b1
next b5
next b6
label_14: if b0= 22 then label_41
let b0=b0- 1
'pause 1000
goto label_3A

label_41: let b0= 31
if b1= 42 then label_51
let b1= b1-1
'pause 1000
goto label_3A

label_51: let b1= 47
if b2= 70 then label_52
let b2= b2-1
if b2= 75 then label_100
'pause 1000
goto label_3A

label_52: let b2= 79
if b3= 141 then label_53
let b3= b3-1
'pause 1000
goto label_3A


label_53: goto main:

label_100: if b3= 141 then main
goto label_3A
 

BCJKiwi

Senior Member
It would have been more helpful to continue your previous thread rather than start a new one.

I see you have changed the size of the loops at label_3A and removed the pause referred to earlier.

Please explain exactly what is controlling the time loop.

It appears to be the nested loops writing continuously to the display module.

I would have thought (without studying the BCD 4511) that you would only need to write to the display once each time a digit needs to be changed and control the time independently of the display.

What was the result of the previous suggestion made?

Also a lot more documentation in the code beside each step - what it does, where its input is from etc, would help others to help you, and will help you when you need to come back to your code in the future.
 

MartinM57

Moderator
You really are going to have a problem building an accurate clock from just a Picaxe and a decoder chip - the PICAXE is just not designed to do that. The proper, and pretty easy, way is to use an external RTC (Real Time Clock) chip.

Continuing as you are will lead to to immense frustration - every time you change your code for whatever reason you will have to change the timing delay/catch up.

Search for DS1307 in this forum and PICAXE Manual 2 - there are plenty of examples.
 

papaof2

Senior Member
I did some experiments with an 18A a year or so back and got an accuracy of 4 minutes/day (about 10 seconds/hour) after several iterations of the timing loops.

Code here: http://www.picaxe.us/software-clock.html

First get all the processing and display code in a "final" format, then make small changes to the short timer loops to manage small time variations. Unless the power supply voltage and the ambient temperature are constant, the timing *will* change from day to day.

John
 
Top