Siox S45 via ES2
Detaljer
- Typ
- Drivrutin
- Upplaggd av
- Ove Jansson, Abelko Innovation
- Version
- 1
- Uppdaterad
- 2018-09-26
- Skapad
- 2018-09-26
- Kategori
- IO enheter, Modbus, Övriga protokoll
- Visningar
- 1787
Beskrivning
.
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
DEVICETYPE S45 NAMED "Siox ES2-S45" TYPEID 18377 IS
PARAMETER
Id : "Adress" [""]INT;
Sek : "Sekund" [""]INT;
PUBLIC
I1 : "Input 1" INT;
I2 : "Input 2" INT;
I3 : "Input 3" INT;
I4 : "Input 4" INT;
I5 : "Input 5" INT;
I6 : "Input 6" INT;
I7 : "Input 7" INT;
C8 : "Counter 8" [""]INT;
C9 : "Counter 9" [""]INT;
C10 : "Counter 10" [""]INT;
C11 : "Counter 11" [""]INT;
C12 : "Counter 12" [""]INT;
C13 : "Counter 13" [""]INT;
PRIVATE
tmp;
sek;
BAUDRATE 9600;
CHECKSUM MODBUS SWAPPED;
TELEGRAM Read4 NAMED "Read 4" IS
QUESTION
DATA[0] := BYTE(Id); % Enhetens Modbus adress
DATA[1] := HEX(03);
DATA[2] <- RWORD(DATA:=9;); % Start address
DATA[4] := RWORD(21); % Antal register att läsa
ANSWER SIZE 47 % (Antal register * 2) + 5
DATA[0] = BYTE(Id);
DATA[1] = HEX(03);
DATA[2] = BYTE(42); % Antal Bytes
DATA[3] -> RWORD(
IF DATA & 1 THEN tmp:=1; ELSE tmp:=0; ENDIF; I1:=tmp;
IF DATA & 2 THEN tmp:=1; ELSE tmp:=0; ENDIF; I2:=tmp;
IF DATA & 4 THEN tmp:=1; ELSE tmp:=0; ENDIF; I3:=tmp;
IF DATA & 8 THEN tmp:=1; ELSE tmp:=0; ENDIF; I4:=tmp;
IF DATA & 16 THEN tmp:=1; ELSE tmp:=0; ENDIF; I5:=tmp;
IF DATA & 32 THEN tmp:=1; ELSE tmp:=0; ENDIF; I6:=tmp;
IF DATA & 64 THEN tmp:=1; ELSE tmp:=0; ENDIF; I7:=tmp;
);
DATA[33] -> RWORD(C8:=DATA;);
DATA[35] -> RWORD(C9:=DATA;);
DATA[37] -> RWORD(C10:=DATA;);
DATA[39] -> RWORD(C11:=DATA;);
DATA[41] -> RWORD(C12:=DATA;);
DATA[43] -> RWORD(C13:=DATA;);
TIMEOUT 800
END;
%SCHEDULER BEGIN
%sek:=Sek;
%IF sek<0 OR sek>59 THEN sek:=0; ENDIF;
%IF sek=TIME_SEC THEN TRANSMIT(Read4); ENDIF;
%END;
END;
PARAMETER
Id : "Adress" [""]INT;
Sek : "Sekund" [""]INT;
PUBLIC
I1 : "Input 1" INT;
I2 : "Input 2" INT;
I3 : "Input 3" INT;
I4 : "Input 4" INT;
I5 : "Input 5" INT;
I6 : "Input 6" INT;
I7 : "Input 7" INT;
C8 : "Counter 8" [""]INT;
C9 : "Counter 9" [""]INT;
C10 : "Counter 10" [""]INT;
C11 : "Counter 11" [""]INT;
C12 : "Counter 12" [""]INT;
C13 : "Counter 13" [""]INT;
PRIVATE
tmp;
sek;
BAUDRATE 9600;
CHECKSUM MODBUS SWAPPED;
TELEGRAM Read4 NAMED "Read 4" IS
QUESTION
DATA[0] := BYTE(Id); % Enhetens Modbus adress
DATA[1] := HEX(03);
DATA[2] <- RWORD(DATA:=9;); % Start address
DATA[4] := RWORD(21); % Antal register att läsa
ANSWER SIZE 47 % (Antal register * 2) + 5
DATA[0] = BYTE(Id);
DATA[1] = HEX(03);
DATA[2] = BYTE(42); % Antal Bytes
DATA[3] -> RWORD(
IF DATA & 1 THEN tmp:=1; ELSE tmp:=0; ENDIF; I1:=tmp;
IF DATA & 2 THEN tmp:=1; ELSE tmp:=0; ENDIF; I2:=tmp;
IF DATA & 4 THEN tmp:=1; ELSE tmp:=0; ENDIF; I3:=tmp;
IF DATA & 8 THEN tmp:=1; ELSE tmp:=0; ENDIF; I4:=tmp;
IF DATA & 16 THEN tmp:=1; ELSE tmp:=0; ENDIF; I5:=tmp;
IF DATA & 32 THEN tmp:=1; ELSE tmp:=0; ENDIF; I6:=tmp;
IF DATA & 64 THEN tmp:=1; ELSE tmp:=0; ENDIF; I7:=tmp;
);
DATA[33] -> RWORD(C8:=DATA;);
DATA[35] -> RWORD(C9:=DATA;);
DATA[37] -> RWORD(C10:=DATA;);
DATA[39] -> RWORD(C11:=DATA;);
DATA[41] -> RWORD(C12:=DATA;);
DATA[43] -> RWORD(C13:=DATA;);
TIMEOUT 800
END;
%SCHEDULER BEGIN
%sek:=Sek;
%IF sek<0 OR sek>59 THEN sek:=0; ENDIF;
%IF sek=TIME_SEC THEN TRANSMIT(Read4); ENDIF;
%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.