F&F MR-AI-1 analog in 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
- 2561
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 MRAI1 NAMED "Analog Input 4" TYPEID 10003 IS
PARAMETER
Id : "Address";
PUBLIC
V1 : "AI1_A" ["mA"]; % current
V2 : "AI2_A" ["mA"]; % current
V3 : "AI3_A" ["mA"]; % current
V4 : "AI4_A" ["mA"]; % current
V5 : "AI1_V" ["V"]; % voltage
V6 : "AI2_V" ["V"]; % voltage
V7 : "AI3_V" ["V"]; % voltage
V8 : "AI4_V" ["V"]; % voltage
PRIVATE
count4;
tmp;
BAUDRATE 9600;
CHECKSUM MODBUS SWAPPED;
TELEGRAM Read4 NAMED "Read 4" IS
QUESTION
DATA[0] := BYTE(Id); % The device Modbus address
DATA[1] := HEX(04); % Modbus command for reading register
DATA[2] <- RWORD(
IF(count4>7) THEN count4 := 0; ENDIF;
IF (count4=0) THEN tmp := 1000;
ELSIF (count4=1) THEN tmp := 1001;
ELSIF (count4=2) THEN tmp := 1002;
ELSIF (count4=3) THEN tmp := 1003;
ELSIF (count4=4) THEN tmp := 1004;
ELSIF (count4=5) THEN tmp := 1005;
ELSIF (count4=6) THEN tmp := 1006;
ELSIF (count4=7) THEN tmp := 1007;
ENDIF;
DATA:= tmp;
);
DATA[4] := RWORD(01);
ANSWER SIZE 7 DATA[0] = BYTE(Id);
DATA[1] = BYTE(04);
DATA[3] -> RWORD(
IF(count4>7) THEN count4 := 0; ENDIF;
IF (count4=0) THEN V1 := DATA;
ELSIF (count4=1) THEN V2 := DATA / 100;
ELSIF (count4=2) THEN V3 := DATA / 100;
ELSIF (count4=3) THEN V4 := DATA / 100;
ELSIF (count4=4) THEN V5 := DATA / 100;
ELSIF (count4=5) THEN V6 := DATA / 100;
ELSIF (count4=6) THEN V7 := DATA / 100;
ELSIF (count4=7) THEN V8 := DATA / 100;
ENDIF;
count4 := count4+1;
);
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 MRAI1 NAMED "Analog Input 4" TYPEID 10003 IS
PARAMETER
Id : "Address";
PUBLIC
V1 : "AI1_A" ["mA"]; % current
V2 : "AI2_A" ["mA"]; % current
V3 : "AI3_A" ["mA"]; % current
V4 : "AI4_A" ["mA"]; % current
V5 : "AI1_V" ["V"]; % voltage
V6 : "AI2_V" ["V"]; % voltage
V7 : "AI3_V" ["V"]; % voltage
V8 : "AI4_V" ["V"]; % voltage
PRIVATE
count4;
tmp;
BAUDRATE 9600;
CHECKSUM MODBUS SWAPPED;
TELEGRAM Read4 NAMED "Read 4" IS
QUESTION
DATA[0] := BYTE(Id); % The device Modbus address
DATA[1] := HEX(04); % Modbus command for reading register
DATA[2] <- RWORD(
IF(count4>7) THEN count4 := 0; ENDIF;
IF (count4=0) THEN tmp := 1000;
ELSIF (count4=1) THEN tmp := 1001;
ELSIF (count4=2) THEN tmp := 1002;
ELSIF (count4=3) THEN tmp := 1003;
ELSIF (count4=4) THEN tmp := 1004;
ELSIF (count4=5) THEN tmp := 1005;
ELSIF (count4=6) THEN tmp := 1006;
ELSIF (count4=7) THEN tmp := 1007;
ENDIF;
DATA:= tmp;
);
DATA[4] := RWORD(01);
ANSWER SIZE 7 DATA[0] = BYTE(Id);
DATA[1] = BYTE(04);
DATA[3] -> RWORD(
IF(count4>7) THEN count4 := 0; ENDIF;
IF (count4=0) THEN V1 := DATA;
ELSIF (count4=1) THEN V2 := DATA / 100;
ELSIF (count4=2) THEN V3 := DATA / 100;
ELSIF (count4=3) THEN V4 := DATA / 100;
ELSIF (count4=4) THEN V5 := DATA / 100;
ELSIF (count4=5) THEN V6 := DATA / 100;
ELSIF (count4=6) THEN V7 := DATA / 100;
ELSIF (count4=7) THEN V8 := DATA / 100;
ENDIF;
count4 := count4+1;
);
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.