F&F MR-AO-1 analog 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
- 2770
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 MRAO1 NAMED "Analog Output 4" TYPEID 10002 IS
PARAMETER
Id : "Address";
V5 : "AO1" ["%"];
V6 : "AO2" ["%"];
V7 : "AO3" ["%"];
V8 : "AO4" ["%"];
PUBLIC
V1 : "AO1" ["%"];
V2 : "AO2" ["%"];
V3 : "AO3" ["%"];
V4 : "AO4" ["%"];
PRIVATE
count6;
BAUDRATE 9600;
CHECKSUM MODBUS SWAPPED;
TELEGRAM Read3 NAMED "Read 3" IS
QUESTION
DATA[0] := BYTE(Id); % Device Modbus address
DATA[1] := HEX(03); % Modbus command to read register code 03
DATA[2] := RWORD(3000); % Start address
DATA[4] := RWORD(4); % Number of registers to read
ANSWER SIZE 13 % (Number of registers * 2) + 5
DATA[0] = BYTE(Id);
DATA[1] = BYTE(03);
DATA[2] = BYTE(8); % Number of Bytes
DATA[3] -> RWORD(V1 := DATA;);
DATA[5] -> RWORD(V2 := DATA;);
DATA[7] -> RWORD(V3 := DATA;);
DATA[9] -> RWORD(V4 := DATA;);
TIMEOUT 300
END;
TELEGRAM WriteRegister NAMED "Write Register" IS
QUESTION
DATA[0] := BYTE(Id); % Device modbus address
DATA[1] := HEX(06); % Modbus command to write single register
DATA[2] <- RWORD(
IF(count6>3) THEN count6 := 0; ENDIF;
IF (count6=0) THEN DATA := 3000;
ELSIF (count6=1) THEN DATA := 3001;
ELSIF (count6=2) THEN DATA := 3002;
ELSIF (count6=3) THEN DATA := 3003;
ENDIF;
); % Register address
DATA[4] <- RWORD(
IF (count6=0) THEN DATA := V5;
ELSIF (count6=1) THEN DATA := V6;
ELSIF (count6=2) THEN DATA := V7;
ELSIF (count6=3) THEN DATA := V8;
ENDIF;
count6 := count6+1;
);
ANSWER SIZE 8
DATA[0] = BYTE(Id);
DATA[1] = BYTE(06);
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 MRAO1 NAMED "Analog Output 4" TYPEID 10002 IS
PARAMETER
Id : "Address";
V5 : "AO1" ["%"];
V6 : "AO2" ["%"];
V7 : "AO3" ["%"];
V8 : "AO4" ["%"];
PUBLIC
V1 : "AO1" ["%"];
V2 : "AO2" ["%"];
V3 : "AO3" ["%"];
V4 : "AO4" ["%"];
PRIVATE
count6;
BAUDRATE 9600;
CHECKSUM MODBUS SWAPPED;
TELEGRAM Read3 NAMED "Read 3" IS
QUESTION
DATA[0] := BYTE(Id); % Device Modbus address
DATA[1] := HEX(03); % Modbus command to read register code 03
DATA[2] := RWORD(3000); % Start address
DATA[4] := RWORD(4); % Number of registers to read
ANSWER SIZE 13 % (Number of registers * 2) + 5
DATA[0] = BYTE(Id);
DATA[1] = BYTE(03);
DATA[2] = BYTE(8); % Number of Bytes
DATA[3] -> RWORD(V1 := DATA;);
DATA[5] -> RWORD(V2 := DATA;);
DATA[7] -> RWORD(V3 := DATA;);
DATA[9] -> RWORD(V4 := DATA;);
TIMEOUT 300
END;
TELEGRAM WriteRegister NAMED "Write Register" IS
QUESTION
DATA[0] := BYTE(Id); % Device modbus address
DATA[1] := HEX(06); % Modbus command to write single register
DATA[2] <- RWORD(
IF(count6>3) THEN count6 := 0; ENDIF;
IF (count6=0) THEN DATA := 3000;
ELSIF (count6=1) THEN DATA := 3001;
ELSIF (count6=2) THEN DATA := 3002;
ELSIF (count6=3) THEN DATA := 3003;
ENDIF;
); % Register address
DATA[4] <- RWORD(
IF (count6=0) THEN DATA := V5;
ELSIF (count6=1) THEN DATA := V6;
ELSIF (count6=2) THEN DATA := V7;
ELSIF (count6=3) THEN DATA := V8;
ENDIF;
count6 := count6+1;
);
ANSWER SIZE 8
DATA[0] = BYTE(Id);
DATA[1] = BYTE(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.