 Using the Quick LD editor

The LD language enables graphic representation of boolean expressions. Boolean AND, OR, NOT operators are explicitly represented by the diagram topology. Boolean input variables are attached to graphic contacts. Boolean output variables are attached to graphic coils. The ISaGRAF Quick LD editor provides easy LD diagram entering using either keyboard or mouse. Elements are automatically linked and arranged on rungs by the Quick LD editor. No connection is drawn manually by the user. The Quick LD editor also arranges rungs in the diagram so that the space filled by the diagram is always optimized.

Basics of the LD language

Entering an LD diagram

Working on an existing diagram

Display options

Commands of the "Tools" menu

Calling other ISaGRAF tools

Parameters of the program

Other commands of the "File" menu

Updating the program diary

Selecting a variable from dictionary


Basics of the LD language

An LD program is expressed as a list of rungs where contacts and coils are arranged. Below are the basic components of an LD diagram:

Rung head (left power rail)

Contacts

Coils

Function blocks

Rung end (right power rail)

Jump symbol

Return symbol

The "EN" input

The "ENO" output

Limitations of Quick LD editor


Rung head (left power rail)

Each rung begins with a left power rail, which represents the initial "TRUE" state. ISaGRAF Quick LD editor automatically creates the left power rail when the first contact of the rung is placed by the user. Each rung may have a logical name, which can be used as a label for jump instructions.


Contacts

A contact modifies the boolean data flow, according to the state of a boolean variable. The name of the variable is displayed upon the contact symbol. The following types of contacts are supported by ISaGRAF Quick LD editor:

direct contact

negated contact

contact with positive (rising) edge detection

contact with negative (falling) edge detection


Coils

A coil represents an action. The rung state (state of the link on the left of the coil) is used to force a boolean variable. The name of the variable is displayed upon the coil symbol. The following types of coils are supported by ISaGRAF Quick LD editor:

direct coil

negated coil

"set" action coil

"reset" action coil

coil with positive (rising) edge detection

coil with negative (falling) edge detection


Function blocks

A block in an LD diagram can represent a function, a function block, a sub-program or an operator. Its first input and output parameters are always connected to the rung. Other input and output parameters are literally written outside of the block rectangle.


Rung end (right power rail)

A rung ends with a right power rail. Using the Quick LD editor, the right power rail is automatically inserted when a coil is placed by the user.


Jump symbol

A jump symbol always refers to a rung label, id. the name of a rung defined somewhere in the same LD diagram. It is placed at the end of a rung. When the rung state is TRUE, the execution of the diagram directly jumps to this target rung. Note that backward jumps are dangerous as they may lead to a blocking of the PLC loop in some cases.


Return symbol

A return symbol is placed at the end of a rung. It indicates that the execution of the program must be stopped if the rung state is TRUE.


The "EN" input

On some operators, functions or function blocks, the first input does not have boolean data type. As the first input must always be connected to the rung, another input is automatically inserted at the first position, called "EN". The block is executed only if the EN input is TRUE. Below is the example of a comparison operator, and the equivalent code expressed in ST:

	IF rung_state THEN    q := (value1 > value 2); ELSE    q := FALSE; END_IF; (* continue rung with q state *)


The "ENO" output

On some operators, functions or function blocks, the first output does not have boolean data type. As the first output must always be connected to the rung, another output is automatically inserted at the first position, called "ENO". The ENO output always takes the same state as the first input of the block. Below is an example with AVERAGE function block, and the equivalent code expressed in ST:

	AVERAGE(rung_state, Signal, 100); OutSignal := AVERAGE.XOUT; eno := rung_state; (* continue rung with eno state *)

On some cases, both EN and ENO are required. Below is an example with an arithmetic operator, and the equivalent code expressed in ST:

	IF rung_state THEN    result := (value1 + value2); END_IF; eno := rung_state; (* continue rung with eno state *)


Limitations of Quick LD editor

The ISaGRAF Quick LD editor does not allow to continue a rung (insert other contacts or coils) on the right of a coil. If several outputs have to be made on the same rung, the corresponding coils must be drawn in parallel.


Entering an LD diagram

All the editing commands of the Quick LD editor may be achieved either with the keyboard or with the mouse.

The editing grid

Starting a new rung

Entering the rung comment

Entering the rung label

Inserting symbols on a rung

Entering symbols

Changing the type of contacts and coils

Inserting a rung in a diagram


The editing grid

The LD diagram is entered in a logical matrix. Each cell of the matrix may contain up to one LD symbol. Use the arrows of the keyboard, or click on a cell to move the current selection. The selected cell is marked in reverse. For some cut/copy/paste operations, it is possible to select several cells. To do that with the mouse, just drag the mouse cursor in the diagram. With keyboard, use arrow keys with SHIFT key pressed.


Starting a new rung

To add a new rung to a diagram, move the selection after the last existing rung and insert a contact (hit F2 or press the corresponding button in the LD toolbar). A new rung with one contact and one coil is created.


Entering the rung comment

Each rung may be documented with up to two lines of text. To enter a rung comment text, move the selection on the cell upon the rung and hit ENTER key, or double click on this cell with the mouse:


Entering the rung label

Each rung may be identified by a name. This name can be used as a target label for jump operations. To enter or change the label of a rung, move the selection on rung head and hit ENTER key, or double click on this cell with the mouse:

The ISaGRAF Quick LD editor keeps the memory of the rung labels you already entered, whether it has been specified for a rung name or a jump operation. The "Jump/Label"' dialog box gives you the possibility either to enter a new label, or to select an existing one.

If you enter a new name, it will automatically be added to the list. The "Remove" button is used to remove the selected name from the list. It does not remove the label on the rung you selected in the diagram. To do this, just press OK when the edit box is empty.


Inserting symbols on a rung

The insertion of symbols (contacts, coils, blocks...) on an existing rung is always made according to the current selection. You have to select a valid cell position within the rung and hit one of the following function keys to insert:

F2	a contact before the selected symbol (on the left)

F3	a contact after the selected symbol (on the right)

F4	a contact in parallel with the selected symbol

F6	a block before the selected symbol (on the left)

F7	a block after the selected symbol (on the right)

F8	a block in parallel with the selected symbol

The following commands are valid when the selection is on the rung output (coil):

F5	add a coil in parallel with the selected one

F9	add a "Jump" symbol in parallel with the selected one

Shift + F9	add a "Return" symbol in parallel with the selected one

For parallel insertion (F4/F8), if several contacts of a rung are selected together, the symbol is inserted in parallel with the group of selected elements. Below is an example:

To insert symbols in the diagram, you can also use the commands of the "Insert" menu. With the mouse, you can click on the LD toolbar, on the type of symbol you want to insert:


Entering symbols

To associate a variable symbol to a contact or a coil, select it and hit ENTER. With the mouse, double click on the contact or coil. A variable selection box appears. Refer to chapter "More about program editors" in this document for further information about how to use this box. To associate a function, function block or operator to a block, hit ENTER when the selection is on the inside its rectangle. To associate a variable symbol to an input or output block parameter the selection must be on the corresponding location, outside the rectangle of the block.

Dialog boxes including variable or block selection lists are normally used for text input. If the "Manual keyboard input" mode is checked in the "Options" menu, variable symbols and block names are entered directly in a single text edit box. Enter new text and hit "Enter" key to validate it, or hit "Escape" key to exit modification and close the text edit box. The text edit box used in "manual keyboard input" mode cannot be closed with the mouse.


Changing the type of contacts and coils

The "Edit / Change coil/contact type" changes the type of the selected contact or coil. A contact may be direct, negated, with positive or negative edge detection. A coil may be direct, negated, set or reset, with positive or negative edge detection. Hitting the SPACE bar has the same effect.


Inserting a rung in a diagram

The "Edit / Insert rung" command insert a new rung in the diagram, before the selected one. The rung is initiated with one contact and one coil.


Working on an existing diagram

The commands of the "Edit" menu are used to change or complete an existing diagram. Most of these commands act on the elements currently selected in the diagram.

Correcting a diagram

Copying symbols

Managing entire rungs

Find and replace


Correcting a diagram

The DEL key can be used to remove the selected elements. It is not possible to remove a coils, a jump or return symbol when it is the only output of a rung. Use "Edit / Undo" command to restore elements after a DEL command. The DEL command can also be applied to a group of elements selected in the diagram. The DEL command can be used when selection is on the rung comment text to reset it. The DEL command, used when the selection is on the rung head, remove the entire rung.


Copying symbols

The "Cut", "Copy", "Paste" commands of the "Edit" menu are used to move or copy selected elements. These commands do not act on rung comments. The "Edit / Paste special" command gives you the choice to insert the pasted elements:

•	before the selected element (on the left)

•	after the selected element (on the right)

•	in parallel with the selected element


Managing entire rungs

All editing commands (delete, copy, cut...) act on the entire rung if the selection is on the rung header (left power rail). This provides an easy way to arrange rungs in the diagram, just by moving the selection in the first column. It is also possible to extend the selection vertically so that it includes several rung headers. In this case edition commands may be applied to a list of entire rungs.


Find and replace

The "Edit / Find" and "Edit / Replace" menu commands are used to find and replace texts in the diagram. Only complete names can be found. Search acts on contacts, coils, block names, block parameters and run labels. It cannot be used to find a string in a rung comment. The Replace command cannot be used to change the type of a block. The research can be made upward or downward, starting at position of the current selection. It "loops" when the limits of the diagram are reached. The following shortcuts are also available for quick research of variable names:

ALT + F2 finds the next element with the same variable name as the element currently selected. This feature can also be applied to function blocks and rung labels.

ALT + F5 finds the next coil with the same variable name as the element currently selected. This feature is mainly used in debug mode, to quickly find out the rungs which forces a suspicious variable.


Display options

The commands of the "Options" menu are used to customize the drawing of the LD diagram on the screen, and to hide or display some types of information.

Rung comments

Names and aliases

Drawing options


Rung comments

Use the "Options / Rung comments" command to hide or display the rung comments in the whole diagram. Hiding the rung comments can be required to have a more condensed view on a huge diagram, as each comment consumes one row in the editing matrix. This option does not affect the contents of the existing rung comments, and can be swapped at any time.


Names and aliases

Each variable, when associated to a contact, a coil or a block I/O parameter is identified by its symbolic name. The ISaGRAF Quick LD editor also introduces the notion or "alias" for each variable. The alias of the variable is the variable comment text, truncated before the first ':' character, and limited to 16 characters. Below are examples:

variable comment:	alias:

short text	short text

long text with no separator	long text with n

short text: long description	short text

Aliases have no effect on the execution of the LD diagram and should be considered as comments for the syntactic point of view. A variable alias is automatically extracted from the variable comment when the name is selected in the variable list. It cannot be changed manually. Use the "Options / Contacts and coils" commands to select a display mode for variable identification. The following mode are available:

•	display only the variable names

•	display only the variable aliases

•	display both names and aliases

Quick LD editor does not automatically updates LD documents when variable aliases are changed in the dictionary. Use the "Options / Contacts and coils / Update aliases" command to update all aliases in edited diagram. You can also set the "Always update on Open" option from "Options / Contacts and coils" to ask ISaGRAF to automatically update all used aliases each time a Quick LD program is open. Warning: Setting this option may significantly increase the time spent to open a program.


Drawing options

The "Options / Layout" command opens a dialog box where are grouped all the parameters and options concerning the editor workspace and the drawing of the graphic LD diagram.

Use the check boxes in the "Workspace" groupbox to display or hide editor tool bar, status bar and LD toolbar. Options of the "Document" groupbox allows you to show or hide points of the editing grid, and to enable/disable the use of colors for the drawing.

Options of the "Zoom" groupbox allows you to select a main zoom ratio. You can also use the "zoom" button in the editor toolbar to swap between default zoom ratios.

You can also customize the X/Y aspect ratio of cells in the editing grid. This last option can be used to reduce the default cell width, if you commonly use short names for variables. You can also use the "width" button in the editor toolbar to change the X/Y aspect ratio without entering the Layout dialog box.

Use the "Options / Font" command to select the name of the character font to be used in all ISaGRAF graphic documents. When selecting font, font style and size are not relevant and do not need to be specified. ISaGRAF graphic editors always calculate the font size according to selected zoom ratio.


Calling other ISaGRAF tools

Verify (compile) the program

 	Simulate or debug the application

Editing the dictionary of variables


Verify (compile) the program

The "File / Verify" command runs the ISaGRAF code generator to verify the programming syntax of the currently edited program. In case of SFC language, both level 1 and 2 are checked. When syntax verification is complete, the code generator window must be closed to continue work on the program. If there is only one program in the application (the edited one) the application code is generated if no syntax error is detected. The "Options / Compiling options" command is used to set compiling and optimizing parameters. Refer to chapter "Using the code generator" in this document for further information about compiling and code generation.


 	Simulate or debug the application

The "File / Simulate" and "File / Debug" commands run the ISaGRAF graphic debugger either in simulation or real connected mode, and re-opens the edited SFC program in debug mode. Used in debug mode, no modification can be entered in the program.


Editing the dictionary of variables

The "File / Dictionary" command is used to edit the dictionary of variables for the current application and the current program. It also contains the entry points to edit the user defined words. The local declarations or defined words relate to the currently edited program.


Parameters of the program

When the edited program is a function, a function block or a sub-program, the "File / Parameters" command is used to define its calling and return parameters. This command has no effect if the edited program is an SFC or top level program from section Begin or End.

Sub-programs, functions or function blocks may have up to 32 parameters (input or output). A function or sub-program always has one (and only one) return parameter, which must have the same name as the function, in order to conform with ST language writing conventions.

The list in the upper left side of the window shows the parameters, in the order of the calling model: first the calling parameters, last the return parameters. The lower part of the window shows the detailed description of the parameter currently selected in the list. Any of the ISaGRAF data types may be used for a parameter. The return parameters must be located after calling parameters in the list. Naming parameters must conform to the following rules:

•	the length of the name cannot exceed 16 characters

•	the first character must be a letter

•	the following characters must be letters, digits or underscore character

•	naming is case insensitive

The "Insert" command is used to insert a new parameter before the selected parameter. The "Delete" command is used to erase the selected parameter. The "Arrange" command automatically rearranges (sorts) the parameters, so that the return parameters are put at the end of the list.


Other commands of the "File" menu

The following commands are available in the "File" menu of all program editors:

Open another program

Printing the program


Open another program

The "File / Open" command allows the user to close the currently edited program and start editing another program of the current project with the same language. This function cannot be used to edit a program written in another language. The new selected program replaces the current one in the editing window.


Printing the program

The "File / Print" command outputs the edited program on printer. This command runs the project document generator to print the LD document.

For graphic programs (SFC, FBD and Quick LD) You can also use the "Edit / Copy drawing" command to copy in the clipboard the drawing of the chart in metafile format, so that it can be pasted in other applications such as word processors. For SFC programs, only the level 1 information (chart, numbering and level 1 comments) appear on the copied metafile.


Updating the program diary

The diary file attached to the edited program may be manually entered using the "File / Diary" command. The diary file is automatically updated with syntax checking output messages each time the program is compiled. Compiling outputs are completed with the compiling date / time stamp.

If the "Update diary" mode is selected in the "Options" menu of program editors, the "Diary" dialog box is opened each time the program is saved on disk.

If OK button is pressed, the entered text note is then stored at the end of the diary file with current date / time stamp. This feature is very useful for maintenance of complete programs, as it provides useful help about the program life cycle.


Selecting a variable from dictionary

 When editing a text program (ST or IL) the "Edit / Insert variable" allows the selection of a declared variable name to be inserted at the current position of the caret. When editing LD or FBD programs, variable selection is required for the description of contacts coils, block I/O parameters or FBD variable boxes. In both cases, the "Select" dialog box is open to select a declared variable.

The "Scope" selection box is used to select between global and local variables. The selection box on the right allows the selection of the data type. Small icons beside the type selection box are button that can be used as shortcuts to select most current data types:

Boolean

Integer / Real

Timer

Message

To select a variable, click on its name in the list. Its name and comment are then displayed on the top of the list. Then press the "OK" button to confirm its selection. It is also possible to directly enter a variable name in the edit control without using the list.


Commands of the "Tools" menu

The following commands are available in the Tools menu. They are used to display information in a small text list at the bottom of the LD editing window:

Show compiler output	display in output window error messages from the last compiling

Find in diagram	find occurrences of a text in whole diagram

and list them in the output window

Hide output window	close the output list window

When error messages or occurrences are displayed in the output window, double click on a line to directly set visible selection at the corresponding location.