Time Clock DS1307

Armagon

Member
Dear All:

I like to show a clock in a LCD using a Serial Real Time Clock DS1307 in 2 different lines, line 1 : HH:MM:SS (24H format) and second line DD:MM:YY, but I don?t now how to program my picAXE18X?

________
girlfriends pics
 
Last edited:

hippy

Ex-Staff (retired)
You have six separate issues to solve, in this order generally -

1) Designing and building the hardware for DS1307 and LCD interface.
2) Reading the DS1307.
3) Writing to the LCD.
4) Converting DS1307 readings to meaningful data.
5) Displaying that meaningful data as required.
6) Setting initial time and date on the DS1307.

The PICAXE Manuals describe most and probably all of this, as do previous Forum posts ( Search is top right of the page ), and there are also links to pages through Google which will provide more information on the various aspects involved.

Take the project one step at a time, get each part working and tested separately, then integrate all the parts together. You may have to back-track occasionally, but that is all part of the learning experience and nothing to be worried about.
 

Armagon

Member
Dear Sir:

Thanks for your help, I just read the manual and I solved all except point 4, how read the information from DS1307 format and display in LCD, I use the command readi2c, and serout to display the reading but only garbage?s show, but noting, how transform the reading from DS1307 and show HH:MM:SS and DD:MM:YY

(I used the wizard of data logger (Program Editor) to set actual time into DS1307)

________
weed vaporizer
 
Last edited:

hippy

Ex-Staff (retired)
Well done, and quick work. The data from the DS1307 I believes comes back as BCD digits packed two to a byte. The command you'll be wanting to look at is "BCDTOASCII"; this will convert the two BCD digits of hours, minutes, seconds and so on to two individual digits which can then be displayed on the CD.
 

Armagon

Member
What do you think about ths program:

main:

label_1:

i2cslave %11010000, i2cslow, i2cbyte
readi2c 0,(b0,b1,b2,b3,b4,b5,b6)

main: inc b1
bcdtoascii b0,b1,b2,b3,b4,b5,b6

serout 6,N2400,(254,1)
pause 30

serout 6,N2400(254,128,"H",#b0," ")
serout 6,N2400(254,131,"M",#b1," ")
serout 6,N2400(254,134,"S",#b2," ")
serout 6,N2400(254,192,"D",#b4," ")
serout 6,N2400(254,195,"M",#b5," ")
serout 6,N2400(254,198,"Y",#b6," ")

goto label_1
 

Armagon

Member
ERRATUM

What do you think about ths program:

main:

label_1:

i2cslave %11010000, i2cslow, i2cbyte
readi2c 0,(b0,b1,b2,b3,b4,b5,b6)

bcdtoascii b0,b1,b2,b3,b4,b5,b6

serout 6,N2400,(254,1)
pause 30

serout 6,N2400(254,128,"H",#b0," ")
serout 6,N2400(254,131,"M",#b1," ")
serout 6,N2400(254,134,"S",#b2," ")
serout 6,N2400(254,192,"D",#b4," ")
serout 6,N2400(254,195,"M",#b5," ")
serout 6,N2400(254,198,"Y",#b6," ")

goto label_1
 

Technical

Technical Support
Staff member
You need to do convert each byte individually e.g.

bcdtoascii b1,b10,b11,b12
serout 6,N2400(254,128,"H",b11,b12," ")

bcdtoascii b2,b10,b11,b12
serout 6,N2400(254,128,"M",b11,b12," ")

etc.
 

hippy

Ex-Staff (retired)
Your BCDTOASCII is overwriting the bytes read using READI2C. This is untested code, but you are probably looking for something more like this ...<code><pre><font size=2 face='Courier'>readi2c 0,(b0,b1,b2,b3,b4,b5,b6)
serout 6,N2400,(254,1)
pause 30
bcdtoascii b0, b12,b13 : serout 6,N2400,(b12,b13,&quot;:&quot;)
bcdtoascii b1, b12,b13 : serout 6,N2400,(b12,b13,&quot;:&quot;)
bcdtoascii b2, b12,b13 : serout 6,N2400,(b12,b13,&quot; &quot;)
bcdtoascii b3, b12,b13 : serout 6,N2400,(b12,b13,&quot;/&quot;)
bcdtoascii b4, b12,b13 : serout 6,N2400,(b12,b13,&quot;/&quot;)
bcdtoascii b5, b12,b13 : serout 6,N2400,(b12,b13)) </font></pre></code> You may have to re-order the outputs; I'm not familiar with using the DS1307.
 
G

Guest

Guest
Dear All:

The program work excellent:

main:

label_1:

serout 6,N2400,(254,1)
pause 30
readi2c 0,(b0,b1,b2,b3,b4,b5,b6)
bcdtoascii b2, b12,b13 : serout 6,N2400,(b12,b13,&quot;:&quot;)
bcdtoascii b1, b12,b13 : serout 6,N2400,(b12,b13,&quot;:&quot;)
bcdtoascii b0, b12,b13 : serout 6,N2400,(b12,b13,254,192)
bcdtoascii b4, b12,b13 : serout 6,N2400,(b12,b13,&quot;/&quot;)
bcdtoascii b5, b12,b13 : serout 6,N2400,(b12,b13,&quot;/&quot;)
bcdtoascii b6, b12,b13 : serout 6,N2400,(b12,b13,254,144)

bcdtoascii b3, b12,b13 : serout 6,N2400,(b12,b13)

pause 960

goto label_1

Now, the LCD display in line 1, HH:MM:SS and the second line DD/MM/YY but in the line 3 the day, but only with a single number 1,2,3 for Sunday, Monday etc, how can I do to change this number for the day name
1 change to Sunday
2 change to Monday
3 &#8230;&#8230;&#8230;&#8230;etc

Thanks
 

Technical

Technical Support
Staff member
If you have already changed your day of week variable (e.g. b8) to an ascii character you can do something like this

Select case b8
case &quot;1&quot;
serout 6,N2400,(&quot;Sun&quot;)
case &quot;2&quot;
serout 6,N2400,(&quot;Mon&quot;)
case &quot;3&quot;
serout 6,N2400,(&quot;Tues&quot;)
etc.
end select
serout 6,N2400,(&quot;day&quot;)

 

Armagon

Member
Dear All:

the program run OK now, but when I disconnect the power, and wait 5 minutes, the LCD diplay ??:??:??, ??/??/??, the button cell bat. 3V is conected and OK, why the RCT can not retain the information
________
silver surfer vaporizer
 
Last edited:

Ralpht

New Member
I have never used one but, I'd hazard a guess that you will need a backup battery to keep the memory alive on the DS1307. One or two of those button cells in a suitable holder along with the apprpriate steering circutry will probabaly do the trick.

 
 

Ralpht

New Member
I just re-read your post and noticed you are using a backup battery. Is the battery alive or dead?. Is it correctly wired so when the main supply goes off the battery instantly takes over. The battery should not be directly connected to the higher supply of the picaxe but through a steering diode to isolate it. In fact double check the datasheets of the DS1307 to ensure the battery is connected correctly according to the chips requirements. Even the slightest interruption will cause the memory to forget it's data.

 
 

craigcurtin

Senior Member
I can confirm that i have use the DS1307 with the CR2032 Lithium &quot;button&quot;batteries on a number of occasions and it definitely retains the data.

I can also confirm i use the AXE033 LCD module (in Serial mode) and the battery backup works fine. So i think you have a connection issue (or a dead CR2032)

Can i ask why you are using the LCD in I2C mode rather than just serial which is much easier ?

Craig
 

Armagon

Member
Dear Craig: about you question ?Can I ask why you are using the LCD in I2C mode rather than just serial which is much easier? really I don?t know why, I am learning, but if you can teach me how, I will be glad ?
________
easy vape vaporizer
 
Last edited:
Top