What are the best algorithm for PID and what unit for tune I (Integral) and tune D (Derivative) ?

Based on the image, what unit are the system use for calculation?

I would recommend checking out these Video Tutorials explaining PID loops and tuning them. Also, we have a nice interactive tool on PID reaction and tuning.


Along with the resources that @greichert pointed you to, I have one more, this Opto22 PID PDF will help you very much in getting the Opto22 PID formula tuned.
Keep in mind, while the PDF mentions SNAP PAC, the formulas used in RIO and EPIC are exactly the same for all devices.
The interactive tool will be your main tool used to get the 4 values you need for your PID application.
The Ziegler Nichols method that the interactive web tool uses has been well proven over many decades.

To answer your exact two questions:

  1. Whats the best algorithm? There is no difference between them. They are all PID and one is not for a specific task any more than another. The reason Opto put a few versions in is because we wanted to make a smooth transitions for controls folks moving from other PLC brands to ours.
    I see in your screenshot you have selected ‘Interacting’, so I expect you have a lot of experience with that one and so are comfortable with it.
    If this is not the case, then select the default Velocity (Type C). Use this one and get to know it. Swapping between the different types will be very frustrating.
  2. What values to use for P, I and D?
    The Velocity type C as explained in that PID PDF uses - gain values for inc/dec and + values for inc/inc (Think heating and cooling), so keep that in mind.
    P or gain is the ‘strength’ of impact the input to set point error will be applied to the output.
    I or Integral is the amount the output will be changed if the input is not at the set point. NOTE! This value is tied very tightly to the Scan Rate. You should not necessarily accept the Opto default scan rate of 1 second. (Think of a car cruise control vs a truck - the car scan rate needs to be MUCH faster than the truck cruise control PID scan rate).
    D or Derivative. This will come into play as the input approaches the set point. If its a really aggressively steep angle then the D term will back things off a lot, if its slowly getting close, the D term does not do much.

As you can see, we cant give you the 4 critical values (P,I,D and scan rate). You need to follow the online interactive tuning guide that Garrick linked you to and find them for the process you are working on.


In my opinion Velocity C is the best for most situations:

If you need Feed Forward though, use one of the others.

When I start to tune a loop, I start with a reasonable Gain and a very small Tune I. You have a large output range so a Gain around 100 is what I would start with if using a 1 sec scan rate.


The PID PDF was a good read. I just implemented the Velocity C form in Codesys. It is a real elegant way to implement a PID without need for doing tricks with the integral accumulator to get bumpless and anti-windup behavior.

1 Like