Siox RO2 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
- 1754
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 R02 NAMED "Siox R02" TYPEID 18379 IS
PARAMETER
Id : "Adress" [""]INT;
PUBLIC
OP1 : "AI1 range 2-10 V / 0,4-2 V / 4-20 mA Range" ["No,Yes"]ENUM;
OP2 : "AI2 range 2-10 V / 0,4-2 V / 4-20 mA Range" ["No,Yes"]ENUM;
OP1b : "AI1 Potentiometer Linearization 0-20 kS" ["No,Yes"]ENUM;
OP2b : "AI2 Potentiometer Linearization 0-20 kS" ["No,Yes"]ENUM;
OP1c : "AI1 0-2 V Range" ["No,Yes"]ENUM;
OP2c : "AI2 0-2 V Range" ["No,Yes"]ENUM;
OP1d : "AI1 NTC Temperature Linearization -50 - +150 °C" ["No,Yes"]ENUM;
OP2d : "AI2 NTC Temperature Linearization -50 - +150 °C" ["No,Yes"]ENUM;
OP1e : "AI1 0-20 mA Range" ["No,Yes"]ENUM;
OP2e : "AI2 0-20 mA Range" ["No,Yes"]ENUM;
OP1f : "AI1 0-10 V Range" ["No,Yes"]ENUM;
OP2f : "AI2 0-10 V Range" ["No,Yes"]ENUM;
OP1g : "AO1 Digital Output 24 V 20 mA" ["No,Yes"]ENUM;
OP2g : "AO2 Digital Output 24 V 20 mA" ["No,Yes"]ENUM;
OP1h : "AO1 2-10 V (4-20 mA for R02-2)" ["No,Yes"]ENUM;
OP2h : "AO2 2-10 V (4-20 mA for R02-2)" ["No,Yes"]ENUM;
OP1i : "AO1 0-10 V (4-20 mA for R02-2)" ["No,Yes"]ENUM;
OP2i : "AO2 0-10 V (4-20 mA for R02-2)" ["No,Yes"]ENUM;
DI1 : "DigitalInput 1" INT;
DI2 : "DigitalInput 2" INT;
AI1 : "AnalogInput 1" [""]INT;
AI2 : "AnalogInput 2" [""]INT;
AO1 : "AnalogOutput 1" ["%"]DEC2;
AO2 : "AnalogOutput 2" ["%"]DEC2;
C1 : "Counter 1" [""]INT;
C2 : "Counter 2" [""]INT;
PRIVATE
tmp;
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(0); % Start address
DATA[4] := RWORD(28); % Antal register att läsa
ANSWER SIZE 61 % (Antal register * 2) + 5
DATA[0] = BYTE(Id);
DATA[1] = HEX(03);
DATA[2] = BYTE(56); % Antal Bytes
DATA[11] -> BYTE( %4
IF DATA & 64 THEN tmp:=1; ELSE tmp:=0; ENDIF; OP1:=tmp;
IF DATA = 40 THEN tmp:=1; ELSE tmp:=0; ENDIF; OP1b:=tmp;
IF DATA = 32 THEN tmp:=1; ELSE tmp:=0; ENDIF; OP1c:=tmp;
IF DATA = 24 THEN tmp:=1; ELSE tmp:=0; ENDIF; OP1d:=tmp;
IF DATA = 8 THEN tmp:=1; ELSE tmp:=0; ENDIF; OP1e:=tmp;
IF DATA = 0 THEN tmp:=1; ELSE tmp:=0; ENDIF; OP1f:=tmp;
);
DATA[12] -> BYTE( %4
IF DATA & 128 THEN tmp:=1; ELSE tmp:=0; ENDIF; OP1g:=tmp;
IF DATA & 64 THEN tmp:=1; ELSE tmp:=0; ENDIF; OP1h:=tmp;
IF DATA > 15 THEN tmp:=0; ELSE tmp:=1; ENDIF; OP1i:=tmp;
);
DATA[13] -> BYTE( %5
IF DATA & 64 THEN tmp:=1; ELSE tmp:=0; ENDIF; OP2:=tmp;
IF DATA = 40 THEN tmp:=1; ELSE tmp:=0; ENDIF; OP2b:=tmp;
IF DATA = 32 THEN tmp:=1; ELSE tmp:=0; ENDIF; OP2c:=tmp;
IF DATA = 24 THEN tmp:=1; ELSE tmp:=0; ENDIF; OP2d:=tmp;
IF DATA = 8 THEN tmp:=1; ELSE tmp:=0; ENDIF; OP2e:=tmp;
IF DATA = 0 THEN tmp:=1; ELSE tmp:=0; ENDIF; OP2f:=tmp;
);
DATA[14] -> BYTE( %4
IF DATA & 128 THEN tmp:=1; ELSE tmp:=0; ENDIF; OP2g:=tmp;
IF DATA & 64 THEN tmp:=1; ELSE tmp:=0; ENDIF; OP2h:=tmp;
IF DATA > 15 THEN tmp:=0; ELSE tmp:=1; ENDIF; OP2i:=tmp;
);
DATA[21] -> RWORD(
IF DATA & 1 THEN tmp:=1; ELSE tmp:=0; ENDIF; DI1:=tmp;
IF DATA & 2 THEN tmp:=1; ELSE tmp:=0; ENDIF; DI2:=tmp;
);
DATA[27] -> RWORD(AO1:=(DATA/4096)*100;);
DATA[29] -> RWORD(AO2:=(DATA/4096)*100;);
DATA[31] -> RWORD(AI1:=DATA;); % 32768 - 32767
DATA[33] -> RWORD(AI2:=DATA;);
DATA[51] -> RWORD32(C1:=DATA;);
DATA[55] -> RWORD32(C2:=DATA;);
TIMEOUT 800
END;
END;
PARAMETER
Id : "Adress" [""]INT;
PUBLIC
OP1 : "AI1 range 2-10 V / 0,4-2 V / 4-20 mA Range" ["No,Yes"]ENUM;
OP2 : "AI2 range 2-10 V / 0,4-2 V / 4-20 mA Range" ["No,Yes"]ENUM;
OP1b : "AI1 Potentiometer Linearization 0-20 kS" ["No,Yes"]ENUM;
OP2b : "AI2 Potentiometer Linearization 0-20 kS" ["No,Yes"]ENUM;
OP1c : "AI1 0-2 V Range" ["No,Yes"]ENUM;
OP2c : "AI2 0-2 V Range" ["No,Yes"]ENUM;
OP1d : "AI1 NTC Temperature Linearization -50 - +150 °C" ["No,Yes"]ENUM;
OP2d : "AI2 NTC Temperature Linearization -50 - +150 °C" ["No,Yes"]ENUM;
OP1e : "AI1 0-20 mA Range" ["No,Yes"]ENUM;
OP2e : "AI2 0-20 mA Range" ["No,Yes"]ENUM;
OP1f : "AI1 0-10 V Range" ["No,Yes"]ENUM;
OP2f : "AI2 0-10 V Range" ["No,Yes"]ENUM;
OP1g : "AO1 Digital Output 24 V 20 mA" ["No,Yes"]ENUM;
OP2g : "AO2 Digital Output 24 V 20 mA" ["No,Yes"]ENUM;
OP1h : "AO1 2-10 V (4-20 mA for R02-2)" ["No,Yes"]ENUM;
OP2h : "AO2 2-10 V (4-20 mA for R02-2)" ["No,Yes"]ENUM;
OP1i : "AO1 0-10 V (4-20 mA for R02-2)" ["No,Yes"]ENUM;
OP2i : "AO2 0-10 V (4-20 mA for R02-2)" ["No,Yes"]ENUM;
DI1 : "DigitalInput 1" INT;
DI2 : "DigitalInput 2" INT;
AI1 : "AnalogInput 1" [""]INT;
AI2 : "AnalogInput 2" [""]INT;
AO1 : "AnalogOutput 1" ["%"]DEC2;
AO2 : "AnalogOutput 2" ["%"]DEC2;
C1 : "Counter 1" [""]INT;
C2 : "Counter 2" [""]INT;
PRIVATE
tmp;
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(0); % Start address
DATA[4] := RWORD(28); % Antal register att läsa
ANSWER SIZE 61 % (Antal register * 2) + 5
DATA[0] = BYTE(Id);
DATA[1] = HEX(03);
DATA[2] = BYTE(56); % Antal Bytes
DATA[11] -> BYTE( %4
IF DATA & 64 THEN tmp:=1; ELSE tmp:=0; ENDIF; OP1:=tmp;
IF DATA = 40 THEN tmp:=1; ELSE tmp:=0; ENDIF; OP1b:=tmp;
IF DATA = 32 THEN tmp:=1; ELSE tmp:=0; ENDIF; OP1c:=tmp;
IF DATA = 24 THEN tmp:=1; ELSE tmp:=0; ENDIF; OP1d:=tmp;
IF DATA = 8 THEN tmp:=1; ELSE tmp:=0; ENDIF; OP1e:=tmp;
IF DATA = 0 THEN tmp:=1; ELSE tmp:=0; ENDIF; OP1f:=tmp;
);
DATA[12] -> BYTE( %4
IF DATA & 128 THEN tmp:=1; ELSE tmp:=0; ENDIF; OP1g:=tmp;
IF DATA & 64 THEN tmp:=1; ELSE tmp:=0; ENDIF; OP1h:=tmp;
IF DATA > 15 THEN tmp:=0; ELSE tmp:=1; ENDIF; OP1i:=tmp;
);
DATA[13] -> BYTE( %5
IF DATA & 64 THEN tmp:=1; ELSE tmp:=0; ENDIF; OP2:=tmp;
IF DATA = 40 THEN tmp:=1; ELSE tmp:=0; ENDIF; OP2b:=tmp;
IF DATA = 32 THEN tmp:=1; ELSE tmp:=0; ENDIF; OP2c:=tmp;
IF DATA = 24 THEN tmp:=1; ELSE tmp:=0; ENDIF; OP2d:=tmp;
IF DATA = 8 THEN tmp:=1; ELSE tmp:=0; ENDIF; OP2e:=tmp;
IF DATA = 0 THEN tmp:=1; ELSE tmp:=0; ENDIF; OP2f:=tmp;
);
DATA[14] -> BYTE( %4
IF DATA & 128 THEN tmp:=1; ELSE tmp:=0; ENDIF; OP2g:=tmp;
IF DATA & 64 THEN tmp:=1; ELSE tmp:=0; ENDIF; OP2h:=tmp;
IF DATA > 15 THEN tmp:=0; ELSE tmp:=1; ENDIF; OP2i:=tmp;
);
DATA[21] -> RWORD(
IF DATA & 1 THEN tmp:=1; ELSE tmp:=0; ENDIF; DI1:=tmp;
IF DATA & 2 THEN tmp:=1; ELSE tmp:=0; ENDIF; DI2:=tmp;
);
DATA[27] -> RWORD(AO1:=(DATA/4096)*100;);
DATA[29] -> RWORD(AO2:=(DATA/4096)*100;);
DATA[31] -> RWORD(AI1:=DATA;); % 32768 - 32767
DATA[33] -> RWORD(AI2:=DATA;);
DATA[51] -> RWORD32(C1:=DATA;);
DATA[55] -> RWORD32(C2:=DATA;);
TIMEOUT 800
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.