PRODUAL wireless sensors version 2.1 TEFL, TEUFL, KLUFL, LAFL, WPIR
Detaljer
Beskrivning
Device definition for PRODUAL wireless sensors version 2.1 TEFL, TEUFL, KLUFL, LAFL, WPIR
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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Modified: 081203 PW Added TypeId 21164 - 68
%
% Device definition for PRODUAL wireless sensors version 2.1
% TEFL, TEUFL, KLUFL, LAFL, WPIR
%
% ABELKO AB Luleå
%
DEVICETYPE TEFL_V2_1 NAMED "Produal2.1_TEFL" TYPEID 21164 IS
PARAMETER
Id : "MasterID";
Nod : "NodID";
PUBLIC
V1 : "Temperatur 1" ["°C"];
V2 : "Temperatur 2" ["°C"];
V3 : "Luftfuktighet" ["%RH"];
V4 : "Fläktstatus";
B1 : "Larm batteri";
B2 : "Avbrott kom.";
B3 : "PIR"; % Bara LAFL
B4 : "Tamper";
PRIVATE
Tmp;
BAUDRATE 38400;
CHECKSUM MODBUS SWAPPED;
TELEGRAM Read NAMED "TEFL_Read" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(04); % Modbus command "04h" read multiple inputregisters
DATA[2] := RWORD(31+4*Nod); % 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 ?
V1 := 0 - (1 + (65535-DATA))/10;
ELSE
V1 := DATA / 10;
ENDIF;
);
DATA[5] -> RWORD(V2 := DATA / 10;);
DATA[7] -> RWORD(V3 := DATA / 10;);
DATA[9] -> RWORD(V4 := DATA;);
TIMEOUT 300
END;
TELEGRAM Larm NAMED "TEFL_Larm" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(02); % Modbus command "02h" read discrete inputs
DATA[2] <- RWORD(IF Nod>0 THEN
IF Tmp>2 THEN Tmp:=0; ELSE Tmp:=Tmp+1; ENDIF;
DATA := Tmp*100 + Nod - 1;
ELSE
DATA := Tmp*100;
ENDIF;
);
DATA[4] := RWORD(1); % number of bits to read
ANSWER SIZE 6
DATA[0] = BYTE(Id);
DATA[1] = HEX(02);
DATA[2] = BYTE(1);
DATA[3] -> BYTE(IF Tmp=0 THEN
IF (DATA & 1) THEN B1:=1; ELSE B1:=0; ENDIF;
ELSIF Tmp=1 THEN
IF (DATA & 1) THEN B2:=1; ELSE B2:=0; ENDIF;
ELSIF Tmp=2 THEN
IF (DATA & 1) THEN B3:=1; ELSE B3:=0; ENDIF;
ELSIF Tmp=3 THEN
IF (DATA & 1) THEN B4:=1; ELSE B4:=0; ENDIF;
ENDIF;
);
TIMEOUT 300
END;
END;
DEVICETYPE TEUFL_V2_1 NAMED "Produal2.1TEUFL" TYPEID 21165 IS
PARAMETER
Id : "MasterID";
Nod : "NodID";
PUBLIC
V1 : "Temperatur" ["°C"];
V2 : "Spänning" ["V"];
%V3 : "Luftfuktighet" ["%RH"];
%V4 : "Fläktstatus";
B1 : "Larm batteri";
B2 : "Avbrott kom.";
B3 : "PIR"; % Bara LAFL
B4 : "Tamper";
PRIVATE
Tmp;
BAUDRATE 38400;
CHECKSUM MODBUS SWAPPED;
TELEGRAM Read NAMED "TEUFL_Read" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(04); % Modbus command "04h" read multiple inputregisters
DATA[2] := RWORD(31+4*Nod); % 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 ?
V1 := 0 - (1 + (65535-DATA))/10;
ELSE
V1 := DATA / 10;
ENDIF;
);
DATA[5] -> RWORD(V2 := DATA / 10;);
%DATA[7] -> RWORD(V3 := DATA / 10;);
%DATA[9] -> RWORD(V4 := DATA;);
TIMEOUT 300
END;
TELEGRAM Larm NAMED "TEUFL_Larm" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(02); % Modbus command "02h" read discrete inputs
DATA[2] <- RWORD(IF Nod>0 THEN
IF Tmp>2 THEN Tmp:=0; ELSE Tmp:=Tmp+1; ENDIF;
DATA := Tmp*100 + Nod - 1;
ELSE
DATA := Tmp*100;
ENDIF;
);
DATA[4] := RWORD(1); % number of bits to read
ANSWER SIZE 6
DATA[0] = BYTE(Id);
DATA[1] = HEX(02);
DATA[2] = BYTE(1);
DATA[3] -> BYTE(IF Tmp=0 THEN
IF (DATA & 1) THEN B1:=1; ELSE B1:=0; ENDIF;
ELSIF Tmp=1 THEN
IF (DATA & 1) THEN B2:=1; ELSE B2:=0; ENDIF;
ELSIF Tmp=2 THEN
IF (DATA & 1) THEN B3:=1; ELSE B3:=0; ENDIF;
ELSIF Tmp=3 THEN
IF (DATA & 1) THEN B4:=1; ELSE B4:=0; ENDIF;
ENDIF;
);
TIMEOUT 300
END;
END;
DEVICETYPE KLUFL_V2_1 NAMED "Produal2.1KLUFL" TYPEID 21166 IS
PARAMETER
Id : "MasterId";
Nod : "NodID";
PUBLIC
V1 : "Temperatur" ["°C"];
V2 : "Belysning" ["lx"];
V3 : "Luftfuktighet" ["%RH"];
%V4 : "Fläktstatus";
B1 : "Larm batteri";
B2 : "Avbrott kom.";
B3 : "PIR"; % Bara LAFL
B4 : "Tamper";
PRIVATE
Tmp;
BAUDRATE 38400;
CHECKSUM MODBUS SWAPPED;
TELEGRAM Read NAMED "KLUFL_Read" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(04); % Modbus command "04h" read multiple inputregisters
DATA[2] := RWORD(31+4*Nod); % 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 ?
V1 := 0 - (1 + (65535-DATA))/10;
ELSE
V1 := DATA / 10;
ENDIF;
);
DATA[5] -> RWORD(V2 := DATA;);
DATA[7] -> RWORD(V3 := DATA / 10;);
%DATA[9] -> RWORD(V4 := DATA;);
TIMEOUT 300
END;
TELEGRAM Larm NAMED "KLUFL_Larm" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(02); % Modbus command "02h" read discrete inputs
DATA[2] <- RWORD(IF Nod>0 THEN
IF Tmp>2 THEN Tmp:=0; ELSE Tmp:=Tmp+1; ENDIF;
DATA := Tmp*100 + Nod - 1;
ELSE
DATA := Tmp*100;
ENDIF;
);
DATA[4] := RWORD(1); % number of bits to read
ANSWER SIZE 6
DATA[0] = BYTE(Id);
DATA[1] = HEX(02);
DATA[2] = BYTE(1);
DATA[3] -> BYTE(IF Tmp=0 THEN
IF (DATA & 1) THEN B1:=1; ELSE B1:=0; ENDIF;
ELSIF Tmp=1 THEN
IF (DATA & 1) THEN B2:=1; ELSE B2:=0; ENDIF;
ELSIF Tmp=2 THEN
IF (DATA & 1) THEN B3:=1; ELSE B3:=0; ENDIF;
ELSIF Tmp=3 THEN
IF (DATA & 1) THEN B4:=1; ELSE B4:=0; ENDIF;
ENDIF;
);
TIMEOUT 300
END;
END;
DEVICETYPE LAFL_V2_1 NAMED "Produal2.1_LAFL" TYPEID 21167 IS
PARAMETER
Id : "MasterId";
Nod : "NodID";
PUBLIC
%V1 : "Temperatur 1" ["°C"];
V2 : "Belysmning" ["lx"];
%V3 : "Luftfuktighet" ["%RH"];
V4 : "Status";
B1 : "Larm batteri";
B2 : "Avbrott kom.";
B3 : "PIR"; % Bara LAFL
B4 : "Tamper";
PRIVATE
Tmp;
BAUDRATE 38400;
CHECKSUM MODBUS SWAPPED;
TELEGRAM Read NAMED "LAFL_Read" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(04); % Modbus command "04h" read multiple inputregisters
DATA[2] := RWORD(31+4*Nod); % 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 ?
% V1 := 0 - (1 + (65535-DATA))/10;
% ELSE
% V1 := DATA / 10;
% ENDIF;
% );
DATA[5] -> RWORD(V2 := DATA;);
%DATA[7] -> RWORD(V3 := DATA / 10;);
DATA[9] -> RWORD(V4 := DATA;);
TIMEOUT 300
END;
TELEGRAM Larm NAMED "LAFL_Larm" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(02); % Modbus command "02h" read discrete inputs
DATA[2] <- RWORD(IF Nod>0 THEN
IF Tmp>2 THEN Tmp:=0; ELSE Tmp:=Tmp+1; ENDIF;
DATA := Tmp*100 + Nod - 1;
ELSE
DATA := Tmp*100;
ENDIF;
);
DATA[4] := RWORD(1); % number of bits to read
ANSWER SIZE 6
DATA[0] = BYTE(Id);
DATA[1] = HEX(02);
DATA[2] = BYTE(1);
DATA[3] -> BYTE(IF Tmp=0 THEN
IF (DATA & 1) THEN B1:=1; ELSE B1:=0; ENDIF;
ELSIF Tmp=1 THEN
IF (DATA & 1) THEN B2:=1; ELSE B2:=0; ENDIF;
ELSIF Tmp=2 THEN
IF (DATA & 1) THEN B3:=1; ELSE B3:=0; ENDIF;
ELSIF Tmp=3 THEN
IF (DATA & 1) THEN B4:=1; ELSE B4:=0; ENDIF;
ENDIF;
);
TIMEOUT 300
END;
END;
DEVICETYPE WPIR_V2_1 NAMED "Produal2.1_WPIR" TYPEID 21168 IS
PARAMETER
Id : "MasterId";
Nod : "NodID";
PUBLIC
V1 : "Temperatur" ["°C"];
%V2 : "Temperatur 1" ["°C"];
V3 : "Luftfuktighet" ["%RH"];
%V4 : "Fläktstatus";
B1 : "Larm batteri";
B2 : "Avbrott kom.";
B3 : "PIR"; % Bara LAFL
B4 : "Tamper";
PRIVATE
Tmp;
BAUDRATE 38400;
CHECKSUM MODBUS SWAPPED;
TELEGRAM Read NAMED "WPIR_Read" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(04); % Modbus command "04h" read multiple inputregisters
DATA[2] := RWORD(31+4*Nod); % 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 ?
V1 := 0 - (1 + (65535-DATA))/10;
ELSE
V1 := DATA / 10;
ENDIF;
);
%DATA[5] -> RWORD(V2 := DATA / 10;);
DATA[7] -> RWORD(V3 := DATA / 10;);
%DATA[9] -> RWORD(V4 := DATA;);
TIMEOUT 300
END;
TELEGRAM Larm NAMED "WPIR_Larm" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(02); % Modbus command "02h" read discrete inputs
DATA[2] <- RWORD(IF Nod>0 THEN
IF Tmp>2 THEN Tmp:=0; ELSE Tmp:=Tmp+1; ENDIF;
DATA := Tmp*100 + Nod - 1;
ELSE
DATA := Tmp*100;
ENDIF;
);
DATA[4] := RWORD(1); % number of bits to read
ANSWER SIZE 6
DATA[0] = BYTE(Id);
DATA[1] = HEX(02);
DATA[2] = BYTE(1);
DATA[3] -> BYTE(IF Tmp=0 THEN
IF (DATA & 1) THEN B1:=1; ELSE B1:=0; ENDIF;
ELSIF Tmp=1 THEN
IF (DATA & 1) THEN B2:=1; ELSE B2:=0; ENDIF;
ELSIF Tmp=2 THEN
IF (DATA & 1) THEN B3:=1; ELSE B3:=0; ENDIF;
ELSIF Tmp=3 THEN
IF (DATA & 1) THEN B4:=1; ELSE B4:=0; ENDIF;
ENDIF;
);
TIMEOUT 300
END;
END;
%
% Modified: 081203 PW Added TypeId 21164 - 68
%
% Device definition for PRODUAL wireless sensors version 2.1
% TEFL, TEUFL, KLUFL, LAFL, WPIR
%
% ABELKO AB Luleå
%
DEVICETYPE TEFL_V2_1 NAMED "Produal2.1_TEFL" TYPEID 21164 IS
PARAMETER
Id : "MasterID";
Nod : "NodID";
PUBLIC
V1 : "Temperatur 1" ["°C"];
V2 : "Temperatur 2" ["°C"];
V3 : "Luftfuktighet" ["%RH"];
V4 : "Fläktstatus";
B1 : "Larm batteri";
B2 : "Avbrott kom.";
B3 : "PIR"; % Bara LAFL
B4 : "Tamper";
PRIVATE
Tmp;
BAUDRATE 38400;
CHECKSUM MODBUS SWAPPED;
TELEGRAM Read NAMED "TEFL_Read" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(04); % Modbus command "04h" read multiple inputregisters
DATA[2] := RWORD(31+4*Nod); % 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 ?
V1 := 0 - (1 + (65535-DATA))/10;
ELSE
V1 := DATA / 10;
ENDIF;
);
DATA[5] -> RWORD(V2 := DATA / 10;);
DATA[7] -> RWORD(V3 := DATA / 10;);
DATA[9] -> RWORD(V4 := DATA;);
TIMEOUT 300
END;
TELEGRAM Larm NAMED "TEFL_Larm" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(02); % Modbus command "02h" read discrete inputs
DATA[2] <- RWORD(IF Nod>0 THEN
IF Tmp>2 THEN Tmp:=0; ELSE Tmp:=Tmp+1; ENDIF;
DATA := Tmp*100 + Nod - 1;
ELSE
DATA := Tmp*100;
ENDIF;
);
DATA[4] := RWORD(1); % number of bits to read
ANSWER SIZE 6
DATA[0] = BYTE(Id);
DATA[1] = HEX(02);
DATA[2] = BYTE(1);
DATA[3] -> BYTE(IF Tmp=0 THEN
IF (DATA & 1) THEN B1:=1; ELSE B1:=0; ENDIF;
ELSIF Tmp=1 THEN
IF (DATA & 1) THEN B2:=1; ELSE B2:=0; ENDIF;
ELSIF Tmp=2 THEN
IF (DATA & 1) THEN B3:=1; ELSE B3:=0; ENDIF;
ELSIF Tmp=3 THEN
IF (DATA & 1) THEN B4:=1; ELSE B4:=0; ENDIF;
ENDIF;
);
TIMEOUT 300
END;
END;
DEVICETYPE TEUFL_V2_1 NAMED "Produal2.1TEUFL" TYPEID 21165 IS
PARAMETER
Id : "MasterID";
Nod : "NodID";
PUBLIC
V1 : "Temperatur" ["°C"];
V2 : "Spänning" ["V"];
%V3 : "Luftfuktighet" ["%RH"];
%V4 : "Fläktstatus";
B1 : "Larm batteri";
B2 : "Avbrott kom.";
B3 : "PIR"; % Bara LAFL
B4 : "Tamper";
PRIVATE
Tmp;
BAUDRATE 38400;
CHECKSUM MODBUS SWAPPED;
TELEGRAM Read NAMED "TEUFL_Read" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(04); % Modbus command "04h" read multiple inputregisters
DATA[2] := RWORD(31+4*Nod); % 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 ?
V1 := 0 - (1 + (65535-DATA))/10;
ELSE
V1 := DATA / 10;
ENDIF;
);
DATA[5] -> RWORD(V2 := DATA / 10;);
%DATA[7] -> RWORD(V3 := DATA / 10;);
%DATA[9] -> RWORD(V4 := DATA;);
TIMEOUT 300
END;
TELEGRAM Larm NAMED "TEUFL_Larm" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(02); % Modbus command "02h" read discrete inputs
DATA[2] <- RWORD(IF Nod>0 THEN
IF Tmp>2 THEN Tmp:=0; ELSE Tmp:=Tmp+1; ENDIF;
DATA := Tmp*100 + Nod - 1;
ELSE
DATA := Tmp*100;
ENDIF;
);
DATA[4] := RWORD(1); % number of bits to read
ANSWER SIZE 6
DATA[0] = BYTE(Id);
DATA[1] = HEX(02);
DATA[2] = BYTE(1);
DATA[3] -> BYTE(IF Tmp=0 THEN
IF (DATA & 1) THEN B1:=1; ELSE B1:=0; ENDIF;
ELSIF Tmp=1 THEN
IF (DATA & 1) THEN B2:=1; ELSE B2:=0; ENDIF;
ELSIF Tmp=2 THEN
IF (DATA & 1) THEN B3:=1; ELSE B3:=0; ENDIF;
ELSIF Tmp=3 THEN
IF (DATA & 1) THEN B4:=1; ELSE B4:=0; ENDIF;
ENDIF;
);
TIMEOUT 300
END;
END;
DEVICETYPE KLUFL_V2_1 NAMED "Produal2.1KLUFL" TYPEID 21166 IS
PARAMETER
Id : "MasterId";
Nod : "NodID";
PUBLIC
V1 : "Temperatur" ["°C"];
V2 : "Belysning" ["lx"];
V3 : "Luftfuktighet" ["%RH"];
%V4 : "Fläktstatus";
B1 : "Larm batteri";
B2 : "Avbrott kom.";
B3 : "PIR"; % Bara LAFL
B4 : "Tamper";
PRIVATE
Tmp;
BAUDRATE 38400;
CHECKSUM MODBUS SWAPPED;
TELEGRAM Read NAMED "KLUFL_Read" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(04); % Modbus command "04h" read multiple inputregisters
DATA[2] := RWORD(31+4*Nod); % 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 ?
V1 := 0 - (1 + (65535-DATA))/10;
ELSE
V1 := DATA / 10;
ENDIF;
);
DATA[5] -> RWORD(V2 := DATA;);
DATA[7] -> RWORD(V3 := DATA / 10;);
%DATA[9] -> RWORD(V4 := DATA;);
TIMEOUT 300
END;
TELEGRAM Larm NAMED "KLUFL_Larm" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(02); % Modbus command "02h" read discrete inputs
DATA[2] <- RWORD(IF Nod>0 THEN
IF Tmp>2 THEN Tmp:=0; ELSE Tmp:=Tmp+1; ENDIF;
DATA := Tmp*100 + Nod - 1;
ELSE
DATA := Tmp*100;
ENDIF;
);
DATA[4] := RWORD(1); % number of bits to read
ANSWER SIZE 6
DATA[0] = BYTE(Id);
DATA[1] = HEX(02);
DATA[2] = BYTE(1);
DATA[3] -> BYTE(IF Tmp=0 THEN
IF (DATA & 1) THEN B1:=1; ELSE B1:=0; ENDIF;
ELSIF Tmp=1 THEN
IF (DATA & 1) THEN B2:=1; ELSE B2:=0; ENDIF;
ELSIF Tmp=2 THEN
IF (DATA & 1) THEN B3:=1; ELSE B3:=0; ENDIF;
ELSIF Tmp=3 THEN
IF (DATA & 1) THEN B4:=1; ELSE B4:=0; ENDIF;
ENDIF;
);
TIMEOUT 300
END;
END;
DEVICETYPE LAFL_V2_1 NAMED "Produal2.1_LAFL" TYPEID 21167 IS
PARAMETER
Id : "MasterId";
Nod : "NodID";
PUBLIC
%V1 : "Temperatur 1" ["°C"];
V2 : "Belysmning" ["lx"];
%V3 : "Luftfuktighet" ["%RH"];
V4 : "Status";
B1 : "Larm batteri";
B2 : "Avbrott kom.";
B3 : "PIR"; % Bara LAFL
B4 : "Tamper";
PRIVATE
Tmp;
BAUDRATE 38400;
CHECKSUM MODBUS SWAPPED;
TELEGRAM Read NAMED "LAFL_Read" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(04); % Modbus command "04h" read multiple inputregisters
DATA[2] := RWORD(31+4*Nod); % 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 ?
% V1 := 0 - (1 + (65535-DATA))/10;
% ELSE
% V1 := DATA / 10;
% ENDIF;
% );
DATA[5] -> RWORD(V2 := DATA;);
%DATA[7] -> RWORD(V3 := DATA / 10;);
DATA[9] -> RWORD(V4 := DATA;);
TIMEOUT 300
END;
TELEGRAM Larm NAMED "LAFL_Larm" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(02); % Modbus command "02h" read discrete inputs
DATA[2] <- RWORD(IF Nod>0 THEN
IF Tmp>2 THEN Tmp:=0; ELSE Tmp:=Tmp+1; ENDIF;
DATA := Tmp*100 + Nod - 1;
ELSE
DATA := Tmp*100;
ENDIF;
);
DATA[4] := RWORD(1); % number of bits to read
ANSWER SIZE 6
DATA[0] = BYTE(Id);
DATA[1] = HEX(02);
DATA[2] = BYTE(1);
DATA[3] -> BYTE(IF Tmp=0 THEN
IF (DATA & 1) THEN B1:=1; ELSE B1:=0; ENDIF;
ELSIF Tmp=1 THEN
IF (DATA & 1) THEN B2:=1; ELSE B2:=0; ENDIF;
ELSIF Tmp=2 THEN
IF (DATA & 1) THEN B3:=1; ELSE B3:=0; ENDIF;
ELSIF Tmp=3 THEN
IF (DATA & 1) THEN B4:=1; ELSE B4:=0; ENDIF;
ENDIF;
);
TIMEOUT 300
END;
END;
DEVICETYPE WPIR_V2_1 NAMED "Produal2.1_WPIR" TYPEID 21168 IS
PARAMETER
Id : "MasterId";
Nod : "NodID";
PUBLIC
V1 : "Temperatur" ["°C"];
%V2 : "Temperatur 1" ["°C"];
V3 : "Luftfuktighet" ["%RH"];
%V4 : "Fläktstatus";
B1 : "Larm batteri";
B2 : "Avbrott kom.";
B3 : "PIR"; % Bara LAFL
B4 : "Tamper";
PRIVATE
Tmp;
BAUDRATE 38400;
CHECKSUM MODBUS SWAPPED;
TELEGRAM Read NAMED "WPIR_Read" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(04); % Modbus command "04h" read multiple inputregisters
DATA[2] := RWORD(31+4*Nod); % 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 ?
V1 := 0 - (1 + (65535-DATA))/10;
ELSE
V1 := DATA / 10;
ENDIF;
);
%DATA[5] -> RWORD(V2 := DATA / 10;);
DATA[7] -> RWORD(V3 := DATA / 10;);
%DATA[9] -> RWORD(V4 := DATA;);
TIMEOUT 300
END;
TELEGRAM Larm NAMED "WPIR_Larm" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(02); % Modbus command "02h" read discrete inputs
DATA[2] <- RWORD(IF Nod>0 THEN
IF Tmp>2 THEN Tmp:=0; ELSE Tmp:=Tmp+1; ENDIF;
DATA := Tmp*100 + Nod - 1;
ELSE
DATA := Tmp*100;
ENDIF;
);
DATA[4] := RWORD(1); % number of bits to read
ANSWER SIZE 6
DATA[0] = BYTE(Id);
DATA[1] = HEX(02);
DATA[2] = BYTE(1);
DATA[3] -> BYTE(IF Tmp=0 THEN
IF (DATA & 1) THEN B1:=1; ELSE B1:=0; ENDIF;
ELSIF Tmp=1 THEN
IF (DATA & 1) THEN B2:=1; ELSE B2:=0; ENDIF;
ELSIF Tmp=2 THEN
IF (DATA & 1) THEN B3:=1; ELSE B3:=0; ENDIF;
ELSIF Tmp=3 THEN
IF (DATA & 1) THEN B4:=1; ELSE B4:=0; ENDIF;
ENDIF;
);
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.