ABB B23113
Detaljer
- Typ
- Drivrutin
- Upplaggd av
- Marcus Willander, Abelko Innovation
- Version
- 2
- Uppdaterad
- 2017-04-03
- Skapad
- 2016-06-08
- Kategori
- Energioptimering, M-bus, Mätare
- Visningar
- 3679
Beskrivning
Läser av en energimätare. Fungerar bara med Ultra!
Bruksanvisning
Detta går bara att använda med IMSE Ultra! Kontakta Marcus vid frågor.
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 ElectricMeter NAMED "ABB_B23113"
IS
PARAMETER
Id :"Address"INT;
PUBLIC
IDNr : "ID number"INT;
rec1 : "Power tot" ["W"]DEC2;
rec2 : "Power L1"["W"]DEC2;
rec3 : "Power L2"["W"]DEC2;
rec4 : "Power L3"["W"]DEC2;
rec5 : "Volt L1"["V"]DEC2;
rec6 : "Volt L2"["V"]DEC2;
rec7 : "Volt L3"["V"]DEC2;
rec8 : "Volt L1-L2"["V"]DEC2;
rec9 : "Volt L3-L2"["V"]DEC2;
rec10 : "Volt L1-L3"["V"]DEC2;
rec11 : "Ampere L1"["A"]DEC2;
rec12 : "Ampere L2"["A"]DEC2;
rec13 : "Ampere L3"["A"]DEC2;
rec18 : "Energy L1"["kWh"]DEC2;
rec19 : "Energy L2 "["kWh"]DEC2;
rec20 : "Energy L3"["kWh"]DEC2;
rec21 : "Energy Tot"["kWh"]DEC2;
rec22 : "Frequency"["Hz"]DEC2;
PRIVATE
Exp;
tmp;
timer;
state;
initSent;
firstRun1;
firstRun2;
timer1;
timer2;
BAUDRATE 2400;
PARITY EVEN;
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);
state := 0;
TIMEOUT 5000
END;
TELEGRAM Read_Power NAMED "Read_Power" IS
QUESTION
DATA[0] := HEX(10);
DATA[1] := HEX(7B);
DATA[2] := BYTE(Id);
DATA[3] <- BYTE(DATA :=Id+123;);
DATA[4] := HEX(16);
ANSWER SIZE 202
DATA[0] = HEX(68);
DATA[1] = HEX(C4);
DATA[2] = HEX(C4);
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(02);
% 32 bit integer
DATA[22] -> WORD(tmp:=DATA;);
DATA[24] -> WORD(tmp:=tmp + 65536*DATA; IF (tmp>2147483647) THEN rec1:=tmp-4294967296; ELSE rec1:=tmp; ENDIF;);
DATA[20] -> BYTE(Exp := (DATA & 7) - 3; rec1 := rec1*10^Exp;);
% 32 bit integer
DATA[31] -> WORD(tmp:=DATA;);
DATA[33] -> WORD(tmp:=tmp + 65536*DATA; IF (tmp>2147483647) THEN rec2:=tmp-4294967296; ELSE rec2:=tmp; ENDIF;);
DATA[27] -> BYTE(Exp := (DATA & 7) - 3; rec2 := rec2*10^Exp;);
% 32 bit integer
DATA[40] -> WORD(tmp:=DATA;);
DATA[42] -> WORD(tmp:=tmp + 65536*DATA; IF (tmp>2147483647) THEN rec3:=tmp-4294967296; ELSE rec3:=tmp; ENDIF;);
DATA[36] -> BYTE(Exp := (DATA & 7) - 3; rec3 := rec3*10^Exp;);
% 32 bit integer
DATA[49] -> WORD(tmp:=DATA;);
DATA[51] -> WORD(tmp:=tmp + 65536*DATA; IF (tmp>2147483647) THEN rec4:=tmp-4294967296; ELSE rec4:=tmp; ENDIF;);
DATA[45] -> BYTE(Exp := (DATA & 7) - 3; rec4 := rec4*10^Exp;);
% 32 bit integer
DATA[59] -> WORD(tmp:=DATA;);
DATA[61] -> WORD(tmp:=tmp + 65536*DATA; IF (tmp>2147483647) THEN rec5:=tmp-4294967296; ELSE rec5:=tmp; ENDIF;);
DATA[55] -> BYTE(Exp := (DATA & 15) - 9; rec5 := rec5*10^Exp;);
% 32 bit integer
DATA[69] -> WORD(tmp:=DATA;);
DATA[71] -> WORD(tmp:=tmp + 65536*DATA; IF (tmp>2147483647) THEN rec6:=tmp-4294967296; ELSE rec6:=tmp; ENDIF;);
DATA[65] -> BYTE(Exp := (DATA & 15) - 9; rec6 := rec6*10^Exp;);
% 32 bit integer
DATA[79] -> WORD(tmp:=DATA;);
DATA[81] -> WORD(tmp:=tmp + 65536*DATA; IF (tmp>2147483647) THEN rec7:=tmp-4294967296; ELSE rec7:=tmp; ENDIF;);
DATA[75] -> BYTE(Exp := (DATA & 15) - 9; rec7 := rec7*10^Exp;);
% 32 bit integer
DATA[89] -> WORD(tmp:=DATA;);
DATA[91] -> WORD(tmp:=tmp + 65536*DATA; IF (tmp>2147483647) THEN rec8:=tmp-4294967296; ELSE rec8:=tmp; ENDIF;);
DATA[85] -> BYTE(Exp := (DATA & 15) - 9; rec8 := rec8*10^Exp;);
% 32 bit integer
DATA[99] -> WORD(tmp:=DATA;);
DATA[101] -> WORD(tmp:=tmp + 65536*DATA; IF (tmp>2147483647) THEN rec9:=tmp-4294967296; ELSE rec9:=tmp; ENDIF;);
DATA[95] -> BYTE(Exp := (DATA & 15) - 9; rec9 := rec9*10^Exp;);
% 32 bit integer
DATA[109] -> WORD(tmp:=DATA;);
DATA[111] -> WORD(tmp:=tmp + 65536*DATA; IF (tmp>2147483647) THEN rec10:=tmp-4294967296; ELSE rec10:=tmp; ENDIF;);
DATA[105] -> BYTE(Exp := (DATA & 15) - 9; rec10 := rec10*10^Exp;);
% 32 bit integer
DATA[119] -> WORD(tmp:=DATA;);
DATA[121] -> WORD(tmp:=tmp + 65536*DATA; IF (tmp>2147483647) THEN rec11:=tmp-4294967296; ELSE rec11:=tmp; ENDIF;);
DATA[115] -> BYTE(Exp := (DATA & 15) - 12; rec11 := rec11*10^Exp;);
% 32 bit integer
DATA[129] -> WORD(tmp:=DATA;);
DATA[131] -> WORD(tmp:=tmp + 65536*DATA; IF (tmp>2147483647) THEN rec12:=tmp-4294967296; ELSE rec12:=tmp; ENDIF;);
DATA[125] -> BYTE(Exp := (DATA & 15) - 12; rec12 := rec12*10^Exp;);
% 32 bit integer
DATA[139] -> WORD(tmp:=DATA;);
DATA[141] -> WORD(tmp:=tmp + 65536*DATA; IF (tmp>2147483647) THEN rec13:=tmp-4294967296; ELSE rec13:=tmp; ENDIF;);
DATA[135] -> BYTE(Exp := (DATA & 15) - 12; rec13 := rec13*10^Exp;);
% 4 digit BCD
DATA[147] -> BYTE(rec22 := (DATA & HEX(F)) + 10*(DATA & HEX(F0))/16;);
DATA[148] -> BYTE(rec22 := (rec22 + 100*(DATA & HEX(F)) + 1000*(DATA & HEX(F0))/16)/100;);
% 12 digit BCD
DATA[171] -> BYTE(rec18 := (DATA & HEX(F)) + 10*(DATA & HEX(F0))/16;);
DATA[172] -> BYTE(rec18 := rec18 + 100*(DATA & HEX(F)) + 1000*(DATA & HEX(F0))/16;);
DATA[173] -> BYTE(rec18 := rec18 + 10000*(DATA & HEX(F)) + 100000*(DATA & HEX(F0))/16;);
DATA[174] -> BYTE(rec18 := rec18 + 1000000*(DATA & HEX(F)) + 10000000*(DATA & HEX(F0))/16;);
DATA[175] -> BYTE(rec18 := rec18 + 100000000*(DATA & HEX(F)) + 1000000000*(DATA & HEX(F0))/16;);
DATA[176] -> BYTE(rec18 := rec18 + 10000000000*(DATA & HEX(F)); IF ((DATA & HEX(F0)) = HEX(F0)) THEN rec18 := 0-rec18; ELSE rec18:=rec18 + 100000000000*(DATA & HEX(F0))/16; ENDIF;);
DATA[167] -> BYTE(Exp := (DATA & 7) - 3; rec18 := (rec18*10^Exp)/1000;);
% 12 digit BCD
DATA[182] -> BYTE(rec19 := (DATA & HEX(F)) + 10*(DATA & HEX(F0))/16;);
DATA[183] -> BYTE(rec19 := rec19 + 100*(DATA & HEX(F)) + 1000*(DATA & HEX(F0))/16;);
DATA[184] -> BYTE(rec19 := rec19 + 10000*(DATA & HEX(F)) + 100000*(DATA & HEX(F0))/16;);
DATA[185] -> BYTE(rec19 := rec19 + 1000000*(DATA & HEX(F)) + 10000000*(DATA & HEX(F0))/16;);
DATA[186] -> BYTE(rec19 := rec19 + 100000000*(DATA & HEX(F)) + 1000000000*(DATA & HEX(F0))/16;);
DATA[187] -> BYTE(rec19 := rec19 + 10000000000*(DATA & HEX(F)); IF ((DATA & HEX(F0)) = HEX(F0)) THEN rec19 := 0-rec19; ELSE rec19:=rec19 + 100000000000*(DATA & HEX(F0))/16; ENDIF;);
DATA[178] -> BYTE(Exp := (DATA & 7) - 3; rec19 := (rec19*10^Exp)/1000;);
% 12 digit BCD
DATA[193] -> BYTE(rec20 := (DATA & HEX(F)) + 10*(DATA & HEX(F0))/16;);
DATA[194] -> BYTE(rec20 := rec20 + 100*(DATA & HEX(F)) + 1000*(DATA & HEX(F0))/16;);
DATA[195] -> BYTE(rec20 := rec20 + 10000*(DATA & HEX(F)) + 100000*(DATA & HEX(F0))/16;);
DATA[196] -> BYTE(rec20 := rec20 + 1000000*(DATA & HEX(F)) + 10000000*(DATA & HEX(F0))/16;);
DATA[197] -> BYTE(rec20 := rec20 + 100000000*(DATA & HEX(F)) + 1000000000*(DATA & HEX(F0))/16;);
DATA[198] -> BYTE(rec20 := rec20 + 10000000000*(DATA & HEX(F)); IF ((DATA & HEX(F0)) = HEX(F0)) THEN rec20 := 0-rec20; ELSE rec20:=rec20 + 100000000000*(DATA & HEX(F0))/16; ENDIF;);
DATA[189] -> BYTE(Exp := (DATA & 7) - 3; rec20 := (rec20*10^Exp)/1000;);
state := 4;
TIMEOUT 5000
END;
TELEGRAM Read_Energy NAMED "Read_Energy" 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 139
DATA[0] = HEX(68);
DATA[1] = HEX(85);
DATA[2] = HEX(85);
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(02);
% 12 digit BCD
DATA[22] -> BYTE(rec21 := (DATA & HEX(F)) + 10*(DATA & HEX(F0))/16;);
DATA[23] -> BYTE(rec21 := rec21 + 100*(DATA & HEX(F)) + 1000*(DATA & HEX(F0))/16;);
DATA[24] -> BYTE(rec21 := rec21 + 10000*(DATA & HEX(F)) + 100000*(DATA & HEX(F0))/16;);
DATA[25] -> BYTE(rec21 := rec21 + 1000000*(DATA & HEX(F)) + 10000000*(DATA & HEX(F0))/16;);
DATA[26] -> BYTE(rec21 := rec21 + 100000000*(DATA & HEX(F)) + 1000000000*(DATA & HEX(F0))/16;);
DATA[27] -> BYTE(rec21 := rec21 + 10000000000*(DATA & HEX(F)) + 100000000000*(DATA & HEX(F0))/16;);
DATA[20] -> BYTE(Exp := (DATA & 7) - 3; rec21 := (rec21*10^Exp)/1000;);
state := 2;
TIMEOUT 5000
END;
SCHEDULER BEGIN
timer1 := timer1 + Read_Energy.ISIDLE;
timer2 := timer2 + Read_Power.ISIDLE;
IF ((Read_Energy.FAILCOUNT) OR (Read_Power.FAILCOUNT)) AND NOT initSent OR (state = 4) THEN
TRANSMIT(Init);
initSent := 1;
ELSE
IF state = 0 THEN
IF (Read_Energy.SETTING <= timer1) OR firstRun1=0 THEN
TRANSMIT(Read_Energy);
state := 1;
timer := 0;
firstRun1:=1;
timer1:=0;
ENDIF;
ELSIF state = 2 THEN
IF (Read_Power.SETTING <= timer2) OR firstRun2=0 THEN
TRANSMIT(Read_Power);
state := 3;
timer := 0;
firstRun2:=1;
timer2:=0;
ENDIF;
ENDIF;
timer := timer + 1;
IF (timer > 10 ) THEN
initSent := 0;
timer:=0;
ENDIF;
ENDIF;
END;
END;
IS
PARAMETER
Id :"Address"INT;
PUBLIC
IDNr : "ID number"INT;
rec1 : "Power tot" ["W"]DEC2;
rec2 : "Power L1"["W"]DEC2;
rec3 : "Power L2"["W"]DEC2;
rec4 : "Power L3"["W"]DEC2;
rec5 : "Volt L1"["V"]DEC2;
rec6 : "Volt L2"["V"]DEC2;
rec7 : "Volt L3"["V"]DEC2;
rec8 : "Volt L1-L2"["V"]DEC2;
rec9 : "Volt L3-L2"["V"]DEC2;
rec10 : "Volt L1-L3"["V"]DEC2;
rec11 : "Ampere L1"["A"]DEC2;
rec12 : "Ampere L2"["A"]DEC2;
rec13 : "Ampere L3"["A"]DEC2;
rec18 : "Energy L1"["kWh"]DEC2;
rec19 : "Energy L2 "["kWh"]DEC2;
rec20 : "Energy L3"["kWh"]DEC2;
rec21 : "Energy Tot"["kWh"]DEC2;
rec22 : "Frequency"["Hz"]DEC2;
PRIVATE
Exp;
tmp;
timer;
state;
initSent;
firstRun1;
firstRun2;
timer1;
timer2;
BAUDRATE 2400;
PARITY EVEN;
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);
state := 0;
TIMEOUT 5000
END;
TELEGRAM Read_Power NAMED "Read_Power" IS
QUESTION
DATA[0] := HEX(10);
DATA[1] := HEX(7B);
DATA[2] := BYTE(Id);
DATA[3] <- BYTE(DATA :=Id+123;);
DATA[4] := HEX(16);
ANSWER SIZE 202
DATA[0] = HEX(68);
DATA[1] = HEX(C4);
DATA[2] = HEX(C4);
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(02);
% 32 bit integer
DATA[22] -> WORD(tmp:=DATA;);
DATA[24] -> WORD(tmp:=tmp + 65536*DATA; IF (tmp>2147483647) THEN rec1:=tmp-4294967296; ELSE rec1:=tmp; ENDIF;);
DATA[20] -> BYTE(Exp := (DATA & 7) - 3; rec1 := rec1*10^Exp;);
% 32 bit integer
DATA[31] -> WORD(tmp:=DATA;);
DATA[33] -> WORD(tmp:=tmp + 65536*DATA; IF (tmp>2147483647) THEN rec2:=tmp-4294967296; ELSE rec2:=tmp; ENDIF;);
DATA[27] -> BYTE(Exp := (DATA & 7) - 3; rec2 := rec2*10^Exp;);
% 32 bit integer
DATA[40] -> WORD(tmp:=DATA;);
DATA[42] -> WORD(tmp:=tmp + 65536*DATA; IF (tmp>2147483647) THEN rec3:=tmp-4294967296; ELSE rec3:=tmp; ENDIF;);
DATA[36] -> BYTE(Exp := (DATA & 7) - 3; rec3 := rec3*10^Exp;);
% 32 bit integer
DATA[49] -> WORD(tmp:=DATA;);
DATA[51] -> WORD(tmp:=tmp + 65536*DATA; IF (tmp>2147483647) THEN rec4:=tmp-4294967296; ELSE rec4:=tmp; ENDIF;);
DATA[45] -> BYTE(Exp := (DATA & 7) - 3; rec4 := rec4*10^Exp;);
% 32 bit integer
DATA[59] -> WORD(tmp:=DATA;);
DATA[61] -> WORD(tmp:=tmp + 65536*DATA; IF (tmp>2147483647) THEN rec5:=tmp-4294967296; ELSE rec5:=tmp; ENDIF;);
DATA[55] -> BYTE(Exp := (DATA & 15) - 9; rec5 := rec5*10^Exp;);
% 32 bit integer
DATA[69] -> WORD(tmp:=DATA;);
DATA[71] -> WORD(tmp:=tmp + 65536*DATA; IF (tmp>2147483647) THEN rec6:=tmp-4294967296; ELSE rec6:=tmp; ENDIF;);
DATA[65] -> BYTE(Exp := (DATA & 15) - 9; rec6 := rec6*10^Exp;);
% 32 bit integer
DATA[79] -> WORD(tmp:=DATA;);
DATA[81] -> WORD(tmp:=tmp + 65536*DATA; IF (tmp>2147483647) THEN rec7:=tmp-4294967296; ELSE rec7:=tmp; ENDIF;);
DATA[75] -> BYTE(Exp := (DATA & 15) - 9; rec7 := rec7*10^Exp;);
% 32 bit integer
DATA[89] -> WORD(tmp:=DATA;);
DATA[91] -> WORD(tmp:=tmp + 65536*DATA; IF (tmp>2147483647) THEN rec8:=tmp-4294967296; ELSE rec8:=tmp; ENDIF;);
DATA[85] -> BYTE(Exp := (DATA & 15) - 9; rec8 := rec8*10^Exp;);
% 32 bit integer
DATA[99] -> WORD(tmp:=DATA;);
DATA[101] -> WORD(tmp:=tmp + 65536*DATA; IF (tmp>2147483647) THEN rec9:=tmp-4294967296; ELSE rec9:=tmp; ENDIF;);
DATA[95] -> BYTE(Exp := (DATA & 15) - 9; rec9 := rec9*10^Exp;);
% 32 bit integer
DATA[109] -> WORD(tmp:=DATA;);
DATA[111] -> WORD(tmp:=tmp + 65536*DATA; IF (tmp>2147483647) THEN rec10:=tmp-4294967296; ELSE rec10:=tmp; ENDIF;);
DATA[105] -> BYTE(Exp := (DATA & 15) - 9; rec10 := rec10*10^Exp;);
% 32 bit integer
DATA[119] -> WORD(tmp:=DATA;);
DATA[121] -> WORD(tmp:=tmp + 65536*DATA; IF (tmp>2147483647) THEN rec11:=tmp-4294967296; ELSE rec11:=tmp; ENDIF;);
DATA[115] -> BYTE(Exp := (DATA & 15) - 12; rec11 := rec11*10^Exp;);
% 32 bit integer
DATA[129] -> WORD(tmp:=DATA;);
DATA[131] -> WORD(tmp:=tmp + 65536*DATA; IF (tmp>2147483647) THEN rec12:=tmp-4294967296; ELSE rec12:=tmp; ENDIF;);
DATA[125] -> BYTE(Exp := (DATA & 15) - 12; rec12 := rec12*10^Exp;);
% 32 bit integer
DATA[139] -> WORD(tmp:=DATA;);
DATA[141] -> WORD(tmp:=tmp + 65536*DATA; IF (tmp>2147483647) THEN rec13:=tmp-4294967296; ELSE rec13:=tmp; ENDIF;);
DATA[135] -> BYTE(Exp := (DATA & 15) - 12; rec13 := rec13*10^Exp;);
% 4 digit BCD
DATA[147] -> BYTE(rec22 := (DATA & HEX(F)) + 10*(DATA & HEX(F0))/16;);
DATA[148] -> BYTE(rec22 := (rec22 + 100*(DATA & HEX(F)) + 1000*(DATA & HEX(F0))/16)/100;);
% 12 digit BCD
DATA[171] -> BYTE(rec18 := (DATA & HEX(F)) + 10*(DATA & HEX(F0))/16;);
DATA[172] -> BYTE(rec18 := rec18 + 100*(DATA & HEX(F)) + 1000*(DATA & HEX(F0))/16;);
DATA[173] -> BYTE(rec18 := rec18 + 10000*(DATA & HEX(F)) + 100000*(DATA & HEX(F0))/16;);
DATA[174] -> BYTE(rec18 := rec18 + 1000000*(DATA & HEX(F)) + 10000000*(DATA & HEX(F0))/16;);
DATA[175] -> BYTE(rec18 := rec18 + 100000000*(DATA & HEX(F)) + 1000000000*(DATA & HEX(F0))/16;);
DATA[176] -> BYTE(rec18 := rec18 + 10000000000*(DATA & HEX(F)); IF ((DATA & HEX(F0)) = HEX(F0)) THEN rec18 := 0-rec18; ELSE rec18:=rec18 + 100000000000*(DATA & HEX(F0))/16; ENDIF;);
DATA[167] -> BYTE(Exp := (DATA & 7) - 3; rec18 := (rec18*10^Exp)/1000;);
% 12 digit BCD
DATA[182] -> BYTE(rec19 := (DATA & HEX(F)) + 10*(DATA & HEX(F0))/16;);
DATA[183] -> BYTE(rec19 := rec19 + 100*(DATA & HEX(F)) + 1000*(DATA & HEX(F0))/16;);
DATA[184] -> BYTE(rec19 := rec19 + 10000*(DATA & HEX(F)) + 100000*(DATA & HEX(F0))/16;);
DATA[185] -> BYTE(rec19 := rec19 + 1000000*(DATA & HEX(F)) + 10000000*(DATA & HEX(F0))/16;);
DATA[186] -> BYTE(rec19 := rec19 + 100000000*(DATA & HEX(F)) + 1000000000*(DATA & HEX(F0))/16;);
DATA[187] -> BYTE(rec19 := rec19 + 10000000000*(DATA & HEX(F)); IF ((DATA & HEX(F0)) = HEX(F0)) THEN rec19 := 0-rec19; ELSE rec19:=rec19 + 100000000000*(DATA & HEX(F0))/16; ENDIF;);
DATA[178] -> BYTE(Exp := (DATA & 7) - 3; rec19 := (rec19*10^Exp)/1000;);
% 12 digit BCD
DATA[193] -> BYTE(rec20 := (DATA & HEX(F)) + 10*(DATA & HEX(F0))/16;);
DATA[194] -> BYTE(rec20 := rec20 + 100*(DATA & HEX(F)) + 1000*(DATA & HEX(F0))/16;);
DATA[195] -> BYTE(rec20 := rec20 + 10000*(DATA & HEX(F)) + 100000*(DATA & HEX(F0))/16;);
DATA[196] -> BYTE(rec20 := rec20 + 1000000*(DATA & HEX(F)) + 10000000*(DATA & HEX(F0))/16;);
DATA[197] -> BYTE(rec20 := rec20 + 100000000*(DATA & HEX(F)) + 1000000000*(DATA & HEX(F0))/16;);
DATA[198] -> BYTE(rec20 := rec20 + 10000000000*(DATA & HEX(F)); IF ((DATA & HEX(F0)) = HEX(F0)) THEN rec20 := 0-rec20; ELSE rec20:=rec20 + 100000000000*(DATA & HEX(F0))/16; ENDIF;);
DATA[189] -> BYTE(Exp := (DATA & 7) - 3; rec20 := (rec20*10^Exp)/1000;);
state := 4;
TIMEOUT 5000
END;
TELEGRAM Read_Energy NAMED "Read_Energy" 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 139
DATA[0] = HEX(68);
DATA[1] = HEX(85);
DATA[2] = HEX(85);
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(02);
% 12 digit BCD
DATA[22] -> BYTE(rec21 := (DATA & HEX(F)) + 10*(DATA & HEX(F0))/16;);
DATA[23] -> BYTE(rec21 := rec21 + 100*(DATA & HEX(F)) + 1000*(DATA & HEX(F0))/16;);
DATA[24] -> BYTE(rec21 := rec21 + 10000*(DATA & HEX(F)) + 100000*(DATA & HEX(F0))/16;);
DATA[25] -> BYTE(rec21 := rec21 + 1000000*(DATA & HEX(F)) + 10000000*(DATA & HEX(F0))/16;);
DATA[26] -> BYTE(rec21 := rec21 + 100000000*(DATA & HEX(F)) + 1000000000*(DATA & HEX(F0))/16;);
DATA[27] -> BYTE(rec21 := rec21 + 10000000000*(DATA & HEX(F)) + 100000000000*(DATA & HEX(F0))/16;);
DATA[20] -> BYTE(Exp := (DATA & 7) - 3; rec21 := (rec21*10^Exp)/1000;);
state := 2;
TIMEOUT 5000
END;
SCHEDULER BEGIN
timer1 := timer1 + Read_Energy.ISIDLE;
timer2 := timer2 + Read_Power.ISIDLE;
IF ((Read_Energy.FAILCOUNT) OR (Read_Power.FAILCOUNT)) AND NOT initSent OR (state = 4) THEN
TRANSMIT(Init);
initSent := 1;
ELSE
IF state = 0 THEN
IF (Read_Energy.SETTING <= timer1) OR firstRun1=0 THEN
TRANSMIT(Read_Energy);
state := 1;
timer := 0;
firstRun1:=1;
timer1:=0;
ENDIF;
ELSIF state = 2 THEN
IF (Read_Power.SETTING <= timer2) OR firstRun2=0 THEN
TRANSMIT(Read_Power);
state := 3;
timer := 0;
firstRun2:=1;
timer2:=0;
ENDIF;
ENDIF;
timer := timer + 1;
IF (timer > 10 ) THEN
initSent := 0;
timer:=0;
ENDIF;
ENDIF;
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.