PLC User Manual

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 54

Ministry of Industry & Minerals

General Systems Company


Bld. 30 St. 46 Sec. 906 Al-Wihda Quart - Baghdad - IRAQ
Tel: 7188961 - 7182798 - 7189235 - Fax: 7187017
P.O. 6550 Al-Mansur Post Office 21605 Baghdad-Iraq
e-mail: esc@uruklink.net

Ministry of OIL

NORTH OIL COMPANY

Wet Crude Oil Project


PLC User Manual
Ref. No.: GSC/ONOC/ PLC User/ENG/005

Releasing Date: 2003


GSC
CONTENT

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

PLC User Manual 2 of 54


GSC
LIST OF ABBREVIATIONS

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

PLC User Manual 3 of 54


GSC
Introduction

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

OPC Server RTOS

Gateway Server Hardware

LAN/RS232

Fig. (2.1): Process Control System

PLC User Manual 4 of 54


GSC
PLC

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:

 Two “dual-redundant” 300W power supplies.


 3.5 inch floppy disk drive.
 (PCA-6116P17 REV: A1.10) PCI back plane that contains
17-PCI slots and 2-CPU slots.
 (PCA-6166 Rev.A1) SBC (Single Board Computer) Card
contains: 64MB RAM, 8MB DOM (Disk On Module),
Keyboard interface, monitor interface, RS232 interface, LAN
interface.
 (D-LINK 10Mb/s) fast Ethernet card.
 IO Cards.

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.

PLC User Manual 5 of 54


GSC
PLC
6. The system can be accessed by logic application to retrieve
or save some useful information or to change some setting
or variables.
7. The system provides an easy to upgrade device driver
skeleton.

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.

PLC User Manual 6 of 54


GSC
PLC Software Package

4. PLC Software Package

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:

1. Total number of PCI-bus slots is 17-Slot (SLOTMAX=17).


2. Two slots are reserved for LAN cards and one slot is reserved for
the DIO card that control redundancy and LED display.
3. Fourteen slots can be used for field I/O signals.
4. Maximum number of DI points per card: DIMAX=64.
5. Maximum number of DO points per card: DOMAX=64.
6. Maximum number of AI points per card: AIMAX=32.
7. Maximum number of AO points per card: AOMAX=6.
8. RTOS considers each 8-DIO points as one point.
9. RTOS field address limits are shown in Table-3.1. Exceeding these
limits will cause an OUTOFRANGE error to be registered.

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;
};

PLC User Manual 7 of 54


GSC
PLC Software Package

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:

 Maximum Code Size=2MB.


 Maximum Data Size=1MB.
 Maximum Input Size=32KB.
 Maximum Output Size=32KB.
 Maximum Memory Size=32KB.
 Maximum Retain Size=64KB.

PLC User Manual 8 of 54


GSC
PLC Software Package

4.1.1 RTOS Installation:


RTOS is specifically the application DA2000.RTA that is installed
on the DOM of PLC. It is self-booting and includes all necessary code
to run like a standard PC operating system. DA2000.RTA generation
is shown in Fig-4.1 below.

C Source Code Configuration Real Time


X.C + X.H File Application
X.CFG DA2000.RTA

C-Builder
BOOTDISK.EXE

Real Time
DA2000.EXE RTLoc.EXE Binary
Format
DA2000.RTB

Fig. (4.1): RTA File Generation

PLC DOM contents and properties are summarized below:

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.

PLC User Manual 9 of 54


GSC
PLC Software Package

 YES.TXT: Text file that answer LOCK command and BOOTDISK


question with Yes.
 *.CFG: DARTOS Configuration File.
 *.HMS: DALOGIC default setting files. After downloading and
running DALOGIC it will save the settings into a group of files
named as (Findex.HMS) where (index=file index number).
F1.HMS and F2.HMS are examples of those files.

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.

PLC User Manual 10 of 54


GSC
PLC Software Package

4.1.2 Offline Configuration:


DARTOS is supported with a configuration program “DAPLCCFG”
written in VB language. With this program you can configure the
I/O cards, change or upgrade the vendors and device ID files,
configure redundancy and WDT, and change the configuration
program settings. DAPLCCFG uses two forms, the “IDS File
Editor” and “PLC Configuration File Builder” that are shown below.

4.1.2.1 IDS File Editor:


The IDS File Editor is used to create or modify the IDS file
“DA2000.IDS”. This file represents the database that contains the
specifications of each card supported by RTOS. According to the
PCI standard, two numbers, the VendorID and DeviceID, identify
each card on the PCI bus. The VendorID is a universally unique
number specified by PCI standardization committee. The vendors
specify a unique device ID for each card. The IDS editor identify
each card by the following specifications:
1. Vendor Name: User-defined string describing a specific
manufacturing company.
2. Vendor ID: Universally unique number identifying a specific
manufacturer.
3. Device Name: User defined string describing a specific card.
4. Device ID: Manufacturer specified unique number identifying
a specific card.
5. DI: Number of DI channels in the card.
6. DO: Number of DO channels in the card.
7. AI: Number of AI channels in the card.
8. AO: Number of AO channels in the card.
9. NW: For network (e.g. LAN) cards, NW represents number of
IP addresses needed to communicate with the card.
Typically, the function configuration bytes are used as the
PLC IP address, and one point (NW=1) is defined as the
gateway IP address.
10. You can save default setting for functions and points by using
the button “Set Fun. Defaults” and the button “Set Pnt.
Defaults” respectively. These values will be loaded
automatically when adding a new card.

PLC User Manual 11 of 54


GSC
PLC Software Package

PLC User Manual 12 of 54


GSC
PLC Software Package

4.1.2.2 PLC Configuration File Builder:


This form is used to define and configure each IO or network card
plugged in the PLC. The card is a hardware device plugged in the
bus slot. The function is an I/O function (DI, DO, AI, or AO) or
network function (NW) defined in the card. One card can include
up to four different functions.

You can define a new card manually as follows:


1. Select vendor, device, bus number, and slot number from
the “Card Configuration” group box. The program will
automatically enable all the functions that are available in
this card.
2. Click the functions that you want to use in the “Card
Configuration” group box. The program will automatically
use number of channels specified in the IDS file as the
span.
3. Click “Add” to add the card to the card list. The program
will automatically check the validity of the card PCI address
(BusNo, SlotNo). The “Function Configuration” group box
will be enabled. Also, the functions selected in the “Card
Configuration” group box will appear enabled in the
“Function Configuration” group box.
4. Click on function in the “Function Configuration” group box,
in order to configure it.
5. Configure the selected function by setting the function
global configurations and the IO base address, and then
click “SetF”. You can also rely on the default function
settings that are loaded from the IDS file automatically
when add a new card or function, or loaded manually using
“LoadF”.
6. Select point or points from the “Point List” in order to
configure it.
7. Configure the selected points by setting the point
configuration and then click “SetP”. Again you can rely on
the default settings that are loaded from the IDS file
automatically for all points when add a new card or
function, or loaded manually using “LoadP”.
8. Use “BrowseCFG” to specify the CFG file name and
location. Click “SaveCFG” to save the CFG file.

PLC User Manual 13 of 54


GSC
PLC Software Package
However, you can use the automated function of the program to
simplify the process of card definition. You can use “AutoPCI” to
open the “AUTO.PCI” file generated by the PLC and automatically
specifying the vendor, device, bus, and slot number for each card.
This function will select all the available functions in the card
automatically. You can uncheck the undesired functions and then
click “ReDefine” to remove it from the CFG file. The IO base
address can be automated by selecting “Auto” using the
“Addressing Mode” button. The default setting for each function
and point will be automatically loaded from the IDS database, you
can change these defaults by using “SetF” and “SetP” as shown
above.

The role of the configuration program and RTOS is just passing


the configuration data from the end user to the device driver.
Therefore, the interpretation of this configuration data is card
dependent. For the time being the following configurations are
defined:
1. Function configuration includes all the configurations that
are common to all the points in the function.
2. Point configuration includes a point specific configuration.
3. For all digital cards both function configuration and point
configuration are not used so that they can be filled with
zeros.
4. For all LAN cards only one point is defined and the function
configuration bytes will be used as the PLC IP address,
while the point configuration bytes will be used as the
gateway IP address.
5. The following AI/O cards define the following configurations.

PLC User Manual 14 of 54


GSC
PLC Software Package

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

PLC User Manual 15 of 54


GSC
PLC Software Package

4.1.3 Startup Sequence:


During its startup RTOS will perform three main tasks:
 Scanning the PCI bus and creating the AUTO.PCI file.
 Initializing the default LAN card, if any, to the default IP
address: PLC IP={100.100.100.101} and Gateway
IP={100.100.100.100}
 Opening the CFG file to apply user defined configuration.

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.

PLC User Manual 16 of 54


GSC
PLC Software Package

4.1.4 Online Control:


In online mode when RTOS is running in the PLC it defines an interface
by which the CoDeSys programs can control and monitor the operation
of the RTOS in the PLC. The interface is defined as follows:
1. The first 32-AI/O points are reserved for the interface. These points
(250→281) must be defined and referenced in the CoDeSys program.
2. DARTOS receives the command codes and arguments in the AO
points and return the data in the AI points.
3. All command codes are sent in FAO0250 and FAO0281. Receiving
the command code in FAI0281 means that the command was
executed. Notice that the command will be executed if and only if
FAO0250=FAO0281.
4. FAI0250 is the successful/failure flag of command execution. Zero
means the command was executed successfully, any other value
means failure.
5. FAO0280 is the “Reply With Error” flag, if set, RTOS will set FAI0250
to 1 and return immediately.
6. FAI0280 is the PLC healthy signal and will toggle its value between 0
and 1 periodically every “UpdateHealthy” cycles.
7. The command codes 0-49 are RTOS commands, any code greater
than 49 is assumed to be directed from HMI to CODESYS, in this
case RTOS will just copy the data from FAOs to FAIs. However, the
RTOS commands are also divided into direct commands (0-19) and
preprocessed (e.g. by CoDeSys) commands (20-49).
8. RTOS reserve the first 32-DIO points for redundancy and controls and
they are used as follows:
 FDI0000: My State=(0/1) Not Active/Active.
 FDI0001: His State=(0/1) Faulty/Healthy
 FDI0002: Join Commands=(0/1) Not Executed/Executed.
 FDI0003: Logic programs on PLC=(0/1) Stop/Running.
 FDO0000: My State active high output.
 FDO0001: My healthy periodic output.

PLC User Manual 17 of 54


GSC
PLC Software Package
The following commands are defined by RTOS. The commands are sorted
according to the code number.

Code-0: Latch Last Command Data


Description:
Keep last contents of FAIs unchanged. It is preferred if you send
this code after the execution of each command.

Inputs:
None.

Outputs:
None.

Code-1: Read RTOS Constants


Description:
This direct command return the internal setting and constants of
RTOS so that you know what’s the system is capable of.

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.

PLC User Manual 18 of 54


GSC
PLC Software Package
Code-2: Read Card Information
Description:
During startup RTOS will save configuration and status
information about each card in an internal array. The first two entries in
this array are reserved for PLC status word (Index-0) and interface
control functions (Index-1), hence, your IO cards indexing will start at 2.

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:

PLC Status Word:


Bit-0= DI Address out of Range.
Bit-1= DO Address out of range.
Bit-2= AI Address out of range.
Bit-3= AO Address out of range.
Bit-4= DI No Physical Card.
Bit-5= DO No Physical Card.
Bit-6= AI No Physical Card.
Bit-7= AO No Physical Card.
Bit-8= No IO cards are defined in the configuration file.
Bit-9= No CFG File Found.
Bit-10= No AUTO.PCI Created.
Bit-11= Unknown Error.

PLC User Manual 19 of 54


GSC
PLC Software Package
Card Status Word:
Bit-0= DI Address out of Range.
Bit-1= DO Address out of range.
Bit-2= AI Address out of range.
Bit-3= AO Address out of range.
Bit-4=VendorID Conflict.
Bit-5= DeviceID Conflict.
Bit-6=Unknown VendorID.
Bit-7=Unknown DeviceID.
Bit-8=Card Configuration Error.
Bit-9=Point Configuration Error.
Bit-10= DI unsupported.
Bit-11= DO unsupported.
Bit-12= AI unsupported.
Bit-13= AO unsupported.
Bit-14= DI Address reused.
Bit-15= DO Address reused.
Bit-16= AI Address reused.
Bit-17=AO Address reused.
Bit-18=Time out error.
Bit-19= Unknown Error.

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.

Code-3: Clear PLC Status


Description:
After fixing errors, you can use this command to make sure that
the error was fixed properly.

Inputs:
None.

Outputs:
FAI0250=0/1(Success /Failure).

PLC User Manual 20 of 54


GSC
PLC Software Package
Code-4: Send Byte to Card Reserved Array
Description:
8-Bytes are reserved by RTOS for each card to be used by the
card device drivers. However, the interpretation of these bytes is card
dependent. The end user can change these bytes to fine tune or
dynamically control the operation of the device driver. For the time being
only the following cards utilizes these bytes:
 PCI-1711/1713/1731 Analog Input: These cards use
CardRes [1] to save the settle time.
 AX5020P Analog Input: This card uses CardRes bytes as
follows:

 CardRes [0]=Operating Mode.


 CardRes [1]=Control Word.
 CardRes [2]= Channel Gain
 CardRes [3]= Last Channel in Converter to scan
 CardRes [4]= Last Channel in AI Card to scan
 CardRes [5]= Converter Channel Counter
 CardRes [6]= AI Card Channel Counter
 CardRes [7]= Skip Cycle Flag
Inputs:
FAO0251=Array Index of card see Code-2.
FAO0252=Byte number (0-7).
FAO0253=Value.

Outputs:
FAI0250=0/1(Success /Failure).

Code-5: Reinstall RTOS


Description:
After downloading a new RTB file into the PLC you can use this
command to reinstall RTOS assuming that the DOM is formatted using
DAFORMAT disk. Notice that this command will be executed if and only
if the following exists in the DOM:
 AUTOEXEC.BAT.
 BOOTDISK.EXE.
 HMSREBOOT.EXE.
 *.RTB.
 BOOTSECT.RTT.

All the files above are installed by DAFORMAT disk.

PLC User Manual 21 of 54


GSC
PLC Software Package
Inputs:
FAO0251=5 Command confirm.

Outputs:
FAI0250=0/1(Success /Failure).

Code-6: Delete CFG File


Description:
This command will delete all the CFG files in the PLC. It is
important to delete the old CFG files before downloading a new CFG file
with new name on line.

Inputs:
FAO0251=6 Command confirm.

Outputs:
FAI0250=0/1(Success /Failure).

Code-7: Switch to Secondary State


Description:
When redundancy is enabled and both PLCs are healthy, you can
instruct the primary PLC to be the secondary one with this command.

Inputs:
FAO0251=7 Command confirm.

Outputs:
FAI0250=0/1(Success /Failure).

Code-8: Restart PLC


Description:
This command might be needed after downloading new
configuration file.

Inputs:
FAO0251=8 Command confirm.

Outputs:
FAI0250=0/1(Success /Failure).

PLC User Manual 22 of 54


GSC
PLC Software Package
Code-9: Stop WDT Update
Description:
You may need this command to make sure the WDT is functioning
properly. This command will instruct RTOS to stop updating the WDT
and hence restarting the PLC.

Inputs:
FAO0251=9 Command confirm.

Outputs:
FAI0250=0/1(Success /Failure).

Code-10: Check Device Driver


Description:
RTOS uses special device drivers to access IO card. With this
command you can know whether or not the device driver of a specific
card is implemented and which IO functions it supports.

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.

PLC User Manual 23 of 54


GSC
PLC Software Package
Code-11: Check Point Address
Description:
Some times the point defined in CODESYS has a wrong address.
You can use this command to know whether the point address is correct
or not.

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).

Code-12: Change Healthy Signal Toggle Limit


Description:
This signal is directed to the workstation so that it knows when the
PLC is off. By default this signal is toggled every 50 cycles.
Inputs:
FAO0251=Number of Cycles.
Outputs:
FAI0250=0/1(Success /Failure).

Code-13: Delete CoDeSys Files from PLC.


Description:
This command will delete all files created by CoDeSys from the
PLC.
Inputs:
FAO0251=13 command confirm
Outputs:
FAI0250=0/1(Success /Failure).

Code-14-19: Are reserved as spare for direct RTOS commands


Description:
Inputs:
Outputs:
FAI0250=0/1(Success /Failure).

PLC User Manual 24 of 54


GSC
PLC Software Package
Code-20: Join Command-1
Description:
This is a preprocessed command that send the address of the
array HMIBIN as well as the address and size of the arrays HMIFDI and
HMIFDO to RTOS. These addresses will be used to update these arrays
directly from RTOS with the new values of field signals. This command
is automatically executed by CoDeSys system code each time a new
project is downloaded or changed online.
Inputs:
FAO0251, 252= HMIBIN Address.
FAO0253, 254= HMIFDI Address.
FAO0255 = HMIFDI Size.
FAO0256, 257= HMIFDO Address
FAO0258 = HMIFDO Size.

Outputs:
FAI0250=0/1(Success /Failure).

Code-21: Join Command-2


Description:
This is a preprocessed command that send the address and size
of the array HMIFAO as well as the address and size of the control and
setting arrays that are defined in the CoDeSys system to RTOS. These
addresses will be used to transfer the contents of these arrays between
the primary and secondary PLC if redundancy is enabled. This
command is automatically executed by CoDeSys system code each
time a new project is downloaded or changed online.

Inputs:
FAO0251=Number of arrays.
FAO0252, 253=Address of Array 0.
FAO0254 =Size of Array 0.

FAO0N, N+1=Address of Array FAO0251-1.


FAO0N+2 =Size of Array FAO0251-1.

Outputs:
FAI0250=0/1(Success /Failure).

PLC User Manual 25 of 54


GSC
PLC Software Package
Code-22: Load File to Buffer
Description:
This command is used to copy blocks of data from files. It is used
by DALOGIC while loading default values to arrays.

Inputs:
FAO0251= File Index.
FAO0252-FAO0253= Buffer Address.
FAO0254= Count.
FAO0280=1 Just send failure reply.

Outputs:
FAI0250=0/1(Success /Failure).

Code-23: Save Buffer To File.


Description:
This command is used to copy blocks of data to files. It is used by
DALOGIC while saving default array values to files.

Inputs:
FAO0251= File Index.
FAO0252-FAO0253= Buffer Address.
FAO0254= Count.
FAO0280=1 Just send failure reply.

Outputs:
FAI0250=0/1(Success /Failure).

Code-24-49: Reserved For Future Use


Code->49: High Level Commands
Description:
These are directed from CODESYS to HMI. RTOS will just copy
FAOs to FAIs.
Inputs:
FAO0280=1 Just send failure reply.

Outputs:
FAI0250=0/1(Success /Failure).

PLC User Manual 26 of 54


GSC
PLC Software Package

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.

PLC User Manual 27 of 54


GSC
PLC Software Package

4.2.1 Online Control:


DALOGIC can communicate with RTOS through its interface.
However, the original aim of this interface is to allow the engineers to
monitor and control RTOS and the PLC through the operator station.
Therefore, another interface is defined by DALOGIC to make sure that
the operator can send commands to CoDeSys or to RTOS through
CoDeSys. Fig.4.2 describes the command interface between HMI,
DALOGIC, and RTOS.

HMI DALOGIC RTOS

Output MAPCAO FAO0250


Command FAO0281

Command
Reply CAOAR

Command
HMICommand COMMANDER Processor

CAIAR

FAI0250
MAPCAI FAI0281

Fig. (4.2): Command Interface Operation

DALOGIC predefine the code that manages the command interface.


The main code is in the folder SYSTEMCODE\KERNEL. The main FB in
this folder is the COMMANDER, which operates as follows:

PLC User Manual 28 of 54


GSC
PLC Software Package
1. The COMMANDER receives all commands from HMI through the string:
HMICommand: STRING (35): =‘cccccaaaaarrrrrggggguuuuuuuuuuuuu’
Where:
‘ccccc’= Command Code
‘aaaaa’= Argument 1
‘rrrrr’= Argument 2
‘ggggg’= Argument 3
‘uuuuuuuuuuuuu’= Argument 4

Notice that command code and arguments 1,2, and 3 must be


exactly five-character string (e.g. 00001 represent number 1). However,
argument 4 is 13-character and used only with command 51 below.

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’

Also, the COMMANDER will automatically clear the code part of


the string so that the same command will not be executed more than
one time. After that the COMMANDER will wait until receiving the
command code at CAIAR [31].

3. If the command is directed to RTOS the COMMANDER will pass it


directly as shown. If it is directed to the COMMANDER or it needs some
preprocessing, the COMMANDER will do the necessary processing and
then pass the command to RTOS.
4. The FB MAPCAO will map the array CAOAR to FAO0250-FAO0281, so
that, the code and argument will reach RTOS.
5. RTOS will execute the command and return the reply in FAI0250-
FAI0281.
6. The FB MAPCAI will map FAI0250-FAI0281 to the array CAIAR.
7. The COMMANDER will set HMIWIN[0]=’ccccc’, that is, the last executed
command code if the command succeeds or otherwise HMIWIN[0]=0.
8. The commander will automatically send command code-0 to DARTOS
to keep the contents of FAI0250-FAI0281 and hence CAIAR unchanged
until receiving the next command.

PLC User Manual 29 of 54


GSC
PLC Software Package
Notice that CAIAR and CAOAR are defined by the system as follows:
CAIAR: ARRAY [0..31] OF WORD;
CAOAR: ARRAY [0..31] OF WORD;

After this brief description of COMMANDER operation, we can summarize


the command interface rules between HMI and DALOGIC as follows.
1. The COMMANDER must receive all commands from HMI through the
string:
HMICommand: STRING (35): =‘cccccaaaaarrrrrggggguuuuuuuuuuuuu’
2. The command execution time is 0.5 second, hence, HMI must wait for
0.5 second and after that check the condition (HMIWIN [0]=’ccccc’),
which means that the command was executed successfully and the
CAIAR buffer contains valid data. If HMIWIN [0]=0 it means the
command execution fails.

The following commands are defined by DALOGIC. The commands are


sorted according to the code number.

Code-0: Idle Command.


Description:
The COMMANDER is waiting for new command.

Inputs:
None.

Outputs:
HMIWIN [0]=Last Command Code.

Code-1-19: RTOS Direct Commands.


Description:
The command is directed from HMI to RTOS. Copy the arguments
and pass the command directly.

Inputs:
See RTOS22 commands.

Outputs:
HMIWIN [0]=Command Code/0 (Success/Failure).
See RTOS22 commands

PLC User Manual 30 of 54


GSC
PLC Software Package
Code-20: Join Command-1.
Description:
This command is a low level command however it needs
preprocessing by the COMMANDER. The COMMANDER will
automatically determine and send the address of HMIBIN as well as the
address and size of HMIFDI and HMIFDO. This command is
automatically executed by system code each time a new project is
downloaded or changed online.

Inputs:
Outputs:
HMIWIN [0]=20/0 (Success/Failure).

Code-21: Join command-2.


Description:
This command is a low level command however it needs
preprocessing by the COMMANDER. The COMMANDER will
automatically determine and send the address and size of the array
HMIFAO as well as the address and size of the control and setting
arrays that are defined in the CoDeSys system. This command is
automatically executed by CoDeSys system code each time a new
project is downloaded or changed online.

Inputs:
Outputs:
HMIWIN [0]=21/0 (Success/Failure).

Code-22: Load File To Buffer.


Description:
This command is a low level command however it needs
preprocessing by the COMMANDER. The COMMANDER will
automatically determine and send the address of the buffer (array) to
receive data. This command is used to load default setting during
startup.

Inputs:
ARG1=Array Index, this index must be greater than 0 because
index 0 is reserved.

Outputs:
HMIWIN [0]=22/0 (Success/Failure).

PLC User Manual 31 of 54


GSC
PLC Software Package
Code-23: Save Buffer To File.
Description:
This command is a low level command however it needs
preprocessing by the COMMANDER. The COMMANDER will
automatically determine and send the address of the data buffer (array).
This command is used to save default setting.

Inputs:
ARG1=Array Index, this index must be greater than 0 because
index 0 is reserved.

Outputs:
HMIWIN [0]=23/0 (Success/Failure).

Code-50: Read Data Bytes From Array.


Description:
This command will read data bytes from one of the internal arrays.

Inputs:
ARG1=Array Index.
ARG2=Bytes Index.
ARG3=Byte Count (MAX=54).

Outputs:
HMIWIN [0]=50/0 (Success/Failure).
CAIAR [1-27]=Data Bytes.

Code-51: Write Data Value To Array.


Description:
This command will write one data word to one of the internal
arrays.
Inputs:
ARG1=Array Index.
ARG2=Byte Index.
ARG3=Type.
=1 Byte.
=2 Word.
=3 Real.
ARG4=Value.
Outputs:
HMIWIN [0]=51/0 (Success/Failure).

PLC User Manual 32 of 54


GSC
PLC Software Package

4.2.2 Task Configuration:


DALOGIC predefines two tasks, however, you can define more
tasks as necessary, but remember to not change the setting of the
existing tasks:

1. SYSTEMTASK: Priority=1, and loop time=250ms. This task will


call the code that handles the command interfacing. Don’t change
any thing in this code, which is located in the folder
SYSTEMCODE.

2. USERTASK: Priority=2, and loop time is user defined. This is


the task where you can call your logic either directly or through
PLC_PRG POU.

PLC User Manual 33 of 54


GSC
PLC Software Package

4.2.3 Global Variables:


DALOGIC predefines 5-global objects, don’t change these object,
because this has bad effects on the program tracing and readability.
The object name is followed either by the word ‘Exported’ which
means that this object is visible to workstation, or the word ‘Local’
which means that this object is invisible to workstation.

1. Constants_Local: This contains the sizes of all the arrays


defined in DALOGIC. You can change the array size by changing
the associated constant in this object.
2. System_Exported: All exported variables and arrays are
located in this object. Don’t modify or add anything to this object
without permission from the R&D supervisors.
3. System_Local: All global system variables that are not
exported are located in this object. Again, don’t modify or add
anything to this object without permission from the R&D
supervisors.
4. UserField_Local: The user must define all field variables in
this object.
5. UserPrivate_Local: The user can define any other global
variable in this object.

PLC User Manual 34 of 54


GSC
PLC Software Package

4.2.4 Naming Convention:


Field variables naming must follow a standard convention to simplify
the process of signal tracing and bug detection. The suggested
convention is as follows:

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;

PLC User Manual 35 of 54


GSC
PLC Software Package

4.2.5 Exported Variables:


The end user on the workstation need to continuously monitor and
sometimes control the plant, therefore, the workstation programs must
be capable of accessing some variables in the PLC. Those variables
are selectively exported by DALOGIC. Increasing the number of
exported variables has bad affects on the network traffics and the
response of workstation programs. Therefore, DALOGIC must export
exactly the necessary variables, no more no less. Changing the name
and format of the exported variables has bad effects on the database
management programs. Therefore, we must come with a standard to
avoid the problems above. The suggested standard classifies the
variables that must be exchanged between the workstation and the
PLC into two types from the PLC point of view:

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 User Manual 36 of 54


GSC
4. HMIRCL: This array used for real commands such as special
set points. The contents of this array can be saved to file and
loaded during PLC startup.

PLC Software
Package

5. HMIFAISETTING: The alarm setting, scan rates, and dead


bands of analog inputs must be saved in this array.
6. HMIRNGSETTING: In general, the conversion from raw to
engineering units is performed by the HMI. However, some times
you need to do some mathematical calculations on analog inputs
values, in this case, you will need to do the conversion in
CODESYS, and this is why you need this array.
7. HMIAPIDSETTING: PID Controller setting must be saved in
this array.
8. HMIDPIDSETTING: The DPID controller is a special type of
PID controllers; its setting must be saved in this array.

PLC User Manual 37 of 54


GSC

PLC Software Package

Table- (4.4)
Array Element Type Array Index File
CAOAR WORD 0 No
HMIBCL BOOL 1 Yes

HMIWCL WORD 2 Yes


HMIRCL REAL 3 Yes
HMIFAISETTING HHSP: WORD; 4 Yes
HSP: WORD;
LSP: WORD;
LLSP: WORD;
HYS: WORD;
LYS: WORD;
DBAND: WORD;
SRAT: WORD;
MINV: WORD;
HMIRNGSETTING Z: REAL; 5 Yes
H: REAL;
HMIAPIDSETTING AUTO: BOOL; 6 Yes
REMOTE: BOOL;
MSP: REAL;
RSP: REAL;
LSP: REAL;
KP: REAL;
TR: WORD;
TD: WORD;
Y_OFFSET: REAL;
Y_MIN: REAL;
Y_MAX: REAL;
RESET: BOOL;
LIMITS_ACTIVE: BOOL;
OVERFLOW: BOOL;
HMIDPIDSETTING OPMD: WORD; 7 Yes
TOL: REAL;
TSPAN: REAL;
TSTEP: REAL;
RESET: BOOL;
RSP: REAL;

PLC User Manual 38 of 54


GSC
LSP: REAL;
STATUS: WORD;
RSP: REAL;
LSP: REAL;
PLC Software Package

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.

A. Field Variables: In general, any signal coming from or going to field


must be exported to the workstation for monitoring. DALOGIC uses
coding (bit to byte mapping) to minimize the number of digital variables
exported. Also, coding is used to minimize the number of exported
variables that are needed to fully describe analog input signal. Field
signals are exported in four arrays:

1. HMIFDI: System and user defined DI points are exported in this


byte array. The mapping from bit to byte reduces the number of
exported variable by a factor of 8 to 1. The mapping is done like this:
The 8 points at X.0 to X.7 are mapped to HMIFDI [X]. For example,
the points at 4.0 to 4.7 will be mapped to HMIFDI [4]. This means
that variable addressing should be consecutive to avoid gaps in the
array. Updating will be disabled temporarily during program
downloading or online changes and then automatically enabled using
join command-1 above. The contents of this array is coded as
follows:
 HMIFDI [0,0]=My State (0/1)(Not Active/Active).
 HMIFDI [0,1]=His State (0/1)(Faulty/Healthy).
 HMIFDI [0,2]=Join Commands (0/1)(Not Executed/Executed).
 HMIFDI [0,3]= Logic Programs in PLC (0/1)(Stop/Running).
 HMIFDI [0,4-7]= Reserved For Future use.
 HMIFDI [1-2-3,x]= Reserved For future use.
 HMIFDI [4-, x]= User defined FDI.

2. HMIFDO: System and user defined DO points are exported in this


byte array. The mapping from bit to byte reduces the number of
exported variable by a factor of 8 to 1.The mapping is done like this:

PLC User Manual 39 of 54


GSC
The 8points at X.0 to X.7 are mapped to HMIFDO [X]. For example,
the points at 4.0 to 4.7 will be mapped to HMIFDO [4]. This means
that variable addressing should be consecutive to avoid gaps in the
array.

PLC Software Package


Updating will be disabled temporarily during program downloading or
online changes and then automatically enabled using join command-
1 above. The contents of this array is coded as follows:
 HMIFDO [0-3,x]= Reserved For the system.
 HMIFDO [4-, x]= User defined FDO.

3. HMIFAI: The entries of this array are connected to a special


preprocessor and converter FB (FAI_TO_HMI). The AI points in this
array are coded to include the AI raw value and the alarm status as
shown below. This coding reduces the number of exported variables
by a factor of 6 to 1. The status part is coded like this:
0=OK
1=LL Alarm
2=L Alarm
4=H Alarm
8=HH Alarm
15=Bad data

AI Raw Value 4-15 Status 0-3

Notice that the status flag of command 5 in the command queue


internally controls FAI_TO_HMI. As long as this flag is false, the
outputs will be (AI=0, AHH=FALSE, AH=FALSE, AL=FALSE,
ALL=FALSE, and BAD=TRUE).

PLC User Manual 40 of 54


GSC
4. HMIFAO: The user AO points are exported in this byte array using
a special preprocessor and converter function (FAO_TO_HMI).

PLC Software Package

B. Indication Variables: If the exported variable is the result of some


logical or mathematical calculations, then, this variable can be exported
in one of three arrays.

 HMIBIN: User defined Boolean indications are exported in this byte


array. The mapping from bit to byte reduces the number of exported
variable by a factor of 8 to 1. The mapping is done using
(BIN_TO_HMI) function. Byte 0,1, and 2 are reserved for system
flags and coded as follows.

HMIBIN [0]: Indexing Error Flags


Bit-0= HMIFDI Indexing Error.
Bit-1= HMIFDO Indexing Error.
Bit-2= HMIFAI Indexing Error.
Bit-3= HMIFAO Indexing Error.
Bit-4= HMIBIN Indexing Error.
Bit-5= HMIWIN Indexing Error.
Bit-6= HMIRIN Indexing Error.

HMIBIN [1-2]: Command Failure Flag


Bit-i = Command i Execution Failed.

 HMIWIN: To export integer variables. Element zero is reserved for


the COMMANDER. The mapping is done using (WIN_TO_HMI)
function.

 HMIRIN: To export real variables. The mapping is done using


(RIN_TO_HMI) function.

PLC User Manual 41 of 54


GSC

PLC Software Package

4.2.6 Startup Sequence:


Analog input setting, controller setting, and some control
commands have a default value to be used when the PLC started.
However, these defaults can be changed from time to time. DALOGIC
has the capabilities to change, save, and load these setting. You can
change any one of these settings using the command interface. If you
want to use the new value as the default value, then you must save
the associated array to disk. Command 22 can be used to save the
array as shown above.
You can enable the loading of default values from file to any one
of the internal arrays. The program FILLCMNDQUEUE has the code
to do this for you. You just need to enable the proper command to
load defaults values to a specific array. The comment lines in this
program will guide you to do this.

Updating of HMIFDI and HMIFDO is also enabled at


FILLCMNDQUEUE by using join command-1. HMIFAO, command
and setting arrays reporting between redundant PLCs are enabled
using join command-2.
The commands above are saved in special array called
CMNDQUEUE; a special FB also called CMNDQUEUE will fetch
these commands and execute them in sequence. If the commands
executed successfully then the flag STATUS in the CMNDQUEUE will
be set to true. You can use these status flags to enable/disable the
functions that rely on the command execution. However, if the
command execution fails, then, the STATUS flag will be zero and an
error will be registered in HMIBIN [1] and HMIBIN [2].

PLC User Manual 42 of 54


GSC

PLC Software Package

4.2.7 Adaptation Procedure:


You can adapt or integrate your logic with DALOGIC predefined
code by using the following procedure.

1. Define your field signals in the global object ‘UserField_Local’. Follow


the naming convention and the addressing rules. Don’t forget to use
consecutive addressing.
2. Add your logic in PLC_PRG or any other POU you want to define. But
don’t forget to call your POUs by USERTASK, or PLC_PRG. If some
of your POUs need special time management then you can define a
new task.
3. Connect your control commands to HMIBCL, HMIWCL, and HMIRCL.
4. Export your exported variables using the exportation functions defined
above.
5. If you have any APID controller, DPID controller, or selector switch
then use the suitable FB from the folder “CONTROLLERS” in the
system code or from DALIB and connect the FB IOs to the associated
setting array as shown above.
6. In the global object ‘Constants_Local’ set the size limit constants as
follows:
 HMIFDISZ=XXX; assuming your last DI is FDIXXXY.
 HMIFDOSZ=XXX; assuming your last DO is FDOXXXY.
 HMIFAISZ=XXXX-282; assuming your last AI is FAIXXXX.
 HMIFAOSZ=XXXX-282; assuming your last AO is FAOXXXX.
 HMIBCLSZ= Last BCL index.
 HMIWCLSZ= Last WCL index.
 HMIRCLSZ= Last RCL Index.
 HMIBINSZ= Last BIN index.
 HMIWINSZ= Last WIN index.
 HMIRINSZ= Last RIN index.
 HMIRNGSZ= Last RNG index.
 HMIAPIDSZ= Last APID index.
 HMIDPIDSZ= Last DPID index.

7. Build your logic, log into the PLC, and run the program.

PLC User Manual 43 of 54


GSC
8. HMIBIN [0] must be equal to zero after running the program;
otherwise, you have an indexing error.

PLC Software Package

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.

PLC User Manual 44 of 54


GSC

Redundancy and WDT

5.Redundancy and WDT.

RTOS supports a programmable hardware watchdog timer. WDT must be


enabled in the CFG file by setting its value to a number between (1 and 63)
second. Zero value will disable the WDT. If the WDT is enabled at value X, it
will restart the PLC if there is no CPU activity during the time interval X-
seconds. You can simulate a CPU failure using command 9 as shown
above.

PLC User Manual 45 of 54


GSC

Redundancy and WDT


RTOS simulate a dual redundant CPU by implementing a dual redundant
PLC that duplicate all components. The principle of operation is one PLC
must be defined as “Primary” the other one is defined as “Secondary”. Both
PLCs will read the same inputs from field and execute the same logic, so
logically, they ust have the same output at any instance of time. Clearly, the
startup transition period is an exception of the rule. However, we cannot
connect two power sources to one load simultaneously. In case of DO, the
output will stick on the value TRUE, if one of the two outputs fails at value
TRUE. In case of AO sink currents, 2*X mA will pass through the load if
each output sinks X mA. If X=20mA, it means 40mA will pass through the
load. Therefore, only one output signal must be connected to the load at any

PLC User Manual 46 of 54


GSC
instance of time. The selection hardware is implemented by using one DO
card in the secondary PLC, and two control relays in each PLC. The relays
are controlled by FDO0000, which is an output from the redundancy control
DO card of the secondary PLC. The principle is that the relays will
disconnect the power supply of the not active PLC from all its outputs while
connecting the power supply of the active PLC to its outputs. This is shown
in Fig.5.1 above. If the primary PLC is active, then FDO0000=FALSE, N/C1
and N/C2 are closed, while N/O1 and N/O2 are open. The primary PLC
supply is connected while the secondary supply is disconnected. If the
secondary PLC is active, then FDO0000=TRUE, N/C1 and N/C2 are open,
while N/O1 and N/O2 are closed. The primary PLC supply is disconnected,
while the secondary PLC supply is connected. Redundancy is enabled and
configured by using DAPLCCFG in the CFG file editor form and the
“Redundancy and WDT” group box as shown above. When selecting the
redundancy state remember to define one PLC as primary and one as
secondary. The two PLC will use a serial (RS232) link to exchange healthy
and update messages between them every “TOut” milliseconds. The
following must be noticed about redundancy.
1. Regardless of primary/secondary selection, the first PLC started will be
the active PLC.
2. If the serial link connected after starting both PLCs, the one configured
as primary will be active.
3. If the serial link fails or disconnected both PLC will claim the active state,
however, only the secondary PLC will control the field.
4. After a serial link failures, the last PLC that was active before the failure
will be the active one.
5. The not active PLC will read the commands and setting arrays from the
active PLC only one time after every serial link establishment.
6. The not active PLC will continuously read the FAO values from the
active PLC.

Building Blocks

6. Building Blocks

DALOGIC defines two groups of function blocks to help the users in


building and tying up their applications with DALOGIC. The first group is
the HMIINTERFACE group, which used to export user-defined variable to
HMI. The functions of these blocks are explained above. DALOGIC
defines to controllers APID “Analog PID” and DPID “Digital PID”. The term
Analog/Digital is used to distinguish the PID output.

PLC User Manual 47 of 54


GSC
1.APID: This is a customized version of the standard PID controller. It is
customized to meat the specifications of DALOGIC. All settings
are taken from the array HMIAPIDSETTING [INDX] whose
internal structure is shown above. All APIDs are connected to
command 7 in the command queue and will be active only if the
status flag of this command is TRUE. AUTO and REMOTE
settings are mode selection variables. APID will internally check
for redundancy status and if is in the not active PLC it will
automatically switch to manual mode and use HMIFAO [INDX]
as the MSP. In this case it will trace the output of the APID
controller at index INDX in the active PLC.

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.

Set Point Value 4-15 Mode 0-3

PLC User Manual 48 of 54


GSC
The mode part is interpreted as follows:
0: No activity: all outputs are false.
1: Relative percentage increases: The increase output will
be active for ((SP*TSPAN)/(100*TSTEP)) cycles.
2: Relative percentage decreases: The decrease output will
be active for ((SP*TSPAN)/(100*TSTEP)) cycles.
3: Semi Auto Mode: This mode will be active until the absolute
difference between RB (Read Back) and LSP is less than TOL
(Tolerance); after that the controller will automatically return to
mode 0.
4: Auto Mode: This mode will be active if the absolute difference
between PV and LSP is greater than TOL (Tolerance); the
controller will automatically return to mode 0 in case of errors. Also,
the user can stop or change this mode manually.
5: Cascade Auto Mode: This mode will be active if the absolute
difference between PV and RSP (Remote SP) is greater than TOL
(Tolerance); the controller will automatically return to mode 0 in
case of errors. Also, the user can stop or change this mode
manually.

The STATUS output of the controller is interpreted as follow:


0: No error;
1: Invalid Set Point: SP>100; (LSP, RSP)<TOL.
2: Invalid Input Change>800.
3: Time out error; no input change after 50 cycles; or infinite
swinging.
4: Invalid Mode.
5: Reset state.

Building Blocks

NOTE1: The following conditions must be satisfied so that the controller


can avoid infinite swinging:
1: STEP<2*TOL.
2: TOL>DEADBAND.

NOTE2: The controller will automatically clear the mode part of the set
point and save the active mode code in the SP value part.

PLC User Manual 49 of 54


GSC

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:

PLC User Manual 50 of 54


GSC
This is a special purposes AI demultiplexer. Its input is coded with the
channel number at bit 0-3 and the AI raw value at bit 4-15. The block
will decode the input and send the raw value to the proper channel.
This block is typically used with AX5020P AI cards when configured to
use the multiplexed direct/indirect mode.

Library

2- SWITCH:
This is a four-way selector switch. The active way is selected by the
value of the input ‘K’.

PLC User Manual 51 of 54


GSC
Table- (7.1)
K Active Way
0 None
1 WAY1
2 WAY2
3 WAY3
4 WAY4

Library

3- Raw/Engineering Value Converters:


These are two conversion functions used to convert raw to engineering
values and vise versa. The raw value is a word ranging from MinV to

PLC User Manual 52 of 54


GSC
4095. The engineering value is a real value ranging from Z to H, where
Z=range 0% and H=range 100%.

Library

4- First Fail Signals Detector:


The FIRSTFAIL function block detects and save the first fail (i.e.
become TRUE) group of inputs in its output word FFOUT. Notice that

PLC User Manual 53 of 54


GSC
FIRSTFAIL can detect groups of signal if the become TRUE within the
same interval of time. The FFOUT output is bit coded and each bit
represent a single input (FC0-FC15). To increase the number of inputs
you can cascade two or more FIRSTFAIL blocks by connecting the
FFOUT to FFIN of the consecutive blocks. Clearly, FFOUT of the last
block must be connected to FFIN of the first block. If you are using only
one block just connect its FFOUT to FFIN. RESET input will clear
FFOUT.

PLC User Manual 54 of 54

You might also like