SRC RS485 MODBUS Thermokon Sensortechnik GmbH
Detaljer
Beskrivning
Drivrutin för SRC RS485 MODBUS Thermokon Sensortechnik GmbH
Bruksanvisning
Hur man installerar typdefinitionerna och driftsätter modulerna finns beskrivet i användarmanualen, kapitel 18.7
Interface Description for SRC RS485 MODBUS (pdf)
Note! Use one Device for each sensor. Individual scale factors possible.
Sensor 1 corresponds to register 1-10
Sensor 2 corresponds to register 11-20
Sensor 32 corresponds to register 311-320
Use the push button on the sensor to let the system learn the sensors.
Activate TELEGRAM "Learn SRC sensor" by setting interval time to 1 second.
Let the telegram run for 10 seconds and then inactivate the TELEGRAM.
Now the SRC-module is ready to receive information type and ID for a sensor.
Push the button on the sensor you want for this sensor number.
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
% 2010-03-11 Justerad Transmitterfunktion med automatisk transmit vid ändring
% 2010-02-02 Nya moduler inlagda.
% Ställa utstatus infört
% 2011-08-18 Fixat skript 21174 så att inläsning sker av sensor 17-32.
% Tidigare erhölls enbart sensor 1-20
% Skript 12173 klarar inläsning av sensor 1-16.
% 2014-11-10 Fixat ThermokonTRANSM skriptet för ställdon.
% Omvänd ordning för databyte 0-3.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Device definition for SRC RS485 MODBUD Thermokon Sensortechnik GmbH
%
% Settings SRC module:
% Parity: None
% Baud: 9600
% Mode: RTU
%
% WMPro devicenet settings
% Use one Device for each sensor with a diffrent sensor number in each device.
% Sensor 1 corresponds to register 1-10 in SRC-RS485 MODBUS module.
% Sensor 2 corresponds to register 11-20 in SRC-RS485 MODBUS module.
% ..
% Sensor 32 corresponds to register 311-320 in SRC-RS485 MODBUS module.
%
% Define a WMPRo device as "ThermokonSENSOR" (menu External units).
% Set parameters "Modbus address" and "Sensor (1-32)" and SAVE.
% Connect selected parameters Data-Byte 0-3 to channels.
% Activate "Read.." TELEGRAM for the sensor you use, example "Read SR04" for
% temperature sensor.
% You can always use the "Read general" for all types of sensors. In that case
% the datavalues are presented as bit values.
%
% Parameter "Set Sensor TYPE" and "Set Sensor ID" are normaly not used.
% They can be used togheter with "(Set Sensor)" to update Type and Id se
% "Manual update" below.
% Use parameter "(LearnID start)" to let Thermokon SRC learn a new sensor.
% Se "Learn sensor" below.
% Telegrams "(LearnID start)", "(LearnID stop)" and "(Set sensor)" are set to
% SILENCE (no communication) and is only started when the corresponding
% parameter value is changed.
%
% THERMOKON SENSOR.
% Learn sensor.
% Use the push button on the sensor to let the system learn the sensors.
% Do like this.
% Activate TELEGRAM "(LearnID start)", set telegram update time to 1 hour.
% Send the TELEGRAM by incrementing the parameter "(LearnID start)" and SAVE.
% This will set the learn-bit in the SRC RS485 module and set the module ready
% to receive information about TYPE and ID for a sensor.
% Now you can push the learn button on the sensor you want to connect
% to the selected WMPRO device. When you push the learn button it is indicated
% on the SRC-RS485 MODBUS module.
% Check the sensor by activating the "Read .." telegram corresponding to the
% sensor (update time 10 seconds). The values are present under "Show values".
% When the sensor values are received the telegram "(LearnID start)" can be
% set to "No communication".
%
% Reset learn-bit.
% If you want to reset the learn-bit in the SRC RS485 module you can
% activate TELEGRAM "(LearnID stop)" (set telegram update time to 1 hour) and
% increment the parameter "(LearnID stop)".
% Set the telegram "(LearnID stop)" to "No communication" when ready.
%
% Manual ID setting.
% For some sensors you have to set the ID manualy.
% Activate TELEGRAM "(Set sensor)" (update time = 1 hour).
% Set parameter "Set Sensor TYP" and "Set Sensor ID" for the sensor and also
% increment the parameter "(Set Sensor)". When the parameter settings are saved
% they will be sent to the SRC RS485 module and the sensor values will be
% updated to the module.
% When the sensor values are received correctly the telegram "(Set sensor)" can
% be set to "No communication".
%
%
% Author: Peter Widetun, ABELKO AB Luleå
% History: 2007-11-14 inital version
%
DEVICETYPE ThermokonSRC1 NAMED "ThermokonSENSOR" TYPEID 21170 IS
PARAMETER
Id : "Modbus address";
SensorNo : "Sensor (1-32)";
SensorORG : "Set Sensor TYPE";
SensorID : "Set Sensor ID";
SensorSet : "(Set Sensor)";
LearnIDOn : "(LearnID start)";
LearnIDOff : "(LearnID stop)";
PUBLIC
SensorType : "Sensor-ORG";
SensorId : "Sensor-ID";
DataByte3 : "Data-Byte 3";
DataByte2 : "Data-Byte 2";
DataByte1 : "Data-Byte 1";
DataByte0 : "Data-Byte 0";
RecTime : "Time telegram";
%DataByte0 : "Digital status";
%DataByte1 : "Temperatur";
%DataByte2 : "Börvärdesjust.";
%DataByte3 : "Fläkthastighet";
PRIVATE
IdHigh;
IdLow;
SilenceStart;
SilenceStop;
SilenceSet;
MLearnIDOn;
MLearnIDOff;
MSensorSet;
Started1;
Started2;
Started3;
BAUDRATE 9600;
CHECKSUM MODBUS SWAPPED;
TELEGRAM ReadGeneral NAMED "Read general" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(03); % Modbus command "03h" read holding registers
% start register
DATA[2] <- RWORD(IF((SensorNo<1) OR (SensorNo>32)) THEN
DATA := 0;
ELSE
DATA := 10*(SensorNo-1);
ENDIF;
);
DATA[4] := RWORD(10); % number of registers to read
ANSWER SIZE 25
DATA[0] = BYTE(Id);
DATA[1] = HEX(03);
%DATA[2] = BYTE(20);
DATA[3] -> RWORD(SensorType := DATA;);
DATA[5] -> RWORD(IdHigh := DATA;);
DATA[7] -> RWORD(SensorId := (IdHigh*65536) + DATA;);
DATA[9] -> RWORD(DataByte3 := DATA;);
DATA[11] -> RWORD(DataByte2 := DATA;);
DATA[13] -> RWORD(DataByte1 := DATA;);
DATA[15] -> RWORD(DataByte0 := DATA;);
DATA[17] -> RWORD(RecTime := DATA;);
TIMEOUT 300
END;
TELEGRAM ReadSR04 NAMED "Read SR04*" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(03); % Modbus command "03h" read holding registers
% start register
DATA[2] <- RWORD(IF((SensorNo<1) OR (SensorNo>32)) THEN
DATA := 0;
ELSE
DATA := 10*(SensorNo-1);
ENDIF;
);
DATA[4] := RWORD(10); % number of registers to read
ANSWER SIZE 25
DATA[0] = BYTE(Id);
DATA[1] = HEX(03);
%DATA[2] = BYTE(20);
DATA[3] -> RWORD(SensorType := DATA;);
DATA[5] -> RWORD(IdHigh := DATA;);
DATA[7] -> RWORD(SensorId := (IdHigh*65536) + DATA;);
%DATA[9] -> RWORD(IF DataByte3 := DATA;); % Fan Speed
% Fan Speed
DATA[9] -> RWORD(IF (DATA > 210) THEN DataByte3 := 4; % >210 Auto 4
ELSIF (DATA > 189) THEN DataByte3 := 0; % 190-210 Stage 0
ELSIF (DATA > 164) THEN DataByte3 := 1; % 165-190 Stage 1
ELSIF (DATA > 144) THEN DataByte3 := 2; % 145-165 Stage 2
ELSE DataByte3 := 3; % <145 Stage 3
ENDIF;
);
DATA[11] -> RWORD(DataByte2 := 100*DATA/255;); % Set point 0-100%
% 0 = 0% Min
% 255 = 100% Max
DATA[13] -> RWORD(DataByte1 := 40 - ((40/255)*DATA);); % Temperature
% 0 = 40°C
% 255 = 0°C
% Occupied Button / Switch
DATA[15] -> RWORD(IF (DATA & 1)>0 THEN DataByte0 := 0; % Bit0=1 unpressed / pos. 0
ELSE DataByte0 := 1; % Bit0=0 pressed / pos. 1
ENDIF;
);
DATA[17] -> RWORD(RecTime := DATA;);
TIMEOUT 300
END;
TELEGRAM ReadSRMDS NAMED "Read SRMDS" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(03); % Modbus command "03h" read holding registers
% start register
DATA[2] <- RWORD(IF((SensorNo<1) OR (SensorNo>32)) THEN
DATA := 0;
ELSE
DATA := 10*(SensorNo-1);
ENDIF;
);
DATA[4] := RWORD(10); % number of registers to read
ANSWER SIZE 25
DATA[0] = BYTE(Id);
DATA[1] = HEX(03);
%DATA[2] = BYTE(20);
DATA[3] -> RWORD(SensorType := DATA;);
DATA[5] -> RWORD(IdHigh := DATA;);
DATA[7] -> RWORD(SensorId := (IdHigh*65536) + DATA;);
% Movement detection
DATA[9] -> RWORD(IF (DATA = 39) THEN DataByte3 := 1; % 39 = Movement
ELSE DataByte3 := 0; % 23 = No movement
ENDIF;
);
DATA[11] -> RWORD(DataByte2 := 100*DATA/255;); % Charging voltage
% 0 = 0%
% 255 = 100%
DATA[13] -> RWORD(DataByte1 := 2*DATA;); % Brightness
% 0 = 0 Lux
% 255 = 512 Lux
DATA[15] -> RWORD(DataByte0 := DATA;);
DATA[17] -> RWORD(RecTime := DATA;);
TIMEOUT 300
END;
TELEGRAM ReadSW01 NAMED "Read SRW01" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(03); % Modbus command "03h" read holding registers
% start register
DATA[2] <- RWORD(IF((SensorNo<1) OR (SensorNo>32)) THEN
DATA := 0;
ELSE
DATA := 10*(SensorNo-1);
ENDIF;
);
DATA[4] := RWORD(10); % number of registers to read
ANSWER SIZE 25
DATA[0] = BYTE(Id);
DATA[1] = HEX(03);
%DATA[2] = BYTE(20);
DATA[3] -> RWORD(SensorType := DATA;);
DATA[5] -> RWORD(IdHigh := DATA;);
DATA[7] -> RWORD(SensorId := (IdHigh*65536) + DATA;);
DATA[9] -> RWORD(DataByte3 := DATA & 1;); % State reed contact
% Bit 0 = 0 Contact open
% Bit 0 = 1 Contact closed
DATA[11] -> RWORD(DataByte2 := DATA;);
DATA[13] -> RWORD(DataByte1 := DATA;);
DATA[15] -> RWORD(DataByte0 := DATA;);
DATA[17] -> RWORD(RecTime := DATA;);
TIMEOUT 300
END;
TELEGRAM ReadSR65 NAMED "Read SR65" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(03); % Modbus command "03h" read holding registers
% start register
DATA[2] <- RWORD(IF((SensorNo<1) OR (SensorNo>32)) THEN
DATA := 0;
ELSE
DATA := 10*(SensorNo-1);
ENDIF;
);
DATA[4] := RWORD(10); % number of registers to read
ANSWER SIZE 25
DATA[0] = BYTE(Id);
DATA[1] = HEX(03);
%DATA[2] = BYTE(20);
DATA[3] -> RWORD(SensorType := DATA;);
DATA[5] -> RWORD(IdHigh := DATA;);
DATA[7] -> RWORD(SensorId := (IdHigh*65536) + DATA;);
DATA[9] -> RWORD(DataByte3 := DATA;);
DATA[11] -> RWORD(DataByte2 := DATA;);
DATA[13] -> RWORD(DataByte1 := (60 - (80/255)*DATA);); % Temperature
% 0 = 60°C
% 255 = -20°C
DATA[15] -> RWORD(DataByte0 := DATA;);
DATA[17] -> RWORD(RecTime := DATA;);
TIMEOUT 300
END;
TELEGRAM ReadSR04rh NAMED "Read SR04*RH" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(03); % Modbus command "03h" read holding registers
% start register
DATA[2] <- RWORD(IF((SensorNo<1) OR (SensorNo>32)) THEN
DATA := 0;
ELSE
DATA := 10*(SensorNo-1);
ENDIF;
);
DATA[4] := RWORD(10); % number of registers to read
ANSWER SIZE 25
DATA[0] = BYTE(Id);
DATA[1] = HEX(03);
%DATA[2] = BYTE(20);
DATA[3] -> RWORD(SensorType := DATA;);
DATA[5] -> RWORD(IdHigh := DATA;);
DATA[7] -> RWORD(SensorId := (IdHigh*65536) + DATA;);
DATA[9] -> RWORD(DataByte3 := 100*DATA/255;); % Set point
% 0 = 0% Min
% 255 = 100% Max
DATA[11] -> RWORD(DataByte2 := 100*DATA/250;); % Humidity 0-100%
% 0 = 0% Min
% 250 = 100% Max
DATA[13] -> RWORD(DataByte1 := ((40/250)*DATA);); % Temperature
% 0 = 0°C
% 250 = 40°C
DATA[15] -> RWORD(IF (DATA & 1)>0 THEN DataByte0 := 0; % Bit3=1 unpressed / pos. 0
ELSE DataByte0 := 1; % Bit3=0 pressed / pos. 1
ENDIF;
);
DATA[17] -> RWORD(RecTime := DATA;);
TIMEOUT 300
END;
TELEGRAM ReadWFR04CO2 NAMED "Read WFR04 CO2" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(03); % Modbus command "03h" read holding registers
% start register
DATA[2] <- RWORD(IF((SensorNo<1) OR (SensorNo>32)) THEN
DATA := 0;
ELSE
DATA := 10*(SensorNo-1);
ENDIF;
);
DATA[4] := RWORD(10); % number of registers to read
ANSWER SIZE 25
DATA[0] = BYTE(Id);
DATA[1] = HEX(03);
%DATA[2] = BYTE(20);
DATA[3] -> RWORD(SensorType := DATA;);
DATA[5] -> RWORD(IdHigh := DATA;);
DATA[7] -> RWORD(SensorId := (IdHigh*65536) + DATA;);
DATA[9] -> RWORD(DataByte3 := DATA;); % Not used ****
DATA[11] -> RWORD(DataByte2 := 2000*DATA/255;); % CO2 *********
% 0 = 0 ppm
% 255 =2000 ppm
DATA[13] -> RWORD(DataByte1 := 50*DATA/255;); % Temperature *
% 0 = 0°C
% 255 = 50°C
DATA[15] -> RWORD(DataByte0 := DATA;); % Not used ???
DATA[17] -> RWORD(RecTime := DATA;);
TIMEOUT 300
END;
TELEGRAM SetID NAMED "(Set Sensor)" IS
QUESTION
DATA[0] := BYTE(Id);
DATA[1] := HEX(10); %Write multipel register
DATA[2] <- RWORD(
IF((SensorNo<1) OR (SensorNo>32)) THEN
DATA := 0;
ELSE
DATA := 10*(SensorNo-1);
ENDIF;
);
DATA[4] <- RWORD(DATA := 3;);
DATA[6] := BYTE(6);
DATA[7] <- RWORD(DATA := SensorORG;);
DATA[9] <- RWORD(DATA := FLOOR(SensorID / 65536););
DATA[11] <- RWORD(DATA := SensorID & 65535;
% Tysta telegrammet efter sändning
SilenceSet := 5;
);
ANSWER SIZE 8
DATA[0] = BYTE(Id);
DATA[1] = HEX(10);
TIMEOUT 1000
END;
TELEGRAM LearnStart NAMED "(LearnID start)" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(0F); % Modbus command "0Fh" force bits (=1)
% Bit address
DATA[2] <- RWORD(IF((SensorNo<1) OR (SensorNo>32)) THEN
DATA := 0;
ELSE
DATA := (SensorNo-1);
ENDIF;
);
DATA[4] := RWORD(1); % number of bits to force
DATA[6] := BYTE(1); % number of bytes
DATA[7] <- BYTE(DATA := 1;% value = 1
% Tysta telegrammet efter sändning
SilenceStart := 5;
);
ANSWER SIZE 8
DATA[0] = BYTE(Id); % ID
DATA[1] = HEX(0F); % Command
%DATA[2] = RWORD(10*(SensorNo-1)); % Start address
%DATA[4] = RWORD(1); % Number of bits
TIMEOUT 300
END;
TELEGRAM LearnStop NAMED "(LearnID stop)" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(0F); % Modbus command "0Fh" force bits (=1)
% Bit address
DATA[2] <- RWORD(IF((SensorNo<1) OR (SensorNo>32)) THEN
DATA := 0;
ELSE
DATA := (SensorNo-1);
ENDIF;
);
DATA[4] := RWORD(1); % number of bits to force
DATA[6] := BYTE(1); % number of bytes
DATA[7] <- BYTE(DATA := 0;% value = 0
% Tysta telegrammet efter sändning
SilenceStop := 5;
);
ANSWER SIZE 8
DATA[0] = BYTE(Id); % ID
DATA[1] = HEX(0F); % Command
%DATA[2] = RWORD(10*(SensorNo-1)); % Start address
%DATA[4] = RWORD(1); % Number of bits
TIMEOUT 300
END;
END;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GROUP LearnStartGroup OF MAX 32 DEVICE TYPEID 21170 SELECT ALL
ITERATOR LearnStart
ALIAS
BEGIN
IF (Started1) THEN
IF (MLearnIDOn <> LearnIDOn) THEN
SEND LearnStart;
MLearnIDOn := LearnIDOn;
ENDIF;
IF (SilenceStart > 0) THEN
SilenceStart := SilenceStart - 1;
SILENCE LearnStart;
ENDIF;
ELSE
SILENCE LearnStart;
MLearnIDOn := LearnIDOn;
Started1 := 1;
ENDIF;
END;
END;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GROUP LearnStopGroup OF MAX 32 DEVICE TYPEID 21170 SELECT ALL
ITERATOR LearnStop
ALIAS
BEGIN
IF (Started2) THEN
IF (MLearnIDOff <> LearnIDOff) THEN
SEND LearnStop;
MLearnIDOff := LearnIDOff;
ENDIF;
IF (SilenceStop > 0) THEN
SilenceStop := SilenceStop - 1;
SILENCE LearnStop;
ENDIF;
ELSE
SILENCE LearnStop;
MLearnIDOff := LearnIDOff;
Started2 := 1;
ENDIF;
END;
END;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GROUP SetSensorGroup OF MAX 32 DEVICE TYPEID 21170 SELECT ALL
ITERATOR SetSensor
ALIAS
BEGIN
IF (Started3) THEN
IF (MSensorSet <> SensorSet) THEN
SEND SetID;
MSensorSet := SensorSet;
ENDIF;
IF (SilenceSet > 0) THEN
SilenceSet := SilenceSet - 1;
SILENCE SetID;
ENDIF;
ELSE
SILENCE SetID;
MSensorSet := SensorSet;
Started3 := 1;
ENDIF;
END;
END;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ROUTINE SensorID
BEGIN
CALL LearnStartGroup.LearnStart;
CALL LearnStopGroup.LearnStop;
CALL SetSensorGroup.SetSensor;
END;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Device definition for SRC RS485 MODBUD Thermokon Sensortechnik GmbH
%
% Settings SRC module:
% Parity: None
% Baud: 9600
% Mode: RTU
%
% WMPro device settings.
% Use one Device for each transmitter with a diffrent sensor number in each device.
% Transmitter 1 corresponds to register 401-410 in SRC-RS485 MODBUS module.
% Transmitter 2 corresponds to register 411-420 in SRC-RS485 MODBUS module.
% ..
% Transmitter 8 corresponds to register 471-480 in SRC-RS485 MODBUS module.
%
% Define a WMPRo device as "ThermokonTRANSM" (menu External units).
% Activate TELEGRAM "Set transmitter" with the update interval you want and also
% activate TELEGRAM "(Send settings)" with update time 1 hour. Time is not so
% important as the telegram is set to SILENCE.
% If you want an update of settings in menu "View | External units" activate
% TELEGRAM "Read general".
% Set parameters "Modbus address", Actuator, ORG-byte, Data-Byte 3... to valid values
% and SAVE. Connect parameters Data-Byte 0-3, Status and (Send telegram) to channels
% if you want to change status from Script or Graphic programming.
% For relay module Databyte 0 is used, ON = 80, OFF = 112.
%
% THERMOKON TRANSMITTER
% Learn transmitter.
% Push the Learn-button on the transmitter.
% Change setting for a Data-Byte in menu "External units | Settings" or change the
% channel value connected to a Data-Byte. You can also change the value (Send)
% if you don't want to change the transmitter settings. This will start a
% transmission from the SRC RS485 (send-bit is set) and detected by the transmitter.
% The learn-led will stop flashing for a moment and then start flashing again.
% Stop learn mode on the transmitter by pushing the learn-button.
% Update transmitter value.
% Every change in Data-Byte 0-3 or Status will generate a transmitt telegram.
% A manual transmitt can be generated by changing the (Send telegram) value.
%
%
% Author: Peter Widetun, ABELKO AB Luleå
% History: 2007-11-14 inital version
% History: 2014-11-10 Changed register order, DB0= Reg404 .. DB3 = Reg407
%
DEVICETYPE ThermokonSRC1 NAMED "ThermokonTRANSM" TYPEID 21171 IS
PARAMETER
Id : "Modbus address";
ActuatorNo : "Actuator (1-8)";
SetOrg : "ORG-Byte (5-7)";
SetDataByte3 : "Data-Byte 3";
SetDataByte2 : "Data-Byte 2";
SetDataByte1 : "Data-Byte 1";
SetDataByte0 : "Data-Byte 0";
SetStatus : "Status";
Send : "(Send telegram)";
PUBLIC
SensorType : "ORG-Byte";
SensorId : "Sender-ID";
DataByte3 : "Data-Byte 3";
DataByte2 : "Data-Byte 2";
DataByte1 : "Data-Byte 1";
DataByte0 : "Data-Byte 0";
Status : "Status";
PRIVATE
Send0;
MSend0;
Started0;
Started1;
SilenceSend;
MSetDataByte0;
MSetDataByte1;
MSetDataByte2;
MSetDataByte3;
MSetStatus;
MSend;
IdHigh;
BAUDRATE 9600;
CHECKSUM MODBUS SWAPPED;
TELEGRAM ReadGeneral NAMED "Read general" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(03); % Modbus command "03h" read holding registers
% start register
DATA[2] <- RWORD(
IF((ActuatorNo<1) OR (ActuatorNo>8)) THEN
DATA := 400; % Ställ register 401 - 410
ELSE
DATA := 400 + (10*(ActuatorNo-1)); % Ställ register 4x0 - 4x9
ENDIF;
);
DATA[4] := RWORD(10); % number of registers to read
ANSWER SIZE 25
DATA[0] = BYTE(Id);
DATA[1] = HEX(03);
%DATA[2] = BYTE(20);
DATA[3] -> RWORD(SensorType := DATA;);
DATA[5] -> RWORD(IdHigh := DATA;);
DATA[7] -> RWORD(SensorId := (IdHigh*65536) + DATA;);
DATA[9] -> RWORD(DataByte0 := DATA;);
DATA[11] -> RWORD(DataByte1 := DATA;);
DATA[13] -> RWORD(DataByte2 := DATA;);
DATA[15] -> RWORD(DataByte3 := DATA;);
DATA[17] -> RWORD(Status := DATA;);
TIMEOUT 300
END;
% New 100204 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TELEGRAM Settings NAMED "Set transmitter" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(10); % Modbus command "10h" write multipels registers
DATA[2] <- RWORD( % Start adress = Databyte 0 [(404-1)+10*No]
IF((ActuatorNo<1) OR (ActuatorNo>8)) THEN
DATA := 400; % Ställ register 401 - 410
ELSE
DATA := 400 + (10*(ActuatorNo-1)); % Ställ register 4x0 - 4x9
ENDIF;
);
DATA[4] := RWORD(10); % Number of registers
DATA[6] := BYTE(20); % Number of bytes
DATA[7] <- RWORD(DATA := SetOrg;); % SetOrg : "Ställ ORG"
DATA[9] <- RWORD(DATA := 0;); % ID High (Not writeable)
DATA[11] <- RWORD(DATA := 0;); % ID Low (Not writeable)
DATA[13] <- RWORD(DATA := SetDataByte0;); % SetDataByte0 : "Ställ Data 0"
DATA[15] <- RWORD(DATA := SetDataByte1;); % SetDataByte1 : "Ställ Data 1"
DATA[17] <- RWORD(DATA := SetDataByte2;); % SetDataByte2 : "Ställ Data 2"
DATA[19] <- RWORD(DATA := SetDataByte3;); % SetDataByte3 : "Ställ Data 3"
DATA[21] <- RWORD(DATA := SetStatus;); % SetStatus : "Ställ Status";
DATA[23] <- RWORD(DATA := 0;); % Not used (Not writeable)
DATA[25] <- RWORD(IF (Started0 = 0) THEN
MSetDataByte0 := SetDataByte0;
MSetDataByte1 := SetDataByte1;
MSetDataByte2 := SetDataByte2;
MSetDataByte3 := SetDataByte3;
MSetStatus := SetStatus;
Started0 := 1;
ENDIF;
IF ((MSetDataByte0 <> SetDataByte0) OR
(MSetDataByte1 <> SetDataByte1) OR
(MSetDataByte2 <> SetDataByte2) OR
(MSetDataByte3 <> SetDataByte3) OR
(MSetStatus <> SetStatus)) THEN
Send0 := Send0 + 1;
MSetDataByte0 := SetDataByte0;
MSetDataByte1 := SetDataByte1;
MSetDataByte2 := SetDataByte2;
MSetDataByte3 := SetDataByte3;
MSetStatus := SetStatus;
ENDIF;
DATA := 0;
); % Not used (Not writeable)
ANSWER SIZE 8
DATA[0] = BYTE(Id);
DATA[1] = HEX(10);
TIMEOUT 1000
END;
TELEGRAM SendSettings NAMED "(Send settings)" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(0F); % Modbus command "0Fh" force bits (=1)
% Bit address
DATA[2] <- RWORD(IF((ActuatorNo<1) OR (ActuatorNo>8)) THEN
DATA := 64;
ELSE
DATA := 64 + (ActuatorNo-1);
ENDIF;
);
DATA[4] := RWORD(1); % number of bits to force
DATA[6] := BYTE(1); % number of bytes
DATA[7] <- BYTE(DATA := 1;% value = 1 for SEND
% Tysta telegrammet efter sändning
SilenceSend := 5;
);
ANSWER SIZE 8
DATA[0] = BYTE(Id); % ID
DATA[1] = HEX(0F); % Command
%DATA[2] = RWORD(10*(SensorNo-1)); % Start address
%DATA[4] = RWORD(1); % Number of bits
TIMEOUT 300
END;
END;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GROUP SendDataGroup OF MAX 8 DEVICE TYPEID 21171 SELECT ALL
ITERATOR SendData
ALIAS
BEGIN
IF (Started1) THEN
IF ((MSend0 <> Send0) OR
(MSend <> Send)) THEN
SEND SendSettings;
MSend0 := Send0;
MSend := Send;
ENDIF;
IF (SilenceSend > 0) THEN
SilenceSend := SilenceSend - 1;
SILENCE SendSettings;
ENDIF;
ELSE
SILENCE SendSettings;
MSend0:= Send0;
MSend := Send;
Started1 := 1;
ENDIF;
END;
END;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ROUTINE TransmitterData
BEGIN
CALL SendDataGroup.SendData;
END;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Device definition for SRC RS485 MODBUD Thermokon Sensortechnik GmbH
%
% Note! Use one Device for temperature from 16 sensors. Same scale factors.
% Sensor temperature 1 corresponds to register 1-10
% Sensor temperature 2 corresponds to register 11-20
% ..
% Sensor temperature 32 corresponds to register 151-160
%
% Read temperature sensor 1-16 (Devicetype ...SRC L)
%
% Author: Peter Widetun, ABELKO AB Luleå
% History: 2007-11-14 inital version
%
DEVICETYPE ThermokonSRC16L NAMED "Thermokon SRC L" TYPEID 21173 IS
PARAMETER
Id : "Adress";
Factor0 : "Temp 0 bit";
Factor255 : "Temp 255 bit";
PUBLIC
Temp1 : "Temperatur 1";
Temp2 : "Temperatur 2";
Temp3 : "Temperatur 3";
Temp4 : "Temperatur 4";
Temp5 : "Temperatur 5";
Temp6 : "Temperatur 6";
Temp7 : "Temperatur 7";
Temp8 : "Temperatur 8";
Temp9 : "Temperatur 9";
Temp10 : "Temperatur 10";
Temp11 : "Temperatur 11";
Temp12 : "Temperatur 12";
Temp13 : "Temperatur 13";
Temp14 : "Temperatur 14";
Temp15 : "Temperatur 15";
Temp16 : "Temperatur 16";
PRIVATE
Cnt;
BAUDRATE 9600;
CHECKSUM MODBUS SWAPPED;
TELEGRAM SensorTemp1_16 NAMED "Läs givare 1-16" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(03); % Modbus command "03h" read holding registers
% start register
DATA[2] <- RWORD( Cnt := Cnt + 1;
IF (Cnt>3) THEN
Cnt := 0;
ENDIF;
IF (Cnt=0) THEN
DATA := 0;
ELSIF (Cnt=1) THEN
DATA := 40;
ELSIF (Cnt=2) THEN
DATA := 80;
ELSE
DATA := 120;
ENDIF;
);
DATA[4] := RWORD(40); % number of registers to read
ANSWER SIZE 85
DATA[0] = BYTE(Id);
DATA[1] = HEX(03);
%DATA[2] = BYTE(80);
DATA[13] -> RWORD(IF (Cnt=0) THEN
Temp1 := Factor0 + ((Factor255-Factor0)/255)*DATA;
ELSIF (Cnt=1) THEN
Temp5 := Factor0 + ((Factor255-Factor0)/255)*DATA;
ELSIF (Cnt=2) THEN
Temp9 := Factor0 + ((Factor255-Factor0)/255)*DATA;
ELSE
Temp13 := Factor0 + ((Factor255-Factor0)/255)*DATA;
ENDIF;
);
DATA[33] -> RWORD(IF (Cnt=0) THEN
Temp2 := Factor0 + ((Factor255-Factor0)/255)*DATA;
ELSIF (Cnt=1) THEN
Temp6 := Factor0 + ((Factor255-Factor0)/255)*DATA;
ELSIF (Cnt=2) THEN
Temp10 := Factor0 + ((Factor255-Factor0)/255)*DATA;
ELSE
Temp14 := Factor0 + ((Factor255-Factor0)/255)*DATA;
ENDIF;
);
DATA[53] -> RWORD(IF (Cnt=0) THEN
Temp3 := Factor0 + ((Factor255-Factor0)/255)*DATA;
ELSIF (Cnt=1) THEN
Temp7 := Factor0 + ((Factor255-Factor0)/255)*DATA;
ELSIF (Cnt=2) THEN
Temp11 := Factor0 + ((Factor255-Factor0)/255)*DATA;
ELSE
Temp15 := Factor0 + ((Factor255-Factor0)/255)*DATA;
ENDIF;
);
DATA[73] -> RWORD(IF (Cnt=0) THEN
Temp4 := Factor0 + ((Factor255-Factor0)/255)*DATA;
ELSIF (Cnt=1) THEN
Temp8 := Factor0 + ((Factor255-Factor0)/255)*DATA;
ELSIF (Cnt=2) THEN
Temp12 := Factor0 + ((Factor255-Factor0)/255)*DATA;
ELSE
Temp16 := Factor0 + ((Factor255-Factor0)/255)*DATA;
ENDIF;
);
TIMEOUT 300
END;
END;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Device definition for SRC RS485 MODBUD Thermokon Sensortechnik GmbH
%
% Note! Use one Device for temperature from 32 sensors. Same scale factors.
% Sensor temperature 1 corresponds to register 1-10
% Sensor temperature 2 corresponds to register 11-20
% ..
% Sensor temperature 32 corresponds to register 311-320
%
% Author: Peter Widetun, ABELKO AB Luleå
% History: 2007-11-14 inital version
%
DEVICETYPE ThermokonSRC16H NAMED "Thermokon SRC H" TYPEID 21174 IS
PARAMETER
Id : "Adress";
Factor0 : "Temp 0 bit";
Factor255 : "Temp 255 bit";
PUBLIC
Temp17 : "Temperatur 17";
Temp18 : "Temperatur 18";
Temp19 : "Temperatur 19";
Temp20 : "Temperatur 20";
Temp21 : "Temperatur 21";
Temp22 : "Temperatur 22";
Temp23 : "Temperatur 23";
Temp24 : "Temperatur 24";
Temp25 : "Temperatur 25";
Temp26 : "Temperatur 26";
Temp27 : "Temperatur 27";
Temp28 : "Temperatur 28";
Temp29 : "Temperatur 29";
Temp30 : "Temperatur 30";
Temp31 : "Temperatur 31";
Temp32 : "Temperatur 32";
PRIVATE
Cnt;
BAUDRATE 9600;
CHECKSUM MODBUS SWAPPED;
TELEGRAM SensorTemp17_32 NAMED "Läs givare17-32" IS
QUESTION
DATA[0] := BYTE(Id); % Modbus unit address
DATA[1] := HEX(03); % Modbus command "03h" read holding registers
% start register
DATA[2] <- RWORD( Cnt := Cnt + 1;
IF (Cnt>3) THEN
Cnt := 0;
ENDIF;
IF (Cnt=0) THEN
DATA := 160;
ELSIF (Cnt=1) THEN
DATA := 200;
ELSIF (Cnt=2) THEN
DATA := 240;
ELSE
DATA := 280;
ENDIF;
);
DATA[4] := RWORD(40); % number of registers to read
ANSWER SIZE 85
DATA[0] = BYTE(Id);
DATA[1] = HEX(03);
%DATA[2] = BYTE(80);
DATA[13] -> RWORD(IF (Cnt=0) THEN
Temp17 := Factor0 + ((Factor255-Factor0)/255)*DATA;
ELSIF (Cnt=1) THEN
Temp21 := Factor0 + ((Factor255-Factor0)/255)*DATA;
ELSIF (Cnt=2) THEN
Temp25 := Factor0 + ((Factor255-Factor0)/255)*DATA;
ELSE
Temp29 := Factor0 + ((Factor255-Factor0)/255)*DATA;
ENDIF;
);
DATA[33] -> RWORD(IF (Cnt=0) THEN
Temp18 := Factor0 + ((Factor255-Factor0)/255)*DATA;
ELSIF (Cnt=1) THEN
Temp22 := Factor0 + ((Factor255-Factor0)/255)*DATA;
ELSIF (Cnt=2) THEN
Temp26 := Factor0 + ((Factor255-Factor0)/255)*DATA;
ELSE
Temp30 := Factor0 + ((Factor255-Factor0)/255)*DATA;
ENDIF;
);
DATA[53] -> RWORD(IF (Cnt=0) THEN
Temp19 := Factor0 + ((Factor255-Factor0)/255)*DATA;
ELSIF (Cnt=1) THEN
Temp23 := Factor0 + ((Factor255-Factor0)/255)*DATA;
ELSIF (Cnt=2) THEN
Temp27 := Factor0 + ((Factor255-Factor0)/255)*DATA;
ELSE
Temp31 := Factor0 + ((Factor255-Factor0)/255)*DATA;
ENDIF;
);
DATA[73] -> RWORD(IF (Cnt=0) THEN
Temp20 := Factor0 + ((Factor255-Factor0)/255)*DATA;
ELSIF (Cnt=1) THEN
Temp24 := Factor0 + ((Factor255-Factor0)/255)*DATA;
ELSIF (Cnt=2) THEN
Temp28 := Factor0 + ((Factor255-Factor0)/255)*DATA;
ELSE
Temp32 := Factor0 + ((Factor255-Factor0)/255)*DATA;
ENDIF;
);
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.