Burkert Type SE56 User Manual
Page 51

TECHNICAL MANUAL
Rev.
Pagine
51/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
51
· Converting a 32 bit decimal value (
32 bit floating point IEEE standard): Bytes contains the four bytes
that constitute the 32 bit number to convert. A 32 bit decimal number can represent values from ±1.4E-45
to ±3.4E+38. The instructions to use may be the following:
NumFlt!=CVS(MID$(Bytes$,4,1)+MID$(Bytes$,3,1)+MID$(Bytes$,2,1)+MID$(Bytes$,1,1))
NOTE: Some old versions of BASIC do not support the CVL instruction and the 32 bit integer format.
4.3 DATE CONVERSION FROM TOTAL MINUTES TO DAY/MONTH/YEAR HOURS:MINUTES
The date read by the Millennium series instruments is expressed in minutes starting from 01/01/1992. The
following program executes the conversion of the value in minutes contained in the 32 bit integer variable
MinTot and prints it in the day/month/year hours:minutes format.
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 in 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 Calculates the total number of days
90 Days& = INT(MinTot& / 1440)
100 REM Calculates the minutes
110 n& = MinTot& MOD 1440
120 Minutes& = n& MOD 60
130 REM Calculates the hours
140 Hour& = INT(n& / 60)
150 REM Calculates the number of leap years. 4 years are 1460 days + 1
160 n& = INT(Days& / 1461)
170 REM Calculates the remaining days, not exact multiples for a period of 4 years
180 m& = Days& MOD 1461
190 REM Determines the p and q correction values for leap years
200 IF m& = 0 THEN q% = 1 ELSE q% = 0
210 IF m& > 365 THEN p% = 1 ELSE p% = 0
220 REM Calculates the total number of years
230 Years& = INT(n& * 4 + (m& - 1 + q%) / 365)
240 REM Calculates the remaining days, not exact multiples of one year
250 Days& = Days& - Years& * 365 - n& - p%
260 REM Determines if the year calculated is a leap year, in this case m = 0
270 m& = Years& AND 3
280 REM Calculates the number of the month and removes the sum of the preceding
290 REM months from the remaining days.
300 FOR i% = 1 TO 12
310 Months% = LengthMonths%(i%)
320 REM If it is February and the year is a leap year, add one day
330 IF i% = 2 AND m& = 0 THEN Months% = Months% + 1
340 REM Continues the cycle until the number of days remaining is lower than the
350 REM length of the month compared
360 IF Days& >= Months% THEN Days& = Days& - Months%: ELSE GO TO 380
370 NEXT
380 REM Assigns the number of the month thus calculated to the variable
390 Months% = i%
400 REM Adjusts the value of the days calculated