PLC cumulative calculation