# PIDRegulator Class

(Automation::PIDRegulator)PID regulator that takes default input SetPoint and feedback Y to produce control output. More...

Header: | #include <PIDRegulator.h> |

Inherits: | CDPOperator<T> |

## Public Functions

PIDRegulator(const CDPPropertyBase &in) | |

virtual | ~PIDRegulator() |

## Reimplemented Public Functions

virtual void | Configure(XMLPrimitive *operatorXML) override |

virtual void | Create(const char *shortName, CDPBaseObject *pParent) override |

virtual void | FillNodeChildren(CDP::StudioAPI::NodeStream &stream) const override |

virtual unsigned int | Process() override |

- 18 public functions inherited from CDPOperator
- 17 public functions inherited from CDPOperatorBase
- 42 public functions inherited from CDPBaseObject
- 26 public functions inherited from CDP::StudioAPI::CDPNode
- 22 public functions inherited from CDP::StudioAPI::ICDPNode

### Additional Inherited Members

- 1 public variable inherited from CDPOperatorBase
- 1 static public member inherited from CDPBaseObject
- 1 protected function inherited from CDP::StudioAPI::CDPNode
- 8 protected variables inherited from CDPOperator
- 5 protected variables inherited from CDPOperatorBase
- 10 protected variables inherited from CDPBaseObject

## Detailed Description

PID regulator that takes default input SetPoint and feedback Y to produce control output.

A Proportional–Integral–Derivative (PID) regulator.

This CDP operator can be used for regulation of process control variables. An error is calculated based on setpoint default input and system feedback (parameter Y), and correction value for controller is calculated by using the P, I and D tuning parameters of the regulator.

The P (proportional) term is negatively multiplied with the error and added to the current output, so as to reduce positional errors. The I (integral) term of the regulator is multiplied by the average error and added to the output. This will attempt to reduce steady-state errors. Finally, the D (derivative) is multiplied by the rate-of-change of the error with respect to time, so as to react quicker to f.i. acceleration changes.

### Arguments

Argument name | Description |
---|---|

Out | The default output representing Control value to system. |

In | The default input. PID set point. The desired state (position) of the system (where we want system reach to). |

Y | Current state (position) of system (feedback). |

Kp | PID regulator tuning parameter (P). Indicates how much to involve previous difference from SetPoint (proportional) term in every new calculation. Use 0 to eliminate proportional component from calculation. |

Ki | PID regulator tuning parameter (I). Indicates how much to involve the time-difference-persisted (integral) term in every new calculation. Use 0 to eliminate integral component from calculation. |

Kd | PID regulator tuning parameter (D). Indicates how much to involve the rate-of-difference (derivtive) term in every new calculation. Use 0 to eliminate derivative component from calculation. |

Kr | PID regulator tuning parameter. Overall gain. Can be used to scale (amplify or reduce) PIDRegulator effect. Use values < 1 to reduce PIDRegulator effect. Use values > 1 to increase PIDRegulator effect. Use value 0 to disable PIDRegulator (so only feed forward will be outputted). Use value 1 for no overall gain. |

Kf | PID regulator tuning parameter. Feed forward (open loop) gain. Use values > 0 to get more responsive control system. Use 0 to disable feed forward. |

Sat | Saturation-based anti-windup limiter for integral term. Route actuator saturation level with values from 0 (normal operation) to 1 (full saturation) into this parameter for anti-windup on integral term. |

TDecay | Integral decay. Values greater than zero can be used to reduce integral term oscillation effect. Use 0 to disable decay. |

MinI | Minimum allowed integral value. Values less than zero will prevent integral term from decreasing below specified value. Use 0 to disable minimum limiting. |

MaxI | Maximum allowed integral value. Values greater than zero will prevent integral term from increasing above specified value. Use 0 to disable maximum limiting. |

Reset | Resets PIDRequlator calculation. When toggled from `0` to `1` PIDRequlator internal state is cleared and calculation reset. |

PIDRegulator can be used in systems like robotic arm controller etc, where PIDRegulator output will control movement motor.

Anti-windup effect can be achieved by using controlled system actuator saturation level (f.e. robotic arm movement current speed vs max speed) giving PIDRegulator feedback about situations when system state change limit is achieved (can not be moved even faster), so that PIDRegulator does not over-calculate its output.

### Read-only properties

Property | Description |
---|---|

InternalPValue | Proportional term value of the last calulation. Can be used to investigate (f.e. graph) PIDRegulator proportional term value used in output calculation. |

InternalIValue | Integral term value of the last calulation. Can be used to investigate (f.e. graph) PIDRegulator integral term value used in output calculation. |

InternalDValue | Derivate term value of the last calulation. Can be used to investigate (f.e. graph) PIDRegulator derivative term value used in output calculation. |

When operator is used inside a signal its default input is automatically tied to signal's InternalValue or previous operator's output. Its default output is automatically tied to next operator's input or to signal's Value. See also CDP Operator Usage In CDP Signals.

**Note: ** This operator can't be used in I/O Servers / CDPChannels because it requires to be run with a constant period. I/O Servers can't always guarantee periodic running since they may be in Offline state, or they can send/receive on change.

### Example

Below is an example plot of PIDRegulator system feedback (Y) signal (orange) at the time when input (SetPoint) (cyan) was set from value 0.0 to 1.0:

### Actual Processing Code of the PIDRegulator

unsigned int PIDRegulator<T>::Process() { if (d->reset) { d->pidCalculator.Reset(); d->reset = false; } if (d->TDecay() >= d->Ts() && d->TDecay() == 0.0) return STATUS_SIGNAL_FAULT; m_output = d->pidCalculator.CalculateControlValue((T)m_input, d->Y(), false, d->Ts()); d->intP = d->pidCalculator.GetIntP(); d->intI = d->pidCalculator.GetIntI(); d->intD = d->pidCalculator.GetIntD(); return STATUS_OK; }

**See also **Argument.

## Member Function Documentation

### PIDRegulator::PIDRegulator(const CDPPropertyBase &*in*)

Constructs a PIDRegulator with input *in*.

`[virtual] `

PIDRegulator::~PIDRegulator()

Destructs the PIDRegulator operator

`[override virtual] `

void PIDRegulator::Configure(XMLPrimitive **operatorXML*)

Reimplemented from CDPBaseObject::Configure().

`[override virtual] `

void PIDRegulator::Create(const char **shortName*, CDPBaseObject **pParent*)

Reimplemented from CDPBaseObject::Create().

`[override virtual] `

void PIDRegulator::FillNodeChildren(CDP::StudioAPI::NodeStream &*stream*) const

Reimplemented from CDPNode::FillNodeChildren().

`[override virtual] `

unsigned int PIDRegulator::Process()

Reimplemented from CDPOperatorBase::Process().

Returns STATUS_OK.

## Get started with CDP Studio today

Let us help you take your great ideas and turn them into the products your customer will love.