PV = oldCV*(1-k) + newCV*k + noise
Yes, what are you trying to simulate?
That has only one time constant or pole which is simulated by k.
There is no dead time, no bias, no system or open loop gain.
What about time?
This is how it is done
Code:
def difeq(t, y, k, t0, t1, c, dt):
""" generate estimated SOPDT solution
y[0] = process value
y[1] = rate of change of the process value"""
_u = control_interp.interp(t-dt) # offset CO for dead time
_dy2dt = (-(t0+t1)*y[1]-y[0]+k*_u+c)/(t0*t1) # SOPDT dif Eq
return np.array([y[1], _dy2dt]) # return PV' and PV''
This simulates a SOPDT system.
k is the open loop gain or degrees/% control output
t0 and t1 are time constants to make the simulation second order.
c is the bias or ambient temperature in this case. When the control output goes to 0 the temperature goes down to ambient temperature, not zero.
dt is the dead time.
_dy2dt needs to be integrated to get the next process variable or temperature.
This function would need to be modified depending on the type of system that is being simulated but it is easy to do in python.
@Jesper, I gave a list of reasons why not do it in the PLC. I can add more reasons.
It is easier to modify the simulator.
The hardware is cheaper than a PLC. I am thinking of using a Raspberry Pi that cost less than $200 with 16bit DACs and ADCs.
The simulation can run much faster with control over time.