Introduction

This library provides the possibility to realize flow chart programming, e.g. it provides function blocks to manipulate the control flow of the program.

With it new programming concepts can be implemented. Multiple quasi-parallel flows can run in one task now. Furthermore flows can be controlled with special parameters. A flow can be stopped or it can be restarted.

The function blocks in this library allow the user to create any kind of flow. This flow is guided by signal lines of the FLOWCTRL data type. Every flow starts with a START function block. If the flow doesn’t consist only of an endless loop, it contains also an END block. Between these two blocks any kind of forks and jumps can be created by the IF function block and a suitable interconnection with the signal lines. The YIELD function block is used to voluntary yield the program execution to other flows and task, so these processes have the chance to be carried on.

From a control flow point of view the following figure shows a little example of a valid flow with all available flow control function blocks.

Basics

The flow programming is seldom used only in itself, but to control other operations. These operations are realized with the normal function blocks. It should paid attention to the rule that data flow and control flow must not be combined in the same layer of a program or macro. Within a control flow all kinds of data flow functions (the operations provided by the normal function blocks) have to be encapsulated within macros without control flow functionality. If this rule is ignored, the download to the target is canceled with an error message. To create such a macro, one input and one output of the data type FLOWCTRL have to be incorporated into the macro. But in both cases the option "Call of data flow sections" has to be selected. So these connectors are not connected within the macro. Such macros can be used to operate within a control flow.

It is also possible to create macros with flow chart programming components. In this case no data flow function block can be used within that macro. These functions have then to be encapsulated in another sub macro.

It also has to be noted that any operation between two YIELD blocks (and also between START and YIELD or YIELD and END) will be executed in one step without any interruption within one program cycle. By using this kind of programming it is easily possible create unwanted side effects up to the point to completely lock the system. The flow chart function blocks have to be used with care.

Example

The following example will show the using and the interactions of the flow chart function blocks. The example program uses a simple counter, which is increased by one until it reaches a specific value (in this case 10000). After that the program ends. The functional operation is encapsulated in the macro COUNT, because data flow and control flow must not be mixed up in the same program level. The visualization block can be used, because it doesn't have a target functionality.

After the program starts, the macro count will be executed. As long as the binary output of that macro is HIGH, the loop will be continued. As soon as a LOW signal is given to the IF block, the program ends.

The COUNT Macro is a typical macro, which is used within flow programming but don't use control flow functionality. It contains an input and an output from the data type "FLOWCTRL", where the option "Call of data flow sections" was selected.

For the functional operation an Addition function block is used to count a value by one. This counter value is given to an output for visualization. As long as this value is less than 10000 the Comparator function block returns a HIGH signal.

Error

In the case a backward jump is programmed without a YIELD block it is possible to create an endless loop, which can lock the complete system. When applied to the given example, there exists a condition, which leads to a defined end of the program. This will prevent an endless loop. Nonetheless there will be the problem that now the complete program will be executed within one program cycle without any interruption until it reaches the END function block. Given a big enough number of loops this will practically lock the system.

For this case a safety mechanism exists for the flow control, which allows only a certain number of uninterrupted loops. Then a lock of the flow is indicated and its execution is halted. This will be displayed by depicting the START function block red.


END

Symbol:

Description:

The END function block marks the end of a flow.

If the flow reaches this function block it stops and can't leave it by itself. Only a reset signal to the according START function block or a restart of the application enable a new processing of the flow. Other flows are not affected by a stopped flow and works as usual.

The END function block is active if the flow reaches this block. It stays in this state until the whole flow is reset.

An overview about flow programming can be found in the chapter Introduction.

Signals:

Name

I/O

Type(s)

Function

Prev

I

FLOWCTRL

Input

Visualization:

When the function block is active the symbol will be depicted green in the online mode.


IF

Symbol:

Description:

With the IF function block it is possible to create alternative flows with forks.

There are two possibilities to progress (Next0 and Next1) the flow will fork out. The choice is given by the binary condition bCond.

The IF function block doesn’t have any state. It is not a dedicated step of the flow. If the flow progress reaches this block, then the flow progresses immediately with one of the two possible sub flows. The flow doesn’t stop here.

The outputs Next0 and Next1 have to be connected to the next flow chart function block. Otherwise the download to the target will be disrupted with an error message.

An overview about flow programming can be found in the chapter Introduction.

Signals:

Name

I/O

Type(s)

Function

Prev

I

FLOWCTRL

Input

bCond

I

BIT

Branching condition

Next0

O

FLOWCTRL

Output

Next1

O

FLOWCTRL

Output

Visualization:

If the function block is not properly connected, it will be depicted red in the run mode.


START

Symbol:

Description:

The START function block tags the start of a flow.

Every flow must have one START function block. Only START function blocks regard the block sequence. The block sequence of START function blocks control the start sequence of different flows in a single application.

The START function block is in an active state only at the start of a flow or after a reset. If the flow reaches the next stepping function block (YIELD or END) this flow block will switch to an inactive state and the next block is set to active.

The START block can also indicate an error state. This happens if the slow is locked (like in an endless loop not interrupted by a YIELD function block).

The output Next has to be connected to the next flow chart function block. Otherwise the download to the target will be disrupted with an error message.

An overview about flow programming can be found in the chapter Introduction.

Parameter:

The parameter dialog can be used to assign up to two control variables to the specific flow, starting with this START function block. These are BIT variables set for "Reset" or "Stop"

If the variable assigned to "Reset" is HIGH, the flow will reset to START. The signal isn’t evaluate as a transition, so the flow stops as long as the “Reset” signal is set to HIGH. Other flows, that use another signal for “Reset”, are not affected.

If the variable assigned to "Stop" is HIGH, the flow stops its progress at the actual active function block. Other flows, that use another signal for “Stop”, are not affected.

Signals:

Name

I/O

Type(s)

Function

Next

O

FLOWCTRL

Output

Visualization:

When the function block is active the symbol will be depicted green and when in the error state red in the online mode.

If the function block is not properly connected, it will be depicted red in the run mode.


YIELD

Symbol:

Description:

The YIELD function block interrupts a flow.

The flow voluntary give away the program execution or other follows or tasks. When the flow gets back its execution, it will continue at this point. By interrupting a flow, the system gets the possibility to execute other flows and processes. Concurrent applications can be realized in this way.

If a backward loop is programmed without such an interruption, an endless loop is created which block any other activities.

The YIELD function block is active when the flow reaches this block and until it reaches the next stateful flow function block (either another YILED or the END block).

The output Next has to be connected to the next flow chart function block. Otherwise the download to the target will be disrupted with an error message.

An overview about flow programming can be found in the chapter Introduction.

Signals:

Name

I/O

Type(s)

Function

Prev

I

FLOWCTRL

Input

Next

O

FLOWCTRL

Output

Visualization:

When the function block is active the symbol will be depicted green in the online mode.

If the function block is not properly connected, it will be depicted red in the run mode.