Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 02:06 13 Nov 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : RTC Settime

Author Message
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 1013
Posted: 06:02am 25 Jun 2019
Copy link to clipboard 
Print this post

Is it legal to use a string for RTC Settime?
Here is my issue:
25-06-2019 15:00:05 Concentrator RTC Setting 19,06,25,15,50,05
[180] RTC Settime TD$
Error: Incorrect argument count
> edit
Sub SetClock 'Clock String looks like "2506191505"+CR
If Val(Mid$(Ser2$,3,2)) < 13
If Val(Mid$(Ser2$,5,2)) > 18 Then
If Val(Right$(Ser2$,4)) < 2400 Then
D$=Left$(Ser2$,2)+"/"+Mid$(Ser2$,3,2)+"/"+Mid$(Ser2$,5,2)
TD$=" "+Mid$(Ser2$,5,2)+","+Mid$(Ser2$,3,2)+","+Left$(Ser2$,2)
DbMsg$="Concentrator Date set to "+D$:DbPrnt
Date$=D$
T$=Mid$(Ser2$,7,2)+":"+Right$(Ser2$,2)+":05"
TD$=TD$+","+Mid$(Ser2$,7,2)+","+Mid$(Ser2$,9,2)+",05"
DbMsg$="Concentrator Time set to "+T$:DbPrnt
Time$=T$
DbMsg$="Concentrator RTC Setting "+TD$:DbPrnt
RTC Settime TD$
End If
 
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 07:49am 25 Jun 2019
Copy link to clipboard 
Print this post

Hi
The format of d$ looks incorrect.
from the manual "RTC SETTIME 2016, 11, 10, 16, 0, 0" your code uses "/" for the date not "," and you need to add the century to the year. Also the order needs to be yyyy, mm, dd, hh ,mm ,ss

Regards

Jman
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3308
Posted: 07:54am 25 Jun 2019
Copy link to clipboard 
Print this post

  OA47 said   Is it legal to use a string for RTC Settime?

No,
You need six separate numeric arguments (as per the manual).
Geoff Graham - http://geoffg.net
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 1013
Posted: 09:16pm 25 Jun 2019
Copy link to clipboard 
Print this post

Thanks Jman, you are right in that I made an error. I was incorrectly grabbing the CR with the last character of the time stamp. Corrected this by using Mid$(Ser2$,9,2).

Thanks Geoff. For giving me the news I expected. Is there any other way of automatically synchronising the RTC with an external device from the date stamp string? Could I get away with RTC Set Reg instead?

OA47
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3308
Posted: 10:18pm 25 Jun 2019
Copy link to clipboard 
Print this post

  OA47 said  Is there any other way of automatically synchronising the RTC with an external device from the date stamp string?

No, if you have the date/time in a string you will have to pick it apart using the string functions and convert it to numbers (not hard to do).

  OA47 said   Could I get away with RTC Set Reg instead

That would work but you would still need to pick the string apart (the RTC requires numbers).


Geoff Graham - http://geoffg.net
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 1013
Posted: 10:32pm 25 Jun 2019
Copy link to clipboard 
Print this post

Thanks Geoff. I am already extracting the string numbers from the date stamp string, but can I use these in code to update the RTC?
OA47

Geoff re-read your post now that I am more awake and I see now that I can use VARIABLES not STRINGS in the RTC SetClock command. All is good, thank you for your assistance and especially MMB.

OA47

Edited by OA47 2019-06-27
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025