|
Forum Index : Microcontroller and PC projects : RTC Settime
| Author | Message | ||||
| OA47 Guru Joined: 11/04/2012 Location: AustraliaPosts: 1013 |
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 ZealandPosts: 711 |
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: AustraliaPosts: 3308 |
No, You need six separate numeric arguments (as per the manual). Geoff Graham - http://geoffg.net |
||||
| OA47 Guru Joined: 11/04/2012 Location: AustraliaPosts: 1013 |
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: AustraliaPosts: 3308 |
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). 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: AustraliaPosts: 1013 |
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 |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |