Carlo Gavazzi EM33 power analyzer
Detaljer
Beskrivning
Device definition for Carlo Gavazzi EM33 power analyzer
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 EM33 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: 2010-03-15 initial version
%
DEVICETYPE CGEM33 NAMED "CG_EM33" TYPEID 21151 IS
PARAMETER
Id :"Address";
PUBLIC
KWh : "KWh";
Ptot : "P tot";
iL1 : "I L1";
iL2 : "I L2";
iL3 : "I 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(6); % 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)) / 1000;
ELSE
iL1 := (Tmp2 + (DATA*65536)) / 1000;
ENDIF;
);
DATA[7] -> RWORD(Tmp2 := DATA;);
DATA[9] -> RWORD(IF DATA > 32767 THEN % Negativ ?
iL2 := 0 - (1 + (65535-Tmp2) + ((65535-DATA)*65536)) / 1000;
ELSE
iL2 := (Tmp2 + (DATA*65536)) / 1000;
ENDIF;
);
DATA[11]-> RWORD(Tmp2 := DATA;);
DATA[13]-> RWORD(IF DATA > 32767 THEN % Negativ ?
iL3 := 0 - (1 + (65535-Tmp2) + ((65535-DATA)*65536)) / 1000;
ELSE
iL3 := (Tmp2 + (DATA*65536)) / 1000;
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(14); % start register
DATA[4] := RWORD(2); % number of registers to read
ANSWER SIZE 9
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;
);
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(12); % start register
DATA[4] := RWORD(2); % number of registers to read
ANSWER SIZE 9
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;
);
TIMEOUT 1000
END;
END;
% Device definition for Carlo Gavazzi EM33 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: 2010-03-15 initial version
%
DEVICETYPE CGEM33 NAMED "CG_EM33" TYPEID 21151 IS
PARAMETER
Id :"Address";
PUBLIC
KWh : "KWh";
Ptot : "P tot";
iL1 : "I L1";
iL2 : "I L2";
iL3 : "I 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(6); % 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)) / 1000;
ELSE
iL1 := (Tmp2 + (DATA*65536)) / 1000;
ENDIF;
);
DATA[7] -> RWORD(Tmp2 := DATA;);
DATA[9] -> RWORD(IF DATA > 32767 THEN % Negativ ?
iL2 := 0 - (1 + (65535-Tmp2) + ((65535-DATA)*65536)) / 1000;
ELSE
iL2 := (Tmp2 + (DATA*65536)) / 1000;
ENDIF;
);
DATA[11]-> RWORD(Tmp2 := DATA;);
DATA[13]-> RWORD(IF DATA > 32767 THEN % Negativ ?
iL3 := 0 - (1 + (65535-Tmp2) + ((65535-DATA)*65536)) / 1000;
ELSE
iL3 := (Tmp2 + (DATA*65536)) / 1000;
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(14); % start register
DATA[4] := RWORD(2); % number of registers to read
ANSWER SIZE 9
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;
);
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(12); % start register
DATA[4] := RWORD(2); % number of registers to read
ANSWER SIZE 9
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;
);
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.