F&F MR-DIO-1 digital in/ut enhet
Detaljer
- Typ
- Drivrutin
- Upplaggd av
- Ove Jansson, Abelko Innovation
- Version
- 1
- Uppdaterad
- 2013-08-28
- Skapad
- 2013-08-28
- Kategori
- IO enheter, Modbus
- Visningar
- 2827
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
% Created by Modbus Creator
% - OBS! The user is responsible for not using the same TYPEID multiple times in the same Webmaster.
% TYPID 10000-19999 are for user defined devices
DEVICETYPE MR_DIO_1 NAMED "InputOutput module" TYPEID 10000 IS
PARAMETER
Id : "Address";
V7 : "DO1" [""]; % Output 1
V8 : "DO2" [""]; % Output 2
V9 : "DO3" [""]; % Output 3
V10 : "DO4" [""]; % Output 4
V11 : "DO5" [""]; % Output 5
V12 : "DO6" [""]; % Output 6
PUBLIC
V1 : "DI1" [""]; % Input 1
V2 : "DI2" [""]; % Input 2
V3 : "DI3" [""]; % Input 3
V4 : "DI4" [""]; % Input 4
V5 : "DI5" [""]; % Input 5
V6 : "DI6" [""]; % Input 6
PRIVATE
count5;
X;
BAUDRATE 9600;
CHECKSUM MODBUS SWAPPED;
TELEGRAM Read1 NAMED "Read 1" IS
QUESTION
DATA[10] := BYTE(Id); % Device Modbus address
DATA[1] := HEX(02); % Modbus command to read register code 01
DATA[2] := RWORD(4000); % Start address
DATA[4] := RWORD(6); % Number of registers to read
ANSWER SIZE 6 % (Number of registers / 8) round up + 5
DATA[120] = BYTE(Id);
DATA[1] = BYTE(02);
DATA[2] = BYTE(1); % Number of bytes Bytes
DATA[3] -> BYTE(
IF (DATA & 1) THEN V1 := 1; ELSE V1 := 0; ENDIF;
IF (DATA & 2) THEN V2 := 1; ELSE V2 := 0; ENDIF;
IF (DATA & 4) THEN V3 := 1; ELSE V3 := 0; ENDIF;
IF (DATA & 8) THEN V4 := 1; ELSE V4 := 0; ENDIF;
IF (DATA & 16) THEN V5 := 1; ELSE V5 := 0; ENDIF;
IF (DATA & 32) THEN V6 := 1; ELSE V6 := 0; ENDIF;
);
TIMEOUT 300
END;
TELEGRAM WriteCoil NAMED "Write Coil" IS
QUESTION
DATA[0] := BYTE(Id); % Device Modbus address
DATA[1] := HEX(05); % Modbus command to write single Coil
DATA[2] <- RWORD(
IF(count5>5) THEN count5 := 0; ENDIF;
IF (count5=0) THEN DATA := 2000;
ELSIF (count5=1) THEN DATA := 2001;
ELSIF (count5=2) THEN DATA := 2002;
ELSIF (count5=3) THEN DATA := 2003;
ELSIF (count5=4) THEN DATA := 2004;
ELSIF (count5=5) THEN DATA := 2005;
ENDIF;
); % Register address
DATA[4] <- RWORD(
IF (count5=0) THEN IF (V7 >0) THEN DATA := 65536; ELSE DATA := 0; ENDIF;
ELSIF (count5=1) THEN IF (V8 >0) THEN DATA := 65536; ELSE DATA := 0; ENDIF;
ELSIF (count5=2) THEN IF (V9 >0) THEN DATA := 65536; ELSE DATA := 0; ENDIF;
ELSIF (count5=3) THEN IF (V10 >0) THEN DATA := 65536; ELSE DATA := 0; ENDIF;
ELSIF (count5=4) THEN IF (V11 >0) THEN DATA := 65536; ELSE DATA := 0; ENDIF;
ELSIF (count5=5) THEN IF (V12 >0) THEN DATA := 65536; ELSE DATA := 0; ENDIF;
ENDIF;
count5 := count5+1;
);
ANSWER SIZE 8
DATA[0] = BYTE(Id);
DATA[1] = BYTE(05);
TIMEOUT 300
END;
TELEGRAM multi NAMED "ALL" IS
QUESTION
DATA[0] := BYTE(Id); % Device Modbus address
DATA[1] := BYTE(15); %
DATA[2] := RWORD(2000); % Start address
DATA[4] := RWORD(6); % Number of registers to write
DATA[6] := BYTE(1);
DATA[7] <- BYTE(
X := 0;
IF (V7 >0) THEN X := X + 1; ENDIF;
IF (V8 >0) THEN X := X + 2; ENDIF;
IF (V9 >0) THEN X := X + 4; ENDIF;
IF (V10 >0) THEN X := X + 8; ENDIF;
IF (V11 >0) THEN X := X + 16; ENDIF;
IF (V12 >0) THEN X := X + 32; ENDIF;
DATA := X;
);
ANSWER SIZE 8
DATA[0] = BYTE(Id);
DATA[1] = BYTE(15);
TIMEOUT 300
END;
END;
% - OBS! The user is responsible for not using the same TYPEID multiple times in the same Webmaster.
% TYPID 10000-19999 are for user defined devices
DEVICETYPE MR_DIO_1 NAMED "InputOutput module" TYPEID 10000 IS
PARAMETER
Id : "Address";
V7 : "DO1" [""]; % Output 1
V8 : "DO2" [""]; % Output 2
V9 : "DO3" [""]; % Output 3
V10 : "DO4" [""]; % Output 4
V11 : "DO5" [""]; % Output 5
V12 : "DO6" [""]; % Output 6
PUBLIC
V1 : "DI1" [""]; % Input 1
V2 : "DI2" [""]; % Input 2
V3 : "DI3" [""]; % Input 3
V4 : "DI4" [""]; % Input 4
V5 : "DI5" [""]; % Input 5
V6 : "DI6" [""]; % Input 6
PRIVATE
count5;
X;
BAUDRATE 9600;
CHECKSUM MODBUS SWAPPED;
TELEGRAM Read1 NAMED "Read 1" IS
QUESTION
DATA[10] := BYTE(Id); % Device Modbus address
DATA[1] := HEX(02); % Modbus command to read register code 01
DATA[2] := RWORD(4000); % Start address
DATA[4] := RWORD(6); % Number of registers to read
ANSWER SIZE 6 % (Number of registers / 8) round up + 5
DATA[120] = BYTE(Id);
DATA[1] = BYTE(02);
DATA[2] = BYTE(1); % Number of bytes Bytes
DATA[3] -> BYTE(
IF (DATA & 1) THEN V1 := 1; ELSE V1 := 0; ENDIF;
IF (DATA & 2) THEN V2 := 1; ELSE V2 := 0; ENDIF;
IF (DATA & 4) THEN V3 := 1; ELSE V3 := 0; ENDIF;
IF (DATA & 8) THEN V4 := 1; ELSE V4 := 0; ENDIF;
IF (DATA & 16) THEN V5 := 1; ELSE V5 := 0; ENDIF;
IF (DATA & 32) THEN V6 := 1; ELSE V6 := 0; ENDIF;
);
TIMEOUT 300
END;
TELEGRAM WriteCoil NAMED "Write Coil" IS
QUESTION
DATA[0] := BYTE(Id); % Device Modbus address
DATA[1] := HEX(05); % Modbus command to write single Coil
DATA[2] <- RWORD(
IF(count5>5) THEN count5 := 0; ENDIF;
IF (count5=0) THEN DATA := 2000;
ELSIF (count5=1) THEN DATA := 2001;
ELSIF (count5=2) THEN DATA := 2002;
ELSIF (count5=3) THEN DATA := 2003;
ELSIF (count5=4) THEN DATA := 2004;
ELSIF (count5=5) THEN DATA := 2005;
ENDIF;
); % Register address
DATA[4] <- RWORD(
IF (count5=0) THEN IF (V7 >0) THEN DATA := 65536; ELSE DATA := 0; ENDIF;
ELSIF (count5=1) THEN IF (V8 >0) THEN DATA := 65536; ELSE DATA := 0; ENDIF;
ELSIF (count5=2) THEN IF (V9 >0) THEN DATA := 65536; ELSE DATA := 0; ENDIF;
ELSIF (count5=3) THEN IF (V10 >0) THEN DATA := 65536; ELSE DATA := 0; ENDIF;
ELSIF (count5=4) THEN IF (V11 >0) THEN DATA := 65536; ELSE DATA := 0; ENDIF;
ELSIF (count5=5) THEN IF (V12 >0) THEN DATA := 65536; ELSE DATA := 0; ENDIF;
ENDIF;
count5 := count5+1;
);
ANSWER SIZE 8
DATA[0] = BYTE(Id);
DATA[1] = BYTE(05);
TIMEOUT 300
END;
TELEGRAM multi NAMED "ALL" IS
QUESTION
DATA[0] := BYTE(Id); % Device Modbus address
DATA[1] := BYTE(15); %
DATA[2] := RWORD(2000); % Start address
DATA[4] := RWORD(6); % Number of registers to write
DATA[6] := BYTE(1);
DATA[7] <- BYTE(
X := 0;
IF (V7 >0) THEN X := X + 1; ENDIF;
IF (V8 >0) THEN X := X + 2; ENDIF;
IF (V9 >0) THEN X := X + 4; ENDIF;
IF (V10 >0) THEN X := X + 8; ENDIF;
IF (V11 >0) THEN X := X + 16; ENDIF;
IF (V12 >0) THEN X := X + 32; ENDIF;
DATA := X;
);
ANSWER SIZE 8
DATA[0] = BYTE(Id);
DATA[1] = BYTE(15);
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.