Kamstrup 401 VMM
Detaljer
Beskrivning
Drivrutin till Kamstrup.
Nytt skript skapat med senaste "M-bus creator" för att hantera negativa värden rätt och rätt checksumma på init-telegram.
Bruksanvisning
Hur man installerar typdefinitionerna och driftsätter modulerna finns beskrivet i användarmanualen, kapitel 18.7.
Juridisk information
Alla skript tillhandahålls i befintligt skick och all användning sker på eget ansvar. Felaktig använding kan leda till skadad eller förstörd utrustning.
Skript kod
DEVICETYPE MBus NAMED "MBus" TYPEID 19418
IS
% --- Device created 13:08:50 2019-05-21
PARAMETER
Id :"Address"INT;
PUBLIC
IDNr : "ID number"INT;
rec1 : "Energy"["Wh"]INT;
rec2 : "Volume"["m³"]DEC2;
rec4 : "Flow Temperature"["°C"]DEC2;
rec5 : "Return Temperature"["°C"]DEC2;
rec6 : "Temperature Difference"["°K"]DEC2;
rec7 : "Power"["W"]DEC2;
rec8 : "Volume Flow"["m³/h"]DEC2;
rec9 : "Energy"["Wh"]INT;
PRIVATE
Exp;
tmp;
BAUDRATE 2400;
PARITY EVEN;
CHRGAPTIMEOUT 10;
CHECKSUM SUM8 SKIP 4;
POSTBYTES 1;
TELEGRAM Init NAMED "Init" IS
QUESTION
DATA[0] := HEX(10);
DATA[1] := HEX(40);
DATA[2] := BYTE(Id);
DATA[3] <- BYTE(DATA :=Id+64;);
DATA[4] := HEX(16);
ANSWER SIZE 1
DATA[0] = HEX(E5);
TIMEOUT 5000
END;
TELEGRAM Read NAMED "Read" IS
QUESTION
DATA[0] := HEX(10);
DATA[1] := HEX(5B);
DATA[2] := BYTE(Id);
DATA[3] <- BYTE(DATA :=Id+91;);
DATA[4] := HEX(16);
ANSWER SIZE 136
DATA[0] = HEX(68);
DATA[1] = HEX(82);
DATA[2] = HEX(82);
DATA[3] = HEX(68);
DATA[4] = HEX(08);
DATA[5] = BYTE(Id);
DATA[6] = HEX(72);
DATA[7] -> BYTE(IDNr := (DATA & HEX(F)) + 10*(DATA & HEX(F0))/16;);
DATA[8] -> BYTE(IDNr := IDNr + 100*(DATA & HEX(F)) + 1000*(DATA & HEX(F0))/16;);
DATA[9] -> BYTE(IDNr := IDNr + 10000*(DATA & HEX(F)) + 100000*(DATA & HEX(F0))/16;);
DATA[10] -> BYTE(IDNr := IDNr + 1000000*(DATA & HEX(F)) + 10000000*(DATA & HEX(F0))/16;);
DATA[14] = HEX(04);
% 8 digit BCD
DATA[21] -> BYTE(rec1 := (DATA & HEX(F)) + 10*(DATA & HEX(F0))/16;);
DATA[22] -> BYTE(rec1 := rec1 + 100*(DATA & HEX(F)) + 1000*(DATA & HEX(F0))/16;);
DATA[23] -> BYTE(rec1 := rec1 + 10000*(DATA & HEX(F)) + 100000*(DATA & HEX(F0))/16;);
DATA[24] -> BYTE(rec1 := rec1 + 1000000*(DATA & HEX(F)); IF ((DATA & HEX(F0)) = HEX(F0)) THEN rec1 := 0-rec1; ELSE rec1:=rec1 + 10000000*(DATA & HEX(F0))/16; ENDIF;);
DATA[20] -> BYTE(Exp := (DATA & 7) - 3; rec1 := rec1*10^Exp;);
% 8 digit BCD
DATA[27] -> BYTE(rec2 := (DATA & HEX(F)) + 10*(DATA & HEX(F0))/16;);
DATA[28] -> BYTE(rec2 := rec2 + 100*(DATA & HEX(F)) + 1000*(DATA & HEX(F0))/16;);
DATA[29] -> BYTE(rec2 := rec2 + 10000*(DATA & HEX(F)) + 100000*(DATA & HEX(F0))/16;);
DATA[30] -> BYTE(rec2 := rec2 + 1000000*(DATA & HEX(F)); IF ((DATA & HEX(F0)) = HEX(F0)) THEN rec2 := 0-rec2; ELSE rec2:=rec2 + 10000000*(DATA & HEX(F0))/16; ENDIF;);
DATA[26] -> BYTE(Exp := (DATA & 7) - 6; rec2 := rec2*10^Exp;);
% 8 digit BCD
DATA[39] -> BYTE(rec4 := (DATA & HEX(F)) + 10*(DATA & HEX(F0))/16;);
DATA[40] -> BYTE(rec4 := rec4 + 100*(DATA & HEX(F)) + 1000*(DATA & HEX(F0))/16;);
DATA[41] -> BYTE(rec4 := rec4 + 10000*(DATA & HEX(F)) + 100000*(DATA & HEX(F0))/16;);
DATA[42] -> BYTE(rec4 := rec4 + 1000000*(DATA & HEX(F)); IF ((DATA & HEX(F0)) = HEX(F0)) THEN rec4 := 0-rec4; ELSE rec4:=rec4 + 10000000*(DATA & HEX(F0))/16; ENDIF;);
DATA[38] -> BYTE(Exp := (DATA & 3) - 3; rec4 := rec4*10^Exp;);
% 8 digit BCD
DATA[45] -> BYTE(rec5 := (DATA & HEX(F)) + 10*(DATA & HEX(F0))/16;);
DATA[46] -> BYTE(rec5 := rec5 + 100*(DATA & HEX(F)) + 1000*(DATA & HEX(F0))/16;);
DATA[47] -> BYTE(rec5 := rec5 + 10000*(DATA & HEX(F)) + 100000*(DATA & HEX(F0))/16;);
DATA[48] -> BYTE(rec5 := rec5 + 1000000*(DATA & HEX(F)); IF ((DATA & HEX(F0)) = HEX(F0)) THEN rec5 := 0-rec5; ELSE rec5:=rec5 + 10000000*(DATA & HEX(F0))/16; ENDIF;);
DATA[44] -> BYTE(Exp := (DATA & 3) - 3; rec5 := rec5*10^Exp;);
% 8 digit BCD
DATA[51] -> BYTE(rec6 := (DATA & HEX(F)) + 10*(DATA & HEX(F0))/16;);
DATA[52] -> BYTE(rec6 := rec6 + 100*(DATA & HEX(F)) + 1000*(DATA & HEX(F0))/16;);
DATA[53] -> BYTE(rec6 := rec6 + 10000*(DATA & HEX(F)) + 100000*(DATA & HEX(F0))/16;);
DATA[54] -> BYTE(rec6 := rec6 + 1000000*(DATA & HEX(F)); IF ((DATA & HEX(F0)) = HEX(F0)) THEN rec6 := 0-rec6; ELSE rec6:=rec6 + 10000000*(DATA & HEX(F0))/16; ENDIF;);
DATA[50] -> BYTE(Exp := (DATA & 3) - 3; rec6 := rec6*10^Exp;);
% 8 digit BCD
DATA[57] -> BYTE(rec7 := (DATA & HEX(F)) + 10*(DATA & HEX(F0))/16;);
DATA[58] -> BYTE(rec7 := rec7 + 100*(DATA & HEX(F)) + 1000*(DATA & HEX(F0))/16;);
DATA[59] -> BYTE(rec7 := rec7 + 10000*(DATA & HEX(F)) + 100000*(DATA & HEX(F0))/16;);
DATA[60] -> BYTE(rec7 := rec7 + 1000000*(DATA & HEX(F)); IF ((DATA & HEX(F0)) = HEX(F0)) THEN rec7 := 0-rec7; ELSE rec7:=rec7 + 10000000*(DATA & HEX(F0))/16; ENDIF;);
DATA[56] -> BYTE(Exp := (DATA & 7) - 3; rec7 := rec7*10^Exp;);
% 8 digit BCD
DATA[63] -> BYTE(rec8 := (DATA & HEX(F)) + 10*(DATA & HEX(F0))/16;);
DATA[64] -> BYTE(rec8 := rec8 + 100*(DATA & HEX(F)) + 1000*(DATA & HEX(F0))/16;);
DATA[65] -> BYTE(rec8 := rec8 + 10000*(DATA & HEX(F)) + 100000*(DATA & HEX(F0))/16;);
DATA[66] -> BYTE(rec8 := rec8 + 1000000*(DATA & HEX(F)); IF ((DATA & HEX(F0)) = HEX(F0)) THEN rec8 := 0-rec8; ELSE rec8:=rec8 + 10000000*(DATA & HEX(F0))/16; ENDIF;);
DATA[62] -> BYTE(Exp := (DATA & 7) - 6; rec8 := rec8*10^Exp;);
% 8 digit BCD
DATA[69] -> BYTE(rec9 := (DATA & HEX(F)) + 10*(DATA & HEX(F0))/16;);
DATA[70] -> BYTE(rec9 := rec9 + 100*(DATA & HEX(F)) + 1000*(DATA & HEX(F0))/16;);
DATA[71] -> BYTE(rec9 := rec9 + 10000*(DATA & HEX(F)) + 100000*(DATA & HEX(F0))/16;);
DATA[72] -> BYTE(rec9 := rec9 + 1000000*(DATA & HEX(F)); IF ((DATA & HEX(F0)) = HEX(F0)) THEN rec9 := 0-rec9; ELSE rec9:=rec9 + 10000000*(DATA & HEX(F0))/16; ENDIF;);
DATA[68] -> BYTE(Exp := (DATA & 7) - 3; rec9 := rec9*10^Exp;);
TIMEOUT 5000
END;
END;
IS
% --- Device created 13:08:50 2019-05-21
PARAMETER
Id :"Address"INT;
PUBLIC
IDNr : "ID number"INT;
rec1 : "Energy"["Wh"]INT;
rec2 : "Volume"["m³"]DEC2;
rec4 : "Flow Temperature"["°C"]DEC2;
rec5 : "Return Temperature"["°C"]DEC2;
rec6 : "Temperature Difference"["°K"]DEC2;
rec7 : "Power"["W"]DEC2;
rec8 : "Volume Flow"["m³/h"]DEC2;
rec9 : "Energy"["Wh"]INT;
PRIVATE
Exp;
tmp;
BAUDRATE 2400;
PARITY EVEN;
CHRGAPTIMEOUT 10;
CHECKSUM SUM8 SKIP 4;
POSTBYTES 1;
TELEGRAM Init NAMED "Init" IS
QUESTION
DATA[0] := HEX(10);
DATA[1] := HEX(40);
DATA[2] := BYTE(Id);
DATA[3] <- BYTE(DATA :=Id+64;);
DATA[4] := HEX(16);
ANSWER SIZE 1
DATA[0] = HEX(E5);
TIMEOUT 5000
END;
TELEGRAM Read NAMED "Read" IS
QUESTION
DATA[0] := HEX(10);
DATA[1] := HEX(5B);
DATA[2] := BYTE(Id);
DATA[3] <- BYTE(DATA :=Id+91;);
DATA[4] := HEX(16);
ANSWER SIZE 136
DATA[0] = HEX(68);
DATA[1] = HEX(82);
DATA[2] = HEX(82);
DATA[3] = HEX(68);
DATA[4] = HEX(08);
DATA[5] = BYTE(Id);
DATA[6] = HEX(72);
DATA[7] -> BYTE(IDNr := (DATA & HEX(F)) + 10*(DATA & HEX(F0))/16;);
DATA[8] -> BYTE(IDNr := IDNr + 100*(DATA & HEX(F)) + 1000*(DATA & HEX(F0))/16;);
DATA[9] -> BYTE(IDNr := IDNr + 10000*(DATA & HEX(F)) + 100000*(DATA & HEX(F0))/16;);
DATA[10] -> BYTE(IDNr := IDNr + 1000000*(DATA & HEX(F)) + 10000000*(DATA & HEX(F0))/16;);
DATA[14] = HEX(04);
% 8 digit BCD
DATA[21] -> BYTE(rec1 := (DATA & HEX(F)) + 10*(DATA & HEX(F0))/16;);
DATA[22] -> BYTE(rec1 := rec1 + 100*(DATA & HEX(F)) + 1000*(DATA & HEX(F0))/16;);
DATA[23] -> BYTE(rec1 := rec1 + 10000*(DATA & HEX(F)) + 100000*(DATA & HEX(F0))/16;);
DATA[24] -> BYTE(rec1 := rec1 + 1000000*(DATA & HEX(F)); IF ((DATA & HEX(F0)) = HEX(F0)) THEN rec1 := 0-rec1; ELSE rec1:=rec1 + 10000000*(DATA & HEX(F0))/16; ENDIF;);
DATA[20] -> BYTE(Exp := (DATA & 7) - 3; rec1 := rec1*10^Exp;);
% 8 digit BCD
DATA[27] -> BYTE(rec2 := (DATA & HEX(F)) + 10*(DATA & HEX(F0))/16;);
DATA[28] -> BYTE(rec2 := rec2 + 100*(DATA & HEX(F)) + 1000*(DATA & HEX(F0))/16;);
DATA[29] -> BYTE(rec2 := rec2 + 10000*(DATA & HEX(F)) + 100000*(DATA & HEX(F0))/16;);
DATA[30] -> BYTE(rec2 := rec2 + 1000000*(DATA & HEX(F)); IF ((DATA & HEX(F0)) = HEX(F0)) THEN rec2 := 0-rec2; ELSE rec2:=rec2 + 10000000*(DATA & HEX(F0))/16; ENDIF;);
DATA[26] -> BYTE(Exp := (DATA & 7) - 6; rec2 := rec2*10^Exp;);
% 8 digit BCD
DATA[39] -> BYTE(rec4 := (DATA & HEX(F)) + 10*(DATA & HEX(F0))/16;);
DATA[40] -> BYTE(rec4 := rec4 + 100*(DATA & HEX(F)) + 1000*(DATA & HEX(F0))/16;);
DATA[41] -> BYTE(rec4 := rec4 + 10000*(DATA & HEX(F)) + 100000*(DATA & HEX(F0))/16;);
DATA[42] -> BYTE(rec4 := rec4 + 1000000*(DATA & HEX(F)); IF ((DATA & HEX(F0)) = HEX(F0)) THEN rec4 := 0-rec4; ELSE rec4:=rec4 + 10000000*(DATA & HEX(F0))/16; ENDIF;);
DATA[38] -> BYTE(Exp := (DATA & 3) - 3; rec4 := rec4*10^Exp;);
% 8 digit BCD
DATA[45] -> BYTE(rec5 := (DATA & HEX(F)) + 10*(DATA & HEX(F0))/16;);
DATA[46] -> BYTE(rec5 := rec5 + 100*(DATA & HEX(F)) + 1000*(DATA & HEX(F0))/16;);
DATA[47] -> BYTE(rec5 := rec5 + 10000*(DATA & HEX(F)) + 100000*(DATA & HEX(F0))/16;);
DATA[48] -> BYTE(rec5 := rec5 + 1000000*(DATA & HEX(F)); IF ((DATA & HEX(F0)) = HEX(F0)) THEN rec5 := 0-rec5; ELSE rec5:=rec5 + 10000000*(DATA & HEX(F0))/16; ENDIF;);
DATA[44] -> BYTE(Exp := (DATA & 3) - 3; rec5 := rec5*10^Exp;);
% 8 digit BCD
DATA[51] -> BYTE(rec6 := (DATA & HEX(F)) + 10*(DATA & HEX(F0))/16;);
DATA[52] -> BYTE(rec6 := rec6 + 100*(DATA & HEX(F)) + 1000*(DATA & HEX(F0))/16;);
DATA[53] -> BYTE(rec6 := rec6 + 10000*(DATA & HEX(F)) + 100000*(DATA & HEX(F0))/16;);
DATA[54] -> BYTE(rec6 := rec6 + 1000000*(DATA & HEX(F)); IF ((DATA & HEX(F0)) = HEX(F0)) THEN rec6 := 0-rec6; ELSE rec6:=rec6 + 10000000*(DATA & HEX(F0))/16; ENDIF;);
DATA[50] -> BYTE(Exp := (DATA & 3) - 3; rec6 := rec6*10^Exp;);
% 8 digit BCD
DATA[57] -> BYTE(rec7 := (DATA & HEX(F)) + 10*(DATA & HEX(F0))/16;);
DATA[58] -> BYTE(rec7 := rec7 + 100*(DATA & HEX(F)) + 1000*(DATA & HEX(F0))/16;);
DATA[59] -> BYTE(rec7 := rec7 + 10000*(DATA & HEX(F)) + 100000*(DATA & HEX(F0))/16;);
DATA[60] -> BYTE(rec7 := rec7 + 1000000*(DATA & HEX(F)); IF ((DATA & HEX(F0)) = HEX(F0)) THEN rec7 := 0-rec7; ELSE rec7:=rec7 + 10000000*(DATA & HEX(F0))/16; ENDIF;);
DATA[56] -> BYTE(Exp := (DATA & 7) - 3; rec7 := rec7*10^Exp;);
% 8 digit BCD
DATA[63] -> BYTE(rec8 := (DATA & HEX(F)) + 10*(DATA & HEX(F0))/16;);
DATA[64] -> BYTE(rec8 := rec8 + 100*(DATA & HEX(F)) + 1000*(DATA & HEX(F0))/16;);
DATA[65] -> BYTE(rec8 := rec8 + 10000*(DATA & HEX(F)) + 100000*(DATA & HEX(F0))/16;);
DATA[66] -> BYTE(rec8 := rec8 + 1000000*(DATA & HEX(F)); IF ((DATA & HEX(F0)) = HEX(F0)) THEN rec8 := 0-rec8; ELSE rec8:=rec8 + 10000000*(DATA & HEX(F0))/16; ENDIF;);
DATA[62] -> BYTE(Exp := (DATA & 7) - 6; rec8 := rec8*10^Exp;);
% 8 digit BCD
DATA[69] -> BYTE(rec9 := (DATA & HEX(F)) + 10*(DATA & HEX(F0))/16;);
DATA[70] -> BYTE(rec9 := rec9 + 100*(DATA & HEX(F)) + 1000*(DATA & HEX(F0))/16;);
DATA[71] -> BYTE(rec9 := rec9 + 10000*(DATA & HEX(F)) + 100000*(DATA & HEX(F0))/16;);
DATA[72] -> BYTE(rec9 := rec9 + 1000000*(DATA & HEX(F)); IF ((DATA & HEX(F0)) = HEX(F0)) THEN rec9 := 0-rec9; ELSE rec9:=rec9 + 10000000*(DATA & HEX(F0))/16; ENDIF;);
DATA[68] -> BYTE(Exp := (DATA & 7) - 3; rec9 := rec9*10^Exp;);
TIMEOUT 5000
END;
END;
Användarnas noteringar
Du måste vara inloggad för att göra en notering. Bli medlem eller logga in. Vi använder en moderator som godkänner noteringarna innan de visas.