this is an example in ST
RC01 (
EN := true,
DT => ,
E1 => ,
YY => ,
MM => ,
DD => ,
WD => ,
HR => ,
MN => ,
SC => );
//Trigger, if the next month
M02:= (RC01MM<>MB70) and M01;
MB70:= RC01MM;
//Pump 1
C01 (
EN := true,
C_ := I01,
D_ := ,
SE := ,
RE := ,
SH := ,
SL := ,
SV := ,
OF => ,
FB => ,
CY => ,
ZE => ,
QV => );
//in 1st cycle of the new month calculate the difference to the last
CASE MB70 OF
1: IF M02 THEN MD51:= C01QV - MD50; END_IF;
2: IF M02 THEN MD40:= C01QV - MD51; END_IF;
3: IF M02 THEN MD41:= C01QV - MD40; END_IF;
4: IF M02 THEN MD42:= C01QV - MD41; END_IF;
5: IF M02 THEN MD43:= C01QV - MD42; END_IF;
6: IF M02 THEN MD44:= C01QV - MD43; END_IF;
7: IF M02 THEN MD45:= C01QV - MD44; END_IF;
8: IF M02 THEN MD46:= C01QV - MD45; END_IF;
9: IF M02 THEN MD47:= C01QV - MD46; END_IF;
10: IF M02 THEN MD48:= C01QV - MD47; END_IF;
11: IF M02 THEN MD49:= C01QV - MD47; END_IF;
12: IF M02 THEN MD50:= C01QV - MD47; END_IF;
ELSE
;
END_CASE;
//Pump 2
C02 (
EN := true,
C_ := I02,
D_ := ,
SE := ,
RE := ,
SH := ,
SL := ,
SV := ,
OF => ,
FB => ,
CY => ,
ZE => ,
QV => );
//in 1st cycle of the new month calculate the difference to the last
CASE MB70 OF
1: IF M02 THEN MD63:= C01QV - MD62; END_IF;
2: IF M02 THEN MD52:= C01QV - MD63; END_IF;
3: IF M02 THEN MD53:= C01QV - MD52; END_IF;
4: IF M02 THEN MD54:= C01QV - MD53; END_IF;
5: IF M02 THEN MD55:= C01QV - MD54; END_IF;
6: IF M02 THEN MD56:= C01QV - MD55; END_IF;
7: IF M02 THEN MD57:= C01QV - MD56; END_IF;
8: IF M02 THEN MD58:= C01QV - MD57; END_IF;
9: IF M02 THEN MD59:= C01QV - MD58; END_IF;
10: IF M02 THEN MD60:= C01QV - MD59; END_IF;
11: IF M02 THEN MD61:= C01QV - MD60; END_IF;
12: IF M02 THEN MD62:= C01QV - MD61; END_IF;
ELSE
;
END_CASE;
//end of program
M01:= true; //false in 1st cycle