Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 11:10 11 Feb 2026 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 : Maximite Question II

Author Message
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 1030
Posted: 05:42am 09 Feb 2026
Copy link to clipboard 
Print this post

I have been struggling writing a sub that will enable a predicted TIME$ and DATE$ when a particular number of seconds are added. I tried using TIMER but the conversion back to DATE$ and TIME$ has become enormous. I have also started with a TIME$ and DATE$ and adding to the STRING values but having to modify for incrementing MINUTES, HOURS, DAYS, YEARS and LEAP YEARS is straining the grey matter to a large extent.

Has this been done by anyone or are there shortcuts that I am missing. I am stuck using MMBaisic 4.04 on a DTX-2 embedded module and unfortunately AI can't get enough data or information to help the situation.

OA47
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6448
Posted: 06:43am 09 Feb 2026
Copy link to clipboard 
Print this post

These are from 2014
Lucky they don't use line numbers.

Usage:
convert date,time to Unix
add the number of seconds.
convert back to date/time

 'date conversion routines
 currentdate$= DATE$
 currenttime$=TIME$
mainloop:
 DAY= VAL(MID$(currentdate$,1,2))
 month= VAL(MID$(currentdate$,4,2))
 year= VAL(MID$(currentdate$,7,4))
 hh=VAL(MID$(currenttime$,1,2))
 mm=VAL(MID$(currenttime$,4,2))
 ss=VAL(MID$(currenttime$,7,2))
 
 'weekday starts at 0 for Sunday to match the RTC chip
 d=DAY:m=month:y=year
 GOSUB toJD
 weekday= ABS((jd%+1) MOD 7) 'weekday starts at 0 for Sunday to match the RTC chip
 dayz$=MID$("SunMonTueWedThuFriSatSun",weekday*3+1,3)
 GOSUB toDOY
 PRINT currentdate$;"  ";currenttime$
 PRINT "Day of year: ";dayofyear
 PRINT "Julian Day : ";jd%
 PRINT "Day of Week: ";weekday;" ";dayz$
 d=DAY:m=month:y=year
 GOSUB tojdtime 'tounix
 PRINT "JD time  : ";jdd
 
 GOSUB fromjdtime 'fromunix
 PRINT udate$;"  ";utime$
 
 INPUT "New Date (DD/MM/YYYY) or X to quit: ",newdate$
 IF UCASE$(newdate$)="X" THEN END
 IF newdate$<>"" THEN currentdate$=newdate$
 INPUT "New Time (HH:MM:SS) : ",newtime$
 IF newtime$<>"" THEN currenttime$=newtime$
 IF (newtime$<>"") OR (newdate$<>"") THEN GOTO mainloop
 
testunix:
 INPUT "Unix time: ",un$
 IF un$="" THEN GOTO mainloop
 IF UCASE$(un$)="X" THEN END
 unix=VAL(un$)
 GOSUB fromunix
 PRINT "Unix time ";STR$(unix,12);" equals ";udate$;"  ";utime$
 GOTO testunix
 
tounix:
 d=DAY:m=month:y=year
 GOSUB toJD
 unixd=jd%-2440588
 hh=VAL(MID$(currenttime$,1,2))
 mm=VAL(MID$(currenttime$,4,2))
 ss=VAL(MID$(currenttime$,7,2))
 unixf=hh*60*60+mm*60+ss
 unix=unixd*86400+unixf
 RETURN
 
fromunix:
 unixd=INT(unix/86400)
 unixf=unix MOD 86400
 IF unixd<0 THEN
   unixf=86400+unixf
 ENDIF
 hh= INT(unixf/3600)
 mm= INT((unixf MOD 3600)/60)
 ss=(unixf MOD 3600) MOD 60
 jd%=unixd+2440588
 GOSUB fromJD
 udate$=STR$(d,2)+"/"+STR$(m,2)+"/"+STR$(y,4)
 utime$=STR$(hh,2)+":"+STR$(mm,2)+":"+STR$(ss,2)
 RETURN
 
toDOY:
 GOSUB toJD
 day1=jd%
 d=31:m=12:y=year-1
 GOSUB toJD
 dayofyear= day1-jd%
 jd%=day1
 RETURN
 
toJD:
 ' valid for Gregorian dates after Oct 15, 1582
 ff=FIX((m-14)/12)
 jd% = FIX((1461*(y+4800+ff))/4)+FIX((367*(m-2-12*ff))/12)-FIX((3*(FIX(y+4900+ff)/100))/4)+d-32075
 RETURN
 
fromJD:
 l = jd%+68569    ' valid for Gregorian dates after Oct 15, 1582
 n = FIX((4*l)/146097)
 l = l-FIX((146097*n+3)/4)
 i = FIX((4000*(l+1))/1461001)
 l = l-FIX((1461*i)/4)+31
 j = FIX((80*l)/2447)
 d = l-FIX((2447*j)/80)
 l = FIX(j/11)
 m = j+2-(12*l)
 y = 100*(n-49)+i+l
 RETURN
 
jdtounix:
 unix=jd%-2440588
 RETURN
 
tojdtime:
 d=DAY:m=month:y=year
 GOSUB toJD
 hh=VAL(MID$(currenttime$,1,2))
 mm=VAL(MID$(currenttime$,4,2))
 ss=VAL(MID$(currenttime$,7,2))
 jdt=(hh*60*60+mm*60+ss)/86400
 jdd=jd%+jdt
 RETURN
 
fromjdtime:
 jd%=INT(jdd)
 jdt=jdd-jd%
 GOSUB fromJD
 jdtime=jdt*86400
 hh= INT(jdtime/3600)
 mm= INT((jdtime MOD 3600)/60)
 ss=(jdtime MOD 3600) MOD 60
 udate$=STR$(d,2)+"/"+STR$(m,2)+"/"+STR$(y,4)
 utime$=STR$(hh,2)+":"+STR$(mm,2)+":"+STR$(ss,2)
 RETURN


Jim
VK7JH
MMedit
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5671
Posted: 07:07am 09 Feb 2026
Copy link to clipboard 
Print this post

Hi Jim,

Good that you found something. I can't go back before 4.5C on CMM1. Is 4.04 a mono maximite ?

P.S. Off-Topic: did you already find a "final" solution for the MMCC 5.40 linux problem. You found a "quick fix" but needed more testing ?

Volhout
PicomiteVGA PETSCII ROBOTS
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6448
Posted: 07:12am 09 Feb 2026
Copy link to clipboard 
Print this post

  Volhout said  Hi Jim,

P.S. Off-Topic: did you already find a "final" solution for the MMCC 5.40 linux problem. You found a "quick fix" but needed more testing ?

Volhout

I am never 100% confident.
Time will tell how well I have done.

Jim
VK7JH
MMedit
 
Pluto
Guru

Joined: 09/06/2017
Location: Finland
Posts: 410
Posted: 01:12pm 09 Feb 2026
Copy link to clipboard 
Print this post

Could the EPOCH functions be useful?
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5671
Posted: 02:39pm 09 Feb 2026
Copy link to clipboard 
Print this post

Hi Pluto,

According MMBasic 4.5C language manual (CMM1), the EPOCH function is not implemented in this version of basic. I am not sure about 4.04, but my estimate is it is not available.

Volhout
PicomiteVGA PETSCII ROBOTS
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5671
Posted: 02:49pm 09 Feb 2026
Copy link to clipboard 
Print this post

@OA47,

There is a version 4.5 MMBasic for the DTX2. Please find attached.
They fixed some bugs with DATE$ and TIME$ according the release notes.

mmbasic.zip

Volhout

P.S. They added some nice commands to MMBasic. Especially the simple multithread  capability. But also "HELP"...
Edited 2026-02-10 01:02 by Volhout
PicomiteVGA PETSCII ROBOTS
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 1030
Posted: 03:35am 10 Feb 2026
Copy link to clipboard 
Print this post

Thankyou Jim for your code unfortunately the version of Basic I am stuck with does not like the Fix line. Is there a way around this?

[CODE[83] jd% = Fix((1461*(y+4800+ff))/4)+Fix((367*(m-2-12*ff))/12)-Fix((3*(Fix(y+4900+ff)/100))/4)+d-32075
Error: Unknown command]

OA47

Found if I deleted the % from the variable the code runs
Edited 2026-02-10 13:42 by OA47
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 1030
Posted: 04:17am 10 Feb 2026
Copy link to clipboard 
Print this post

@ Volhout As the embedded Maximite is a DTX-2 (a variation at the time) I dont believe that there are any updates available. As far as I can see it is Version 4.4 Rev 5

OA47
Edited 2026-02-10 14:31 by OA47
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2991
Posted: 04:19am 10 Feb 2026
Copy link to clipboard 
Print this post

V4.5C complete package also available here -https://geoffg.net/MonoMaximite.html
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6448
Posted: 04:26am 10 Feb 2026
Copy link to clipboard 
Print this post

Sorry about that. Integers ( % suffix ) only came in with V4.6 firmware.

I hope you don't run into an overflow.

What date range are you expecting to cover?

Jim
VK7JH
MMedit
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 1030
Posted: 04:37am 10 Feb 2026
Copy link to clipboard 
Print this post

@ Jim The current code generates a period in seconds from 1 to years and this new DATE and Time is set and scanned for. I wonder if the period is only a couple of second that they would be lost in the conversion to JD time eg 2.46108e+06.


@ Volhout, I was certainly wrong it looks like I must have missed the 4.5 update. I will look through the docs and see what it has to offer.

OA47
Edited 2026-02-10 14:48 by OA47
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2991
Posted: 05:04am 10 Feb 2026
Copy link to clipboard 
Print this post

Searched for DTX2-4105C MMBasic firmware to see what is the latest but the links to it are dead.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6448
Posted: 05:08am 10 Feb 2026
Copy link to clipboard 
Print this post

Try this at the beginning of the code I sent previously (after removing all the %)
 currentdate$= DATE$
 currenttime$=TIME$
 INPUT "Number of seconds away (+ or -)",difsec
 PRINT "Starting time  ";currentdate$;" ";currenttime$
 DAY= VAL(MID$(currentdate$,1,2))
 month= VAL(MID$(currentdate$,4,2))
 year= VAL(MID$(currentdate$,7,4))
 hh=VAL(MID$(currenttime$,1,2))
 mm=VAL(MID$(currenttime$,4,2))
 ss=VAL(MID$(currenttime$,7,2))
 GOSUB tounix
 'print "startsec = ";unix
 unix = unix + difsec
 GOSUB fromunix
 PRINT udate$;" ";utime$
 


Back in the single precision days, I separated the whole days from the part days.
We might have to resort to that here.

I might have to look it the old-parts draw for a Maximite to test it properly.

Jim
VK7JH
MMedit
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 1030
Posted: 06:34am 10 Feb 2026
Copy link to clipboard 
Print this post

@ Jim

Added that code but the new date needs proceeding zeros added.

Number of seconds away (+ or -)4500
Starting time  10-02-2026 17:30:11
10/2/2026 18:44:16
10-02-2026  17:30:11
Day of year:  41
Julian Day :  2.46108e+06
Day of Week:  2 Tue
JD time  :  2.46108e+06
10/2/2026  18:0:0

OA47
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6448
Posted: 06:50am 10 Feb 2026
Copy link to clipboard 
Print this post

This is more compact (but only for positive diffs so far)

 currentdate$= DATE$
 currenttime$=TIME$
 INPUT "Number of seconds away (+ or -) ",difsec
 PRINT "Starting time  ";currentdate$;" ";currenttime$
 wholedays = toJD(currentdate$)
 secondsDay = partday(currenttime$)
 
 newseconds = secondsDay + difsec
 newwholedays = wholedays + INT(newseconds/86400)
 newseconds = newseconds MOD 86400
 newtime$ = frompartday$(newseconds)
 newdate$ = fromJD$(newwholedays)
 
 PRINT newdate$;" ";newtime$
 
 FUNCTION toJD(thisdate$)
 d = VAL(MID$(thisdate$,1,2))
 m = VAL(MID$(thisdate$,4,2))
 y = VAL(MID$(thisdate$,7,4))
 ' valid for Gregorian dates after Oct 15, 1582
 ff=FIX((m-14)/12)
 tojd = FIX((1461*(y+4800+ff))/4)+FIX((367*(m-2-12*ff))/12)-FIX((3*(FIX(y+4900+ff)/100))/4)+d-32075
 END FUNCTION
 
 FUNCTION partDay(thistime$)
 hh=VAL(MID$(thistime$,1,2))
 mm=VAL(MID$(thistime$,4,2))
 ss=VAL(MID$(thistime$,7,2))
 partday=(hh*60*60+mm*60+ss)
 END FUNCTION
 
  FUNCTION frompartDay$(secs)
  hh= INT(secs/3600)
 mm= INT((secs MOD 3600)/60)
 ss=(secs MOD 3600) MOD 60
 frompartDay$=RIGHT$("0"+STR$(hh),2)+":"+RIGHT$("0"+STR$(mm),2)+":"+RIGHT$("0"+STR$(ss),2)
  END FUNCTION
 
  FUNCTION fromJD$(jd)
    l = jd+68569    ' valid for Gregorian dates after Oct 15, 1582
 n = FIX((4*l)/146097)
 l = l-FIX((146097*n+3)/4)
 i = FIX((4000*(l+1))/1461001)
 l = l-FIX((1461*i)/4)+31
 j = FIX((80*l)/2447)
 d = l-FIX((2447*j)/80)
 l = FIX(j/11)
 m = j+2-(12*l)
 y = 100*(n-49)+i+l
 fromJD$=RIGHT$("0"+STR$(d),2)+"/"+RIGHT$("0"+STR$(m),2)+"/"+STR$(y,4)
  END FUNCTION


I will play further.
Edited 2026-02-10 17:01 by TassyJim
VK7JH
MMedit
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5671
Posted: 06:54am 10 Feb 2026
Copy link to clipboard 
Print this post

Hi OA47,

The link is not dead. Maybe your browser refuses to download because it is not a HTTPS site, but HTTP.

Dimetech Maximite Download

But this is the exact package that I zipped up for you 6 posts ago. It contains the user manual, the list of changes, the added commands, the release notes, the hex file, everything you need, even a description of 2 different ways to put the firmware into your DXT2-4105. If you have firmware 4.04 the only one method works (pickit3), if your current code is 4.4 you can also use the built in bootloader.

Regards,

Volhout
Edited 2026-02-10 16:58 by Volhout
PicomiteVGA PETSCII ROBOTS
 
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 2026