Professional Documents
Culture Documents
PLC User Manual
PLC User Manual
PLC User Manual
Ministry of OIL
CONTENT:
1. LIST OF ABBREVIATIONS.............................................................3
2. INTRODUCTION ……………………………………………………………….4
3. PLC...................................................................................................5
3.1 HARDWARE.....................................................................................5
3.2 SOFTWARE......................................................................................5
4. PLC SOFTWARE.............................................................................7
4.1 RTOS...........................................................................................7
4.1.1 RTOS INSTALLATION.........................................................9
4.1.2 OFFLINE CONFIGURATION................................................11
4.1.2.1 IDS EDITOR...................................................................11
4.1.2.2 CFG FILE BUILDER......................................................13
4.1.3 STARTUP SEQUENCE.......................................................16
4.1.4 ONLINE CONTROL...........................................................17
4.2 LOGIC........................................................................................27
4.2.1 ONLINE CONTROL...........................................................28
4.2.2 TASK CONFIGURATION.....................................................33
4.2.3 GLOBAL VARIABLES.........................................................34
4.2.4 NAMING CONVENTION.....................................................35
4.2.5 EXPORTED VARIABLES....................................................36
4.2.5.1 INPUTS...........................................................36
4.2.5.2 OUTPUTS.......................................................39
4.2.6 STARTUP SEQENCE..........................................................42
4.2.7 ADAPTATION PROCEDURE................................................43
5. Redundancy and WDT……………………………………..…………45
6. LOGIC Building Block…………………………………..…….………47
7. Library…………..……………………………………………….………50
1. LIST OF ABBREVIATIONS
LIST OF ABBREVIATIONS
Abbreviation Description
AH Alarm High
AHH Alarm High-High
AL Alarm Low
ALL Alarm Low-Low
ARG Argument
BAD Bad Value
SBC Single Board Computer
DB Database
DBAND Dead Band
DOM Disk On Module
HHSP High-High Alarm Set Point
HMI Human Machine Interface
HSP High Alarm Set Point
HYS High Alarm Hysterias Set Point
IP Internet Protocol
IRQ Interrupt Request
LAN Local Area Network
LLSP Low-Low Alarm Set Point
LSP Low Alarm Set Point
LYS Low Alarm Hysterias Set Point
MINV Minimum Value
MSP Manual Set Point
OLE Object Linking Embedding
OPC OLE for Process Control
PCI Peripheral Component Interconnect
PLC Programmable Logic Control
POU Program Organization Unit
PV Process Value
RB Read Back
RSP Remote Set Point
SP Set Point
SRAT Scan Rate
TOL Tolerance
TSPAN Time Span
TSTEP Time Step
WDT Watch Dog Timer
NW Network
2. Introduction
PCS (Process Control System) is a PC-Based open architecture
system. The standard I386 and compatible PCs are the main hardware
components of the system. The system hardware as well as the software
layers is shown in Fig.2.1. This document is the users manual for project
engineers to use PCS.
Workstation PLC
HMI DB DALOGIC
LAN/RS232
3. PLC
3.1. Hardware:
PLC hardware components are:
1-Cabinet with dimensions (H-W-D) = (2250-600-680mm).
2-24Vdc supplies for field signals.
3-Terminal blocks for field signal wire termination.
4-Terminal Modules for IO card D-Type connector’s termination.
Also, any necessary signal conversion and protection is
implemented in these modules.
5-PLC case that contain the following:
3.2. Software:
Two applications RTOS and DALOGIC are running in PLC. The
main features of these programs are summarized below; and a
detailed description is given in chapter-4.
A- RTOS:
RTOS is an application written in C-language and designed to
run under I386 or compatible systems. This version of RTOS
provides the following features:
1. PCI card detection and configuration; using standard format
configuration files.
2. During PLC startup the system can detect and annunciate
configuration errors.
3. At run time the system can detect and annunciate all
addressing “and configuration” errors.
4. The system supports hardware dual redundant PLC.
5. The system supports a programmable WDT.
B- DALOGIC:
DALOGIC is a skeleton CoDeSys program that can utilize the
services provided by RTOS and provide a well-defined
interface for HMI programs. DALOGIC provides the following
features:
1.DALOGIC utilizes the interfaces and capabilities of RTOS.
2.DALOGIC defines standard interfaces to be used by HMI
and database management programs.
3.DALOGIC minimizes the symbol file size to improve the
efficiency of the HMI and database management program.
4.DALOGIC uses grouping and ordering of program
components to make the program more readable and
manageable.
4.1 RTOS:
In order to use RTOS properly you must know how to configure it
offline and how to read or possibly change its setting online. First of
all, you must know the following about PLC and RTOS:
Table (4.1)
Signal Formula Base Address Range
DI (DIMAX/8)*SLOTMAX 0 0.0→135.7
DO (DOMAX/8)*SLOTMAX 0 0.0→135.7
AI 32+(AIMAX*SLOTMAX) 250 250→825
AO 32+(AOMAX*SLOTMAX) 250 250→383
10. RTOS will scan the PCI bus during its startup to build the file
AUTO.PCI in which you will find a list of all the cards that are
defined for RTOS, that is, the cards that has device drivers. For
each card there is one structure as the one below:
struct stAutoPCI
{
DWORD Vid;
DWORD Did;
WORD BusNo;
WORD SlotNo;
};
11. RTOS will use the first card that support NW function in
AUTO.PCI file as the default LAN card. Also, it will use
{100.100.100.100} as the default gateway IP address, and
{100.100.100.101} as the default PLC IP address. This address can
be used to communicate with the PLC in case the CFG file is
missing.
12. The specifications of the logic program that can be loaded and
executed by RTOS are:
C-Builder
BOOTDISK.EXE
Real Time
DA2000.EXE RTLoc.EXE Binary
Format
DA2000.RTB
1. Single primary DOS partition (C:) that utilizes all the DOM space
(8MB).
2. FAT12 format with drive labeled DA2000.
3. In drive C: the basic files are:
DA2000.RTA: Real time application.
DA2000.RTB: Real time binary file can be used to reinstall
RTOS.
BOOTDISK.EXE: DOS executable file used to install the RTB file
as RTA application.
HMSRBOOT: DOS executable file used to restart the PLC when
started in DOS mode.
To do offline installation of RTOS on the DOM of the PLC for the first
time you must use FDISK to create one primary DOS partition that
utilize all the available space and make it active. After that you must
restart the PLC using the DAFORMAT disk. DAFORMAT disk will
automatically format the DOM using FAT12 and copy all the necessary
executables and files and then install RTOS. DAFORMAT indicates its
completion with three beeps. Assuming the DOM is already partitioned
you can use DAFORMAT any number of times to reinstall RTOS or
installing new version without need to use FDISK.
To do online installation of RTOS on the DOM you must have RTOS
running on the PLC and then log into the PLC using DALOGIC program.
From the “OnLine” menu select “Write File to PLC”, to transfer the file
DA2000.RTB to the PLC. After that you can reinstall DARTOS using
online command interface, as you will see later.
Table- (4.2)
Card Type Card Configuration Point
Configuration
1711/1713 AI F0= Control Register (BASE*+6) P0=Gain (BASE+2)
/1731 F1= Settle Time
AX5020P AI F0= Operating Mode** Only C2 is used
F1= Control Word (BASE+2) because all points
F2= Card Gain (BASE+1) are assumed to
F3= Last Channel in MUX in low have the same
order nibble range.
Last channel in AI card in
high order nibble
1711 AO F0= Control Register (BASE+14)
1720 AO F0= Control Register (BASE+8)
F1= Synchronized output
(BASE+15)
Fx=Function Configuration Byte Number x
Px=Point Configuration Byte Number x
*BASE= The card IO space BASE address refer to the card user manual
**Operating Mode=
0 Single Direct
1 Single Indirect
2 MUX Direct
3 MUX Indirect
Detailed information and error messages (if any) are displayed during
the startup sequence. The user interaction with RTOS is defined as
follow:
1. The user can press “S” to skip the CFG file; this is useful if there
is a fatal error in the CFG file that may cause a system crash.
Notice that RTOS will skip the CFG file only if the default LAN
card is already detected and configured.
2. The user can press “E” to instruct RTOS to stop at all error
messages; this is useful in debugging and solving configuration
error.
3. The user can press “M” to instruct RTOS to stop at all error and
information messages; this is useful to make sure that all the IO
cards are already defined in the CFG file.
4. In case of fatal errors RTOS will display an error message and
sound an infinite number of periodic beeps until the system is
turned off or restarted. PCI BIOS access failure is an example of
fatal errors. Another example is the configuration file access
failure while the default LAN is not detected, because in this
case there is no way to communicate with the PLC.
5. In case of soft errors RTOS will display error message and
sound two beeps. Vendor and Device ID conflicts are examples
of soft errors. Soft errors are registered in the internal database
of RTOS. As you will see later, you can access RTOS at run time
to read the status word of each configured card.
6. Missing the CFG file while the default LAN card is detected is
considered a soft error, but it will sound three beeps.
7. If the startup completed without errors, the program will sound
one long beep. You must notice that the PLC is normally running
without keyboard or monitor so how do you know if there is an
error or not. Beside you can access RTOS at run time; the beep
is the indication. In general, one beep means every thing is OK,
more than one beep means there is some error.
Inputs:
None.
Outputs:
None.
Inputs:
None.
Outputs:
FAI0250=0/1(Success /Failure).
FAI0251=RTOS master version no.
FAI0252=RTOS minor version no.
FAI0253=DIMAX.
FAI0254=DOMAX.
FAI0255=AIMAX.
FAI0256=AOMAX.
FAI0257=SLOTMAX.
FAI0258=Redundancy Disabled/Primary/Secondary (0/1/2).
FAI0259=Redundancy COM Port.
FAI0260=Redundancy Time Out in milliseconds.
FAI0261=WDT.
FAI0262=Healthy Signal Toggle Limit.
Inputs:
FAO0251=Array Index.
Outputs:
FAI0250=0/1(Success /Failure).
FAI0251=Vendor ID.
FAI0252=Device ID.
FAI0253=Functions.
FAI0254=Bus No.
FAI0255=Slot No.
FAI0256=Base Address.
FAI0257=IRQ Line No.
FAI0258- FAI0259=Status Word.
FAI0260- FAI0263=Card Reserved Data.
The status word is important to know the status of each card as well as
the status of the PLC. Zero value means the status is OK (no errors). The
errors are bit coded and interpreted as follows:
The “Functions” field identifies the number of functions defined for this
card. Zero value means no function is defined. Functions are bit coded as
follows:
Functions:
Bit-0= DI Function.
Bit-1= DO Function.
Bit-2= AI Function.
Bit-3= AO Function.
Bit-4= NW Function.
Inputs:
None.
Outputs:
FAI0250=0/1(Success /Failure).
Outputs:
FAI0250=0/1(Success /Failure).
Outputs:
FAI0250=0/1(Success /Failure).
Inputs:
FAO0251=6 Command confirm.
Outputs:
FAI0250=0/1(Success /Failure).
Inputs:
FAO0251=7 Command confirm.
Outputs:
FAI0250=0/1(Success /Failure).
Inputs:
FAO0251=8 Command confirm.
Outputs:
FAI0250=0/1(Success /Failure).
Inputs:
FAO0251=9 Command confirm.
Outputs:
FAI0250=0/1(Success /Failure).
Inputs:
FAO0251=Card VendorID.
FAO0252=Card DeviceID.
Outputs:
FAI0250=0/1(Success /Failure).
FAI0251=Functions supported, zero means not implemented, else
it is bit coded as Follows:
Bit-0=DI.
Bit-1=DO.
Bit-2=AI.
Bit-3=AO.
Bit-4=NW.
Inputs:
FAO0251=Point Type (0=DI, 1=DO, 2=AI, 3=AO).
FAO0252=Point Address; For DIO this is the byte part of the ‘AT’
address because RTOS deals with bytes only. For AIO
this the ‘AT’ addresses.
Outputs:
FAI0250=0/1(Success /Failure).
FAI0251=Range (1=OK, 2=Under range, 4=Over range).
FAI0252=Card (0= No physical card, 1=Interface Control Point,
>1= Card Index+2).
Outputs:
FAI0250=0/1(Success /Failure).
Inputs:
FAO0251=Number of arrays.
FAO0252, 253=Address of Array 0.
FAO0254 =Size of Array 0.
Outputs:
FAI0250=0/1(Success /Failure).
Inputs:
FAO0251= File Index.
FAO0252-FAO0253= Buffer Address.
FAO0254= Count.
FAO0280=1 Just send failure reply.
Outputs:
FAI0250=0/1(Success /Failure).
Inputs:
FAO0251= File Index.
FAO0252-FAO0253= Buffer Address.
FAO0254= Count.
FAO0280=1 Just send failure reply.
Outputs:
FAI0250=0/1(Success /Failure).
Outputs:
FAI0250=0/1(Success /Failure).
4.2 DALOGIC:
DALOGIC is the part of system that performs the logic function. It is
built up on and utilizes the services provided by RTOS, also it must
provide services to be used by HMI. Just like RTOS, DALOGIC put
some limits and rules for the programmers to avoid interfacing errors
and optimize the code and data size. Tabel-4.2 below summarizes the
definition of the CoDeSys IO address space. Notice that the address
space is divided into two ranges. The DI/O range is 2000 points
starting from 0, while the AI/O range is 2000 points starting from 250.
This is because analog and digital points of the same type (input or
output) will reference the same memory segment; hence they cannot
share the same address. For example, you cannot define AI0 and DI0
as follow:
AI0 AT %IW0: WORD;
DI0 AT %IX0.0: BOOL;
Table- (4.3)
Signal Base Range Reserved Add User Add
DI 0 0.0→249.7 0.0→3.7 4.0→249.7
DO 0 0.0→249.7 0.0→3.7 4.0→249.7
AI 250 0→1999 250→281 282→2249
AO 250 0→1999 250→281 282→2249
You must not forget that RTOS puts another range limit
derived from PLC hardware specification.
Command
Reply CAOAR
Command
HMICommand COMMANDER Processor
CAIAR
FAI0250
MAPCAI FAI0281
2. The COMMANDER will decode the string and map it like this:
CAOAR [0]=’ccccc’
CAOAR [1]=’aaaaa’
CAOAR [2]=’rrrrr’
CAOAR [3]=’ggggg’
CAOAR [31]=’ccccc’
Inputs:
None.
Outputs:
HMIWIN [0]=Last Command Code.
Inputs:
See RTOS22 commands.
Outputs:
HMIWIN [0]=Command Code/0 (Success/Failure).
See RTOS22 commands
Inputs:
Outputs:
HMIWIN [0]=20/0 (Success/Failure).
Inputs:
Outputs:
HMIWIN [0]=21/0 (Success/Failure).
Inputs:
ARG1=Array Index, this index must be greater than 0 because
index 0 is reserved.
Outputs:
HMIWIN [0]=22/0 (Success/Failure).
Inputs:
ARG1=Array Index, this index must be greater than 0 because
index 0 is reserved.
Outputs:
HMIWIN [0]=23/0 (Success/Failure).
Inputs:
ARG1=Array Index.
ARG2=Bytes Index.
ARG3=Byte Count (MAX=54).
Outputs:
HMIWIN [0]=50/0 (Success/Failure).
CAIAR [1-27]=Data Bytes.
1. DI: Name=FDIABCD
‘ABC’ is the byte field of the ‘AT’ address while ‘D’ is the bit field of the
‘AT’ address.
Examples:
FDI0000 AT %IX0.0: BOOL;
FDI0011 AT %IX1.1: BOOL;
FDI0047 AT %IX4.7: BOOL;
FDI2497 AT %IX249.7: BOOL;(*ABC=249, D=7*)
2. DO: Name=FDOABCD
‘ABC’ is the byte field of the ‘AT’ address while ‘D’ is the bit field of
the ‘AT’ address.
Examples:
FDO0007 AT %QX0.7: BOOL;
FDO0024 AT %QX2.4: BOOL;
FDO0053 AT %QX5.3: BOOL;(*ABC=005, D=3*)
FDO2497 AT %QX249.7: BOOL;
3. AI: Name=FAIABCD
‘ABCD’ is the ‘AT’ address.
Examples:
FAI0250 AT %IW250: WORD;
FAI0281 AT %IW281: WORD;
FAI0282 AT %IW282: WORD;(*ABCD=0282*)
4. AO: Name=FAOABCD
‘ABCD’ is the ‘AT’ address.
Examples:
FAO0250 AT %QW250: WORD;
FAO0281 AT %QW281: WORD;(*ABCD=0281*)
FAO0282 AT %QW282: WORD;
4.2.5.1 Inputs:
These variables carry control commands and data such as alarm
setting and set points from the workstation to the PLC. It is clear
that the workstation will rarely need to read back these variables.
Therefore, there is no need to export all these variables; we just
need a connection with them. DALOGIC defines this type of
variables grouped in arrays and uses the command interface to
access them. Therefore, only HMICommand string is exported. You
can read/write any entry in these arrays using command 50/51
shown above. As you have seen above, in order to read, write,
load, or save any array you must know the array index.Table-4.4
below summarizes the input arrays defined by DALOGIC and a
brief description of each array follows:
1. CAOAR: Control AO Array, it is used to carry command codes
and arguments to RTOS. It is internally connected to FAO0250-
FAO0281. The array index is 0, however, you cannot save this
array to disk.
2. HMIBCL: This array used for Boolean commands such as
start/stop command. The contents of this array can be saved to
file and loaded during PLC startup.
3. HMIWCL: This array used for integer commands such as
selection command. The contents of this array can be saved to
file and loaded during PLC startup.
PLC Software
Package
Table- (4.4)
Array Element Type Array Index File
CAOAR WORD 0 No
HMIBCL BOOL 1 Yes
4.2.5.2 Outputs:
These variables carry information from the PLC to the workstation.
Here is the bulk number of exported variables. Beside the command
interface string and field signals the user may export some indication
variables that are the result of mathematical or logical calculations
performed by the PLC. In what follows we will summarize these
variables and describes the techniques used to minimize the number
of these variables.
7. Build your logic, log into the PLC, and run the program.
9. Using HMI code, download the default settings of AI, APID, …etc.
into the program arrays.
10.Using HMI code, save the arrays into disk files using command 22
and the array index shown in Table-4.4.
11.Logout the program and go to FILLCMNDQUEUE program to enable
default setting loading.
12.Rebuild, download, and run your program. HMIBIN [0,1,2] and must
be equal to zero after running the program.
Building Blocks
6. Building Blocks
Table- (6.1)
AUTO REMOTE Mode OUT PID SP
0 0 Manual Mode MSP PV
1 0 Auto local PID output LSP
1 1 Auto Remote PID output RSP
Building Blocks
2.DPID: This function block can be used to control devices that expect
increase/decrease signal from the controller. All settings are
taken from the array HMIDPIDSETTING [INDX] whose internal
structure is shown above. All DPIDs are connected to command
7 in the command queue and will be active only if the state value
of this command is TRUE. This block operates in five modes and
uses coded set point input.
Building Blocks
NOTE2: The controller will automatically clear the mode part of the set
point and save the active mode code in the SP value part.
Library
7. Library
The library DALIB supports DALOGIC. It contains few function blocks that
are needed to complete the scenario. In this library you will find.
1- AIDMUX16:
Library
2- SWITCH:
This is a four-way selector switch. The active way is selected by the
value of the input ‘K’.
Library
Library