BAS2-MBIO-D44 (modbus)
Detaljer
- Typ
- Drivrutin
- Upplaggd av
- Ove Jansson, Abelko Innovation
- Version
- 5
- Uppdaterad
- 2017-02-21
- Skapad
- 2015-08-28
- Kategori
- IO enheter, Modbus
- Visningar
- 2810
Beskrivning
Enheten har 4 digitala ingångar och 4 reläutgångar
Bruksanvisning
.
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
%
% 170221 (PW) Changed start address for read from 100 to 99 and for wrte from 200 to 199.
%
DEVICETYPE BAS2D44 NAMED "BAS2-MBIO-D44" TYPEID 15896 IS
PARAMETER
Id : "Adress" [""]INT;
W1 : "Output 1" [""]INT;
W2 : "Output 2" [""]INT;
W3 : "Output 3" [""]INT;
W4 : "Output 4" [""]INT;
PUBLIC
DI1 : "Input 1" [""]INT; %
DI2 : "Input 2" [""]INT; %
DI3 : "Input 3" [""]INT; %
DI4 : "Input 4" [""]INT; %
PRIVATE
tmp;
BAUDRATE 9600;
PARITY EVEN;
CHECKSUM MODBUS SWAPPED;
TELEGRAM Read NAMED "Read" IS
QUESTION
DATA[0] := BYTE(Id);
DATA[1] := HEX(04);
DATA[2] := RWORD(99);
DATA[4] := RWORD(1);
ANSWER SIZE 7
DATA[0] = BYTE(Id);
DATA[1] = HEX(04);
DATA[3] -> RWORD(
IF DATA&1 THEN DI1:=1; ELSE DI1:=0; ENDIF;
IF DATA&2 THEN DI2:=1; ELSE DI2:=0; ENDIF;
IF DATA&4 THEN DI3:=1; ELSE DI3:=0; ENDIF;
IF DATA&8 THEN DI4:=1; ELSE DI4:=0; ENDIF;
);
TIMEOUT 300
END;
TELEGRAM Write NAMED "Write" IS
QUESTION
DATA[0] := BYTE(Id);
DATA[1] := HEX(10);
DATA[2] := RWORD(199);
DATA[4] := BYTE(1);
DATA[5] <- RWORD(
IF W1>0 THEN tmp:=1; ELSE tmp:=0; ENDIF;
IF W2>0 THEN tmp:=tmp+2; ENDIF;
IF W3>0 THEN tmp:=tmp+4; ENDIF;
IF W4>0 THEN tmp:=tmp+8; ENDIF;
DATA := tmp;
);
ANSWER SIZE 8
DATA[0] = BYTE(Id);
DATA[1] = HEX(10);
TIMEOUT 300
END;
END;
% 170221 (PW) Changed start address for read from 100 to 99 and for wrte from 200 to 199.
%
DEVICETYPE BAS2D44 NAMED "BAS2-MBIO-D44" TYPEID 15896 IS
PARAMETER
Id : "Adress" [""]INT;
W1 : "Output 1" [""]INT;
W2 : "Output 2" [""]INT;
W3 : "Output 3" [""]INT;
W4 : "Output 4" [""]INT;
PUBLIC
DI1 : "Input 1" [""]INT; %
DI2 : "Input 2" [""]INT; %
DI3 : "Input 3" [""]INT; %
DI4 : "Input 4" [""]INT; %
PRIVATE
tmp;
BAUDRATE 9600;
PARITY EVEN;
CHECKSUM MODBUS SWAPPED;
TELEGRAM Read NAMED "Read" IS
QUESTION
DATA[0] := BYTE(Id);
DATA[1] := HEX(04);
DATA[2] := RWORD(99);
DATA[4] := RWORD(1);
ANSWER SIZE 7
DATA[0] = BYTE(Id);
DATA[1] = HEX(04);
DATA[3] -> RWORD(
IF DATA&1 THEN DI1:=1; ELSE DI1:=0; ENDIF;
IF DATA&2 THEN DI2:=1; ELSE DI2:=0; ENDIF;
IF DATA&4 THEN DI3:=1; ELSE DI3:=0; ENDIF;
IF DATA&8 THEN DI4:=1; ELSE DI4:=0; ENDIF;
);
TIMEOUT 300
END;
TELEGRAM Write NAMED "Write" IS
QUESTION
DATA[0] := BYTE(Id);
DATA[1] := HEX(10);
DATA[2] := RWORD(199);
DATA[4] := BYTE(1);
DATA[5] <- RWORD(
IF W1>0 THEN tmp:=1; ELSE tmp:=0; ENDIF;
IF W2>0 THEN tmp:=tmp+2; ENDIF;
IF W3>0 THEN tmp:=tmp+4; ENDIF;
IF W4>0 THEN tmp:=tmp+8; ENDIF;
DATA := tmp;
);
ANSWER SIZE 8
DATA[0] = BYTE(Id);
DATA[1] = HEX(10);
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.