 Using the FBD/LD editor

The ISaGRAF FBD/LD graphic editor allows the user to enter complete FBD programs, which may includes parts in LD. It combines graphic and text editing capabilities, so both diagrams and corresponding inputs and outputs can be entered. As this editor is more dedicated to FBD language, pure LD diagrams should rather be entered using the ISaGRAF Quick LQ editor.

Basics of the FBD/LD languages

Entering an FBD diagram

Working on an existing diagram

Display options

Styles and modification tracking

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 FBD/LD languages

The FBD language is a graphic representation of many different types of equations. Operators are represented by rectangular function boxes. Function inputs are connected to the left side of the box. Function outputs are connected to the right side. Diagram inputs and outputs (variables) are connected to the function boxes with logical links. An output of a function box may be connected to the input of another box.

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. Contacts and coils are connected together and to left and right power rails by horizontal lines. Each line segment has a boolean state of FALSE or TRUE. The boolean state is the same for all the segments directly linked together. Any horizontal line connected to the left vertical power rail has the TRUE state.

Left power rail

Right power rail

LD vertical "OR" connection

Contacts

Coils

Function blocks

Labels

Jumps

Return symbol

Variables

Connection links

Connection links with boolean negation

User defined corners

LD and FBD diagrams are always interpreted from the left to the right, and from the top to the bottom. Refer to the ISaGRAF Language reference Manual for more details about LD and FBD languages. These are the basic graphic components of the LD and FBD languages, such as supported by the FBD/LD editor:


Left power rail

Rungs must be connected on the left to a left power rail, which represents the initial "TRUE" state. ISaGRAF FBD editor also allows to connect any boolean symbol to a left power rail.


Right power rail

Coils may be connected on the right to a right power rail. This is an optional feature when using the ISaGRAF FBD/LD editor. If a coil is not connected on the right, it includes a right power rail in its own drawing.


LD vertical "OR" connection

LD vertical connection accepts several connections on the left and several connections on the right. Each connection on the right is equal to the OR combination of the connections on the left.


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 FBD/LD editor:

direct contact

negated contact

contact with positive (rising) edge detection

contact with negative (falling) edge detection


Coils

A coil represents an action. It must be connected on the left to a boolean symbol such as a contact. The name of the variable is displayed upon the coil symbol. The following types of coils are supported by ISaGRAF FBD/LD editor:

direct coil

negated coil

"set" action coil

"reset" action coil


Function blocks

A block in an FBD diagram can represent a function, a function block, a sub-program or an operator. Inputs and outputs must be connected to variables, contacts or coils, or other block inputs or outputs. Formal parameter names are displayed inside of the block rectangle.


Labels

Labels can be placed everywhere in the diagram. Labels are used as targets for jump instructions, to change the execution order in the diagram. Labels are not connected to other elements. It is highly recommended to place labels on the left of the diagram, in order to increase the diagram readability.


Jumps

A jump symbol always refers to a label, placed elsewhere in the diagram. Its left connection must be linked to a boolean point. When the left connection is TRUE, the execution of the diagram directly jumps to this target label. 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 connected to a boolean point. It indicates that the execution of the program must be stopped if the rung state is TRUE.


Variables

Variables in the diagram are represented inside small rectangles, connected on the left or on the right to other elements of the diagram.


Connection links

Connection links are drawn between elements put in the diagram. Links are always drawn from an output to an input point (in the direction of the data flow).


Connection links with boolean negation

Some boolean links are represented with a small circle on their right extremity. This represent a boolean negation of the information transported by the link.


User defined corners

User defined points may be defined on links. They allow the user to manually control the routing of a link. If no corner is placed, the ISaGRAF FBD/LD editor uses a default routing algorithm.


Entering an FBD diagram

To enter a diagram, you have to place elements (blocks, variables, contacts, coils...) in the graphic area, and draw links between them.

Inserting objects

Selecting objects

Inserting comments

Moving objects

 	Drawing links

Changing link drawing

Changing the type of a link

Drawing LD rungs

Multiple connections


Inserting objects

To insert an object in the diagram, select the corresponding button in the toolbar and click in the graphic area, where you want to insert it.


Selecting objects

Selecting graphic objects is needed for most of the editing commands. The ISaGRAF LD/FBD graphic editor enables the selection of one or more existing objects in the diagram area. To select objects, the "select" (button with an arrow) choice must be checked in the editor toolbar. To select one object, the user only has to click on its symbol. To select a list of objects, drag the mouse in the diagram and select a rectangle area. All the graphic objects that intersect the selection rectangle are marked as "selected". A selected object is drawn with little black squares around its graphic symbol. By making a new selection, all previously selected objects are unselected. To remove the existing selection, simply click with the mouse on an empty area, outside of the rectangle which borders the selected objects.


Inserting comments

Comments may be inserted anywhere in the diagram. Comments have no influence on the program execution. They allow a higher readability of the diagram. To insert a comment block, select this button in the toolbar, and drag the mouse to select the rectangle area where comment must be drawn. Then enter the text of the comment. No special leading or trailing characters such as "(*" and "*)" are needed when entering the text of a comment block. A comment block may be resized by dragging the corners of its border when it is selected.


Moving objects

To move objects in the diagram, you have to select them, and drag the mouse to move the selected area in the diagram. To move connected objects, the user simply has to move the graphic symbols put on the diagram. The ISaGRAF LD/FBD editor will automatically redraw the connection lines between the objects that were moved, based on their new location.


 	Drawing links

Select one of these buttons in the toolbar to draw a link between connection points of existing elements. If you draw a link from a connection point to an empty location in the diagram, it is automatically terminated by a user defined corner, so that you can continue drawing another segment.


Changing link drawing

The "Tools / Move line" command is used when a link is selected in the diagram to change its automatic routing. This command has no effect when the link is connected to a user defined corner. When a link is drawn as three segments, this command changes the position of the second segment. Below are examples:


Changing the type of a link

You can easily change the type of link (with or without boolean negation) by double clicking with the mouse on its right extremity.


Drawing LD rungs

To draw a new LD rung, first insert the left power rail. Then place a coil: it will be automatically linked to the power rail. Other contacts and vertical OR connections may be directly inserted on the rung line, without drawing any new connection link.

When a new LD contact or coil is inserted in an empty space of the editing area, the new horizontal rung line is automatically drawn from the new inserted element to the existing power rails on the left and on the right. This line is not automatically drawn if the new contact or coil is not placed between power rails. The new inserted contact or coil can then be freely moved on the drawn rung. The horizontal lines created by the editor while inserting an LD contact or coil symbol can be selected and deleted. You can insert a new LD contact or coil symbol on the horizontal line of an existing rung. The editor automatically cuts the rungs and connects it to the left and right connection points of the new inserted contact or coil.


Multiple connections

A multiple connection can be created on the right of any output point. It means that the information is broadcasted to several other points in the diagram. The same state is propagated on each extremity on the right. The number of lines drawn at the right of an output connection point is not limited. Two connection lines cannot have their right extremity connected on the same input point, except for the following LD symbols:

right power rail

multiple connection on the left (OR) operator

These LD symbols can have an unlimited number of inputs.


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

Find and replace

Displaying the execution order

Entering symbols and texts

Selecting function block type

Getting free space


Correcting a diagram

The DEL key can be used to remove the selected elements. Pending links are deleted with selected elements. 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 "Cut", "Copy", "Paste" commands of the "Edit" menu are used to move or copy selected elements.


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. Research acts on contacts, coils, block names, variables and labels. It cannot be used to find a string in a comment text. The Replace command cannot be used to change the name of a block. The research can be made upward or downward, starting at the current selection position. It "loops" when the limits of the diagram are reached.


Displaying the execution order

When an FBD diagram includes backward loops, the execution order cannot follow the single left to right / top to bottom method. In order to avoid confusion, use the "Tools / Show execution order" command or press Control + F1 keys to display the execution order that will be used at compiling time. Tags numbered from 1 to N are displayed close to symbols that lead to an action (coils, set variables and function blocks).


Entering symbols and texts

Double click with the mouse on an element to enter the associated symbol or text. This applies to variables, contacts and coils, comment texts and labels. When used on a contact or coil, this also allows to change its type (direct, negated...).

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.

If the "Auto input" mode is checked in the "Options" menu, the variable symbol must be entered immediately each time a new contact or coil is inserted. The symbol must always be entered immediately when a variable or label is inserted.


Selecting function block type

Double click with the mouse on a block is used to change its type. The block type is selected from the list of available operators, functions and function blocks. This command also allows to change the number of input points in the case of a commutative operator. (e.g. AND, OR, ADD, MUL...)


Getting free space

When you press the right button of the mouse in the FBD drawing area, a popup menu is displayed. It contains the following commands that can be used to insert or remove free space at the location of the mouse cursor:

Insert rows: This command inserts horizontal free space, made of 4 rows according to the grid step, starting at the position of the mouse cursor where popup menu is open.

Delete rows: This command removes unused horizontal space (rows) starting at the position of the mouse cursor where popup menu is open. This command cannot be used to remove FBD elements.

When popup menu is open, a gray line in the FBD drawing area indicates where empty space will be inserted or removed.


Display options

The commands of the "Options" menu are used to customize the drawing of the FBD diagram on the screen.

Layout customization

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 diagram. Use the check boxes in the "Workspace" groupbox to display or hide editor toolbars and status bar. Option of the "Document" groupbox allows you to show or hide points of the editing grid.

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.

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 contents of the edited diagram.

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.


Styles and modification tracking

The ISaGRAF LD/FBD editor enables you to assign a graphic style to any component of an LD/FBD diagram. A style is mainly defined as a special diagram coloring. But ISaGRAF also uses styles to enable modification tracking in diagrams for version control purpose.

Predefined styles

Modification tracking

Note that styles are not visible during simulation or On-Line debug, as colors (red and blue) are used in that mode to highlight TRUE / FALSE states of spied variables.


Predefined styles

The following styles are pre-defined:

Normal	Default drawing (black). For modification tracking, "normal" style indicates that elements having that style are part of the original diagram. "Normal" style elements are normally scanned during execution.

Modified	Elements marked as "modified" are painted in pink. For modification tracking, the "modified" style is used to highlight elements that have been added or changed after the original release of the diagram. "Modified" style elements are normally scanned during execution.

Deleted	Elements marked as "deleted" are painted in gray, with dashed lines. Such elements are not taken into account for the execution of the diagram. This style is used to keep a track of elements removed after the original release when version control is required.

Custom	In addition to predefined style, ISaGRAF LD/FBD editor allows you to select any color to be applied to a part of the diagram. Such elements are considered as having a "Custom" style. The use of "Custom" style has no effect on the diagram execution at run time.

Use the commands of "Style" sub-menu in "Edit" menu to manually apply a style to selected elements.


Modification tracking

The use of styles, and the availability of the "Deleted" style allows automatic modification tracking in an existing diagram. Use the "Mark modifications" command in "Edit/Style" menu to enable or disable modification tracking.

When the "Mark modifications" option is set, all elements changed in or added to the diagram are automatically set with "Modified" style. When an element is deleted, using "Delete" or "Cut" commands, they are not visually removed from the diagram, but simply marked with "Deleted" style". This enables the user to automatically keep a trace of all modifications entered in the diagram.

Use the "Edit/Style/Remove all deleted items" to actually remove all elements marked with "Deleted" style from the LD/FBD diagram. This command does not take care of the current selection, and always applies to the entire diagram.

To "restore" one element marked with the "Deleted" style, select the desired element and apply to it the "Normal" style, the "Modified" style or any "Custom" style. Such operation may lead to invalid connections (more than one link connected to the same input point) that will be detected during next program verification.


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