# PID controller error calculation when the setpoint and the process variable both grow over time

Suppose I have a robot which can perform some work and be rewarded with a point 50-70% of the time. I want a different number of points to be collected every hour of the day. This is modelled using a function which tells me the number of points I expect to have at time t, giving setpoint(t), which grows from 0 points in the first minute of the day to 100,000 points by the end.

My process variable is the number of points I have collected so far. The process input is the intensity of the work required to reach the desired number of points at the time.

The problem with my current error calculation (total points expected to be collected by current timestamp - points collected so far) is that the PV being twice the setpoint in the first hour results in a significantly smaller error compared to an overshoot of the same magnitude in the last hour.

How should I modify the error to minimise fluctuations caused by both SP and PV growing over time? Would 1 - PV/SV work?

• So you want to put more emphasis on reaching 100,000 points by the end, instead of tracking the setpoint? Dec 18, 2022 at 13:22
• resembles the "carrot and rabbit" approach, have you tried to catch the carrot, looking at your distance (i.e. error), and controlling the error? if the carrot is farther than some distance, control your velocity (not the error), and when you're within the treshold switch to error control? Dec 23, 2022 at 22:04
• @fibonatic Ideally, I'd always collect the desired number of points per hour (when looking at the non-cumulative distribution). If this is done optimally, the final number of points (100,000) should be reached. The problem with the non-cumulative distribution of points for the setpoint is that I'd need to have a moving sum window of some duration whenever I want to sample the setpoint. I see. Since there are two objectives (most optimal work intensity and reaching the setpoint in the cumulative distribution), it would be better to slowly shift from one error to the other. Dec 28, 2022 at 2:09