 Using the SFC editor

The SFC language is used to describe operations of a sequential process. It uses a simple graphic representation for the different steps of a process, and conditions that enable the change of active steps. An SFC program is entered by using the ISaGRAF graphic SFC editor. SFC is the core of the IEC 1131-3 standard. The other languages usually describe the actions within the steps and the logical conditions for the transitions. The ISaGRAF graphic SFC editor allows the user to enter complete SFC programs. It combines graphic and text editing capabilities, thus allowing the entry of both the SFC chart, and the corresponding actions and conditions.

SFC language main topics

Entering SFC chart

Working on an existing SFC chart

Entering the level 2 programming

Inserting a variable name

Inserting a Pulse action block in step

Inserting a Non stored action block in step

New P0 and P1 action qualifiers

Boolean actions

SFC actions

Transitions written in ST

Transitions written in Quick Ladder

Commands of the "Tools" menu

Using the SFC gallery

Calling other ISaGRAF tools

Other commands of the "File" menu

Updating the program diary

Selecting a variable from dictionary


SFC language main topics

The SFC language is used to represent sequential processes. It divides the process cycle into a number of well-defined successive steps (self-contained situations), separated by transitions. Refer to the ISaGRAF Languages Reference Manual for more details on the SFC language.

Divergences and convergences

Jump to a step

Macro steps

SFC components are joined by oriented lines. The default orientation of a line is up to down. These are the basic graphic components used to build an SFC chart:

Initial step

Step

Transition

Jump to a step

Macro step

Macro beginning step

Macro ending step

The SFC programming is usually separated into two different levels: The Level 1 shows the graphic chart, reference numbers of the steps and the transitions, and comments attached to the steps and the transitions. The Level 2 is the ST or IL programming of the actions within the steps, or the conditions attached to the transitions. Actions or conditions may refer to sub-programs written in other languages (FBD, LD, ST or IL). Below is an example of level 1 and level 2 programming:

The level 2 programming of a step is entered in a text editor. It can includes action blocks programmed in ST or IL. The level 2 programming of a transition can be entered either in IL or ST text languages, or with Quick LD editor.


Divergences and convergences

Divergences and convergences are used to represent multiple links between steps and transitions. Simple divergences or convergences represent different inclusive possibilities between different sub parts of the process.

Double divergences represent parallel processes.


Jump to a step

The SFC editor only allows the user to draw links in the up to down direction. A jump to a step can be used to represent a link to an upper part of the chart. Following charts are equivalent:

Jump to a transition is forbidden, and must be explicitly represented as a double (AND) convergence.


Macro steps

A macro step is a unique representation of a stand-alone group of steps and transitions. A macro step begins with a beginning step and terminates with an ending step.

The detailed representation of a macro step must be described in the same SFC program. The macro-step symbol must have the same reference number as the macro beginning step. A macro step description may contain another macro step.


Entering SFC chart

To draw an SFC chart, the user simply has to introduce the significant components of the chart. All the single lines joining two elements (horizontally or vertically) are drawn automatically by the SFC editor. To place an SFC component on the chart, the user has to move the selection to appropriate location and select the type of the component in the editor toolbar. The symbol is inserted at the current position. The following keyboard sequences can also be used:

Insert an initial step

Insert a single step

Insert a transition

Insert a jump to a step

 	Insert an OR divergence or convergence / Add branches

 	Insert an AND divergence or convergence / Add branches

Insert a macro step

 	Insert begin or end step for the body of a macro step

(The " [image] " symbol indicates a combination with SHIFT key)

The editing grid shows matrix cells. An editor option allows the user to show or hide the grid during chart input. The grid is very useful for initial layout of SFC chart, or selecting sub-parts of the chart. Use the "Options / Layout" command to display or hide the grid.

The ISaGRAF SFC editor always shows the current position in the matrix. The focused cell is marked in gray. The small square on its bottom right corner can be used to freely resize the cells. The X/Y ratio of the cells can also be changed this way.


 	Creating a divergence or convergence

Divergences and convergences are always drawn from the left to the right. To draw a divergence or a convergence, its left branches has to be placed on the chart area. The type of drawing (simple or double) is set by selecting one of these buttons in the toolbar.


   	Adding branches to divergences

The start and stop position of each auxiliary branch is placed on the divergence or convergence line using these buttons in the toolbar. The left corner of the divergence or convergence must be present before inserting new branches. The right corners have the same style (simple or double) as the main left corner. Right corners cannot be placed if the main left corner has not been added.


Inserting a macro step

This button is used to insert a macro step in the main chart. The body of the macro step must be entered elsewhere in the same SFC program.


 	Body of a macro step

Macro steps must be described in the same SFC program as the main chart. A macro step must start with a beginning step and stop with an ending step. The sub-chart described as the macro implementation must be self-contained. The macro beginning step must have the same reference as the macro-step symbol of the main branch.


Working on an existing SFC chart

You can use either the mouse or keyboards arrows to select a rectangle area in the chart. The whole selected area is marked in gray. The commands of the "Edit" menu can then used:

  	Cut / copy / delete / paste commands

Move elements

Renumbering steps and transitions

Direct access to a step or transition

Find and replace texts


 	Cut / copy / delete / paste commands

The following commands are available from the "Edit" menu when the "arrow" button is selected in the editor toolbar:

Cut	Move selected rectangle from the screen to the SFC clipboard

Copy	Copy selected rectangle from the screen to the SFC clipboard

Delete	Clear (delete) selected rectangle

Paste	Insert contents SFC clipboard at the current position

The "Edit / Paste" copies SFC clipboard to the screen. Copy / Paste commands work on both SFC chart and step/transition level 2 programming. It is also possible to copy a chart in a program and paste it in another SFC program. Elements are inserted before the currently selected position.


Move elements

When SFC elements are selected in the SFC chart, you can move them to another location of the chart by dragging the selection with the mouse. While you drag the selection, the initial location of selected elements is hatched.

The destination area for moved elements must be empty. No insertion is possible while moving SFC symbols.


Renumbering steps and transitions

Each step or transition is identified by a logical number in the SFC chart. The "Edit / Renumber" command allows the user to automatically set up numerically sequential reference numbers for any of the steps and the transitions of the currently edited SFC program. When a step number is changed, all the jumps to this step are automatically updated with the new reference number. (this also applies to macro steps and beginning steps)


Direct access to a step or transition

The "Edit / Go to" command allows the user to access an existing step or transition. The scrolling position is automatically adapted so that the step or transition is visible.


Find and replace texts

The "Edit / Find Replace" command can be used to find or replace text strings in the complete program (all steps and transitions). The Find/Replace dialog box is used to enter a searched text and directly open the level 2 programming section where text occurs.


Entering the level 2 programming

To enter the Level 2 text, the user must double click on the step or transition symbol. The level 2 programming is displayed on the right of the SFC window. The separation line between SFC chart and level 2 programming can be freely moved.

You can open one or two level 2 areas at the same time. The following commands are available from keyboard, mouse or the "Edit" menu:

Keyboard	Mouse	"Edit" menu

Open in last default window	Enter	Double Click	Edit level 2

Open in separate window	Ctrl+Enter	Ctrl + DoubleClick	Edit Level 2 in separate window

When two level 2 windows are visible, the separation between them can be freely moved. The button on the right of the level 2 title bar is used to close a level 2 window.

The default language for Level 2 programming is ST (Structured Text). For transitions, level 2 programming can also be entered with Quick LD editor. Use the "ST/LD" button in level 2 title bar to change the active language. This command is valid only if the level 2 programming window is empty.

A single line edit box appears at the top of the level 2 window. It is used to enter a short description text. This text will be displayed as an IEC comment in drawing of SFC symbols. It is very useful as it it used by other commands such as "Go To..." and also in the SFC printout to ducment SFC steps and transitions.

The "Options / Refresh" command can be used at any time when level 2 windows are open to refresh the main SFC chart with modified level 2 programs.

Inserting a variable name

Inserting a Pulse action block in step

Inserting a Non stored action block in step

 	New P0 and P1 action qualifiers

Boolean actions

SFC actions

Transitions written in ST

Transitions written in Quick Ladder


Inserting a variable name

When programming in text language, press this button to select a variable declared in the project dictionary and insert its name at the current position of the caret. When programming in Quick LD, press this button to select the variable to be attached to the selected contact or block I/O parameter.


Inserting a Pulse action block in step

When programming the level 2 of a step, press this button to insert the template of a Pulse action block at the current position of the caret. Below is the format of a Pulse action block:

Action (P) :

ST statement;

...

End_Action;

Pulse actions are instructions which are executed only once when the step becomes active. Refer to the ISaGRAF language reference for further details on SFC programming.


Inserting a Non stored action block in step

When programming the level 2 of a step, press this button to insert the template of a Non stored action block at the current position of the caret. Below is the format of a Non stored action block:

Action (N) :

ST statement;

...

End_Action;

Non stored actions are instructions which are executed on every PLC cycle when the step is active. Refer to the ISaGRAF language reference for further details on SFC programming.


 	New P0 and P1 action qualifiers

ISaGRAF supports new P0 and P1 action qualifiers. When programming the level 2 of a step, press these buttons to insert the template of a P0 or P1 action block at the current position of the caret. Below is the format of such blocks:

Action (P0) :	Action (P1) :

ST statement;	ST statement;

...	...

End_Action;	End_Action;

P1 actions are instructions which are executed only once when the step becomes active (same as Pulse). P0 actions are instructions which are executed only once when the step becomes inactive. Refer to the ISaGRAF language reference for further details on SFC programming.


Boolean actions

Other text semantics are available to directly act on a boolean variable according to the step activity. Such actions consist of attaching the step activity signal to an internal or output boolean variable. This is the syntax of the basic boolean actions:

<boolean_variable> (N);	assigns the step activity signal to the variable

<boolean_variable>;	same effect (N attribute is optional)

/ <boolean_variable>;	assigns the negation of the step activity signal to the variable

Other features are available to set or reset a boolean variable, when the step becomes active. This is the syntax of set and reset boolean actions:

<boolean_variable> (S);	sets the variable to TRUE when the step activity signal becomes TRUE

<boolean_variable> (R);	resets the variable to FALSE when the step activity signal becomes TRUE


SFC actions

Other text semantics are available to control the execution of a child SFC program. An SFC action is a child SFC sequence, started or killed according to the condition of the step activity signal. An SFC action can have the N (Non stored), S (Set), or R (Reset) qualifier. This is the syntax of the basic SFC actions:

<child_program> (N);	starts the child sequence when the step becomes active, and kills the child sequence when the step becomes inactive

<child_program>;	same effect as the preceding syntax (N attribute is optional)

<child_program> (S);	starts the child sequence when the step becomes active - nothing is done when the step becomes inactive

<child_program> (R);	kills the child sequence when the step becomes active - nothing is done when the step becomes inactive

The SFC sequence specified as an action must be an existing child SFC program of the currently edited program, created with the ISaGRAF program manager.


Transitions written in ST

The level 2 of a transition is a boolean expression. To program it in ST language, just enter the boolean condition according to the ST syntax. Optionally, a semi colon may be added at the end of the expression.


Transitions written in Quick Ladder

Quick LD editor is available to program the level 2 condition of a transition. In this case, the diagram is made of just one rung, with only one coil which represents the transition. The name of the transition is not repeated with the coil symbol. Below is an example of transition condition programmed in Quick LD.

When programming in Quick LD, use the keyboard arrows to move the selection in the programming logical grid, and then use the following shortcuts to insert symbols:

F2:	insert a contact after the selected symbol / initiate the rung

F3:	insert a contact before the selected symbol

F4:	insert a contact in parallel with the selected symbol

F6:	insert a block after the selected symbol

F7:	insert a block before the selected symbol

F8:	insert a block in parallel with the selected symbol

You can also click on the function key bar at the bottom of the level 2 window instead of hitting function keys.

Hit RETURN when the selection is on a contact or a block I/O parameter to select a variable or enter a constant value. Hit RETURN when the selection is on a function block to select the type of the function block. You can also double click on a symbol for the same effect.

Hit SPACE bar when a contact is selected to change the type of contact (direct, negated or with pulse detection). Refer to the chapter "Using the Quick LD editor" in this document for more details about Quick LD capabilities.


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.


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 produce the SFC printout.

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. 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 SFC window:

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

Find in steps and transitions	find occurrences of a text in all steps and transitions

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 open the level 2 programming window at the corresponding location.


Using the SFC gallery

The ISaGRAF SFC editor manages an SFC gallery: it is a collection of SFC structures that can be inserted in any SFC chart. Elements of the SFC gallery can optionally embed the level 2 programming of steps and transitions. Use the following commands of the "Tools" menu:

Copy to SFC gallery	copy selected elements to SFC gallery

Paste from SFC gallery	paste an SFC gallery element at the current location

When copying to SFC gallery (i.e. creating a new SFC gallery element), you can optionally ask to embed level 2 programming of selected SFC symbols.