Magna3 Modbus 2017
Detaljer
- Typ
- Drivrutin
- Upplaggd av
- Ove Jansson, Abelko Innovation
- Version
- 1
- Uppdaterad
- 2017-03-14
- Skapad
- 2017-03-14
- Kategori
- Modbus, Värme, Vatten och avlopp
- Visningar
- 2848
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 Grundfos NAMED "GrundfosMagna3" TYPEID 21341 IS
PARAMETER
Id : "Adress" INT;
V14 : "wControlMode" ["S=0,Fq=1,hd=3,P=4,DP=5,PP=6,F=7,T=8,L=10,AA=128,FA=129,Ls=130"]ENUM; %[S=0,Fq=1,hd=3,P=4,DP=5,PP=6,F=7,T=8,L=10,AA=128,FA=129,Ls=130
V15 : "wOperationMode" ["AutoCtrl=0,OpenLoopmin=4,OpenLoopmax=6"]ENUM;
V16 : "wSetpoint" ["%"]DEC2;
V17 : "wRunning" ["OFF,ON"]ENUM; % anpassad så att 1=start och 0=stop, detta är inte enligt modbus manualen för Grundfos utan för att styret använder det.
PUBLIC
V1 : "StatusRegister" ["bits"]INT;
V2 : "ProcessFeedback" ["%"]DEC2;
V3 : "ControlMode" ["S=0,Fq=1,hd=3,P=4,DP=5,PP=6,F=7,T=8,L=10,AA=128,FA=129,Ls=130"]ENUM;
V4 : "OperationMode" ["AutoCtrl=0,OpenLoopmin=4,OpenLoopmax=6"]ENUM;
V5 : "AlarmStatus" [""]INT;
V6 : "Head" ["bar"]DEC3;
V7 : "VolumeFlow" ["m3/h"]DEC1;
V8 : "Speed" ["rpm"]INT;
V9 : "ActualSetpoint" ["%"]DEC2; % according to control mode
V10 : "PumpLiquidTemp" ["°C"]DEC2;
V11 : "AuxSensorInput" ["%"]DEC2;
V12 : "UserSetpoint" ["%"]DEC2;
V13 : "DiffPressure" ["bar"]DEC3;
V18 : "RemoteTemp2" ["°C"]DEC2;
V19 : "HeatEnergyCounter" ["kWh"]INT;
V20 : "HeatPower" ["W"]INT;
V21 : "PumpPower" ["W"]INT;
V22 : "PumpEnergy" ["kWh"]INT;
V23 : "OperationTime" ["h"]INT;
PINenabled : "RequirePIN" ["No,Yes"]ENUM;
WriteAccess : "WriteEnabled" ["No,Yes"]ENUM;
pFamily : "Grundfos product family" INT;
pType : "Grundfos product Type" INT;
pVersion : "Grundfos product version" INT;
PRIVATE
count3;
count6;
tmp;
heatenergy_hi;
heatpower_hi;
pumppower_hi;
pumpenergy_hi;
operationtime_hi;
BAUDRATE 9600;
CHECKSUM MODBUS SWAPPED;
TELEGRAM ReadCIMStatus NAMED "Read CIM status" IS
QUESTION
DATA[0] := BYTE(Id); % Enhetens Modbus adress
DATA[1] := HEX(03); % Modbus kommando för att läsa register
DATA[2] := RWORD(20);
DATA[4] := RWORD(12);
ANSWER SIZE 29
DATA[0] = BYTE(Id);
DATA[1] = HEX(03);
DATA[19] -> RWORD(
IF DATA & 1 THEN PINenabled := 1; ELSE PINenabled := 0; ENDIF;
IF DATA & 2 THEN WriteAccess := 1; ELSE WriteAccess := 0; ENDIF;
);
DATA[21] -> RWORD(pFamily:=DATA;);
DATA[23] -> RWORD(pType:=DATA;);
DATA[25] -> RWORD(pVersion:=DATA;);
TIMEOUT 800
END;
TELEGRAM ReadStatus NAMED "Read pump status" IS
QUESTION
DATA[0] := BYTE(Id); % Enhetens Modbus adress
DATA[1] := HEX(03); % Modbus kommando för att läsa register
DATA[2] := RWORD(200);
DATA[4] := RWORD(05);
ANSWER SIZE 15
DATA[0] = BYTE(Id);
DATA[1] = HEX(03);
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;);
TIMEOUT 800
END;
TELEGRAM ReadData NAMED "Read pump data" IS
QUESTION
DATA[0] := BYTE(Id); % Enhetens Modbus adress
DATA[1] := HEX(03); % Modbus kommando för att läsa register
DATA[2] := RWORD(300);
DATA[4] := RWORD(54);
ANSWER SIZE 113
DATA[0] = BYTE(Id);
DATA[1] = HEX(03);
DATA[3] -> RWORD(V6 := DATA/1000;); % 300
DATA[5] -> RWORD(V7 := DATA/10;);
DATA[9] -> RWORD(V8 := DATA;);
DATA[17] -> RWORD(V9 := DATA/100;);
DATA[25] -> RWORD(pumppower_hi := DATA;);
DATA[27] -> RWORD(V21 := (pumppower_hi*65536) + DATA;);
DATA[45] -> RWORD(V10 := (DATA/100) - 273.15;);
DATA[51] -> RWORD(V11 := DATA/100;); % 324
DATA[55] -> RWORD(operationtime_hi := DATA;);
DATA[57] -> RWORD(V23 := (operationtime_hi*65536) + DATA;);
DATA[65] -> RWORD(pumpenergy_hi := DATA;);
DATA[67] -> RWORD(V22 := (pumpenergy_hi*65536) + DATA;);
DATA[75] -> RWORD(V18 := (DATA/100) - 273.15;);
DATA[77] -> RWORD(V12 := DATA/100;);
DATA[79] -> RWORD(V13 := DATA/1000;);
DATA[105] -> RWORD(heatenergy_hi := DATA;);
DATA[107] -> RWORD(V19 := (heatenergy_hi*65536) + DATA;);
DATA[109] -> RWORD(heatpower_hi := DATA;);
DATA[111] -> RWORD(V20 := (heatpower_hi*65536) + DATA;);
TIMEOUT 800
END;
TELEGRAM WriteRegister NAMED "Write Register" IS
QUESTION
DATA[0] := BYTE(Id); % Enhetens Modbus adress
DATA[1] := HEX(10); % Modbus kommando för att skriva register
DATA[2] := RWORD(100);
DATA[4] := RWORD(4);
DATA[6] := BYTE(8);
DATA[7] <- RWORD(IF (V17=0) THEN DATA := 1; ELSE DATA := 3; ENDIF;);
DATA[9] <- RWORD(DATA:=V14;);
DATA[11] <- RWORD(DATA:=V15;);
DATA[13] <- RWORD(DATA:=V16*100;);
ANSWER SIZE 8
DATA[0] = BYTE(Id);
DATA[1] = HEX(10);
TIMEOUT 800
END;
END;
PARAMETER
Id : "Adress" INT;
V14 : "wControlMode" ["S=0,Fq=1,hd=3,P=4,DP=5,PP=6,F=7,T=8,L=10,AA=128,FA=129,Ls=130"]ENUM; %[S=0,Fq=1,hd=3,P=4,DP=5,PP=6,F=7,T=8,L=10,AA=128,FA=129,Ls=130
V15 : "wOperationMode" ["AutoCtrl=0,OpenLoopmin=4,OpenLoopmax=6"]ENUM;
V16 : "wSetpoint" ["%"]DEC2;
V17 : "wRunning" ["OFF,ON"]ENUM; % anpassad så att 1=start och 0=stop, detta är inte enligt modbus manualen för Grundfos utan för att styret använder det.
PUBLIC
V1 : "StatusRegister" ["bits"]INT;
V2 : "ProcessFeedback" ["%"]DEC2;
V3 : "ControlMode" ["S=0,Fq=1,hd=3,P=4,DP=5,PP=6,F=7,T=8,L=10,AA=128,FA=129,Ls=130"]ENUM;
V4 : "OperationMode" ["AutoCtrl=0,OpenLoopmin=4,OpenLoopmax=6"]ENUM;
V5 : "AlarmStatus" [""]INT;
V6 : "Head" ["bar"]DEC3;
V7 : "VolumeFlow" ["m3/h"]DEC1;
V8 : "Speed" ["rpm"]INT;
V9 : "ActualSetpoint" ["%"]DEC2; % according to control mode
V10 : "PumpLiquidTemp" ["°C"]DEC2;
V11 : "AuxSensorInput" ["%"]DEC2;
V12 : "UserSetpoint" ["%"]DEC2;
V13 : "DiffPressure" ["bar"]DEC3;
V18 : "RemoteTemp2" ["°C"]DEC2;
V19 : "HeatEnergyCounter" ["kWh"]INT;
V20 : "HeatPower" ["W"]INT;
V21 : "PumpPower" ["W"]INT;
V22 : "PumpEnergy" ["kWh"]INT;
V23 : "OperationTime" ["h"]INT;
PINenabled : "RequirePIN" ["No,Yes"]ENUM;
WriteAccess : "WriteEnabled" ["No,Yes"]ENUM;
pFamily : "Grundfos product family" INT;
pType : "Grundfos product Type" INT;
pVersion : "Grundfos product version" INT;
PRIVATE
count3;
count6;
tmp;
heatenergy_hi;
heatpower_hi;
pumppower_hi;
pumpenergy_hi;
operationtime_hi;
BAUDRATE 9600;
CHECKSUM MODBUS SWAPPED;
TELEGRAM ReadCIMStatus NAMED "Read CIM status" IS
QUESTION
DATA[0] := BYTE(Id); % Enhetens Modbus adress
DATA[1] := HEX(03); % Modbus kommando för att läsa register
DATA[2] := RWORD(20);
DATA[4] := RWORD(12);
ANSWER SIZE 29
DATA[0] = BYTE(Id);
DATA[1] = HEX(03);
DATA[19] -> RWORD(
IF DATA & 1 THEN PINenabled := 1; ELSE PINenabled := 0; ENDIF;
IF DATA & 2 THEN WriteAccess := 1; ELSE WriteAccess := 0; ENDIF;
);
DATA[21] -> RWORD(pFamily:=DATA;);
DATA[23] -> RWORD(pType:=DATA;);
DATA[25] -> RWORD(pVersion:=DATA;);
TIMEOUT 800
END;
TELEGRAM ReadStatus NAMED "Read pump status" IS
QUESTION
DATA[0] := BYTE(Id); % Enhetens Modbus adress
DATA[1] := HEX(03); % Modbus kommando för att läsa register
DATA[2] := RWORD(200);
DATA[4] := RWORD(05);
ANSWER SIZE 15
DATA[0] = BYTE(Id);
DATA[1] = HEX(03);
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;);
TIMEOUT 800
END;
TELEGRAM ReadData NAMED "Read pump data" IS
QUESTION
DATA[0] := BYTE(Id); % Enhetens Modbus adress
DATA[1] := HEX(03); % Modbus kommando för att läsa register
DATA[2] := RWORD(300);
DATA[4] := RWORD(54);
ANSWER SIZE 113
DATA[0] = BYTE(Id);
DATA[1] = HEX(03);
DATA[3] -> RWORD(V6 := DATA/1000;); % 300
DATA[5] -> RWORD(V7 := DATA/10;);
DATA[9] -> RWORD(V8 := DATA;);
DATA[17] -> RWORD(V9 := DATA/100;);
DATA[25] -> RWORD(pumppower_hi := DATA;);
DATA[27] -> RWORD(V21 := (pumppower_hi*65536) + DATA;);
DATA[45] -> RWORD(V10 := (DATA/100) - 273.15;);
DATA[51] -> RWORD(V11 := DATA/100;); % 324
DATA[55] -> RWORD(operationtime_hi := DATA;);
DATA[57] -> RWORD(V23 := (operationtime_hi*65536) + DATA;);
DATA[65] -> RWORD(pumpenergy_hi := DATA;);
DATA[67] -> RWORD(V22 := (pumpenergy_hi*65536) + DATA;);
DATA[75] -> RWORD(V18 := (DATA/100) - 273.15;);
DATA[77] -> RWORD(V12 := DATA/100;);
DATA[79] -> RWORD(V13 := DATA/1000;);
DATA[105] -> RWORD(heatenergy_hi := DATA;);
DATA[107] -> RWORD(V19 := (heatenergy_hi*65536) + DATA;);
DATA[109] -> RWORD(heatpower_hi := DATA;);
DATA[111] -> RWORD(V20 := (heatpower_hi*65536) + DATA;);
TIMEOUT 800
END;
TELEGRAM WriteRegister NAMED "Write Register" IS
QUESTION
DATA[0] := BYTE(Id); % Enhetens Modbus adress
DATA[1] := HEX(10); % Modbus kommando för att skriva register
DATA[2] := RWORD(100);
DATA[4] := RWORD(4);
DATA[6] := BYTE(8);
DATA[7] <- RWORD(IF (V17=0) THEN DATA := 1; ELSE DATA := 3; ENDIF;);
DATA[9] <- RWORD(DATA:=V14;);
DATA[11] <- RWORD(DATA:=V15;);
DATA[13] <- RWORD(DATA:=V16*100;);
ANSWER SIZE 8
DATA[0] = BYTE(Id);
DATA[1] = HEX(10);
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.