Author |
Message |
vk7krj Newbie
Joined: 15/01/2015 Location: AustraliaPosts: 12 |
Posted: 08:08pm 11 Feb 2015 |
Copy link to clipboard |
Print this post |
|
Sorry to be a pest- another question- in the sub below, I just want to set the hour on the PCF8563, but I get an invalid syntax error when I try it- is there any way of just setting the hour on the PCF8563 from within MMbasic?
sub plus_one_hour:
hour = val(time$,2)
if hour = 23 then hour = 00 else hour = hour + 1
rtc gettime
' rtc settime 15,02,04,23,17,00
rtc settime ,,,hour,,
dst_flag = 1
end sub
Ken. Ken, vk7krj
www.vk7krj.com |
|
Grogster
Admin Group
Joined: 31/12/2012 Location: New ZealandPosts: 9073 |
Posted: 08:20pm 11 Feb 2015 |
Copy link to clipboard |
Print this post |
|
From what I understand of that command, you need to specify all the data in one go - you cannot just substitute commas for missing data - that will what is causing MMBASIC to throw a fit.
EDIT: You could use RTC GETTIME, to suck the current time out of the RTC, and then extract what you need to copy over from DATE$ and TIME$, then recombine that back into your RTC SETTIME command.
So, something along the lines of:(not tested)
RTC GETTIME
HOUR=VAL(MID$(TIME$,1,2))
MINUTE=VAL(MID$(TIME$,4,2))
SECOND=VAL(MID$(TIME$,7,2))
DAY=VAL(MID$(DATE$,1,2))
MONTH=VAL(MID$(DATE$,4,2))
YEAR=VAL(MID$(DATE$,7,2))
HOUR=HOUR+1
RTC SETTIME YEAR,MONTH,DAY,HOUR,MINUTE,SECOND
That SHOULD do it for you, and all within one second easily.
Edited by Grogster 2015-02-13 Smoke makes things work. When the smoke gets out, it stops! |
|
busa Regular Member
Joined: 12/02/2015 Location: AustraliaPosts: 81 |
Posted: 09:32pm 11 Feb 2015 |
Copy link to clipboard |
Print this post |
|
Hi, new member here. I had a similar problem and this is what worked for me.
hour = VAL(left$(TIME$, 2))
min = val(mid$(time$,4,2))
sec = val(right$(time$,2))
ho=hour
if hour =23 then ho=00 else ho = ho + 1
hou$ = str$(ho,2,0,"0")
mi$ = str$(min,2,0,"0")
se$ = str$(sec,2,0,"0")
ti$ = hou$+":"+mi$+":"+se$
TIME$ = ti$
RTC SETTIME
etc
etc
Hope this contribution helps as this forum has been a huge help to me
Regards |
|
MicroBlocks
Guru
Joined: 12/05/2012 Location: ThailandPosts: 2209 |
Posted: 09:55pm 11 Feb 2015 |
Copy link to clipboard |
Print this post |
|
What happens when you add an hour to 23:50 on Februari 28 2015 ? :):)
Make sure it is earlier then 22:59 when you add the hour to prevent headaches.
Microblocks. Build with logic. |
|
vk7krj Newbie
Joined: 15/01/2015 Location: AustraliaPosts: 12 |
Posted: 09:59pm 11 Feb 2015 |
Copy link to clipboard |
Print this post |
|
Many thanks Grogster, that did the job beautifully, the daylight saving switch now works exactly as it should, I just added a test for the 12th hour- here is the (tested & working) sub-
sub plus_one_hour:
RTC GETTIME
hour=VAL(MID$(TIME$,1,2))
minute=VAL(MID$(TIME$,4,2))
second=VAL(MID$(TIME$,7,2))
day=VAL(MID$(DATE$,1,2))
month=VAL(MID$(DATE$,4,2))
year=VAL(MID$(DATE$,7,2))
if hour = 12 then hour = 1 else hour = hour + 1
RTC SETTIME year,month,day,hour,minute,second
dst_flag = 1
end sub
I must say, I didn't expect you to write the code for me- but I am very grateful you did, now I can finally put the code down and start to translate my breadboard mess into a pcb.
Ken, vk7krj
www.vk7krj.com |
|
vk7krj Newbie
Joined: 15/01/2015 Location: AustraliaPosts: 12 |
Posted: 10:05pm 11 Feb 2015 |
Copy link to clipboard |
Print this post |
|
TZAdvantage, yes I had thought about that, but the club & people who will be using this timer for the forseeable future will never be using it past about 9 in the evening- for which I am grateful- it would have made the coding much more difficult for me (read- many more questions to the group mind.....). Ken, vk7krj
www.vk7krj.com |
|
Grogster
Admin Group
Joined: 31/12/2012 Location: New ZealandPosts: 9073 |
Posted: 10:13pm 11 Feb 2015 |
Copy link to clipboard |
Print this post |
|
Glad to help.
Welcome to both you, and our newest recurit - busa.
I was only playing with that idea in my head, and had not tested it at all, as I don't have any RTC modules or chips I can use with the Micromite, so I was just guessing, but glad it works.
Note to you(and busa): Don't be afraid to be a "Pest" - some very helpful and friendly folks here. That, and you are not a pest by any definition of the word - keep the questions coming. Gives us all something to think about.
...but next time, I will hint the code, but let you write it! Smoke makes things work. When the smoke gets out, it stops! |
|