Setting time on AXE033 LCD with RTC

westaust55

Moderator
Hi all,

I have assembled the AXE033 LCD display and added the optional DS1307 RTC kit. I have a problem with the setting of the time :mad:.

I have tested the LCD side of the AXE033 in both Serial and i2c modes and that is working perectly okay :).

I have run a small program to set the date and time in the RTC (in serial mode) but am finding that if I set a date and time, then after a pause display the time, I always get the previous settings.

Note that the clock is being set in some matter as the data is available later and I do see the following message in the top row each time:
***Data 0 Set***


By way of explanation,
If I first set the RTC to 01/01/08 and time to 20:00 then a pprevious setting is displayed.

If I change the date to 01/02/08 and the time to 20:10 and rerun my program, then after a pause when I display the time I see 01/01/08 and time to 20:00.

Then if I change the date to 12/03/08 and the time to 20:20 and rerun my program, then after a pause when I display the time I see 01/02/08 and the time as 20:10.

If I run the program a second time without chnaging the date and time data then the desired values are then displayed.

Below is the program I have created:

main: pause 1000
serout 7, N2400, (254,1) ; clear the screen
pause 1000
serout 7, N2400, ("hello Westaust55")
pause 2000
; remove REMs to set time
; serout 7, N2400, (253,0,"12/03/08 20:24 ")
;
; pause 1000 ; I have tried values upto 10,000 here
serout 7, N2400, (0)
pause 1000
end


It is as if there is some kind of buffer holding the latest set of data so that the new data is held back from the RTC. Other than run the program twice to get the desired data into the RTC I am currently at a lost :confused:.

Any thoughts or comments would be appreciated.
 

BCJKiwi

Senior Member
Firstly the DS-1307 is an i2c device so the serout won't program the DS-1307.

The serout line is simply placing the date/time string in a buffer and then it is being read later as you describe.

See the i2c tutorial in the Rev-Ed documentation (Program Editor Help, Picaxe-18 datasheets, i2c Tutorial) for explanation and sample code,
or,
here for a working example;
http://www.picaxeforum.co.uk/showthread.php?t=8078
from the code snippets section of the forum.
 

westaust55

Moderator
Hi BJCKiwi,

What you are saying seems to be incorrect.

Granted the DS1307 is an I2C chip BUT the AXE033 has an interface chip on board. The text is too faint but seems it may be a PIC and would be capable of providing an I2C interface (its just PIC software to control a couple of I/O pins).

Using the Serial Input I CAN set the date and time. I just cannot read the time back, only display it directly to the LCD. The AXE033 manul/datasheet in section 3.0 has commands to set the date and time plus the alarm
It is JUST that there seems to be an unexplained buffer between the data I write from my PICAXE and the DS1307 chip.

If I write through the serial link twice the required date and time DOES go into the DS1307 RTC chip.

As some further tests to verify the above:

I turned off the AXE033 power, changed the mode to CLOCK and it now displays the correct time so it has to be writing from the serial input to the RTC (or where is the time coming from say 6 hours later to be correct).

I then entered a small program into my PICAXE only to use the serial link and not set but just display the time and the current date and time are shown in the bottom line of the LCD.

Hopefully some erudite person can provide me with a correction as to what I am doing wrong or why it is so.
 

tarzan

Senior Member
Which Mode? (serial or i2c)

From the manual:
Which Mode? (serial or i2c)

Most users will use the module in the default serial mode. The only reason to use it in i2c mode is if:
1) You are using a PICAXE-X chip and
2) You wish to read the time/data from the DS1307 clock upgrade directly into the PICAXE.
In all othe cases the serial mode should be used.
In i2c mode the LCD module acts as a ‘dumb’ i2c slave device. The clock and alarm functions are not available - all clock and alarm functions must be carried out by the PICAXE X part itself.

 

BeanieBots

Moderator
Hopefully some erudite person can provide me with a correction as to what I am doing wrong or why it is so.
You're not reading the manual!

BCJKiwi is correct, Tarzan has pointed out the relevant bit.
To set the time in the DS1307, you MUST talk to it with I2C.
Serial can only be used to 'print' characters on the screen.
Also, read up about the DS1307. You must send it BCD codes. Trying to send decimal values will give very unexpected results.


EDIT:-
You are indeed correct that it is possible to set the clock with serial.
Your code however only displays it once, then ends.
So, each time you run your code, you will see the setting made in the previous run. I think that matches what you describe.

What happens if you run the example code in manual?
eg.

main:
serout 7, N2400, (0)
pause 500
goto main
 
Last edited:

westaust55

Moderator
Delay when Setting time on AXE033 LCD with RTC

Firstly, thanks BeanieBots, for the confirmation that the RTC CAN be set in Serial mode.

I had (as per the note embedded in the code I inserted in my first post) tried delays of up to 10 seconds between setting the date and time and trying to display the data.
The example in the Revolution manual on the upper half of page 12 shows only a 1 second pause.


For some further testing, I amended my program to read:

main: pause 1000
serout 7, N2400, (254,1) ; clear the screen
pause 1000
serout 7, N2400, ("hello Westaust55")
pause 2000
; remove REMs to set time
serout 7, N2400, (253,0,"11/03/08 17:30 ")
pause 10000 ; YES a TOTAL of 10 seconds !!!
shwtim: for b0 = 32 to 80
serout 7, N2400, (254,1) ; clear the screen
pause 200
serout 7, N2400, (b0) ; display a different char each loop
pause 1000
serout 7, N2400, (0) ; display the date and time
pause 2000
next b0
end​

With this program and changing the date setting each run (to make it easier to see what is happening), I have discovered a little more about what IS really happening.

The results are:

Each time the program is run, after the message:
***DATA 0 SET*** [/INDENT]
is displayed, the old date is still displayed for approximately 40 seconds (this varies and I have measured from 38 to 42 seconds). :mad:

THEN after the 40 seconds from the serout command to set the date and time, the new date and time IS finally shown, starting at exactly the date previously entered. :)

I have run this program quite a number of times and the results ARE repeatable +/- a few seconds.

So the problem is now defined as:
Why does it take 40 seconds for the date and time to be updated on the AXE033​
with the DS1307 RTC? :confused: [/INDENT]


Now to ponder further . . .
The AXE030 manual downloadable from the Revolution website is V4.1
The manual which I have received with my AXE033 kit is V4.2 !

Wonder if there is a new firmware version and this new version has this bug in it causing the delay ? :confused:

Any further comment would be greatly appreciated.

westaust55
(all typos proudly my own)
 

Peter M

Senior Member
just a suggestion, from memory (pardon the pun), been a long time since i played with one of these critters, I think it only updates the display once a minute??? but not sure. so it may read the new value when the display updates

it definately worked with serial, that was all I had at the time (tee hee), used an 08.

serout 7, N2400, (253,0,"11/03/08 17:30 ")
I assume there's 2 spaces after the 17:30 (just been squashed by this forums dislike of white space)

Just disregard all this if I'm speakin' out me freckle
 

BeanieBots

Moderator
Sorry, I have no idea:confused: Maybe Technical can comment.
Might be a bug in the latest version but it could be as simple as it only updates every minute.
 

Technical

Technical Support
Staff member
The time can be set in serial mode, as the manual explains.

The AXE033 firmware hasn't been changed for several years. The AXE033 checks the time/date every half second or so. However if it refreshed the 'clock display' on the LCD screen every time, you would end up with a lot of screen flicker and pointless processing.

So it only refreshes the LCD clock display when the minute changes. So the screen will stay at whatever it was previously until the next minute ticks over, at this point the new date/hour/minute will then be displayed.

Most people only ever do this once in the AXE033 lifetime (as the backup cell keeps the time up to date) so don't notice this delay whilst programming!

We'll update the manual and sample program to clarify this process.
 

westaust55

Moderator
Setting time/date on AXE033 in Serial mode

Thanks Technical,

A clear answer:
1. The AXE can have the time/date set in Serial mode
2. The AXE033 checks the time/date "every half second or so".

Agree that you would not normally update the time display every second or two - pointless since seconds are not displayed.
I was doing that after I spotted that with just a 1 second delay after setting the time/date that the data seemingly had not changed and was trying to work out if I had a code error or faulty hardware.


Regards
westaust55
(all typos proudly my own)
 

westaust55

Moderator
Hi Technical,

Some further input if you are going to update and amend the AXE033 manual.

Can I suggest that you also correct the typo at Page 6.

Under the heading "ic2 programming details"
the second sentence commences with:
"The SPE030 family code"

Believe this should read:
"The AXE033 family code"

Regards
Westaust55
 

Johnmb

Member
What is meant by "family code"? In what way is "AXE033" considered to be a family? What are the members of that family? I ask because I just read on page 6 of the "AXE033 Serial/i2c LCD" pdf the statement
"The SPE030 family code is $C6 ...." where $C6 is slaveaddress. I am trying to understand i2c and in particular the use of it in using 24LCxxx memory devices, so any reference to"family" as it relates i2c is of interest. Thank you, John
 
Top