Grundfos CIM modbus modul
Detaljer
- Typ
- Drivrutin
- Upplaggd av
- Ove Jansson, Abelko Innovation
- Version
- 2
- Uppdaterad
- 2014-12-12
- Skapad
- 2014-12-12
- Kategori
- Modbus, Värme, Vatten och avlopp
- Visningar
- 3047
Beskrivning
Generell drivrutin till Grundfos CIM modul för pumpar
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
% Skapad med Modbus Creator
% - OBS! Användaren ansvarar själv för att samma TYPID inte används flera gånger i samma apparat.
% TYPID 10000-19999 är för användardefinierade enheter
DEVICETYPE GrundfosCIM NAMED "GrundfosCIM" TYPEID 18345 IS
PARAMETER
Id : "Adress";
V10 : "ResetAlarm" [""]; % 0=no resetting, 1=resetting
V11 : "ControlMode" [""]; % 0=constant speed, 1=Constant freq, 2=Const head, 4=Const pressure, 5=Const diff pressure, 6=Proportional pressure, 7=Const flow, 8=Const temp, 10=Const level, 128=AUTO adapt, 129=AUTO adapt (set FLOW limit), 130= Closed-loop sensor
V12 : "OperationMode" [""]; % 0=auto-control, 4=OpenLoopMin, 6=OpenLoopMax Note OnOffReq has higher prio
V13 : "Setpoint" ["%"]DEC2; % scales to the controlmode method
PUBLIC
V1 : "PumpStatus" [""]; % Bit register
V2 : "ProcessFeedback" ["%"]DEC2;
V3 : "ControlMode" [""]; % 0=constant speed, 1=Constant freq, 2=Const head, 4=Const pressure, 5=Const diff pressure, 6=Proportional pressure, 7=Const flow, 8=Const temp, 10=Const level, 128=AUTO adapt, 129=AUTO adapt (set FLOW limit), 130= Closed-loop sensor
V4 : "OperationMode" [""]; % 0=auto-control, 4=OpenLoopMin, 6=OpenLoopMax Note OnOffReq has higher prio
V5 : "AlarmCode" [""];
V6 : "Head" ["bar"]DEC3;
V7 : "VolumeFlow" ["m3/h"]DEC1;
V8 : "Speed" ["rpm"];
V9 : "ActualSetPoint" ["%"]DEC2;
PRIVATE
count6;
BAUDRATE 9600;
CHECKSUM MODBUS SWAPPED;
TELEGRAM Read4 NAMED "Read 4" IS
QUESTION
DATA[0] := BYTE(Id); % Enhetens Modbus adress
DATA[1] := HEX(04); % Modbus kommando för att läsa register kod 04
DATA[2] := RWORD(200); % Start address
DATA[4] := RWORD(108); % Antal register att läsa
ANSWER SIZE 221 % (Antal register * 2) + 5
DATA[0] = BYTE(Id);
DATA[1] = BYTE(04);
DATA[2] = BYTE(216); % Antal Bytes
DATA[3] -> RWORD(V1 := DATA;);
DATA[5] -> RWORD(V2 := DATA/100;);
DATA[7] -> RWORD(V3 := DATA;);
DATA[9] -> RWORD(V4 := DATA;);
DATA[11] -> RWORD(V5 := DATA;);
DATA[203] -> RWORD(V6 := DATA/1000;);
DATA[205] -> RWORD(V7 := DATA/10;);
DATA[209] -> RWORD(V8 := DATA;);
DATA[217] -> RWORD(V9 := DATA/100;);
TIMEOUT 300
END;
TELEGRAM WriteRegister NAMED "Write Register" IS
QUESTION
DATA[0] := BYTE(Id); % Enhetens Modbus adress
DATA[1] := HEX(06); % Modbus kommando för att skriva ett register
DATA[2] <- RWORD(
IF(count6>3) THEN count6 := 0; ENDIF;
IF (count6=0) THEN DATA := 100;
ELSIF (count6=1) THEN DATA := 101;
ELSIF (count6=2) THEN DATA := 102;
ELSIF (count6=3) THEN DATA := 103;
ENDIF;
); % Register adress
DATA[4] <- RWORD(
IF (count6=0) THEN DATA := V10;
ELSIF (count6=1) THEN DATA := V11;
ELSIF (count6=2) THEN DATA := V12;
ELSIF (count6=3) THEN DATA := V13*100;
ENDIF;
count6 := count6+1;
);
ANSWER SIZE 8
DATA[0] = BYTE(Id);
DATA[1] = BYTE(06);
TIMEOUT 300
END;
END;
% Skapad med Modbus Creator
% - OBS! Användaren ansvarar själv för att samma TYPID inte används flera gånger i samma apparat.
% TYPID 10000-19999 är för användardefinierade enheter
DEVICETYPE GrundfosCIM2 NAMED "GrundfosCIM2" TYPEID 18346 IS
PARAMETER
Id : "Adress";
PUBLIC
V1 : "Power" ["W"]; % 32bit
V2 : "PumpLiquidTemp" ["K"]DEC2;
V3 : "AuxSensorInput" ["%"]DEC2;
V4 : "Energy" ["kWh"]DEC2; % 32bit
V5 : "Volume" ["m3"]DEC2;
V6 : "RemoteTemp2" ["K"]DEC2;
V7 : "UserSetPoint" ["%"]DEC2;
V8 : "HeatEnergyCounter" ["kWh"]; % 32bit
V9 : "HeatPower" ["W"]; % 32bit
V10 : "HeatDiffTemp" ["K"]DEC2;
PRIVATE
tmp;
BAUDRATE 9600;
CHECKSUM MODBUS SWAPPED;
TELEGRAM Read4 NAMED "Read 4" IS
QUESTION
DATA[0] := BYTE(Id); % Enhetens Modbus adress
DATA[1] := HEX(04); % Modbus kommando för att läsa register kod 04
DATA[2] := RWORD(311); % Start address
DATA[4] := RWORD(45); % Antal register att läsa
ANSWER SIZE 95 % (Antal register * 2) + 5
DATA[0] = BYTE(Id);
DATA[1] = BYTE(04);
DATA[2] = BYTE(90); % Antal Bytes
DATA[3] -> RWORD(tmp := DATA * 65536;);%32
DATA[5] -> RWORD(V1 := tmp + DATA;);
DATA[23] -> RWORD(V2 := DATA/100;);
DATA[29] -> RWORD(V3 := DATA/100;);
DATA[43] -> RWORD(tmp := DATA * 65536;);%32
DATA[45] -> RWORD(V4 := (tmp + DATA););
DATA[51] -> RWORD(V5 := DATA/100;);
DATA[53] -> RWORD(V6 := DATA/100;);
DATA[55] -> RWORD(V7 := DATA/100;);
DATA[83] -> RWORD(tmp := DATA * 65536;);%32
DATA[85] -> RWORD(V8 := (tmp +DATA););%32
DATA[87] -> RWORD(tmp := DATA * 65536;);%32
DATA[89] -> RWORD(V9 := DATA + tmp;);%32
DATA[91] -> RWORD(V10 := DATA/100;);
TIMEOUT 300
END;
END;
% - OBS! Användaren ansvarar själv för att samma TYPID inte används flera gånger i samma apparat.
% TYPID 10000-19999 är för användardefinierade enheter
DEVICETYPE GrundfosCIM NAMED "GrundfosCIM" TYPEID 18345 IS
PARAMETER
Id : "Adress";
V10 : "ResetAlarm" [""]; % 0=no resetting, 1=resetting
V11 : "ControlMode" [""]; % 0=constant speed, 1=Constant freq, 2=Const head, 4=Const pressure, 5=Const diff pressure, 6=Proportional pressure, 7=Const flow, 8=Const temp, 10=Const level, 128=AUTO adapt, 129=AUTO adapt (set FLOW limit), 130= Closed-loop sensor
V12 : "OperationMode" [""]; % 0=auto-control, 4=OpenLoopMin, 6=OpenLoopMax Note OnOffReq has higher prio
V13 : "Setpoint" ["%"]DEC2; % scales to the controlmode method
PUBLIC
V1 : "PumpStatus" [""]; % Bit register
V2 : "ProcessFeedback" ["%"]DEC2;
V3 : "ControlMode" [""]; % 0=constant speed, 1=Constant freq, 2=Const head, 4=Const pressure, 5=Const diff pressure, 6=Proportional pressure, 7=Const flow, 8=Const temp, 10=Const level, 128=AUTO adapt, 129=AUTO adapt (set FLOW limit), 130= Closed-loop sensor
V4 : "OperationMode" [""]; % 0=auto-control, 4=OpenLoopMin, 6=OpenLoopMax Note OnOffReq has higher prio
V5 : "AlarmCode" [""];
V6 : "Head" ["bar"]DEC3;
V7 : "VolumeFlow" ["m3/h"]DEC1;
V8 : "Speed" ["rpm"];
V9 : "ActualSetPoint" ["%"]DEC2;
PRIVATE
count6;
BAUDRATE 9600;
CHECKSUM MODBUS SWAPPED;
TELEGRAM Read4 NAMED "Read 4" IS
QUESTION
DATA[0] := BYTE(Id); % Enhetens Modbus adress
DATA[1] := HEX(04); % Modbus kommando för att läsa register kod 04
DATA[2] := RWORD(200); % Start address
DATA[4] := RWORD(108); % Antal register att läsa
ANSWER SIZE 221 % (Antal register * 2) + 5
DATA[0] = BYTE(Id);
DATA[1] = BYTE(04);
DATA[2] = BYTE(216); % Antal Bytes
DATA[3] -> RWORD(V1 := DATA;);
DATA[5] -> RWORD(V2 := DATA/100;);
DATA[7] -> RWORD(V3 := DATA;);
DATA[9] -> RWORD(V4 := DATA;);
DATA[11] -> RWORD(V5 := DATA;);
DATA[203] -> RWORD(V6 := DATA/1000;);
DATA[205] -> RWORD(V7 := DATA/10;);
DATA[209] -> RWORD(V8 := DATA;);
DATA[217] -> RWORD(V9 := DATA/100;);
TIMEOUT 300
END;
TELEGRAM WriteRegister NAMED "Write Register" IS
QUESTION
DATA[0] := BYTE(Id); % Enhetens Modbus adress
DATA[1] := HEX(06); % Modbus kommando för att skriva ett register
DATA[2] <- RWORD(
IF(count6>3) THEN count6 := 0; ENDIF;
IF (count6=0) THEN DATA := 100;
ELSIF (count6=1) THEN DATA := 101;
ELSIF (count6=2) THEN DATA := 102;
ELSIF (count6=3) THEN DATA := 103;
ENDIF;
); % Register adress
DATA[4] <- RWORD(
IF (count6=0) THEN DATA := V10;
ELSIF (count6=1) THEN DATA := V11;
ELSIF (count6=2) THEN DATA := V12;
ELSIF (count6=3) THEN DATA := V13*100;
ENDIF;
count6 := count6+1;
);
ANSWER SIZE 8
DATA[0] = BYTE(Id);
DATA[1] = BYTE(06);
TIMEOUT 300
END;
END;
% Skapad med Modbus Creator
% - OBS! Användaren ansvarar själv för att samma TYPID inte används flera gånger i samma apparat.
% TYPID 10000-19999 är för användardefinierade enheter
DEVICETYPE GrundfosCIM2 NAMED "GrundfosCIM2" TYPEID 18346 IS
PARAMETER
Id : "Adress";
PUBLIC
V1 : "Power" ["W"]; % 32bit
V2 : "PumpLiquidTemp" ["K"]DEC2;
V3 : "AuxSensorInput" ["%"]DEC2;
V4 : "Energy" ["kWh"]DEC2; % 32bit
V5 : "Volume" ["m3"]DEC2;
V6 : "RemoteTemp2" ["K"]DEC2;
V7 : "UserSetPoint" ["%"]DEC2;
V8 : "HeatEnergyCounter" ["kWh"]; % 32bit
V9 : "HeatPower" ["W"]; % 32bit
V10 : "HeatDiffTemp" ["K"]DEC2;
PRIVATE
tmp;
BAUDRATE 9600;
CHECKSUM MODBUS SWAPPED;
TELEGRAM Read4 NAMED "Read 4" IS
QUESTION
DATA[0] := BYTE(Id); % Enhetens Modbus adress
DATA[1] := HEX(04); % Modbus kommando för att läsa register kod 04
DATA[2] := RWORD(311); % Start address
DATA[4] := RWORD(45); % Antal register att läsa
ANSWER SIZE 95 % (Antal register * 2) + 5
DATA[0] = BYTE(Id);
DATA[1] = BYTE(04);
DATA[2] = BYTE(90); % Antal Bytes
DATA[3] -> RWORD(tmp := DATA * 65536;);%32
DATA[5] -> RWORD(V1 := tmp + DATA;);
DATA[23] -> RWORD(V2 := DATA/100;);
DATA[29] -> RWORD(V3 := DATA/100;);
DATA[43] -> RWORD(tmp := DATA * 65536;);%32
DATA[45] -> RWORD(V4 := (tmp + DATA););
DATA[51] -> RWORD(V5 := DATA/100;);
DATA[53] -> RWORD(V6 := DATA/100;);
DATA[55] -> RWORD(V7 := DATA/100;);
DATA[83] -> RWORD(tmp := DATA * 65536;);%32
DATA[85] -> RWORD(V8 := (tmp +DATA););%32
DATA[87] -> RWORD(tmp := DATA * 65536;);%32
DATA[89] -> RWORD(V9 := DATA + tmp;);%32
DATA[91] -> RWORD(V10 := DATA/100;);
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.