• Skip to main content
  • Skip to header right navigation
  • Skip to site footer
CDP Studio logo

CDP Studio

The no-code and full-code software development tool for distributed control systems and HMI

  • Doc
  • Why CDP
    • Software developers
    • Automation engineers
    • Managers
  • Products
    • Automation Designer
    • HMI Designer
    • Maritime HMIs
  • Services
  • Use cases
  • Pricing
  • Try CDP

CDP Studio Documentation

  • Framework - Automation
  • PIDRegulator
  • 5.0.0

PIDRegulator Class

(Automation::PIDRegulator)

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

Header: #include <PIDRegulator>
Inherits: CDPOperator<T>
  • List of all members, including inherited members

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 unsigned int Process() override
  • 18 public functions inherited from CDPOperator
  • 17 public functions inherited from CDPOperatorBase
  • 49 public functions inherited from CDPBaseObject
  • 27 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 nameDescription
OutThe default output representing Control value to system.
InThe default input. PID set point. The desired state (position) of the system (where we want system reach to).
YCurrent state (position) of system (feedback).
KpPID 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.
KiPID 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.
KdPID 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.
KrPID 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.
KfPID regulator tuning parameter. Feed forward (open loop) gain. Use values > 0 to get more responsive control system. Use 0 to disable feed forward.
SatSaturation-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.
TDecayIntegral decay. Values greater than zero can be used to reduce integral term oscillation effect. Use 0 to disable decay.
MinIMinimum allowed integral value. Values less than zero will prevent integral term from decreasing below specified value. Use 0 to disable minimum limiting.
MaxIMaximum allowed integral value. Values greater than zero will prevent integral term from increasing above specified value. Use 0 to disable maximum limiting.
ResetResets 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

PropertyDescription
InternalPValueProportional term value of the last calulation. Can be used to investigate (f.e. graph) PIDRegulator proportional term value used in output calculation.
InternalIValueIntegral term value of the last calulation. Can be used to investigate (f.e. graph) PIDRegulator integral term value used in output calculation.
InternalDValueDerivate 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] unsigned int PIDRegulator::Process()

Reimplemented from CDPOperatorBase::Process().

Returns STATUS_OK.

The content of this document is confidential information not to be published without the consent of CDP Technologies AS.

CDP Technologies AS, www.cdpstudio.com

Get started with CDP Studio today

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

Try CDP Studio for free
Why CDP Studio?

CDP Technologies AS
Hundsværgata 8,
P.O. Box 144
6001 Ålesund, Norway

Tel: +47 990 80 900
E-mail: info@cdptech.com

Company

About CDP

Contact us

Services

Partners

Blog

Developers

Get started

User manuals

Support

Document download

Release notes

My account

Follow CDP

  • LinkedIn
  • YouTube
  • GitHub

© Copyright 2025 CDP Technologies. Privacy and cookie policy.

Return to top