Carlo Gavazzi EM21 power analyzer
Detaljer
Beskrivning
Drivrutin
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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Device definition for Carlo Gavazzi EM21 power analyzer
%
% Settings module:
% Parity: None
% Baud: 9600
% Mode: RTU
%
% NOTE! The RS-485 bus must be cross-connected.
% WMPro terminal A -> CG EM24 terminal B
% WMPro terminal B -> CG EM24 terminal A
%
% Author: Peter Malmberg, ABELKO AB Luleå
%
% History: 2007-03-07 initial version
% Modified: 2008-03-07 Handels negativ values and values over 65535
%
DEVICETYPE CGEM21 NAMED "CG_EM21" TYPEID 21151 IS
PARAMETER
Id :"Address";
PUBLIC
KWh : "KWh";
Kvarh : "Kvarh";
Ptot : "P tot";
VAtot : "VA tot";
VARtot : "VAR tot";
iL1 : "I L1";
iL2 : "I L2";
iL3 : "I L3";
pL1 : "P L1";
pL2 : "P L2";
pL3 : "P L3";
varL1 : "VAR L1";
varL2 : "VAR L2";
varL3 : "VAR L3";
vL1 : "V L1";
vL2 : "V L2";
vL3 : "V L3";
PRIVATE
Tmp1;
Tmp2;
Tmp3;
Tmp4;
Tmp5;
Tmp6;
BAUDRATE 9600;
CHECKSUM MODBUS SWAPPED;
TELEGRAM ReadVoltage NAMED "Read Voltage" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(04); % Modbus command "04h" read multiple inputregisters
DATA[2] := RWORD(00); % start register
DATA[4] := RWORD(6); % number of registers to read
ANSWER SIZE 17
DATA[0] = BYTE(Id);
DATA[1] = HEX(04);
DATA[3] -> RWORD(Tmp1 := DATA;);
DATA[5] -> RWORD(IF DATA > 32767 THEN % Negativ ?
vL1 := 0 - (1 + (65535-Tmp1) + ((65535-DATA)*65536)) / 10;
ELSE
vL1 := (Tmp1 + (DATA*65536)) / 10;
ENDIF;
);
DATA[7] -> RWORD(Tmp1 := DATA;);
DATA[9] -> RWORD(IF DATA > 32767 THEN % Negativ ?
vL2 := 0 - (1 + (65535-Tmp1) + ((65535-DATA)*65536)) / 10;
ELSE
vL2 := (Tmp1 + (DATA*65536)) / 10;
ENDIF;
);
DATA[11]-> RWORD(Tmp1 := DATA;);
DATA[13]-> RWORD(IF DATA > 32767 THEN % Negativ ?
vL3 := 0 - (1 + (65535-Tmp1) + ((65535-DATA)*65536)) / 10;
ELSE
vL3 := (Tmp1 + (DATA*65536)) / 10;
ENDIF;
);
TIMEOUT 300
END;
TELEGRAM ReadCurrent NAMED "Read Current" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(04); % Modbus command "04h" read multiple inputregisters
DATA[2] := RWORD(12); % start register
DATA[4] := RWORD(6); % number of registers to read
ANSWER SIZE 17
DATA[0] = BYTE(Id);
DATA[1] = HEX(04);
DATA[3] -> RWORD(Tmp2 := DATA;);
DATA[5] -> RWORD(IF DATA > 32767 THEN % Negativ ?
iL1 := 0 - (1 + (65535-Tmp2) + ((65535-DATA)*65536)) / 100;
ELSE
iL1 := (Tmp2 + (DATA*65536)) / 100;
ENDIF;
);
DATA[7] -> RWORD(Tmp2 := DATA;);
DATA[9] -> RWORD(IF DATA > 32767 THEN % Negativ ?
iL2 := 0 - (1 + (65535-Tmp2) + ((65535-DATA)*65536)) / 100;
ELSE
iL2 := (Tmp2 + (DATA*65536)) / 100;
ENDIF;
);
DATA[11]-> RWORD(Tmp2 := DATA;);
DATA[13]-> RWORD(IF DATA > 32767 THEN % Negativ ?
iL3 := 0 - (1 + (65535-Tmp2) + ((65535-DATA)*65536)) / 100;
ELSE
iL3 := (Tmp2 + (DATA*65536)) / 100;
ENDIF;
);
TIMEOUT 1000
END;
TELEGRAM ReadPower NAMED "Read Power" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(04); % Modbus command "04h" read multiple inputregisters
DATA[2] := RWORD(18); % start register
DATA[4] := RWORD(6); % number of registers to read
ANSWER SIZE 17
DATA[0] = BYTE(Id);
DATA[1] = HEX(04);
DATA[3] -> RWORD(Tmp3 := DATA;);
DATA[5] -> RWORD(IF DATA > 32767 THEN % Negativ ?
pL1 := 0 - (1 + (65535-Tmp3) + ((65535-DATA)*65536)) / 10;
ELSE
pL1 := (Tmp3 + (DATA*65536)) / 10;
ENDIF;
);
DATA[7] -> RWORD(Tmp3 := DATA;);
DATA[9] -> RWORD(IF DATA > 32767 THEN % Negativ ?
pL2 := 0 - (1 + (65535-Tmp3) + ((65535-DATA)*65536)) / 10;
ELSE
pL2 := (Tmp3 + (DATA*65536)) / 10;
ENDIF;
);
DATA[11]-> RWORD(Tmp3 := DATA;);
DATA[13]-> RWORD(IF DATA > 32767 THEN % Negativ ?
pL3 := 0 - (1 + (65535-Tmp3) + ((65535-DATA)*65536)) / 10;
ELSE
pL3 := (Tmp3 + (DATA*65536)) / 10;
ENDIF;
);
TIMEOUT 1000
END;
TELEGRAM ReadRPower NAMED "Read reactive Power" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(04); % Modbus command "04h" read multiple inputregisters
DATA[2] := RWORD(30); % start register
DATA[4] := RWORD(6); % number of registers to read
ANSWER SIZE 17
DATA[0] = BYTE(Id);
DATA[1] = HEX(04);
DATA[3] -> RWORD(Tmp4 := DATA;);
DATA[5] -> RWORD(IF DATA > 32767 THEN % Negativ ?
varL1 := 0 - (1 + (65535-Tmp4) + ((65535-DATA)*65536)) / 10;
ELSE
varL1 := (Tmp4 + (DATA*65536)) / 10;
ENDIF;
);
DATA[7] -> RWORD(Tmp4 := DATA;);
DATA[9] -> RWORD(IF DATA > 32767 THEN % Negativ ?
varL2 := 0 - (1 + (65535-Tmp4) + ((65535-DATA)*65536)) / 10;
ELSE
varL2 := (Tmp4 + (DATA*65536)) / 10;
ENDIF;
);
DATA[11]-> RWORD(Tmp4 := DATA;);
DATA[13]-> RWORD(IF DATA > 32767 THEN % Negativ ?
varL3 := 0 - (1 + (65535-Tmp4) + ((65535-DATA)*65536)) / 10;
ELSE
varL3 := (Tmp4 + (DATA*65536)) / 10;
ENDIF;
);
TIMEOUT 1000
END;
TELEGRAM ReadEnergy NAMED "Read Energy" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(04); % Modbus command "04h" read multiple inputregisters
DATA[2] := RWORD(52); % start register
DATA[4] := RWORD(4); % number of registers to read
ANSWER SIZE 13
DATA[0] = BYTE(Id);
DATA[1] = HEX(04);
DATA[3] -> RWORD(Tmp5 := DATA;);
DATA[5] -> RWORD(IF DATA > 32767 THEN % Negativ ?
KWh := 0 - (1 + (65535-Tmp5) + ((65535-DATA)*65536)) / 10;
ELSE
KWh := (Tmp5 + (DATA*65536)) / 10;
ENDIF;
);
DATA[7] -> RWORD(Tmp5 := DATA;);
DATA[9] -> RWORD(IF DATA > 32767 THEN % Negativ ?
Kvarh := 0 - (1 + (65535-Tmp5) + ((65535-DATA)*65536)) / 10;
ELSE
Kvarh := (Tmp5 + (DATA*65536)) / 10;
ENDIF;
);
TIMEOUT 1000
END;
TELEGRAM ReadPowerTot NAMED "Read Power tot" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(04); % Modbus command "04h" read multiple inputregisters
DATA[2] := RWORD(40); % start register
DATA[4] := RWORD(6); % number of registers to read
ANSWER SIZE 17
DATA[0] = BYTE(Id);
DATA[1] = HEX(04);
DATA[3] -> RWORD(Tmp6 := DATA;);
DATA[5] -> RWORD(IF DATA > 32767 THEN % Negativ ?
Ptot := 0 - (1 + (65535-Tmp6) + ((65535-DATA)*65536)) / 10;
ELSE
Ptot := (Tmp6 + (DATA*65536)) / 10;
ENDIF;
);
DATA[7] -> RWORD(Tmp6 := DATA;);
DATA[9] -> RWORD(IF DATA > 32767 THEN % Negativ ?
VAtot := 0 - (1 + (65535-Tmp6) + ((65535-DATA)*65536)) / 10;
ELSE
VAtot := (Tmp6 + (DATA*65536)) / 10;
ENDIF;
);
DATA[11]-> RWORD(Tmp6 := DATA;);
DATA[13]-> RWORD(IF DATA > 32767 THEN % Negativ ?
VARtot := 0 - (1 + (65535-Tmp6) + ((65535-DATA)*65536)) / 10;
ELSE
VARtot := (Tmp6 + (DATA*65536)) / 10;
ENDIF;
);
TIMEOUT 1000
END;
END;
% Device definition for Carlo Gavazzi EM21 power analyzer
%
% Settings module:
% Parity: None
% Baud: 9600
% Mode: RTU
%
% NOTE! The RS-485 bus must be cross-connected.
% WMPro terminal A -> CG EM24 terminal B
% WMPro terminal B -> CG EM24 terminal A
%
% Author: Peter Malmberg, ABELKO AB Luleå
%
% History: 2007-03-07 initial version
% Modified: 2008-03-07 Handels negativ values and values over 65535
%
DEVICETYPE CGEM21 NAMED "CG_EM21" TYPEID 21151 IS
PARAMETER
Id :"Address";
PUBLIC
KWh : "KWh";
Kvarh : "Kvarh";
Ptot : "P tot";
VAtot : "VA tot";
VARtot : "VAR tot";
iL1 : "I L1";
iL2 : "I L2";
iL3 : "I L3";
pL1 : "P L1";
pL2 : "P L2";
pL3 : "P L3";
varL1 : "VAR L1";
varL2 : "VAR L2";
varL3 : "VAR L3";
vL1 : "V L1";
vL2 : "V L2";
vL3 : "V L3";
PRIVATE
Tmp1;
Tmp2;
Tmp3;
Tmp4;
Tmp5;
Tmp6;
BAUDRATE 9600;
CHECKSUM MODBUS SWAPPED;
TELEGRAM ReadVoltage NAMED "Read Voltage" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(04); % Modbus command "04h" read multiple inputregisters
DATA[2] := RWORD(00); % start register
DATA[4] := RWORD(6); % number of registers to read
ANSWER SIZE 17
DATA[0] = BYTE(Id);
DATA[1] = HEX(04);
DATA[3] -> RWORD(Tmp1 := DATA;);
DATA[5] -> RWORD(IF DATA > 32767 THEN % Negativ ?
vL1 := 0 - (1 + (65535-Tmp1) + ((65535-DATA)*65536)) / 10;
ELSE
vL1 := (Tmp1 + (DATA*65536)) / 10;
ENDIF;
);
DATA[7] -> RWORD(Tmp1 := DATA;);
DATA[9] -> RWORD(IF DATA > 32767 THEN % Negativ ?
vL2 := 0 - (1 + (65535-Tmp1) + ((65535-DATA)*65536)) / 10;
ELSE
vL2 := (Tmp1 + (DATA*65536)) / 10;
ENDIF;
);
DATA[11]-> RWORD(Tmp1 := DATA;);
DATA[13]-> RWORD(IF DATA > 32767 THEN % Negativ ?
vL3 := 0 - (1 + (65535-Tmp1) + ((65535-DATA)*65536)) / 10;
ELSE
vL3 := (Tmp1 + (DATA*65536)) / 10;
ENDIF;
);
TIMEOUT 300
END;
TELEGRAM ReadCurrent NAMED "Read Current" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(04); % Modbus command "04h" read multiple inputregisters
DATA[2] := RWORD(12); % start register
DATA[4] := RWORD(6); % number of registers to read
ANSWER SIZE 17
DATA[0] = BYTE(Id);
DATA[1] = HEX(04);
DATA[3] -> RWORD(Tmp2 := DATA;);
DATA[5] -> RWORD(IF DATA > 32767 THEN % Negativ ?
iL1 := 0 - (1 + (65535-Tmp2) + ((65535-DATA)*65536)) / 100;
ELSE
iL1 := (Tmp2 + (DATA*65536)) / 100;
ENDIF;
);
DATA[7] -> RWORD(Tmp2 := DATA;);
DATA[9] -> RWORD(IF DATA > 32767 THEN % Negativ ?
iL2 := 0 - (1 + (65535-Tmp2) + ((65535-DATA)*65536)) / 100;
ELSE
iL2 := (Tmp2 + (DATA*65536)) / 100;
ENDIF;
);
DATA[11]-> RWORD(Tmp2 := DATA;);
DATA[13]-> RWORD(IF DATA > 32767 THEN % Negativ ?
iL3 := 0 - (1 + (65535-Tmp2) + ((65535-DATA)*65536)) / 100;
ELSE
iL3 := (Tmp2 + (DATA*65536)) / 100;
ENDIF;
);
TIMEOUT 1000
END;
TELEGRAM ReadPower NAMED "Read Power" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(04); % Modbus command "04h" read multiple inputregisters
DATA[2] := RWORD(18); % start register
DATA[4] := RWORD(6); % number of registers to read
ANSWER SIZE 17
DATA[0] = BYTE(Id);
DATA[1] = HEX(04);
DATA[3] -> RWORD(Tmp3 := DATA;);
DATA[5] -> RWORD(IF DATA > 32767 THEN % Negativ ?
pL1 := 0 - (1 + (65535-Tmp3) + ((65535-DATA)*65536)) / 10;
ELSE
pL1 := (Tmp3 + (DATA*65536)) / 10;
ENDIF;
);
DATA[7] -> RWORD(Tmp3 := DATA;);
DATA[9] -> RWORD(IF DATA > 32767 THEN % Negativ ?
pL2 := 0 - (1 + (65535-Tmp3) + ((65535-DATA)*65536)) / 10;
ELSE
pL2 := (Tmp3 + (DATA*65536)) / 10;
ENDIF;
);
DATA[11]-> RWORD(Tmp3 := DATA;);
DATA[13]-> RWORD(IF DATA > 32767 THEN % Negativ ?
pL3 := 0 - (1 + (65535-Tmp3) + ((65535-DATA)*65536)) / 10;
ELSE
pL3 := (Tmp3 + (DATA*65536)) / 10;
ENDIF;
);
TIMEOUT 1000
END;
TELEGRAM ReadRPower NAMED "Read reactive Power" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(04); % Modbus command "04h" read multiple inputregisters
DATA[2] := RWORD(30); % start register
DATA[4] := RWORD(6); % number of registers to read
ANSWER SIZE 17
DATA[0] = BYTE(Id);
DATA[1] = HEX(04);
DATA[3] -> RWORD(Tmp4 := DATA;);
DATA[5] -> RWORD(IF DATA > 32767 THEN % Negativ ?
varL1 := 0 - (1 + (65535-Tmp4) + ((65535-DATA)*65536)) / 10;
ELSE
varL1 := (Tmp4 + (DATA*65536)) / 10;
ENDIF;
);
DATA[7] -> RWORD(Tmp4 := DATA;);
DATA[9] -> RWORD(IF DATA > 32767 THEN % Negativ ?
varL2 := 0 - (1 + (65535-Tmp4) + ((65535-DATA)*65536)) / 10;
ELSE
varL2 := (Tmp4 + (DATA*65536)) / 10;
ENDIF;
);
DATA[11]-> RWORD(Tmp4 := DATA;);
DATA[13]-> RWORD(IF DATA > 32767 THEN % Negativ ?
varL3 := 0 - (1 + (65535-Tmp4) + ((65535-DATA)*65536)) / 10;
ELSE
varL3 := (Tmp4 + (DATA*65536)) / 10;
ENDIF;
);
TIMEOUT 1000
END;
TELEGRAM ReadEnergy NAMED "Read Energy" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(04); % Modbus command "04h" read multiple inputregisters
DATA[2] := RWORD(52); % start register
DATA[4] := RWORD(4); % number of registers to read
ANSWER SIZE 13
DATA[0] = BYTE(Id);
DATA[1] = HEX(04);
DATA[3] -> RWORD(Tmp5 := DATA;);
DATA[5] -> RWORD(IF DATA > 32767 THEN % Negativ ?
KWh := 0 - (1 + (65535-Tmp5) + ((65535-DATA)*65536)) / 10;
ELSE
KWh := (Tmp5 + (DATA*65536)) / 10;
ENDIF;
);
DATA[7] -> RWORD(Tmp5 := DATA;);
DATA[9] -> RWORD(IF DATA > 32767 THEN % Negativ ?
Kvarh := 0 - (1 + (65535-Tmp5) + ((65535-DATA)*65536)) / 10;
ELSE
Kvarh := (Tmp5 + (DATA*65536)) / 10;
ENDIF;
);
TIMEOUT 1000
END;
TELEGRAM ReadPowerTot NAMED "Read Power tot" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(04); % Modbus command "04h" read multiple inputregisters
DATA[2] := RWORD(40); % start register
DATA[4] := RWORD(6); % number of registers to read
ANSWER SIZE 17
DATA[0] = BYTE(Id);
DATA[1] = HEX(04);
DATA[3] -> RWORD(Tmp6 := DATA;);
DATA[5] -> RWORD(IF DATA > 32767 THEN % Negativ ?
Ptot := 0 - (1 + (65535-Tmp6) + ((65535-DATA)*65536)) / 10;
ELSE
Ptot := (Tmp6 + (DATA*65536)) / 10;
ENDIF;
);
DATA[7] -> RWORD(Tmp6 := DATA;);
DATA[9] -> RWORD(IF DATA > 32767 THEN % Negativ ?
VAtot := 0 - (1 + (65535-Tmp6) + ((65535-DATA)*65536)) / 10;
ELSE
VAtot := (Tmp6 + (DATA*65536)) / 10;
ENDIF;
);
DATA[11]-> RWORD(Tmp6 := DATA;);
DATA[13]-> RWORD(IF DATA > 32767 THEN % Negativ ?
VARtot := 0 - (1 + (65535-Tmp6) + ((65535-DATA)*65536)) / 10;
ELSE
VARtot := (Tmp6 + (DATA*65536)) / 10;
ENDIF;
);
TIMEOUT 1000
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.