The solution may lie in the definition of PID control.
P=Proportional, control response proportional to error.
I=Integral, the control response is proportional to the "area" of error versus time. A simple calculation would be to periodically (e.g. once per second) calculate error, and accumulate the error in a register. The value of the register would represent the product of error and time, giving a representation of integral error.
D=derivative, effectively is the error moving closer or further away from the setpoint. Another way of looking at it is the slope of the control parameter. This could be calulated by measuring the control parameter periodically, and subtracting successive measurements.