12/9/2016 7:58 PM  
Joined: 12/9/2010 Last visit: 10/8/2022 Posts: 623 Rating: (72) 
Respected all, I wish to write logic for simple PID controller in FC in SCL. I am using velocity algorithm as follows: y = y_{t1}+ Kp(e_{t}– e_{t1}) + Kp/Ti(e_{t}) + (Kp*Td/sampling time)(e_{t}– 2* e_{t1}+ e_{t2}) ; where y = output & e =error; I have completed PLC coding for equation & tested and found satisfactory. I have following queries:

Last edited by: Sachinpatke at: 12/10/2016 5:44:25 AMIf you like the comment, rate it (right top) or thank it (left bottom). 

12/10/2016 8:15 AM  
Joined: 1/28/2009 Last visit: 2/21/2023 Posts: 6794 Rating: (1340)

Hello, PID controllers may sound easy to master and implement but there are many points to consider for their proper operation , safety for practical use and their optimization.You will understand all concepts in math if you work on regulation for many years and tried different algorithm on various PLC from several manufacturer.Here are some answers: You question#1 , Anti reset windup is a strategy to hold integral calculation while the total PID output pass the certain limit with certain sign of error. You question#6 ,Auto tuner is an independent algorithm and can be applied to any PID algorithm with similar standard in parameters and switches(PID selection). The ultimate point, please implement your PID algorithm in an FB. I hope this helps you, HD Hosseini 
This contribution was helpful to1 thankful Users 
12/10/2016 5:48 PM  
Joined: 6/24/2013 Last visit: 3/15/2023 Posts: 1503 Rating: (384)

Hi Integrate if (error>0 and PID Output<Max) OR (error<0 and PID Output>Min). Otherwise skip integration in particular step There are many options. I activate Deadband when Error crosses the Setpoint for 3rd time. The Deadband Counter is cleared when error leaves the Deadband and PID reactivates. Calculate Integrated Error from Your PID Equation and preinitialize I term on switchover Manual>Auto. Give option to reset Integrator to 0 on switchover [i.e. for heating applications] I have considered sampling time of 1 sec. What is needed to be done for variable sampling time? Give Sampling Time as an Input. if it is variable measure time since last PID loop call. Use measured time and it will work OK. The output of above equation is below zero(minus). What is significance and remedy while converting to unscaled output for AO? Set Limits for output and  if output>High limit correct it to output=limit and set Out_Limit_H=1 which can inhibit integrator (see antiwindup)  if output<Low limit correct it to output=limit and set Out_Limit_L=1 which can inhibit integrator (see antiwindup) Can Autotuning be implemented here? yes, use separate algorithm. but take care not to destroy the plant (you may limit 
This contribution was helpful to1 thankful Users 
Follow us on