Carlo Gavazzi EM26 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 EM26 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
% Modified: 2008-09-02 Climacheck: Adjusted register update and CT/VT ratio setup added
%
DEVICETYPE CarloGavazziEM24 NAMED "CarloGavazziEM24" TYPEID 21150 IS
PARAMETER
Id :"Address";
CTRatio :"CurrentT ratio"; % (reg 4397)
VTRatio :"VoltageT ratio"; % (reg 4399)
PUBLIC
pL1 : "Power L1" ["W"]; % (reg 19)
pL2 : "Power L2" ["W"]; % (reg 21)
pL3 : "Power L3" ["W"]; % (reg 23)
iL1 : "Current L1" ["A"]; % (reg 13) Ampere * 1000
iL2 : "Current L2" ["A"]; % (reg 15)
iL3 : "Current L3" ["A"]; % (reg 17)
vL1 : "Voltage L1" ["V"]; % (reg 1) Volt * 10
vL2 : "Voltage L2" ["V"]; % (reg 3)
vL3 : "Voltage L3" ["V"]; % (reg 5)
pFL1 : "Power factor1" [""]; % (reg 51)
pFL2 : "Power factor2" [""]; % (reg 52)
pFL3 : "Power factor3" [""]; % (reg 53)
pF : "Power factor" [""]; % (reg 54) PF * 1000
Psum : "Power sum" ["W"]; % (reg 41) Watt * 10
%pVAsum : "Psum Apparent" ["VA"]; % (reg 43) VA * 10
pVARsum : "Psum Reaktiv" ["var"]; % (reg 45) var * 10
KWhtot : "Energy total" ["kWh"]; % (reg 63) kWh * 10
KVARhtot : "Energy Reaktiv" ["kvarh"]; % (reg 65) kvarh * 10
KWhL1 : "Energy L1" ["kWh"]; % (reg 71)
KWhL2 : "Energy L2" ["kWh"]; % (reg 72)
KWhL3 : "Energy L3" ["kWh"]; % (reg 73)
%varL1 : "Reaktiv power1" ["var"]; % (reg 31)
%varL2 : "Reaktiv power2" ["var"]; % (reg 33)
%varL3 : "Reaktiv power3" ["var"]; % (reg 35)
PRIVATE
Tmp;
Tmp1;
Tmp2;
Tmp3;
Tmp4;
Tmp5;
Tmp6;
CTCnt;
VTCnt;
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)) / 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 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(62); % 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 ?
KWhtot := 0 - (1 + (65535-Tmp5) + ((65535-DATA)*65536)) / 10;
ELSE
KWhtot := (Tmp5 + (DATA*65536)) / 10;
ENDIF;
);
DATA[7] -> RWORD(Tmp5 := DATA;);
DATA[9] -> RWORD(IF DATA > 32767 THEN % Negativ ?
KVARhtot := 0 - (1 + (65535-Tmp5) + ((65535-DATA)*65536)) / 10;
ELSE
KVARhtot := (Tmp5 + (DATA*65536)) / 10;
ENDIF;
);
TIMEOUT 1000
END;
TELEGRAM ReadPowerTot NAMED "Read Power sum" 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 ?
Psum := 0 - (1 + (65535-Tmp6) + ((65535-DATA)*65536)) / 10;
ELSE
Psum := (Tmp6 + (DATA*65536)) / 10;
ENDIF;
);
% No apparent power
%DATA[7] -> RWORD(Tmp6 := DATA;);
%DATA[9] -> RWORD(IF DATA > 32767 THEN % Negativ ?
% pVAsum := 0 - (1 + (65535-Tmp6) + ((65535-DATA)*65536)) / 10;
% ELSE
% pVAsum := (Tmp6 + (DATA*65536)) / 10;
% ENDIF;
% );
DATA[11]-> RWORD(Tmp6 := DATA;);
DATA[13]-> RWORD(IF DATA > 32767 THEN % Negativ ?
pVARsum := 0 - (1 + (65535-Tmp6) + ((65535-DATA)*65536)) / 10;
ELSE
pVARsum := (Tmp6 + (DATA*65536)) / 10;
ENDIF;
);
TIMEOUT 1000
END;
TELEGRAM ReadPowerFactor NAMED "Read P.Factor" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(04); % Modbus command "04h" read multiple inputregisters
DATA[2] := RWORD(50); % 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(IF DATA > 32767 THEN % Negativ ?
pFL1 := 0 - (1 + (65535-DATA)) / 1000;
ELSE
pFL1 := DATA / 1000;
ENDIF;
);
DATA[5] -> RWORD(IF DATA > 32767 THEN % Negativ ?
pFL2 := 0 - (1 + (65535-DATA)) / 1000;
ELSE
pFL2 := DATA / 1000;
ENDIF;
);
DATA[7] -> RWORD(IF DATA > 32767 THEN % Negativ ?
pFL3 := 0 - (1 + (65535-DATA)) / 1000;
ELSE
pFL3 := DATA / 1000;
ENDIF;
);
DATA[9] -> RWORD(IF DATA > 32767 THEN % Negativ ?
pF := 0 - (1 + (65535-DATA)) / 1000;
ELSE
pF := DATA / 1000;
ENDIF;
);
TIMEOUT 1000
END;
TELEGRAM WriteCTRatio NAMED "Set CT-ratio" IS
QUESTION
DATA[0] := BYTE(Id);
DATA[1] := HEX(06); %Write singel register
DATA[2] <- RWORD( %Start adress 4397-1 (0x112C)
IF CTCnt=0 THEN
DATA := 4396; %Low register (0x112C) LSW;
ELSE
DATA := 4397; %High register (0x112D) MSW;
ENDIF;
);
DATA[4] <- RWORD(
IF (CTCnt=0) THEN
Tmp := FLOOR((10*CTRatio) / 65536); % Value high CT
DATA := (10*CTRatio) - (Tmp*65536); % Value low CT (LSW)
CTCnt:= 1;
ELSE
DATA := FLOOR((10*CTRatio) / 65536); % Value high CT (MSW)
CTCnt:= 0;
ENDIF;
);
ANSWER SIZE 8
DATA[0] = BYTE(Id);
DATA[1] = HEX(06);
TIMEOUT 300
END;
TELEGRAM WriteVTRatio NAMED "Set VT-ratio" IS
QUESTION
DATA[0] := BYTE(Id);
DATA[1] := HEX(06); %Write singel register
DATA[2] <- RWORD( %Start adress 4399-1 (0x112E)
IF (VTCnt=0) THEN
DATA := 4398; %Low register (0x112E) LSW;
ELSE
DATA := 4399; %High register (0x112F) MSW;
ENDIF;
);
DATA[4] <- RWORD(
IF (VTCnt=0) THEN
Tmp := FLOOR((10*VTRatio) / 65536); % Value high VT
DATA := (10*VTRatio) - (Tmp*65536); % Value low VT (LSW)
VTCnt:= 1;
ELSE
DATA := FLOOR((10*VTRatio) / 65536); % Value high VT (MSW)
VTCnt:= 0;
ENDIF;
);
ANSWER SIZE 8
DATA[0] = BYTE(Id);
DATA[1] = HEX(06);
TIMEOUT 300
END;
END;
% Device definition for Carlo Gavazzi EM26 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
% Modified: 2008-09-02 Climacheck: Adjusted register update and CT/VT ratio setup added
%
DEVICETYPE CarloGavazziEM24 NAMED "CarloGavazziEM24" TYPEID 21150 IS
PARAMETER
Id :"Address";
CTRatio :"CurrentT ratio"; % (reg 4397)
VTRatio :"VoltageT ratio"; % (reg 4399)
PUBLIC
pL1 : "Power L1" ["W"]; % (reg 19)
pL2 : "Power L2" ["W"]; % (reg 21)
pL3 : "Power L3" ["W"]; % (reg 23)
iL1 : "Current L1" ["A"]; % (reg 13) Ampere * 1000
iL2 : "Current L2" ["A"]; % (reg 15)
iL3 : "Current L3" ["A"]; % (reg 17)
vL1 : "Voltage L1" ["V"]; % (reg 1) Volt * 10
vL2 : "Voltage L2" ["V"]; % (reg 3)
vL3 : "Voltage L3" ["V"]; % (reg 5)
pFL1 : "Power factor1" [""]; % (reg 51)
pFL2 : "Power factor2" [""]; % (reg 52)
pFL3 : "Power factor3" [""]; % (reg 53)
pF : "Power factor" [""]; % (reg 54) PF * 1000
Psum : "Power sum" ["W"]; % (reg 41) Watt * 10
%pVAsum : "Psum Apparent" ["VA"]; % (reg 43) VA * 10
pVARsum : "Psum Reaktiv" ["var"]; % (reg 45) var * 10
KWhtot : "Energy total" ["kWh"]; % (reg 63) kWh * 10
KVARhtot : "Energy Reaktiv" ["kvarh"]; % (reg 65) kvarh * 10
KWhL1 : "Energy L1" ["kWh"]; % (reg 71)
KWhL2 : "Energy L2" ["kWh"]; % (reg 72)
KWhL3 : "Energy L3" ["kWh"]; % (reg 73)
%varL1 : "Reaktiv power1" ["var"]; % (reg 31)
%varL2 : "Reaktiv power2" ["var"]; % (reg 33)
%varL3 : "Reaktiv power3" ["var"]; % (reg 35)
PRIVATE
Tmp;
Tmp1;
Tmp2;
Tmp3;
Tmp4;
Tmp5;
Tmp6;
CTCnt;
VTCnt;
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)) / 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 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(62); % 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 ?
KWhtot := 0 - (1 + (65535-Tmp5) + ((65535-DATA)*65536)) / 10;
ELSE
KWhtot := (Tmp5 + (DATA*65536)) / 10;
ENDIF;
);
DATA[7] -> RWORD(Tmp5 := DATA;);
DATA[9] -> RWORD(IF DATA > 32767 THEN % Negativ ?
KVARhtot := 0 - (1 + (65535-Tmp5) + ((65535-DATA)*65536)) / 10;
ELSE
KVARhtot := (Tmp5 + (DATA*65536)) / 10;
ENDIF;
);
TIMEOUT 1000
END;
TELEGRAM ReadPowerTot NAMED "Read Power sum" 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 ?
Psum := 0 - (1 + (65535-Tmp6) + ((65535-DATA)*65536)) / 10;
ELSE
Psum := (Tmp6 + (DATA*65536)) / 10;
ENDIF;
);
% No apparent power
%DATA[7] -> RWORD(Tmp6 := DATA;);
%DATA[9] -> RWORD(IF DATA > 32767 THEN % Negativ ?
% pVAsum := 0 - (1 + (65535-Tmp6) + ((65535-DATA)*65536)) / 10;
% ELSE
% pVAsum := (Tmp6 + (DATA*65536)) / 10;
% ENDIF;
% );
DATA[11]-> RWORD(Tmp6 := DATA;);
DATA[13]-> RWORD(IF DATA > 32767 THEN % Negativ ?
pVARsum := 0 - (1 + (65535-Tmp6) + ((65535-DATA)*65536)) / 10;
ELSE
pVARsum := (Tmp6 + (DATA*65536)) / 10;
ENDIF;
);
TIMEOUT 1000
END;
TELEGRAM ReadPowerFactor NAMED "Read P.Factor" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(04); % Modbus command "04h" read multiple inputregisters
DATA[2] := RWORD(50); % 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(IF DATA > 32767 THEN % Negativ ?
pFL1 := 0 - (1 + (65535-DATA)) / 1000;
ELSE
pFL1 := DATA / 1000;
ENDIF;
);
DATA[5] -> RWORD(IF DATA > 32767 THEN % Negativ ?
pFL2 := 0 - (1 + (65535-DATA)) / 1000;
ELSE
pFL2 := DATA / 1000;
ENDIF;
);
DATA[7] -> RWORD(IF DATA > 32767 THEN % Negativ ?
pFL3 := 0 - (1 + (65535-DATA)) / 1000;
ELSE
pFL3 := DATA / 1000;
ENDIF;
);
DATA[9] -> RWORD(IF DATA > 32767 THEN % Negativ ?
pF := 0 - (1 + (65535-DATA)) / 1000;
ELSE
pF := DATA / 1000;
ENDIF;
);
TIMEOUT 1000
END;
TELEGRAM WriteCTRatio NAMED "Set CT-ratio" IS
QUESTION
DATA[0] := BYTE(Id);
DATA[1] := HEX(06); %Write singel register
DATA[2] <- RWORD( %Start adress 4397-1 (0x112C)
IF CTCnt=0 THEN
DATA := 4396; %Low register (0x112C) LSW;
ELSE
DATA := 4397; %High register (0x112D) MSW;
ENDIF;
);
DATA[4] <- RWORD(
IF (CTCnt=0) THEN
Tmp := FLOOR((10*CTRatio) / 65536); % Value high CT
DATA := (10*CTRatio) - (Tmp*65536); % Value low CT (LSW)
CTCnt:= 1;
ELSE
DATA := FLOOR((10*CTRatio) / 65536); % Value high CT (MSW)
CTCnt:= 0;
ENDIF;
);
ANSWER SIZE 8
DATA[0] = BYTE(Id);
DATA[1] = HEX(06);
TIMEOUT 300
END;
TELEGRAM WriteVTRatio NAMED "Set VT-ratio" IS
QUESTION
DATA[0] := BYTE(Id);
DATA[1] := HEX(06); %Write singel register
DATA[2] <- RWORD( %Start adress 4399-1 (0x112E)
IF (VTCnt=0) THEN
DATA := 4398; %Low register (0x112E) LSW;
ELSE
DATA := 4399; %High register (0x112F) MSW;
ENDIF;
);
DATA[4] <- RWORD(
IF (VTCnt=0) THEN
Tmp := FLOOR((10*VTRatio) / 65536); % Value high VT
DATA := (10*VTRatio) - (Tmp*65536); % Value low VT (LSW)
VTCnt:= 1;
ELSE
DATA := FLOOR((10*VTRatio) / 65536); % Value high VT (MSW)
VTCnt:= 0;
ENDIF;
);
ANSWER SIZE 8
DATA[0] = BYTE(Id);
DATA[1] = HEX(06);
TIMEOUT 300
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.