Advanced programming techniques

This chapter contains more information about the ISaGRAF Workbench and target system. The user is advised to be familiar with the ISaGRAF tools and methods, before reading this section.

More about ISaGRAF tools

Locked I/Os and virtual I/Os

PC-PLC link validation

ISaGRAF directories

Application symbols

Limits of ISaGRAF "LARGE" (WDL) workbench


More about ISaGRAF tools

When using the ISaGRAF editing tools, the user can press the right mouse button to open a popup menu, which contains the main editing commands. The menu is opened at the current position of the cursor. This is very useful to reduce mouse operations during cut and paste commands.

The ISaGRAF tools support multiple execution. Although same tool cannot be opened twice to edit the same document, it is possible to open different windows with the same tool and edit different objects as parallel operations.

Other commands are available to find information about graphic buttons in toolbars. Double click an empty area of a toolbar to display the contents of the toolbar as a popup menu. Stay with the mouse cursor on a graphic button displays the corresponding text command.


Locked I/Os and virtual I/Os

Defining an I/O board as virtual disconnects the processing of the physical I/O channels. When a board is defined as virtual, the ISaGRAF kernel operations are not changed. The only difference is that input sensors are not read and output devices are not updated. In this mode, it is possible to use the ISaGRAF debugger to modify the input values. The Virtual attribute applies to a complete board. It is programmed during the I/O board definition, before the application code generation. The virtual attribute is a static feature, and is stored when the application is stopped and restarted.

Another possibility is the I/O variable locking. It consists of disconnecting one physical device and the corresponding ISaGRAF I/O variable. Variable locking and unlocking is performed through the debugger. Variable locking is a dynamic operation, and is not memorized when the application restarts. The lock operation applies to only one variable (one I/O channel) at a time. This is the summary of main I/O controlling features:

Virtual Attribute	Lock command

selection tool	I/O board connection	debugger

definition	static	dynamic

selection mode	board	variable

application	validation and tests	maintenance

The following chart explains the I/O data flow between the ISaGRAF tasks:

When an input variable is locked, the various accesses to the data base are not changed, but the input device is disconnected. Input values can be set with the debugger and processed by the ISaGRAF kernel:

When an output variable is locked, the run-time kernel and the output driver are disconnected. In this case, access is still possible to the output device, via the output driver, with the ISaGRAF debugger:

When setting the virtual attribute for an input the input data base and the associated input devices are disconnected. A virtual I/O driver replaces the real one.

Setting the virtual attribute follows the same rules for an input board or an output board. For output boards, the ISaGRAF kernel updates the output data base. This data base and the associated output devices are, however, disconnected. A virtual I/O driver replaces the real one.

To summarize all possibilities:


PC-PLC link validation

Most of the problems related to poor communication between the ISaGRAF workbench and the target PLC are represented in the debugger window by the "disconnected" status message. Before any diagnostic tests are performed, the communication should be validated when no application is active in the target PLC. This way the serial communication link can be validated on its own, isolating it from execution related effects.

The "C" language, used for description of the conversion functions and C functions, allows direct access to the target system. A programming error in such a software component may generate system errors or incorrect ISaGRAF system behavior. Such problems may occur when I/O drivers are developed with the ISaGRAF I/O toolkit. System errors, for example, may be caused if an I/O board is connected on an invalid bus address. The following table gives a synthetic summary of error diagnostics:

status	context	diagnostic
"disconnected" (before download)		- target is not running - no cable / invalid cable - invalid link parameters - ISaGRAF target badly installed
"disconnected" (after download)	cycle to cycle starting mode	- invalid I/O configuration - system crash
	real time starting mode	- invalid I/O configuration - system crash (due of "C" programming)
"no application"		- application not downloaded - application not started (due of "C" programming) - Intel/Motorola mismatch - Invalid target version


ISaGRAF directories

The ISaGRAF Workbench works on a dedicated disk directory structure. The root directory of this architecture is specified by the user during the installation of ISaGRAF. The default name for the ISaGRAF root directory is ISAWIN. This is the standard disk architecture created by the installation program:

These are the standard ISaGRAF sub-directories

DIRECTORY	CONTENTS
APL	root directory for the ISaGRAF projects each project corresponds to one sub directory which contains all the data of the project
	other directories may exist for other project groups. ISaGRAF installation program creates "SMP" directory where are stored samples applications.
COM	"common" range data Data can be used by any project
EXE	ISaGRAF programs and help files
LIB	ISaGRAF libraries: - lists of elements - parameters or interface for each element - technical notes
LIB\IOC	source code for I/O configurations
LIB\FNC	source code of functions written in IEC languages
LIB\FBL	source code of function blocks written in IEC languages
LIB\SRC	source code for conversions and C functions
LIB\DEFS	source header for conversions and C functions
LIB\RELS	conversions and C functions object code
LIB\DEV	command files for developing "C" libraries makefiles, link lists, etc...
TMP	temporary files: sub-directories of TMP are reserved for the ISaGRAF  Code Generator and cannot be deleted.

The sub-directories can be moved to other disk locations. When the user has a non-standard architecture, the pathnames of the sub-directories should be declared in the WS001 section, in the ISA.ini initialization file, in the EXE sub-directory of ISaGRAF. Here are the entries of the WS001 section:

Isa	root directory for ISaGRAF architecture
IsaExe	root directory for ISaGRAF programs and help files
IsaApl	root directory for ISaGRAF projects
IsaTmp	directory for temporary files
IsaSrc	directory for library source code
IsaDefs	directory for library source headers

Note that if you change the IsaTmp entry to another directory, you must create the sub-directories OBJS, RELS and DATA in the new directory. The following example uses the entries of the WS001 section to redefine the standard ISaGRAF disk architecture:

;file c:\ISAWIN\EXE\ISA.ini

[WS001]

Isa=c:\isawin

IsaExe=c:\isawin\exe

IsaApl=c:\isawin\apl

IsaTmp=c:\isawin\tmp

IsaSrc=c:\isawin\lib\src

IsaDefs=c:\isawin\lib\defs

When you want to add "C" functions or function blocks to the ISaGRAF target, the \ISAWIN\LIB\DEV directory is used to store development files: command files, makefiles, maps, etc... The \ISAWIN\LIB\RELS directory is used to store the object files generated during "C" compiling, and the ISaGRAF "C" libraries required for LINK operations.


Application symbols

Each object of an ISaGRAF application is referenced by a name (entered during variable declaration) and an internal virtual address, calculated by the code generator. The virtual address of a variable is not its network address entered during the declaration of the variable. Virtual addresses are used for communication work, and special "C" applications using the OEM option. When the ISaGRAF code generator is run, it makes an ASCII file with the logical correspondence between names and virtual addresses for all the objects (variable, programs, steps...) of the project. This file can be easily interrogated for information about the ISaGRAF static data base from any user's application. The file is named "APPLI.TST" and is located in the directory of the ISaGRAF project: "\ISAWIN\APL\proname" (proname is the name of the project). This section describes the detailed format of the "APPLI.TST" file. The main notations used for the following descriptions, is shown below:

VA	virtual address

ATTR	attribute of a variable

USP	"C" function

Possible values for the attributes of a variable are shown below. Such values occur in the "attributes" fields:

+X	internal variable

+C	read-only internal variable

+I	input variable

+O	output variable

All the numbers, except virtual addresses, are expressed as decimal integers. The virtual addresses (VA) are expressed as hexadecimal 4 digit numbers, and are preceded by the character "!". For example:

123	this is a decimal number

!A003	this is an hexadecimal virtual address

The main structure of the file "APPLI.TST" is shown below. The file is structured as a list of blocks. A block is a list of records. Each record is described on one line of text. Each block begins with a header, put on one line of text.

Start block

description blocks

end block

The general syntax of one block is shown below:

@ <block_name> <arguments>

#record...

#record...

...

The structure of the first block, containing the main information about the application, is shown below:

@ISA_SYMBOLS,<appli_crc>

#NAME,<appli_name>,<version>

#DATE,<creation_date>

#SIZE,G=<nbprg>,S=<nbstep>,T=<nbtra>,L=0,P=<nbpro>,V=<nbvar>

#COMMENT,cj international

appli_crc	application symbols checksum

appli_name	name of the application

version	ISaGRAF workbench version number

creation_date	application generation date

nbprg	number of programs

nbstep	number of SFC steps

nbtra	number of SFC transitions

nbpro	number of "C" functions used

nbvar	total number of variables

The structure of the last block, which signals the end of the file, is shown below:

@END_SYMBOLS

The structure of the block used to describe the programs of the application, is shown below:

@PROGRAMS,<nbprg>

#<va>,<name>

#...

nbprg	number of programs defined in this block

va	virtual address of the program

name	program name

The structure of the block used to describe the SFC steps of the application is shown below. Note there is one virtual step defined for each non-SFC program:

@STEPS,<nbsteps>

#<va>,<name>,<father>

#...

nbsteps	number of steps defined in this block

va	virtual address of the step

name	step name

father	virtual address of the father

The structure of the block used to describe the SFC transitions of the application, is shown below:

@TRANSITIONS,<nbtrans>

#<va>,<name>,<father>

#...

nbtrans	number of transitions defined in this block

va	virtual address of the transition

name	transition name

father	virtual address of the father

The structure of the block used to describe the boolean variables of the application, is shown below:

@BOOLEANS,<nb_boo>

#<va>,<name>,<attr>,<program>,<eq_false>,<eq_true>

#...

and if variable number exceeds 4095:

X#(1.<varno>),<name>,<attr>,<program>,<eq_false>,<eq_true>

nb_boo	number of variables in this block

va	virtual address of the variable

varno	range of the address (within boolean data type)

name	name of the variable

attr	attribute of the variable

program	virtual address of the parent program

or "!0000" for a global variable

eq_false	string used for false value

eq_true	string used for true value

The structure of the block used to describe the analog variables of the application, is shown below:

@ANALOGS,<nb_ana>

#<va>,<name>,<attr>,<program>,<format>,<unit>

#...

and if variable number exceeds 4095:

X#(2.<varno>),<name>,<attr>,<program>,<format>,<unit>

nb_ana	number of variables in this block

va	virtual address of the variable

varno	range of the address (within analog data type)

name	name of the variable

attr	attribute of the variable

program	virtual address of the parent program

or "!0000" for a global variable

format	= "I" for an integer variable

= "F" for a real variable

unit	unit string

The structure of the block used to describe the timer variables of the application, is shown below:

@TIMERS,<nb_tmr>

#<va>,<name>,<attr>,<program>

#...

and if variable number exceeds 4095:

X#(3.<varno>),<name>,<attr>,<program>

nb_tmr	number of variables in this block

va	virtual address of the variable

varno	range of the address (within timer data type)

name	name of the variable

attr	attribute of the variable (always +X: internal)

program	virtual address of the parent program

or "!0000" for a global variable

The structure of the block used to describe the message variables of the application, is shown below:

@MESSAGES,<nb_msg>

#<va>,<name>,<attr>,<program>,<max_len>

#...

and if variable number exceeds 4095:

X#(4.<varno>),<name>,<attr>,<program>,<max_len>

nb_msg	number of variables in this block

va	virtual address of the variable

varno	range of the address (within message data type)

name	name of the variable

attr	attribute of the variable

program	virtual address of the parent program

or "!0000" for a global variable

max_len	maximum length (declared capacity)

The structure of the block used to describe the "C" functions used in the application, is shown below:

@USP,<nb_usp>

#<va>,<name>

#...

nb_usp	number of C functions in this block

va	virtual address of the C function

name	name of the C function

The structure of the block used to describe the "C" function block instances used in the application, is shown below:

@FBINSTANCES,<nb_fb>

#<va>,<inst_name>,<fb_name>

#...

nb_fb	number of instances of a C function blocks in this block

va	virtual address of the C function block instance

inst_name	name of the C function block instance

fb_name	name of the reference C function block


Limits of ISaGRAF "LARGE" (WDL) workbench

There are some limitations for the objects used in the ISaGRAF Workbench. Of course, many other practical limits are due to the configuration of the computer used (available memory and disk space), and the capabilities of the ISaGRAF target system (available memory, available hardware and software resources...). The following numbers absolute limits that cannot be exceeded.

For a project:

Object	Maximum	Notes

Programs	255	grouping main, sub and child programs

Levels in the hierarchy	20

The number of projects installed on the Workbench is only limited by the available space on the hard disk.

For names:

Name for:	Maximum	Notes

Project	8 char

Program	8 char

Variable	16 char	+ 60 characters for comment

Defined word label	16 char

Defined equivalence	255 char	+ 60 characters for comment

Conversion table	16 char

List of variables	16 char

function / f.block (lib)	8 char	this applies to C functions, C function blocks

or functions written in IEC languages

function parameter (lib)	16 char	this applies to C functions, C function blocks

or functions written in IEC languages

IO board	8 char

IO configuration	8 char

Board oem parameter	16 char

Conversion function	8 char

Editing (for one program):

Object	Maximum	Notes

SFC rows	600

SFC columns	20

SFC steps	4095	for the whole project, grouping steps, initial steps,

beginning and ending steps

SFC transitions	4095	for the whole application

LD/FBD editing	200 cols

2000 rows	this is the size of the editing area in cell units.

Quick LD editing	no limit	limits are imposed by the PC capacity

IL labels	251	in the same IL program

Text editing	40KBytes	or less according to the system configuration

For the dictionary (for one project):

Object	Maximum	Notes

Boolean variables	65535

Analog variables	65535	grouping integer and real variables

Timers	65535

Message variables	65535

The limits given for maximum number of boolean, analog or message variables group internal, input and output variables. It also includes all hidden temporary or variables allocated by compilers. The number of variables edited together (same type, same scope), in the dictionary editor cannot exceed 16000. Depending on PC configuration, the limit can be less than 16000. The application cannot run on an ISaGRAF target version V3.21 or earlier if the total number of variable for one type exceeds 4095. The sandard "Modbus" link using network addresses does not cannot be used if number of variables for one type exceeds 4095.

Defined words	4095	in the same list (same range)

Defined words	255	used in the same program

Conversion tables	127	used in the application

Points in one table	32	defined in the same conversion table

IO connections:

Object	Maximum	Notes

IO Boards	256	defined for the same application

(boards or complex equipment)

Number of I/O boards including single boards and items of complex equipments cannot exceed 256.

IO channels	128	on the same board

For libraries:

Object	Maximum	Notes

Functions (IEC lang.)	255	installed together in the library

Function blocks

(IEC lang.)	255	installed together in the library

C functions	255	installed together in the library

C function blocks	255	installed together in the library

function blocks

instances	4095	for the same type of function block in the same application

Function input parameters	31	this applies to C functions and functions written in IEC languages

Function block parameters	32	freely distributed between input and output parameters.

At least 1 output parameter is required.

Conversion function	128	installed together in the library

IO configurations	255	installed together in the library

IO boards	255	installed together in the library

Complex IO equipt.	255	installed together in the library

Board oem parameters	16