Peter Nachtwey
Member
Attached is a zip file that contains a python script that calculates the PID gains for SOPDT systems. You must install python3, numpy, scipy and matplotlib or Anaconda to run the script. The input file must be a text type file like a comma, tab or space separated variable file that has 3 columns. Time, control output in percent and the process variable. You need to edit the path to the data and make sure that the delimiter is set right. The script will take about a minute to run.
I have included a file called hotrod.txt. This file was originally generated by Ron Beaufort from his 'hotrod' tuning class. This files is about 10 years old.
The output is a some mathematical data about how good the fit is. There is also a plot that shows how well the model can estimate the actual response using the same input. The estimated response and actual response ( PV ) should be close to identical. The final output shows the plant open loop gain, two time constants, an offset ( ambient temperature in this case ) and a dead time.
A closed loop time constant needs to be calculated to determine how strongly the PID parameters will react to errors. The PID parameters are then calculated. Make the closed loop time constant smaller for a stronger response and longer for a weaker response to errors.
The PID gains are calculated assuming the ISA model of dependent gains.
The PID parameters may not be directly useable for all PLCs or closed loop controller. First, most PLCs use time constants in minutes. Because the time base in the hotrod.txt is in seconds, the time constants need to be converted to minutes. If your input file uses minutes then no adjustments are necessary. The calculated controller gain has units of percent control output per unit of error which is degrees fahrenheit in this case. Some controllers have controllers where the gain is counts of output per counts of error. This will require scaling or unit analysis to covert my calculated gains to PLC conts out/counts in gains.
I have included a file called hotrod.txt. This file was originally generated by Ron Beaufort from his 'hotrod' tuning class. This files is about 10 years old.
The output is a some mathematical data about how good the fit is. There is also a plot that shows how well the model can estimate the actual response using the same input. The estimated response and actual response ( PV ) should be close to identical. The final output shows the plant open loop gain, two time constants, an offset ( ambient temperature in this case ) and a dead time.
A closed loop time constant needs to be calculated to determine how strongly the PID parameters will react to errors. The PID parameters are then calculated. Make the closed loop time constant smaller for a stronger response and longer for a weaker response to errors.
The PID gains are calculated assuming the ISA model of dependent gains.
The PID parameters may not be directly useable for all PLCs or closed loop controller. First, most PLCs use time constants in minutes. Because the time base in the hotrod.txt is in seconds, the time constants need to be converted to minutes. If your input file uses minutes then no adjustments are necessary. The calculated controller gain has units of percent control output per unit of error which is degrees fahrenheit in this case. Some controllers have controllers where the gain is counts of output per counts of error. This will require scaling or unit analysis to covert my calculated gains to PLC conts out/counts in gains.