Burkert Type SE56 User Manual
Page 52

TECHNICAL MANUAL
Rev.
Pagine
52/52
Filling By
Checked By
03
PROFIBUS DP MODULE- DATA LINK
DESCRIPTION
Document Data
Date
Date
File name
ProfibusDP_emanual_Burkert_04.doc
19/03/08 19/03/08 19/03/08
52
410 Days& = Days& + 1
420 REM Determines the last two digits of the year
430 Years& = (Years& + 92) MOD 100
440 REM Finally prints the complete date
450 PRINT Days&; "/"; Months%; "/"; Years&; " "; Hours&; ":"; Minutes&
NOTE: Some old versions of BASIC do not support the 32 bit integer format.
4.4 DATE CONVERSION FROM DAY/MONTH/YEAR HOURS:MINUTES TO TOTAL MINUTES
The date we can set serially in the Millennium series instruments must be expressed in total minutes starting
from 01/01/1992. The program that performs the conversion from a string of 14 characters (AsciiData) in
the day/month/year hours:minutes format, transforms it into 4 formatted characters ready to be sent to the
serial line (MinTot).
Note the use of suffixes "%" and "&" to respectively indicate the 16 and 32 bit variables. Both types are
necessary to optimise the calculations and to contain the values which cannot be expressed in just 16 bits.
10 REM Length in days for each month of the year
20 DATA 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
30 REM Defines a group of twelve elements to memorise the length in days of each month in
40 REM the year
50 DIM LengthMonths%(12)
60 REM Initialises each element of the group
70 FOR i% = 1 TO 12: READ LengthMonths%(i%): NEXT i%
80 REM Takes the number of years starting from 1992
90 Years% = (VAL(MID$(AsciiData$, 7, 2)) + 8) MOD 100
100 REM Determines if the year contained in the entry string is a leap year, in this case, m = 0
110 m% = Years% AND 3
120 REM Takes the number of the month from the entry string
130 Months% = VAL(MID$(AsciiData$, 4, 2))
140 REM Calculates all the days of the year corresponding to the date of the entry string
150 Days& = VAL(MID$(AsciiData$, 1, 2))
160 FOR i% = 1 TO Mesi% - 1
170 Days& = Days& + LengthMonths%(i%)
180 REM If it is February and the year is a leap year, it adds one day
190 IF i% = 2 AND m% = 0 THEN Days& = Days& + 1
200 NEXT i%
210 REM Adds a day if the year of the entry string is not a leap year
220 IF m% <> 0 THEN Days& = Days& + 1
230 REM Calculates the total number of days corresponding to the entry date
240 Days& = Days& + (Years% * 365) + INT(Years% / 4)
250 REM Takes the number of hours and minutes from the entry date
260 Hours& = VAL(MID$(AsciiData$, 10, 2))
270 Minutes& = VAL(MID$(AsciiData$, 13, 2))
280 REM Calculates the total number of minutes to the entry date
290 Minutes& = Minutes& + (Days& * 1440) + (Hours& * 60)
300 REM Finally formats the bytes that represent the number in the right order for sending
310 MinTot$ = MKL$(Minutes&)
320 MinTot$ =
MID$(MinTot$,4,1)+MID$(MinTot$,3,1)+MID$(MinTot$,2,1)+MID$(MinTot$,1,1)
NOTE: Some old versions of BASIC do not support the MKL instruction and the 32 bit integer format.