Beruflich Dokumente
Kultur Dokumente
Version
1.2.1
DISCLAIMER
Citect Pty. Limited makes no representations or warranties with respect to this manual and, to
the maximum extent permitted by law, expressly limits its liability for breach of any warranty
that may be implied to the replacement of this manual with another. Further, Citect Pty. Limited
reserves the right to revise this publication at any time without incurring an obligation to notify
any person of the revision.
COPYRIGHT
TRADEMARKS
Citect Pty Limited has made every effort to supply trademark information about company
names, products and services mentioned in this manual. Trademarks shown below were
derived from various sources.
IBM, IBM PC and IBM PC AT are registered trademarks of International Business Machine
Corporation.
MS-DOS, Windows, Windows 98, Windows 2000, Windows XP and Excel are trademarks of
Microsoft Corporation.
General Notice:
Some product names used in this manual are used for identification purposes only and may be
trademarks of their respective companies.
TABLE OF CONTENTS
Contents
INTRODUCTION.........................................................................................................................................4
UNIT CONFIGURATION.........................................................................................................................10
PHASES ......................................................................................................................................................11
VALVES .....................................................................................................................................................12
OTHER INFORMATION................................................................................................................................12
Unit Status............................................................................................................................................13
Unit Control Tag ..................................................................................................................................13
PHASES .......................................................................................................................................................13
AGITATOR ON OFF PHASE .........................................................................................................................14
DRAIN TO PACKAGING PHASE ...................................................................................................................15
FM1 ADDITION .........................................................................................................................................16
FM1 RELEASE PHASE ................................................................................................................................17
FM1 REPORT PHASE..................................................................................................................................18
MANUAL INPUT PHASE ..............................................................................................................................19
MANUAL INPUT REPORT PHASE ................................................................................................................20
OPERATIONS ............................................................................................................................................20
AGITATOR ON OFF OPERATION .................................................................................................................20
CHOCOLATE MILK OPERATION .................................................................................................................22
DRAIN TO PACKAGING OPERATION...........................................................................................................25
Extended Mix Opertion ........................................................................................................................26
MANUAL INPUT OPERATION ......................................................................................................................29
THE CHOCOLATE MILK MASTER RECIPE .....................................................................................30
CHOCOLATE MILK UNIT PROCEDURE........................................................................................................31
AGITATOR ON OPERATION ........................................................................................................................32
CHOCOLATE MILK OPERATION .................................................................................................................33
AGITATOR OFF OPERATION .......................................................................................................................34
MANUAL INPUT OPERATION ......................................................................................................................34
EXTENDED MIX OPERATION......................................................................................................................35
DRAIN TO PACKAGING OPERATION...........................................................................................................35
FURTHER COMMENTS ..........................................................................................................................36
GENERAL ...................................................................................................................................................36
CITECT PROJECT ........................................................................................................................................36
DIAGNOSTIC PAGE.....................................................................................................................................36
MANUAL CONTROLS .................................................................................................................................37
UNIT CONTROL TAG ..................................................................................................................................37
CITECT BATCH REDUNDANT DATABASE ...................................................................................................37
ARCHIVE DATABASE .................................................................................................................................38
BATCH 1.1- BATCH API ............................................................................................................................42
BASIC TROUBLE SHOOTING .......................................................................................................................43
Stuck Phases.........................................................................................................................................44
Unlocking a pipe ..................................................................................................................................46
Checking a Control Recipe Overview ..................................................................................................47
1 Introduction
This project is designed to illustrate some basic and some more advanced features of Citect
SCADA Batch and the way in which it interacts with the PLC and Citect. The example system
is illustrated above. There are three Tanks containing three different Materials and two Units
that can simultaneously draw on these Tanks to mix flavoured milk.
Tank 1 always contains sugar and Tank 2 contains different flavours, chocolate, strawberry
etc. Tank 3 always contains milk..
There is an equipment constraint in that Tanks 1 and 2 share the same flow meter so that only
one of them can be used as a source of raw material at a time.
Note: Many of the terms used relate to the ISAs Batch Control Standard 88.01. For additional
information regarding S88 and its Procedural Model, see http:\\www.isa.org
Note: Some additional features have been added to show how the Batch API (introduced with
CitectSCADA Batch 1.1) can be used to automate some Batch procedures from Citect. See
additional comments at the end of this document,
The Citect.ini that was used to develop the project has been included to show typical Batch
entries.
Please note that Batch_Example is intended for a single computer installation of Citect and
Batch Server and Clients using Memory and Disk PLCs. This makes the setup for a demo
system self contained.
Note 1: If there is a Citect key on your PC and it does not include a Batch license,
CitectSCADA Batch will NOT start in Demo Mode but will have 0 Batch Licenses and therefore
will not function. To run both Citect and Batch in Demo Mode remove the Citect key and
restart both applications.
Note 2: A section called [Batch_Example] can be used to change some of the behaviour of
this example. The parameters that can be set and their default values are listed below:-
[Batch_Example] Default
SQLSvr=. ., the local, default SQL Instance.
SQLUsr=sa sa, the SQL System Administrator.
SQLPwd= , no password, not recommended by Microsoft.
SPDelay=200 Delay in ms between SQL Stored Proc. calls
SimulationDelay=500 Delay in ms for flow simulation Cicode
UpdateCitectCount=10 If set to 10, SQL Stored Procs. Run every 10 time
SQL=1 1 = export batch data to SQL Server
Access=0 1 = export batch data to MS Access
DTSFilePkg= C:\DataLinks\ExportBatchData.dts
UserLevel 0 = manual input form without password
1 = manual input form will require a password
2 = manual input form suppressed for continuous testing
The DTSFilePkg parameter tells Batch Example to run the file version of the DTS Package at
the path indicated. If this entry exists but is empty, Batch Example will look for the DTS
Package on the default instance of the local SQL Server.
The defaults shown are built into Cicode and if they are acceptable no Citect.ini entry is
necessary.
Note 4: Do not access the Batch Viewer, Batch Scheduler or other Batch ActiveX pages via
the automatically generated Citect Page Menu. You should use the buttons on the Cell Page,
which use the correct Cicode function or use navigation within the Batch ActiveX Controls.
Note 5: The physical valves associated with each unit (Valves 4, 5, 6, 7, 8 & 9) are controlled
by virtual Valves 4, 5, 6, 7, 8 & 9 which are in turn controlled by the Batch Engine. The Citect
Tags for the virtual valves begin with BE_. Additional logic is used to close the physical
valves when the Unit they are associated with is in the Held state. There is an LED adjacent
to each physical valve which shows the status of the virtual valves. When a unit is in the Held
state some of the virtual valves will be open but the physical valves will be closed. This logic in
Batch_Example is implemented in Cicode but would normally be implemented in the PLC.
1. When logging in to the Batch Editor, Equipment Editor and Batch Engine, a valid User
ID is 123 with Password batch123. There is also a User ID 999 with password
Batch998 or Batch999.
2. In the Recipe Editor Create a Process Order for say 100,000 Kg of Chocolate Milk.
3. Create a few (about 5) Control Recipes from the Process Order with an Order Size of
1,000 Kg for Unit 1 and 800 Kg for Unit 2. To make them easy to identify, it is
suggested that the Batch Start No should be u1-choc- and u2-choc-_. Note: The
batch engine will break up the order size based on the allowable batch size as defined
by the Unit. If we, for instance, define an order size of 2,000 Kg, this will create 2
batches or Control Recipes.
4. Transfer at least one Control Recipe for each Unit to the Batch Scheduler (Right click
on Control Recipes, in Recipe Editor, to bring up the Control Recipes list).
5. Confirm, in the Batch Editor, that Tank 1 contains sugar, Tank 2 Chocolate and Tank 3
Milk.
6. Use the Batch Scheduler (in Citect) to Release a Control Recipe for each Unit.
7. Go to the Citect Cell Page and note that the batches have been loaded into each unit.
8. Return to the Schedule page, double click the Unit 1 batch and Start it.
9. Click the Back button, double click the Unit 2 batch and Start it.
10. Return to the Cell page and observe the sequence in which valves are opened &
closed and behaviour of the flow meters. Note how access to Pipe 1 and Pipe 2 is
controlled by the Batch Engine.
11. Notice that the set points are scaled to the batch sizes for Units 1 & 2.
12. When batches have finished on both units go to the Report Page and open the reports
for each batch.
13. Go to the Batch Summary Page and observe the data that has been logged for each
batch.
As an additional test, try changing the Material in Tank 2 to be something other than Chocolate
and run another Control Recipe. The Material is changed by clicking on the Material name for
any Tank.
Observe that the batch runs until it attempts to add Chocolate then waits (neither the virtual
Valve for the Unit nor Pipe 1 are activated) until the Material for Tank 2 is changed to
Chocolate before completing.
The Units can be put into the Held state by clicking on the Hold button for the Unit. The LED
will change to red and the Unit will go to the Held state. To continue the batch, first click the
Hold button to turn the Hold LED off, then go to the Unit Procedure level in the Batch Viewer
and Restart and Operations that in the Held state. Note that the Batch Engine only changes
the state of the Unit; any control actions (to stop flow etc) must be implemented in the control
system. Batch_Example illustrates how this can be achieved in Citect although most of the
logic would normally be implemented in the PLC.
Pipe 1
Pipe 2
Unit 1 Unit 2
Product 1 Product 2
The Tanks can be regarded as Material sources and the Units as Material destinations. The
pipes and valves are used by the Batch Engine to create logical connections between
Materials in the Tanks and the Units.
The valves have been given the same numbers as the physical valves in the plant but they are
actually virtual valves. The Citect Tags for the virtual valves begin with BE_. For example the
virtual counterpart of Valve1 is BE_Valve1. Similarly, while Pipes 1 & 2 appear to match up
with pipes in the plant, they are virtual pipes. Notice that valves 1, 2 and 3 do not appear in
this virtual diagram at all.
The virtual valves are associated with the destination Unit whereas the virtual pipes are
associated with the source Tank or Tanks.
In the Equipment Editor, Valves 4 & 6 are assigned to Pipe 1 and Valves 5 & 7 are assigned to
Pipe 2. In turn Pipe 1 is assigned to Tanks 1 and 2 and Pipe 2 is assigned to Tank 3. Finally
Valves 4 & 5 are assigned to Unit 1 and Valves 6 & 7 to Unit 2.
On the following page, the some of the Equipment Editor forms involved are shown.
When a recipe calls for a Material, the Batch Engine checks which virtual Valves are
associated with the Unit. If it finds a Pipe that is associated with a Tank that contains the
required Material, it will activate the Pipe and the Valve that connects the Pipe to the Unit. If
the Material cannot be found in any of the available Tanks, none of the virtual Pipe or Valve
Tags will be activated. If the Tags are used to control the Batch, execution will halt until the
required Material is assigned to one of the Tanks. If more than one available Tank contains the
Material one of them will be selected but which one is not predictable. The Active Tank check
box in the Recipe Editor can be used to control which Tank is selected under these
circumstances. The Lot Number assigned to the Tank is used in the Batch Report.
A PowerPoint (EquipmentModel.ppt) illustrating how Tanks, Pipes and Valves work can be
found in the OtherFiles folder for the Batch_Example Citect Project.
In the Equipment Editor the Pipes and Valves are assigned Citect Tags which are set to 1 or 0
at the appropriate times during the execution of a batch. This will happen when the Batch
Engine finds the requested Material via a particular virtual Valve and Pipe.
The Citect Tags are used to activate PLC logic that controls the plant. In general the Pipe Tag
can be used to activate equipment associated with the source of the Material (the Tank) and
the Valve Tag to connect to the destination (Unit). Almost always additional logic is required
5 Unit Configuration
The configuration of each Unit is what ties the Phases and Operations to real items of Plant.
The Max batch size parameter is used by the Recipe Editor (RE) when creating Control
Recipe. If the Control Recipe quantity exceeds this number, multiple Control Recipes are
created.
The Min batch size is also used by the RE when creating Control Recipes to ensure that
batches are not less than this quantity.
5.1 Phases
Phases that are applicable to the Unit are added and the Phase Parameters as assigned to
Citect Tags. The Release Parameters are internal to the Batch Engine and are therefore not
assigned to Citect Tags.
5.2 Valves
Valves are assigned to the Unit thus linking the Unit to Pipes and Tanks for the purpose of
adding (dosing) Materials and logging (Reporting) the quantities and Lot Numbers. The Citect
Tags for each Valve were previously assigned in the Valve Definition. The Batch Engine will
set the appropriate Valve (and its associated Pipe) to 1 when it locates a Material required
during dosing.
6 Phases
The following Phases are utilised in the example Recipe 000004 Chocolate Milk:-
Most of the Parameters in Phases (e.g. Input, Output and Report) are assigned to PLC Tags.
When defining Phases, the Parameters and their Parameter Types are configured within each
Phase. These Parameters are assigned to Tags when they are assigned to Units making it
possible to use them on multiple Units by using different Citect Tags.
This is a simple Phase that turns the Unit Agitator on or off depending whether the parameter
is set to 1 or 0.
This Phase has been set up as a demonstration showing how some Phase Logic can be
implemented in the Batch Engine. In this case the Batch Engines senses when low level has
been reached. When adding Materials, measurements are more critical and such logic is
performed in the PLC.
10_DrainValve An Output that controls the Virtual Drain Valve. PLC logic uses the status
of this Virtual Valve to control the Physical Valve depending whether or not Unit is in the Held
State.
20_UnitLevel An Input used in the Transition logic to sense when the Unit is nearly empty.
00_Start is a bit that is set by the Batch Engine to Start the Phase.
10_SetPoint is an output to the PLC controlling the amount of sugar or flavour to be added.
This is the Preset value for the flow meter
20_Tank1or2 Parameter is an output to the PLC. It set to the value of 1 or 2 in the Chocolate
Mix Operation to control whether Valve 1 (Tank 1) or Valve 2 (Tank 2) is opened.
99_Completed bit is an input from the PLC indicating that the Flow Meter has measured a
quantity of sugar or flavour equal to the Set Point. The logic to drive this bit occurs in the PLC
(possibly within the flow meter).
Note that FM2 Addition Phase doesnt require a Source Parameter because there is only one
Tank (Tank 3) to supply milk.
This Phase is always configured to occur immediately after the FM1 Report Phase to release
Pipe 1.
10_Release is an internal Batch Engine Parameter and does not have a Citect Tag assigned
to it. This parameter is required to release the Pipe, Valve and Tank when a Raw Material
addition is complete. The release is assigned a Raw Material in the Unit Procedure (see
below).
20_Completed is an output Parameter which resets (sets to 0) the Ready bit that was set to 1
by the PLC logic. It is used by a transition in the Recipe to sense that sugar or flavour dosing
has completed.
This Phase is always configured to immediately follow the FM1 Addition Phase.
This phase sets a bit in the PLC which triggers a Citect Event to pop up a Cicode form into
which two parameters can be entered (Milk SNK and Specific Gravity). Whether the form is
closed, the values are written to Citect Tags and the Complete bit is set.
00_Start An Output that triggers a Citect Event to pop up the Cicode form.
99_Complete Input that is set on completion of the form entries and used as a Transition
signal completion of data entry to the Batch Engine.
This Phase always immediately follows the Manual Input Phase and logs the values entered
into the Citect form.
SG_Report A Report Parameter mapped to a different Citect Tag for each Unit to log the
Specific Gravity
SNF_Report A Report Parameter to log the SNF value entered into the form.
7 Operations
The Operations defined for Master Recipe 0001 Chocolate Milk are as follows:-
This Operation simply executes the Agitator On Off Phase setting the Unit Agitator Tag to 1 or
0 as per the 10_Agitator parameter.
The Sort numbers are used by the Batch Viewer (BV) to control the order in which elements
are displayed.
This is the most complex Operation. Sugar and Milk are added simultaneously. For the
Material (Sugar, Milk, and Chocolate) Addition Phases, the proportional quantities are
configured.
The Transitions
wait for the PLC to set the Complete(d) bit.
The Report Phases log the Set Point and Actual (measured) values.
The Release Phases Release the Pipe from the appropriate Material. At the same time the
Complete bit is reset.
This Operation, opens the Unit Drain Valve waits for the unit to empty then closes the Unit
Drain Valve.
The Transition (Step 20) waits for the Unit Level to be less than 10. If the Transition was Unit
Level equals 10, then the value could pass through that values without the condition being
met.
The intention of this Operation is intended to demonstrate the ability to change logic flow in a
recipe based on input from Citect. The Transitions 20 and 50 senses whether the Unit
Extended Mix bit is set or not.
The Extended Mix On Phase turns the Agitator on and waits 10 seconds then the Extended
Mix Off Phase turns the Agitator off.
This Operation sets a Tag in Citect that triggers and Event while calls a Cicode function to pop
up a form to accept two parameters from the Operator.
The Show Form Phase sets the Citect Tag associated with 00_Start Parameter to 1. This will
be a different Tag for each Unit.
When the Tag is set to 1, a Cicode function called ManualInputForm() is run. The Operator
enters the two parameters and clicks OK.
As the form is closed, the data is written to Citect Tags for Reporting by Citect SCADABatch
and the Event trigger Tag is set to 0 (in Cicode).
The top level of the Master Recipe is the Unit Procedure, in this case Chocolate Milk.
Where appropriate, a Master Recipe can have more than one Unit Procedure and they can be
configured in series or parallel. For example there could be a small mixer feeding into the main
mixer to pre-mix vitamins. The Master Recipe would then have a Pre-mix Unit Procedure
followed by the Chocolate Milk Unit Procedure.
Using the Master Recipe 001 Chocolate Milk the Unit Procedure is illustrated on next page.
The Unit Procedure has a series of sequential as shown. Each step is infact one of the
Operations that have been configured.
Sets the Tag that .controls the Unit Agitator to 1, starting it.
Executes all the Phases involved in mixing Chocolate Milk. All the parameters and their values
can be seen in the list (not all are visible here).
This Operation executes the same Phase ( Agitator On Off) as Agitator On but sets the
parameter to 0, turning the Agitator off.
Shows a Citect form for manual input and logs the data to the Batch database.
Depending whether the Extended Mix Tag for the Unit has been set, the Operation does
nothing (NOP) or runs the Agitator for 10 seconds again using the Agitator On Off Phase.
This Operation opens the Unit Drain Valve and waits for the Unit Level to fall to a low level.
9 Further Comments
9.1 General
The Citect project (Batch Example) has a Cicode file (BatchTest.ci) containing code to
simulate Material Flow and emulate PLC logic. As can be seen from the Cicode, some simple
PLC logic is required to control plant equipment in response to virtual Pipes, virtual Valves,
Phase Parameters and being set by the Batch Engine. Citect Tags are also used to provide
feedback to the Batch Engine via Input Parameters, for example, when a flow meter has
measured the required quantity of material.
Tank 3, for example, demonstrates the basic principals of Tanks, Valves. Pipes and Units and
Tanks1 & 2 illustrate how to deal with a slightly more complex situation.
The demo can also be used to demonstrate the way in which the Batch Engine queues
requests to use a common Pipe when two (or more) Units are executing batches
simultaneously.
In a real project none of this Cicode should be necessary; the Material flow simulation would
not be required at all and the remaining logic would be implemented as PLC code.
The PLC code would be structured quite differently to the Cicode simulation code.
In the above example, the Flag for Unit 1 FM1 is amber because the Batch Engine has
requested Chocolate and Tank 2 contains Strawberry. The Flag is amber whenever a request
for a Pipe is no met whether it because it is in use by another Unit or the Material cannot be
found.
The best way to access these is via the XDb functions in CTBInclude. These functions
automatically access the active Batch Database in a redundant Batch configuration. The
Cicode functions UpdateCitect() and ManualInput() show the recommended way to do this.
Particular care must be taken to use the GetAktivHandle() and SemSignal() function as shown
to achieve the required semaphore access the XDb functions.
A Cicode Function called BatchExport is called. The Cicode executes a SQL Server DTS
Package called ExportBatchData to copy the data from the Batch Database to another
Database. The DTS Package can be found in the OtherFiles\DataLinks folder. Also in the
Folder are the two Universal Data Link (UDL) files used by the DTS Package. There is also a
Crystal Report based on this data (BatchSummary.rpt) and a sample PDF output
(BatchSummary.pdf) of the report.
Some SQL Server knowledge and access to SQL Server Enterprise Manager is required to set
this up. The procedure is as follows.
The data for each Batch will be copied to the BatchStageTables database at the completion of
each Batch using the ExportBatchData DTS Package.
The Crystal Report file BatchDetails.rpt requires an ODBC System DSN called
BatchArchive which should point to the BatchStageTables database. The Report uses
Stored Procedure called usp_sel_BatchData which has one parameter, the Batch ID.
Some customers prefer not to install SQL Server and use Microsoft Access to store the data
and run reports. Batch_Example includes a simple Access database called
Batch_Example.mdb and some Cicode to export Batch Data to it. To activate the Cicode, find
or create a {Batch_Example] section in Citect.ini and set Access=1.
You will need to establish two ODBC DSNs to use Access code. The first is Batch_Example
and is a SQL Server DSN as shown on the next page:-
This DSN is used to link the Access database to Tables and Views in the Batch database
using a User ID of batch with the password batch.
The second is and Access DSN called Batch_Example_MSAccess which looks like this:-
This DSN is used by Cicode to connect to the Access database. For the linked SQL tables to
function correctly in Cicode, the batch passwords are saved with the links.
Access can also be used as a reporting tool for data stored in SQL Server.
In the Access database, ODBC links (using the DSN Batch_Example) to public views in the
Batch database are accessed by Queries in Access to move data for the current Batch into
SQL tables. The Access Queries are called from Cicode using the Batch_Example_MSAccess
DSN.
Continuous Batches Light. When this light is green any batch (Control Recipe) that is loaded
by the Batch Scheduler will start automatically when the Batch Scheduler status becomes In
Progress and the Control Recipe status is idle. If a large number of recipes have been
scheduled, they will run automatically one after the other. The light can be toggled on and off
by clicking on iy.
Schedule Order. This button calls some Cicode that displays list of Process Orders. If a
Process Order is sleeted and the OK button is clicked, all Control Recipes in the Process
Order that are either Not Assigned or Assigned are Released. The first batch in the list
should start automatically all others will become Scheduled and should execute in turn.
Using this button avoids having to Transfer (Recipe Editor) and Release (Batch Scheduler)
every batch (Control Recipe) that has been generated for a Process Order.
Unschedule Order. This button can be used to unscheduled batches by Process Order. All
batches for the selected Process Order that are Scheduled are changed to Assigned.
Start Batch. This button can be used when the Continuous Batches Light is turned off to start
a batch from the Citect page. It is assumed that the next batch to be run has been loaded by
the Batch Scheduler and the the status is In Progress (idle).
The Batch Engine spends most of its waiting for Transitions to occur but in the example show
above it is waiting on two Phases. This is because Chocolate Milk Phase is waiting to gain
access to a Pipe.
The next picture shows the normal situation where the Batch Engine is waiting on a
Transition. Note that Transition steps are indicated by (T).
Another reason that a batch might become stuck on a Phase is if a Tag that it is trying to write
to or read from does not exist. This is not likely to happen in Batch Example but it can happen
on a new project. See also comments on checking the Control Recipe Overview
The last reason that a batch can become stuck on a Phase is if a Pipe that the Phase is trying
to acquire has been left busy from a previous batch. Later in this document the resetting of a
locked Pipe is discussed.
If you select a Transition you can monitor the transition condition and it will change to green
when it becomes true, see next page.
Notice also that there is a tool tip on each variable in the expression indicating which
Parameter is used to obtain the value.
To sum up, there are three common reasons for a batch becoming stuck..
1. The Material in Tank 2 is not correct for the Recipe being executed. It could be a
Chocolate Milk Recipe with strawberry flavour in Tank 2 for example.
2. One of the Tags assigned to parameters for a Unit may be invalid.
3. The Phase might be trying to reserve a Pipe that has been left busy by a previous
batch.
Lastly double click on the busy Pipe and click Yes free it. If the Pipe appears more than once
in the list, it doesnt matter which one you double click.
Notice that the scaled Material quantities are shown and the Tags that will be used for each
parameter are listed. If there is problem getting a Recipe to work for the first time, it can be
very useful to print out this report and check that Tags are correct etc.