EasyManua.ls Logo

Elcontrol Microvip 3 plus - Page 59

Elcontrol Microvip 3 plus
65 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
54
Num$ = ""
FOR k = 1 TO LEN(Data$) - 3 STEP 2
'Rewrites the whole number from the most significant couple of digits
' to the last significant
Num$ = MID$(Data$, k, 2) + Num$
NEXT k
IF LEFT$(Num$, 1) = "8" THEN
'Negative number
Num$ = "-" + RIGHT$(Num$, LEN(Num$) - 1)' Cut char. "8" and add "-"
END IF
AsciiToFloat = VAL(Num$) * 10 ^ Exponent
END FUNCTION
FUNCTION CheckLrc (EnergyReply$)
'Compares the Received and the Calculated LRC
EnergyReply$ = MID$(EnergyReply$, 2, LEN(EnergyReply$)) ' Cut char. ":"
RxLrc$ = RIGHT$(EnergyReply$, 2)
EnergyReply$ = LEFT$(EnergyReply$, LEN(EnergyReply$) - 2)' Cut LRC
CalcLrc$ = LRC(EnergyReply$)
LOCATE 4, 35
IF RxLrc$ <> CalcLrc$ THEN
PRINT "Communication Error !"
CheckLrc = FALSE
ELSE
PRINT "Communication OK ! "
CheckLrc = TRUE
END IF
END FUNCTION
FUNCTION LRC$ (strng$)
'Longitudinal Redundancy Check calculation
TEMP = 0
FOR i = 1 TO LEN(strng$) STEP 2
A$ = MID$(strng$, i, 2)
DECVALUE = AsciiHexToDec(A$)
TEMP = TEMP + DECVALUE ' sum of all character
NEXT i
TEMP = TEMP MOD 256
TEMP = 256 - TEMP
LRC$ = HEX$(TEMP)
END FUNCTION
SUB Pause (n)
FOR i = 1 TO n: PLAY "P64": NEXT i
END SUB
SUB SetArrayMeasures
'Reads the label and the required screen position
SHARED Measures AS Measure
FOR i = 1 TO 38:
READ Measures(i).Nome, Measures(i).OutRow, Measures(i).OutCol
Measures(i).NCh = 6
NEXT i
'Counters Lenght = 10 characters
Measures(29).NCh = 10: Measures(30).NCh = 10 'kWh kVArh
Measures(36).NCh = 10: Measures(37).NCh = 10 'kWh1 kWh2
Measures(38).NCh = 10 'kWh3
END SUB
SUB ShowData (EnergyReply$)
' Shows the measures on the screen
SHARED Measures AS Measure
Stepp = 26: PRINT STRING$(80, "Õ")
Pointer = 17
FOR i = 1 TO 38
LOCATE 7 + Measures(i).OutRow, (Measures(i).OutCol - 1) * Stepp + 1
PRINT RTRIM$(Measures(i).Nome); " = ";
Meas$ = MID$(EnergyReply$, Pointer, Measures(i).NCh)
PRINT AsciiToFloat(Meas$)
Pointer = Pointer + Measures(i).NCh
NEXT i
END SUB

Related product manuals