FIDELIX Analog inputs UltraBase
Detaljer
- Typ
- Drivrutin
- Upplaggd av
- Ove Jansson, Abelko Innovation
- Version
- 6
- Uppdaterad
- 2019-01-15
- Skapad
- 2013-04-07
- Kategori
- IO enheter, Modbus
- Visningar
- 4752
Beskrivning
Stöd för Fidelix analoga inputs enheter i Ultra Base
Bruksanvisning
All inputs are calculated for Voltage, Current and Resistance.
Use value due to selected input type.
Aktivera telegram "Läs AI" för att uppdatera värden. Sätt lämpligt uppdateringsintervall t.ex 5 sekunder.
Aktivera telegram "Aktivera AI" för att aktivera ingångar. Lämpligt uppdateringsintervall 60 sekunder eller mer.
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
% To calculate Current use formula I = U / 100ohm
% To calculate Resistance use formula R = 4700ohm * U / (2.5V - U)
%
% Author: Peter Widetun, ABELKO AB Luleå
% History: 2009-12-14 Ändrat kommando 4 till kommando 3 Read holding registers
% History: 2019-01-04 Satt gap-time och rättat startregister för aktivering AI
% History: 2019-01-15 omräkning till alla enheter Spänning, Ström, resistans för alla ingångar.
%
DEVICETYPE FidelixAIN NAMED "Fidelix A.IN_all" TYPEID 21220 IS
PARAMETER
Id : "Adress" INT;
EN1 :"Enable AI1" INT;
EN2 :"Enable AI2" INT;
EN3 :"Enable AI3" INT;
EN4 :"Enable AI4" INT;
EN5 :"Enable AI5" INT;
EN6 :"Enable AI6" INT;
EN7 :"Enable AI7" INT;
EN8 :"Enable AI8" INT;
PUBLIC
AU1 : "Spänning 1" ["V"] DEC2;
AU2 : "Spänning 2" ["V"] DEC2;
AU3 : "Spänning 3" ["V"] DEC2;
AU4 : "Spänning 4" ["V"] DEC2;
AU5 : "Spänning 5" ["V"] DEC2;
AU6 : "Spänning 6" ["V"] DEC2;
AU7 : "Spänning 7" ["V"] DEC2;
AU8 : "Spänning 8" ["V"] DEC2;
AI1 : "Ström 1" ["mA"] DEC2; %For current measurement
AI2 : "Ström 2" ["mA"] DEC2;
AI3 : "Ström 3" ["mA"] DEC2;
AI4 : "Ström 4" ["mA"] DEC2;
AI5 : "Ström 5" ["mA"] DEC2;
AI6 : "Ström 6" ["mA"] DEC2;
AI7 : "Ström 7" ["mA"] DEC2;
AI8 : "Ström 8" ["mA"] DEC2;
AR1 : "Resistans 1" ["Ohm"] DEC1; % For resistance measurement
AR2 : "Resistans 2" ["Ohm"] DEC1;
AR3 : "Resistans 3" ["Ohm"] DEC1;
AR4 : "Resistans 4" ["Ohm"] DEC1;
AR5 : "Resistans 5" ["Ohm"] DEC1;
AR6 : "Resistans 6" ["Ohm"] DEC1;
AR7 : "Resistans 7" ["Ohm"] DEC1;
AR8 : "Resistans 8" ["Ohm"] DEC1;
PRIVATE
Tmp;
LB1;
LB2;
LB3;
LB4;
LB5;
LB6;
LB7;
LB8;
BAUDRATE 9600;
CHRGAPTIMEOUT 5;
CHECKSUM MODBUS SWAPPED;
TELEGRAM AnalogInput NAMED "Läs 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(Tmp := ((DATA*16) + LB1) / 1048575; % Input value 0-1
AU1 := 10*Tmp; % Voltage measurement (maxvoltage = 10)
AI1 := 1000 * 2.5*Tmp / 100; % Current (mA) = 1000 * U/100 (maxvoltage = 2.5)
Tmp := 2.5*Tmp; % Resistance (maxvoltage = 2.5)
IF (Tmp<2.49) THEN
AR1 := (4700 * Tmp) / (2.5 - Tmp); % Resistance = (470Ohm * U) / (2.5V - U)
ELSE
AR1 := 1000000;
ENDIF;
);
DATA[5] -> RWORD(Tmp := ((DATA*16) + LB2) / 1048575; % Input value 0-1
AU2 := 10*Tmp; % Voltage measurement (maxvoltage = 10)
AI2 := 1000 * 2.5*Tmp / 100; % Current (mA) = 1000 * U/100 (maxvoltage = 2.5)
Tmp := 2.5*Tmp; % Resistance (maxvoltage = 2.5)
IF (Tmp<2.49) THEN
AR2 := (4700 * Tmp) / (2.5 - Tmp); % Resistance = (470Ohm * U) / (2.5V - U)
ELSE
AR2 := 1000000;
ENDIF;
);
DATA[7] -> RWORD(Tmp := ((DATA*16) + LB3) / 1048575; % Input value 0-1
AU3 := 10*Tmp; % Voltage measurement (maxvoltage = 10)
AI3 := 1000 * 2.5*Tmp / 100; % Current (mA) = 1000 * U/100 (maxvoltage = 2.5)
Tmp := 2.5*Tmp; % Resistance (maxvoltage = 2.5)
IF (Tmp<2.49) THEN
AR3 := (4700 * Tmp) / (2.5 - Tmp); % Resistance = (470Ohm * U) / (2.5V - U)
ELSE
AR3 := 1000000;
ENDIF;
);
DATA[9] -> RWORD(Tmp := ((DATA*16) + LB4) / 1048575; % Input value 0-1
AU4 := 10*Tmp; % Voltage measurement (maxvoltage = 10)
AI4 := 1000 * 2.5*Tmp / 100; % Current (mA) = 1000 * U/100 (maxvoltage = 2.5)
Tmp := 2.5*Tmp; % Resistance (maxvoltage = 2.5)
IF (Tmp<2.49) THEN
AR4 := (4700 * Tmp) / (2.5 - Tmp); % Resistance = (470Ohm * U) / (2.5V - U)
ELSE
AR4 := 1000000;
ENDIF;
);
DATA[11] -> RWORD(Tmp := ((DATA*16) + LB5) / 1048575; % Input value 0-1 (20 bitar)
AU5 := 10*Tmp; % Voltage measurement (maxvoltage = 10)
AI5 := 1000 * 2.5*Tmp / 100; % Current (mA) = 1000 * U/100 (maxvoltage = 2.5)
Tmp := 2.5*Tmp; % Resistance (maxvoltage = 2.5)
IF (Tmp<2.49) THEN
AR5 := (4700 * Tmp) / (2.5 - Tmp); % Resistance = (470Ohm * U) / (2.5V - U)
ELSE
AR5 := 1000000;
ENDIF;
);
DATA[13] -> RWORD(Tmp := ((DATA*16) + LB6) / 1048575; % Input value 0-1
AU6 := 10*Tmp; % Voltage measurement (maxvoltage = 10)
AI6 := 1000 * 2.5*Tmp / 100; % Current (mA) = 1000 * U/100 (maxvoltage = 2.5)
Tmp := 2.5*Tmp; % Resistance (maxvoltage = 2.5)
IF (Tmp<2.49) THEN
AR6 := (4700 * Tmp) / (2.5 - Tmp); % Resistance = (470Ohm * U) / (2.5V - U)
ELSE
AR6 := 1000000;
ENDIF;
);
DATA[15] -> RWORD(Tmp := ((DATA*16) + LB7) / 1048575; % Input value 0-1
AU7 := 10*Tmp; % Voltage measurement (maxvoltage = 10)
AI7 := 1000 * 2.5*Tmp / 100; % Current (mA) = 1000 * U/100 (maxvoltage = 2.5)
Tmp := 2.5*Tmp; % Resistance (maxvoltage = 2.5)
IF (Tmp<2.49) THEN
AR7 := (4700 * Tmp) / (2.5 - Tmp); % Resistance = (470Ohm * U) / (2.5V - U)
ELSE
AR7 := 1000000;
ENDIF;
);
DATA[17] -> RWORD(Tmp := ((DATA*16) + LB8) / 1048575; % Input value 0-1
AU8 := 10*Tmp; % Voltage measurement (maxvoltage = 10)
AI8 := 1000 * 2.5*Tmp / 100; % Current (mA) = 1000 * U/100 (maxvoltage = 2.5)
Tmp := 2.5*Tmp; % Resistance (maxvoltage = 2.5)
IF (Tmp<2.49) THEN
AR8 := (4700 * Tmp) / (2.5 - Tmp); % Resistance = (470Ohm * U) / (2.5V - U)
ELSE
AR8 := 1000000;
ENDIF;
);
TIMEOUT 1000
END;
TELEGRAM AnalogEnable NAMED "Aktivera AI" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(10); % Modbus command "0x10" write multiple registers
DATA[2] := RWORD(10); % start register
DATA[4] := RWORD(1); % number of registers to write
DATA[6] := BYTE(2); % number of bytes
DATA[7] <- RWORD(
IF EN1 THEN Tmp := 1; ELSE Tmp := 0; ENDIF;
IF EN2 THEN Tmp := Tmp + 2; ENDIF;
IF EN3 THEN Tmp := Tmp + 4; ENDIF;
IF EN4 THEN Tmp := Tmp + 8; ENDIF;
IF EN5 THEN Tmp := Tmp + 16; ENDIF;
IF EN6 THEN Tmp := Tmp + 32; ENDIF;
IF EN7 THEN Tmp := Tmp + 64; ENDIF;
IF EN8 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;
% Device definition for FIDELIX Analog inputs
%
% Settings module:
% Parity: None
% Baud: 9600
% Mode: RTU
%
% Analog inputs are measured in Voltage
% To calculate Current use formula I = U / 100ohm
% To calculate Resistance use formula R = 4700ohm * U / (2.5V - U)
%
% Author: Peter Widetun, ABELKO AB Luleå
% History: 2009-12-14 Ändrat kommando 4 till kommando 3 Read holding registers
% History: 2019-01-04 Satt gap-time och rättat startregister för aktivering AI
% History: 2019-01-15 omräkning till alla enheter Spänning, Ström, resistans för alla ingångar.
%
DEVICETYPE FidelixAIN NAMED "Fidelix A.IN_all" TYPEID 21220 IS
PARAMETER
Id : "Adress" INT;
EN1 :"Enable AI1" INT;
EN2 :"Enable AI2" INT;
EN3 :"Enable AI3" INT;
EN4 :"Enable AI4" INT;
EN5 :"Enable AI5" INT;
EN6 :"Enable AI6" INT;
EN7 :"Enable AI7" INT;
EN8 :"Enable AI8" INT;
PUBLIC
AU1 : "Spänning 1" ["V"] DEC2;
AU2 : "Spänning 2" ["V"] DEC2;
AU3 : "Spänning 3" ["V"] DEC2;
AU4 : "Spänning 4" ["V"] DEC2;
AU5 : "Spänning 5" ["V"] DEC2;
AU6 : "Spänning 6" ["V"] DEC2;
AU7 : "Spänning 7" ["V"] DEC2;
AU8 : "Spänning 8" ["V"] DEC2;
AI1 : "Ström 1" ["mA"] DEC2; %For current measurement
AI2 : "Ström 2" ["mA"] DEC2;
AI3 : "Ström 3" ["mA"] DEC2;
AI4 : "Ström 4" ["mA"] DEC2;
AI5 : "Ström 5" ["mA"] DEC2;
AI6 : "Ström 6" ["mA"] DEC2;
AI7 : "Ström 7" ["mA"] DEC2;
AI8 : "Ström 8" ["mA"] DEC2;
AR1 : "Resistans 1" ["Ohm"] DEC1; % For resistance measurement
AR2 : "Resistans 2" ["Ohm"] DEC1;
AR3 : "Resistans 3" ["Ohm"] DEC1;
AR4 : "Resistans 4" ["Ohm"] DEC1;
AR5 : "Resistans 5" ["Ohm"] DEC1;
AR6 : "Resistans 6" ["Ohm"] DEC1;
AR7 : "Resistans 7" ["Ohm"] DEC1;
AR8 : "Resistans 8" ["Ohm"] DEC1;
PRIVATE
Tmp;
LB1;
LB2;
LB3;
LB4;
LB5;
LB6;
LB7;
LB8;
BAUDRATE 9600;
CHRGAPTIMEOUT 5;
CHECKSUM MODBUS SWAPPED;
TELEGRAM AnalogInput NAMED "Läs 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(Tmp := ((DATA*16) + LB1) / 1048575; % Input value 0-1
AU1 := 10*Tmp; % Voltage measurement (maxvoltage = 10)
AI1 := 1000 * 2.5*Tmp / 100; % Current (mA) = 1000 * U/100 (maxvoltage = 2.5)
Tmp := 2.5*Tmp; % Resistance (maxvoltage = 2.5)
IF (Tmp<2.49) THEN
AR1 := (4700 * Tmp) / (2.5 - Tmp); % Resistance = (470Ohm * U) / (2.5V - U)
ELSE
AR1 := 1000000;
ENDIF;
);
DATA[5] -> RWORD(Tmp := ((DATA*16) + LB2) / 1048575; % Input value 0-1
AU2 := 10*Tmp; % Voltage measurement (maxvoltage = 10)
AI2 := 1000 * 2.5*Tmp / 100; % Current (mA) = 1000 * U/100 (maxvoltage = 2.5)
Tmp := 2.5*Tmp; % Resistance (maxvoltage = 2.5)
IF (Tmp<2.49) THEN
AR2 := (4700 * Tmp) / (2.5 - Tmp); % Resistance = (470Ohm * U) / (2.5V - U)
ELSE
AR2 := 1000000;
ENDIF;
);
DATA[7] -> RWORD(Tmp := ((DATA*16) + LB3) / 1048575; % Input value 0-1
AU3 := 10*Tmp; % Voltage measurement (maxvoltage = 10)
AI3 := 1000 * 2.5*Tmp / 100; % Current (mA) = 1000 * U/100 (maxvoltage = 2.5)
Tmp := 2.5*Tmp; % Resistance (maxvoltage = 2.5)
IF (Tmp<2.49) THEN
AR3 := (4700 * Tmp) / (2.5 - Tmp); % Resistance = (470Ohm * U) / (2.5V - U)
ELSE
AR3 := 1000000;
ENDIF;
);
DATA[9] -> RWORD(Tmp := ((DATA*16) + LB4) / 1048575; % Input value 0-1
AU4 := 10*Tmp; % Voltage measurement (maxvoltage = 10)
AI4 := 1000 * 2.5*Tmp / 100; % Current (mA) = 1000 * U/100 (maxvoltage = 2.5)
Tmp := 2.5*Tmp; % Resistance (maxvoltage = 2.5)
IF (Tmp<2.49) THEN
AR4 := (4700 * Tmp) / (2.5 - Tmp); % Resistance = (470Ohm * U) / (2.5V - U)
ELSE
AR4 := 1000000;
ENDIF;
);
DATA[11] -> RWORD(Tmp := ((DATA*16) + LB5) / 1048575; % Input value 0-1 (20 bitar)
AU5 := 10*Tmp; % Voltage measurement (maxvoltage = 10)
AI5 := 1000 * 2.5*Tmp / 100; % Current (mA) = 1000 * U/100 (maxvoltage = 2.5)
Tmp := 2.5*Tmp; % Resistance (maxvoltage = 2.5)
IF (Tmp<2.49) THEN
AR5 := (4700 * Tmp) / (2.5 - Tmp); % Resistance = (470Ohm * U) / (2.5V - U)
ELSE
AR5 := 1000000;
ENDIF;
);
DATA[13] -> RWORD(Tmp := ((DATA*16) + LB6) / 1048575; % Input value 0-1
AU6 := 10*Tmp; % Voltage measurement (maxvoltage = 10)
AI6 := 1000 * 2.5*Tmp / 100; % Current (mA) = 1000 * U/100 (maxvoltage = 2.5)
Tmp := 2.5*Tmp; % Resistance (maxvoltage = 2.5)
IF (Tmp<2.49) THEN
AR6 := (4700 * Tmp) / (2.5 - Tmp); % Resistance = (470Ohm * U) / (2.5V - U)
ELSE
AR6 := 1000000;
ENDIF;
);
DATA[15] -> RWORD(Tmp := ((DATA*16) + LB7) / 1048575; % Input value 0-1
AU7 := 10*Tmp; % Voltage measurement (maxvoltage = 10)
AI7 := 1000 * 2.5*Tmp / 100; % Current (mA) = 1000 * U/100 (maxvoltage = 2.5)
Tmp := 2.5*Tmp; % Resistance (maxvoltage = 2.5)
IF (Tmp<2.49) THEN
AR7 := (4700 * Tmp) / (2.5 - Tmp); % Resistance = (470Ohm * U) / (2.5V - U)
ELSE
AR7 := 1000000;
ENDIF;
);
DATA[17] -> RWORD(Tmp := ((DATA*16) + LB8) / 1048575; % Input value 0-1
AU8 := 10*Tmp; % Voltage measurement (maxvoltage = 10)
AI8 := 1000 * 2.5*Tmp / 100; % Current (mA) = 1000 * U/100 (maxvoltage = 2.5)
Tmp := 2.5*Tmp; % Resistance (maxvoltage = 2.5)
IF (Tmp<2.49) THEN
AR8 := (4700 * Tmp) / (2.5 - Tmp); % Resistance = (470Ohm * U) / (2.5V - U)
ELSE
AR8 := 1000000;
ENDIF;
);
TIMEOUT 1000
END;
TELEGRAM AnalogEnable NAMED "Aktivera AI" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(10); % Modbus command "0x10" write multiple registers
DATA[2] := RWORD(10); % start register
DATA[4] := RWORD(1); % number of registers to write
DATA[6] := BYTE(2); % number of bytes
DATA[7] <- RWORD(
IF EN1 THEN Tmp := 1; ELSE Tmp := 0; ENDIF;
IF EN2 THEN Tmp := Tmp + 2; ENDIF;
IF EN3 THEN Tmp := Tmp + 4; ENDIF;
IF EN4 THEN Tmp := Tmp + 8; ENDIF;
IF EN5 THEN Tmp := Tmp + 16; ENDIF;
IF EN6 THEN Tmp := Tmp + 32; ENDIF;
IF EN7 THEN Tmp := Tmp + 64; ENDIF;
IF EN8 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;
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.