Fidelix general
Detaljer
- Typ
- Drivrutin
- Upplaggd av
- Ove Jansson, Abelko Innovation
- Version
- 1
- Uppdaterad
- 2013-04-07
- Skapad
- 2013-04-07
- Kategori
- IO enheter, Modbus
- Visningar
- 3440
Beskrivning
For Fidelix IO modules
Bruksanvisning
Analog inputs are measured in Voltage
Input not used set "Sensor type" = 0 :bitvalue.
To calculate Voltage set "Sensor type" = 50 :formula.
To calculate Current set "Sensor type" = 40 :formula I = U / 100ohm)
To calculate Resistance set "sensor type" = 30 :formula R = 4700ohm * U / (2.5V - U)
To calculate Temperature set "sensor type" = 1-21,
1 Pt100 EN 50 751 alpha 0.00385,
2 Pt100 alpha 0.00375,
3 Pt100 alpha 0.00392,
4 Pt1000 EN 50 751 alpha 0.00385,
5 Pt1000 alpha 0.00375,
6 Pt1000 alpha 0.00392,
7 Ni1000 DIN,
8 Ni1000 LG,
9 QAC31/32 old,
10 NTC575 (QAC3132),
11 FWT1G,
12 FOT35,
13 TAC ECU,
14 Satchwell DOT,
15 Satchwell DW1204 DWS1202,
16 Satchwell DO2202,
17 IVT,
18 NIBE,
19 KTY 10/7,
20 Bodendammen,
21 T7043 Honywell
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
% Device definition for FIDELIX Analog inputs
%
% Settings module:
% Parity: None
% Baud: 9600
% Mode: RTU
%
% Analog inputs are measured in Voltage
% Input not used set "Sensor type" = 0 :bitvalue
% To calculate Voltage set "Sensor type" = 50 :formula
% To calculate Current set "Sensor type" = 40 :formula I = U / 100ohm)
% To calculate Resistance set "sensor type" = 30 :formula R = 4700ohm * U / (2.5V - U)
% To calculate Temperature set "sensor type" = 1-21
% 1 Pt100 EN 50 751 alpha 0.00385
% 2 Pt100 alpha 0.00375
% 3 Pt100 alpha 0.00392
% 4 Pt1000 EN 50 751 alpha 0.00385
% 5 Pt1000 alpha 0.00375
% 6 Pt1000 alpha 0.00392
% 7 Ni1000 DIN
% 8 Ni1000 LG
% 9 QAC31/32 old
% 10 NTC575 (QAC3132)
% 11 FWT1G
% 12 FOT35
% 13 TAC ECU
% 14 Satchwell DOT
% 15 Satchwell DW1204 DWS1202
% 16 Satchwell DO2202
% 17 IVT
% 18 NIBE
% 19 KTY 10/7
% 20 Bodendammen
% 21 T7043 Honywell
%
% Author: Peter Widetun, ABELKO AB Luleå
% History: 2011-12-08 Adjusted for individual settings for analog inputs
%
DEVICETYPE FidelixAIN NAMED "Fidelix A.IN" TYPEID 21220 IS
PARAMETER
Id : "Address";
% Sensor type 0 = OFF
% Sensor type 1-21 = Temperatur
% Sensor type 30 = Ohm
% Sensor type 40 = milliAmpere
% Sensor type 50 = Volt
Type_T1 :"Sensor type 1" [""] INT;
Type_T2 :"Sensor type 2" [""] INT;
Type_T3 :"Sensor type 3" [""] INT;
Type_T4 :"Sensor type 4" [""] INT;
Type_T5 :"Sensor type 5" [""] INT;
Type_T6 :"Sensor type 6" [""] INT;
Type_T7 :"Sensor type 7" [""] INT;
Type_T8 :"Sensor type 8" [""] INT;
PUBLIC
I1 : "Analog input 1" [""];
I2 : "Analog input 2" [""];
I3 : "Analog input 3" [""];
I4 : "Analog input 4" [""];
I5 : "Analog input 5" [""];
I6 : "Analog input 6" [""];
I7 : "Analog input 7" [""];
I8 : "Analog input 8" [""];
PRIVATE
Tmp;
LB1;
LB2;
LB3;
LB4;
LB5;
LB6;
LB7;
LB8;
AI1;
AI2;
AI3;
AI4;
AI5;
AI6;
AI7;
AI8;
Input;
R;
T;
Type;
R2;
R3;
R5;
R7;
LNR;
BAUDRATE 9600;
CHECKSUM MODBUS SWAPPED;
TELEGRAM AnalogInput NAMED "Read AI" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(03); % Modbus command "03h" Read holding registers
DATA[2] := RWORD(0); % Start address register
DATA[4] := RWORD(10); % Number of registers
ANSWER SIZE 25
DATA[0] = BYTE(Id); % ID
DATA[1] = HEX(03); % Modbus command "03h" Read holding registers
DATA[2] = BYTE(20); % Byte count
DATA[19] -> RWORD(
LB1 := (DATA & 15);
LB2 := (DATA & 240) / 16;
LB3 := (DATA & 3840) / 256;
LB4 := (DATA & 61440)/ 4096;
);
DATA[21] -> RWORD(
LB5 := (DATA & 15);
LB6 := (DATA & 240) / 16;
LB7 := (DATA & 3840) / 256;
LB8 := (DATA & 61440)/ 4096;
);
DATA[3] -> RWORD(IF (Type_T1 = 0) THEN % OFF
AI1 := 0; % Set value to 0
ELSIF (Type_T1 = 50) THEN % Voltage measurement
AI1 := ((DATA*16) + LB1) / 104857.5; % Maxbit=10V
ELSIF (Type_T1 = 40) THEN % Current measurement I=U/100Ohm
AI1 := (2.5 * (DATA*16) + LB1) / 1048575; % Maxbit=2.5V
ELSE % Resistance measurement R = 470Ohm * U / (2.5V - U)
Tmp := (2.5 * (DATA*16) + LB1) / 1048575; % Maxbit = 2.5V
IF Tmp<2.5 THEN AI1 := (4700 * Tmp) / (2.5 - Tmp);
ELSE AI1 := 0;
ENDIF;
ENDIF;
);
DATA[5] -> RWORD(IF (Type_T2 = 0) THEN % OFF
AI2 := 0; % Set value to 0
ELSIF (Type_T2 = 50) THEN % Voltage measurement
AI2 := ((DATA*16) + LB2) / 104857.5; % Maxbit=10V
ELSIF (Type_T2 = 40) THEN % Current measurement I=U/100Ohm
AI2 := (2.5 * (DATA*16) + LB2) / 1048575; % Maxbit=2.5V
ELSE % Resistance measurement R = 470Ohm * U / (2.5V - U)
Tmp := (2.5 * (DATA*16) + LB2) / 1048575; % Maxbit = 2.5V
IF Tmp<2.5 THEN AI2 := (4700 * Tmp) / (2.5 - Tmp);
ELSE AI2 := 0;
ENDIF;
ENDIF;
);
DATA[7] -> RWORD(IF (Type_T3 = 0) THEN % OFF
AI3 := 0; % Set value to 0
ELSIF (Type_T3 = 50) THEN % Voltage measurement
AI3 := ((DATA*16) + LB3) / 104857.5; % Maxbit=10V
ELSIF (Type_T3 = 40) THEN % Current measurement I=U/100Ohm
AI3 := (2.5 * (DATA*16) + LB3) / 1048575; % Maxbit=2.5V
ELSE % Resistance measurement R = 470Ohm * U / (2.5V - U)
Tmp := (2.5 * (DATA*16) + LB3) / 1048575; % Maxbit = 2.5V
IF Tmp<2.5 THEN AI3 := (4700 * Tmp) / (2.5 - Tmp);
ELSE AI3 := 0;
ENDIF;
ENDIF;
);
DATA[9] -> RWORD(IF (Type_T4 = 0) THEN % OFF
AI4 := 0; % Set value to 0
ELSIF (Type_T4 = 50) THEN % Voltage measurement
AI4 := ((DATA*16) + LB4) / 104857.5; % Maxbit=10V
ELSIF (Type_T4 = 40) THEN % Current measurement I=U/100Ohm
AI4 := (2.5 * (DATA*16) + LB4) / 1048575; % Maxbit=2.5V
ELSE % Resistance measurement R = 470Ohm * U / (2.5V - U)
Tmp := (2.5 * (DATA*16) + LB4) / 1048575; % Maxbit = 2.5V
IF Tmp<2.5 THEN AI4 := (4700 * Tmp) / (2.5 - Tmp);
ELSE AI4 := 0;
ENDIF;
ENDIF;
);
DATA[11] -> RWORD(IF (Type_T5 = 0) THEN % OFF
AI5 := 0; % Set value to 0
ELSIF (Type_T5 = 50) THEN % Voltage measurement
AI5 := ((DATA*16) + LB5) / 104857.5; % Maxbit=10V
ELSIF (Type_T5 = 40) THEN % Current measurement I=U/100Ohm
AI5 := (2.5 * (DATA*16) + LB5) / 1048575; % Maxbit=2.5V
ELSE % Resistance measurement R = 470Ohm * U / (2.5V - U)
Tmp := (2.5 * (DATA*16) + LB5) / 1048575; % Maxbit = 2.5V
IF Tmp<2.5 THEN AI5 := (4700 * Tmp) / (2.5 - Tmp);
ELSE AI5 := 0;
ENDIF;
ENDIF;
);
DATA[13] -> RWORD(IF (Type_T6 = 0) THEN % OFF
AI6 := 0; % Set value to 0
ELSIF (Type_T6 = 50) THEN % Voltage measurement
AI6 := ((DATA*16) + LB6) / 104857.5; % Maxbit=10V
ELSIF (Type_T6 = 40) THEN % Current measurement I=U/100Ohm
AI6 := (2.5 * (DATA*16) + LB6) / 1048575; % Maxbit=2.5V
ELSE % Resistance measurement R = 470Ohm * U / (2.5V - U)
Tmp := (2.5 * (DATA*16) + LB6) / 1048575; % Maxbit = 2.5V
IF Tmp<2.5 THEN AI6 := (4700 * Tmp) / (2.5 - Tmp);
ELSE AI6 := 0;
ENDIF;
ENDIF;
);
DATA[15] -> RWORD(IF (Type_T7 = 0) THEN % OFF
AI7 := 0; % Set value to 0
ELSIF (Type_T7 = 50) THEN % Voltage measurement
AI7 := ((DATA*16) + LB7) / 104857.5; % Maxbit=10V
ELSIF (Type_T7 = 40) THEN % Current measurement I=U/100Ohm
AI7 := (2.5 * (DATA*16) + LB7) / 1048575; % Maxbit=2.5V
ELSE % Resistance measurement R = 470Ohm * U / (2.5V - U)
Tmp := (2.5 * (DATA*16) + LB7) / 1048575; % Maxbit = 2.5V
IF Tmp<2.5 THEN AI7 := (4700 * Tmp) / (2.5 - Tmp);
ELSE AI7 := 0;
ENDIF;
ENDIF;
);
DATA[17] -> RWORD(IF (Type_T8 = 0) THEN % OFF
AI8 := 0; % Set value to 0
ELSIF (Type_T8 = 50) THEN % Voltage measurement
AI8 := ((DATA*16) + LB8) / 104857.5; % Maxbit=10V
ELSIF (Type_T8 = 40) THEN % Current measurement I=U/100Ohm
AI8 := (2.5 * (DATA*16) + LB8) / 1048575; % Maxbit=2.5V
ELSE % Resistance measurement R = 470Ohm * U / (2.5V - U)
Tmp := (2.5 * (DATA*16) + LB8) / 1048575; % Maxbit = 2.5V
IF Tmp<2.5 THEN AI8 := (4700 * Tmp) / (2.5 - Tmp);
ELSE AI8 := 0;
ENDIF;
ENDIF;
);
TIMEOUT 1000
END;
TELEGRAM AnalogEnable NAMED "Activate inputs" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(10); % Modbus command "0x10" write multiple registers
DATA[2] := RWORD(0); % start register
DATA[4] := RWORD(1); % number of registers to write
DATA[6] := BYTE(2); % number of bytes
DATA[7] <- RWORD(
IF Type_T1 THEN Tmp := 1; ELSE Tmp := 0; ENDIF;
IF Type_T2 THEN Tmp := Tmp + 2; ENDIF;
IF Type_T3 THEN Tmp := Tmp + 4; ENDIF;
IF Type_T4 THEN Tmp := Tmp + 8; ENDIF;
IF Type_T5 THEN Tmp := Tmp + 16; ENDIF;
IF Type_T6 THEN Tmp := Tmp + 32; ENDIF;
IF Type_T7 THEN Tmp := Tmp + 64; ENDIF;
IF Type_T8 THEN Tmp := Tmp + 128; ENDIF;
DATA := Tmp;
);
ANSWER SIZE 8
DATA[0] = BYTE(Id);
DATA[1] = HEX(10);
%DATA[2] = RWORD(0); % start register
%DATA[4] = RWORD(8); % number of registers to write
TIMEOUT 300
END;
END;
GROUP Fidelix OF MAX 5 DEVICE TYPEID 21220
% Fidelix AI Group script
SELECT ALL
ITERATOR CalcAI
ALIAS
BEGIN
IF Input = 1 THEN
Type := Type_T1;
R := AI1;
ELSIF Input = 2 THEN
Type := Type_T2;
R := AI2;
ELSIF Input = 3 THEN
Type := Type_T3;
R := AI3;
ELSIF Input = 4 THEN
Type := Type_T4;
R := AI4;
ELSIF Input = 5 THEN
Type := Type_T5;
R := AI5;
ELSIF Input = 6 THEN
Type := Type_T6;
R := AI6;
ELSIF Input = 7 THEN
Type := Type_T7;
R := AI7;
ELSE
Type := Type_T8;
R := AI8;
Input := 0;
ENDIF;
% Calculate for temperature for Type 1-21
IF Type = 1 THEN %Pt100 EN 50 751 alpha 0.00385
T := 3383.809524 - 0.08658008660 * (1758480889 - 2310000 * R)^0.5;
ELSIF Type = 2 THEN %Pt100 alpha 0.00375
T := 3164.451827 - 8305.647840 * (0.169241 - 0.000240800 * R)^0.5;
ELSIF Type = 3 THEN %Pt100 alpha 0.00392
T := 3392.940594 - 8527.911855 * (0.1817473668 - 0.00023452400 * R)^0.5;
ELSIF Type = 4 THEN %Pt1000 EN 50 751 alpha 0.00385
T := 3383.809524 - 865.8008660 * (17.58480889 - 0.00231 * R)^0.5;
ELSIF Type = 5 THEN %Pt1000 alpha 0.00375
T := 3164.451827 - 830.5647840 * (16.9241 - 0.002408 * R)^0.5;
ELSIF Type = 6 THEN %Pt1000 alpha 0.00392
T := 3392.940594 - 852.7911855 * (18.17473668 - 0.00234524 * R)^0.5;
ELSIF Type = 7 THEN %Ni1000 DIN
R5:= R*R*R*R*R;
R7:= R5*R*R;
T := (-412.6) + (140.41 * (1 + (0.00764 * R))^0.5) - (0.0000000000000000625 * R5) - (0.00000000000000000000000125 * R7);
ELSIF Type = 8 THEN %Ni1000 LG
R2:= R*R;
R3:= R2*R;
T := (-300.0187) + (R * 0.3888) - (R2 * 0.00010355) + (R3 * 0.000000014749);
ELSIF Type = 9 THEN %QAC31/32 old
R2:= R*R;
R3:= R2*R;
IF R <= 622.27 THEN
T := 1840.822526461981 - (8.81283638032425 * R) + (0.01481833026842 * R2) - (0.000008693645718129028 * R3);
ELSIF R <= 655.74 THEN
T := 18284.57180623524 - (87.53497076730491 * R) + (0.14047361791540 * R2) - (0.00007556728104760220 * R3);
ELSE
T := 447598.5593294129 - (2034.707401563966 * R) + (3.08435262703205 * R2) - (0.00155918519608 * R3);
ENDIF;
ELSIF Type = 10 THEN %NTC575 (QAC3132)
R2:= R*R;
R3:= R2*R;
IF R <= 616.7 THEN
T := 1984.368236149433 - (9.45847603610924 * R) + (0.01577267911992 * R2) - (0.000009153756833227248 * R3);
ELSIF R <= 675.5 THEN
T := 13500.31890121417 - (64.89024643188350 * R) + (0.10472492893027 * R2) - (0.00005674169841769381 * R3);
ELSE
T := -8135.044676629710 + (25.40018648262130 * R) - (0.01986043031034 * R2);
ENDIF;
ELSIF Type = 11 THEN %FWT1G
T := (-264.6311531847244) + (R * 0.13733939226662) - (R * R * 0.000008300189626466234);
ELSIF Type = 12 THEN %FOT35
LNR:= LN(R);
T := 245.7686957352614 - (R * 0.0002180214076186565) + (R * R * 0.000000001160703041443256) + (0.07334532481221 * LNR * LNR * LNR) - (34.06632737942485 * LNR);
ELSIF Type = 13 THEN %TAC ECU
LNR:= LN(R);
T := (-273.15) + (1 / (0.00114944558407 + (0.0002941176088004037 * LNR) - (0.0000000000002525998855897292 * LNR* LNR* LNR)));
ELSIF Type = 14 THEN %Satchwell DOT
R2 := R*R;
R3 := R2*R;
IF R >= 7661 THEN
T := 508885.1065949351 - (19.71706149035526 * R) + (0.001301247481832191 * R2) - (0.00000003594831664363352 * R3) - (3738912.809188366 / LN(R));
ELSIF R >= 1193 THEN
T := (-128.4611061637296) - (0.007002012490937275 * R) + (0.0000006986512762901833 * R2) - (0.00000000006639391744752032 * R3) + (1529.490359465714 / LN(R));
ELSE
T := (-339.6118638033802) + (0.09063945312481900 * R) - (0.00006415896542404209 * R2) + (0.00000001784096838726073 * R3) + (2639.015168861766 / LN(R));
ENDIF;
ELSIF Type = 15 THEN %Satchwell DW1204 DWS1202
R2 := R*R;
R3 := R2*R;
IF R >= 2236 THEN
T := 39382.90132075548 - (6.021252248143583 * R) + (0.0013733544102798 * R2) - (0.0000001313622917888568 * R3) - (241223.6906016618 / LN(R));
ELSIF R >= 974 THEN
T := (-888.2657030489725) + (0.1056691176426888 * R) - (0.00002987131417113171 * R2) + (0.000000002522599122874649 * R3) + (6271.371860366971 / LN(R));
ELSE
T := (-9517.677682528738) + (4.164299211339042 * R) - (0.002604874308355931 * R2) + (0.0000006794599871065049 * R3) + (50956.91507092444 / LN(R));
ENDIF;
ELSIF Type = 16 THEN %Satchwell DO2202
R2 := R*R;
R3 := R2*R;
T := (-1021.199118881201) + (0.04569968689660045 * R) + (0.00002069764420667956 * R2) - (0.00000000981645089002807 * R3) + (6869.504979681983 / LN(R));
ELSIF Type = 17 THEN %IVT
LNR:= LN(R);
T := (-273.15) + (1 / (0.001311184263438729 + (0.0002338997792885658 * LNR) + (0.0000001077046283506101 * LNR * LNR * LNR)));
ELSIF Type = 18 THEN %NIBE
LNR:= LN(R);
T := (-273.15) + (1 / (0.001387800349275742 + (0.0002400761437010071 * LNR) + (0.00000008613539226217632 * LNR * LNR * LNR)));
ELSIF Type = 19 THEN %KTY 10/7
R2 := R*R;
R3 := R2*R;
T := 311.5439406854249 + (0.04844211701143084 * R) - (0.000002908837846165819 * R2) + (0.0000000001362467604839759 * R3) - (2848.566087438425 / LN(R));
ELSIF Type = 20 THEN %Bodendammen
LNR:= LN(R);
T := (-273.15) + (1 / (0.001466426327478712 + (0.0002385193263772018 * LNR) + (0.0000001006014722395608 * LNR * LNR * LNR)));
ELSIF Type = 21 THEN %T7043 Honywell
LNR:= LN(R);
T := (-273.15) + (1 / (0.001705367599798446 + (0.0002527653342936799 * LNR) + (0.0000000005227580950721076 * LNR * LNR * LNR)));
ELSE
T := R;
ENDIF;
IF Input = 1 THEN
I1 := T;
ELSIF Input = 2 THEN
I2 := T;
ELSIF Input = 3 THEN
I3 := T;
ELSIF Input = 4 THEN
I4 := T;
ELSIF Input = 5 THEN
I5 := T;
ELSIF Input = 6 THEN
I6 := T;
ELSIF Input = 7 THEN
I7 := T;
ELSE
I8 := T;
ENDIF;
Input := Input + 1;
END;
END;
ROUTINE UpdateTemp
%Calls Fidelix.CalcAI to calculate temperatures from resistance measurements
BEGIN
%One call for each input
CALL Fidelix.CalcAI; % Analog Input 1
CALL Fidelix.CalcAI; % Analog Input 2
CALL Fidelix.CalcAI; % Analog Input 3
CALL Fidelix.CalcAI; % Analog Input 4
CALL Fidelix.CalcAI; % Analog Input 5
CALL Fidelix.CalcAI; % Analog Input 6
CALL Fidelix.CalcAI; % Analog Input 7
CALL Fidelix.CalcAI; % Analog Input 8
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.