Вы находитесь на странице: 1из 9

Kingfisher Examples: PID Simulation

Kingfisher Examples
Kingfisher PID Simulation
for CP-30 and G30 Processors

Version 1.0
Kingfisher Examples: PID Simulation

Preface

Copyright Copyright CSE Semaphore (Australia) Pty Ltd. ABN 35 006 805 910
www.cse-semaphore.com/mykingfisher,
info.kingfisher@cse-semaphore.com
Intellectual CSE Semaphore asserts ownership of the intellectual property contained
Property herein and claims copyright and authorship excluding any intellectual property
already in the public domain. CSE Semaphore has and retains all rights of
ownership and use of the material herein in its on-going business.
Licence This document is provided to the intended recipient(s) under a non-exclusive
licence. This licence permits Fair Use of the document for operational
requirements, without payment of further royalty or licence fee. Fair Use
includes making copies of the document for operational, backup and archive
purposes. Fair Use includes distributing copies of the document to other
entities for the purposes of their performing related works for the intended
recipient(s). Fair Use does not include creating, selling or distributing copies of
the document for other purposes. All copies must retain this statement of
Intellectual Property and Copyright.
Version 1.0: First Release of document
Kingfisher Examples: PID Simulation

1. Introduction

This document will investigate the use of the Kingfisher Proportional


Integral Derivative (PID) function block. PID is used to calculate the
difference between a measured process value and a desired set-point
and attempts to minimize difference by intelligently modifying the output
variable. The PID function takes the following into account:

• A proportional component which calculates which calculates a


proportional response to the current error value

• An integral component which calculates a response based upon


accumulated error

• A derivative component which calculates a response based upon the


error values rate of change

The following formula is used:]

Evaluated from 0 to t

Where:

Kp = Proportional Constant
Ki = Integral Constant
Kd = Differential Constant
t= Sample Interval
en = Current Process Error (n)
en - 1 = Previous Error (n - 1)
en - 2 = Previous Error (n - 2)
en - 3 = Previous Error (n - 3)

The accompanying project ‘Tb+ PID Example.zip’


(available from MyKingfisher) simulates a varying input to allow the PID
algorithm to be experimented with observed, and tuned before
deployment.

1 Version 1.0
Kingfisher Examples: PID Simulation

1. Running the Project


The PID Simulation project has 32 PID loops running simultaneously. For
simplicity, only one will be considered in this document.

Note that spreadsheet software package is required to complete this


example. Users are expected to be familiar with basic data manipulation
techniques.

Requirements

• Toolbox PLUS+ 3.8.4 or higher


• ISaGRAF with Licence (build 5.13 or lat-
er)
• ‘Tb+ PID Example.zip’ example project
available from MyKingfisher
• CP-30 or G30 processor with 2604
firmware or later
(Utilizing two processors for
redundancy testing optional)
• PS-12/22 Power Supply Module
• Backplane

The project contains DI-10 modules used for outputs from the PID
process. As simulation logic will be used, these modules are not required.

To get started, open the example project and launch


ISaGRAF. From the project tree view select the
TEST_FBD program.

4 Version 1.0
Kingfisher Examples: PID Simulation

Simulation Logic

At the core of the simulation logic is an oscillator and a state machine.

The oscillator generates a SETPOINT_REAL with selectable amplitude and


offset, and also outputs an INDEX_DINT variable.

The INDEX _DINT is used to drive a state machine based on the MOD
function block.

The MOD function bock gives the remainder of a division of INDEX_DINT


and 32, which is compared to an index number (zero in the case above).

This means that once every 32 increments of INDEX_DINT, this logic will be
executed.

These logic blocks assign the SETPOINT_REAL to DNP3 analog inputs


which are forwarded to the Set Point inputs of the PID functions.

The PID function outputs are also DNP3 variables, allowing event logs for
each variable to be inspected. This is very convenient for characterizing
performance.

5 Version 1.0
Kingfisher Examples: PID Simulation

PID Test Logic

The test logic is a simple implementation of the PID function block. All 32
instances are the same allowing you to observe any changes made to the
PID loop. The following is the PID function controlling DNPAO0.

PV (Real): The measured process value.


In this Example: The value output by the PID function (DNPAO0).

SP (Real): The desired set point.


In this Example: The generated value from the simulation logic (DNPAI0).

AM (Bool): Automatic or Manual operation mode. When operating in


automatic mode, the function block will calculate an output value based
on PID calculations. In manual mode, the function block output value will
simply track the Set-Point value without calculation.
In this Example: Input from DI10Di1.Value to allow experimentation with
both modes.

DIRE (Bool): Direct (True) or Reverse (False) calculation mode. When direct,
the output value will increase as the measured process value increases.
When reverse, the output value will decrease as the measured process
(PV) value increases.
In this Example: Set TRUE

KP (Real): The PID proportional constant.


In this Example: Variable KP_REAL (set to 1.0)

6 Version 1.0
Kingfisher Examples: PID Simulation

KI (Real): The PID integral constant.


In this Example: The Variable KI_REAL (Set to 0.01)

KD (Real): THe PID derivative constant.


In this Example: The Variable KD_REAL (Set to 0.1)

Time (Real): The time interval (in milliseconds) between sampling the
process variable. (Note the minimum interval that can be used is limited
by the ISaGRAF cycle time).
In this Example: The Variable TS_TIME (Set to 500 ms)

DBDP (Real): Dead-band positive. The allowable positive error between the
Process Variable (PV) and the Set-Point (SV). If the positive error is less
than this value, the output will not be adjusted.
Dead-band settings
In this Example: The Variable DEADBANDDP_REAL (Set to 0.1)
can be used to
suppress ‘hunting’
DBDN (Real): Dead-band negative. The allowable negative error between (oscillation) in the
the Process Variable (PV) and the Set-Point (SV). If the negative error is output.
less than this value, the output will not be adjusted.
In this Example: The Variable DEADBANDDN_REAL (Set to 0.1)

ATNP (Real): Anti-Rest Positive. The upper limit of the Process Variable (PV)
to suppress an integral response. The Anti-Reset range can be used to
suppress over-correction (and overshoot) of the output value during initial
tuning actions where there is a significant difference between the
Process Value and the Set-Point value.
In this Example: Static value 0.0

ANTN (Real): Anti-Reset Negative. The lower limit of the Process Variable
(PV) to suppress an integral response. The Anti-Reset range can be used
to suppress over-correction (and undershoot) of the output value during
initial tuning actions where there is a significant difference between the
Process Value and the Set-Point value.
In this Example: Static value 0.0

MIN (Real): The minimum output value.


In this Example: The Variable MIN_REAL (Set to 0)

MAX (Real): The maximum output value.


In this Example: The Variable MAX_REAL (Set to 10,000)

OUT (Real): The output value of the function block.


In this Example: Assigned to variable DNPAO0.value

7 Version 1.0
Kingfisher Examples: PID Simulation

Observing Operation

One of the more convenient ways to see the PID block tracking the Set-
Point value is to retrieve all the logs generated by the DNP3 driver and
graph them in spreadsheet software such as Microsoft Excel or
OpenOffice Calc.

To do this, download configuration and logic to your CP-30 processor


and allow it to run for a while.

Download and export the Event Logs to a CSV file.

Open the file in your spreadsheet software package of choice. In this case
OpenOffice Calc will be used as it is widely supported and available for
free.

When opening the CSV file, be sure to specify ‘comma’ in the separation
options, otherwise the data will not be formatted correctly.

Once imported, the ID, Date, RTU, Flags, Type, and Priority columns can
be deleted.

Order the data alphabetically with respect to the DNP3 Variable names,
then create a 2D line chart for each of the Variables DNPAI0 and
DNPAO0.

8 Version 1.0
Kingfisher Examples: PID Simulation

The Results

The following charts are of the PID function block Set-Point and
Process Variable. Note the RTU was run overnight to accumulate Event
Logs.

Process Variable

Set Point

The two series were not placed on the same chart as they overlap and
obscure one another.

This method of inspecting the operation of the PID block can be used in
real world situations to ascertain the quality of tuning effects.

9 Version 1.0

Вам также может понравиться