Introduction

Basics – program working sequence

Because the function blocks in this library can be used to manipulate the program execution, a basic overview of the program working sequence will be given here.

The sequence of a program for executing function blocks is ordered by the function block number. Every function block with target system code has its own unique number. The numbers starts with 1 and the function blocks will be executed in ascending order. The function blocks read the actual input values, perform their functionality and issue new values at the outputs. These output values are last until they get renewed by the function block in the next program cycle.

The example in the following figure shows how the numbering sequence will influence the result of an operation.

The first subtraction (block number 2) calculates with one current value from the sinus generator as well as with one value from the last cycle, provided by the addition block (number 3), which will be updated only after the subtraction. The second subtraction calculates always with current values. Because of this working sequence the results differ.

With the jump function blocks from this library the program execution can be manipulated even further, to enable jumps within the program. The impact of these will also depend on the function block numbers (both the numbers of the jump blocks and the numbers of the other function blocks).

Example Jump function blocks

With the help of a little example, you can see how the jump function blocks can influence the working sequence.

The first figure shows the example without any active jumps. The function blocks work normally and provide the same result.

In the following figure the forward jump (A) is active. That's why the second addition (block number 4) is skipped. The other function blocks are working normally.

In the next figure the backward jump (B) is active. In the first program cycle the first three additions are executed. Then the jump point is reached and the jump back happens. From this point onward only two additions (number 4 and 6) still operate.

The jump function block is set in a way that allows up to 1000 back jumps in one program cycle. If this number is reached the program is interrupted and a new program cycle can operate. This new cycle will still starts at the jump destination block.

It can be seen in the figure, that the jump start block (C) shows gray arrows. This indicates that this part of the program was never reached.

In the last figure the backward jump (C) is active. The program is executed exactly one time, until it reaches the jump point. After this the program only operates this one jump (block number 10 and 9). The program performs this endless loop and no other function block is executed anymore.


Break - Manually

Symbol:

Edit mode:

Run mode:

Online mode:

Description:

This function block allows the manually interruption of the regular working sequence.

The function block offers three push buttons. With these buttons the user is able to decide, if the program run is stopped at this point or not.

The three push buttons allows the following functionality

- Stop: The program run will be interrupted and stopped at this pint until another action is used.

- Run: The program run will not be interrupted and a stopped program will be continued, until another action is used.

- Step: The program is currently stopped. The program run will be continued for one cycle. The next time the program reaches this function block, it will be stopped again.

This function block disrupts the program cycle completely. The program can only be continued in the next cycle if the stopping is lifted.

The state of the function block can be already selected in the run mode.

Visualization:

A walking manikin indicates the normal program run and a stopping manikin shows an interruption.

During the online mode the green color indicate the normal program run. A red manikin indicates that the program is currently stopped at this function block and a yellow one shows that an interruption is selected, but the function block is currently not reachable (e.g. another function block already interrupts the program).

The currently usable push buttons are highlighted.


Break - Signal

Symbol:

Edit mode:

Online mode:

Description:

This function block allows a program controlled interruption of the normal working sequence.

Depending in the input MAKEJMP the program run can be stopped at this point or not. If MAKEJMP is HIGH, the program will halt at this function block.

Signals:

Name

I/O

Type(s)

Function

MAKEJMP

I

BIT

Switch for the stop

Visualization:

A walking manikin indicates the normal program run and a stopping manikin shows an interruption.

During the online mode the green color indicate the normal program run. A red manikin indicates that the program is currently stopped at this function block and a yellow one shows that an interruption is selected, but the function block is currently not reachable (e.g. another function block already interrupts the program).


Jump - Destination

Symbol: |
Description: | This function block is used as a destination of a jump within a program. The input DESTMARK is connected to a jump start block. In this way a fully functional jump is defined.
Signals: | Name | I/O | Type(s) | Function
 | DESTMARK | I | DBCTRL | Connection to jump start
Comment: | This function block does not have a target code. It is only used for creating a jump target marker for the program.


Jump - Start

Symbol:

Edit mode:

Run and online mode:

Online mode:

Description:

This function block, together with a jump destination block, will realize a jump within a program.

In this way the program execution can be manipulated at will. The output MYDEST has to be connected to a jump destination block, otherwise the download to the target system will fail.

If the input MAKEJMP is HIGH the program will jump to the connected destination bloc, otherwise the normal working sequence is processed.

A jump can be made forward or backward to an earlier function block. Backward jumps can easily generate infinite loops. A so called Watchdog is used to keep the overall system working. It is used to limit the number of backward jumps for a single cycle. For this case, an internal variable counts the number of backward jumps. If the limit is reached, the function block interrupts the execution of its thread. Therefore other threads with a lower priority can be executed. Then the watchdog counter will be reset and the program continues its run where it stops. Only the program where this function block belongs to will be interrupted, parallel working programs are not affected.

An example an more explanations about program execution and working sequence can be found in the chapter Introduction.

Parameter:

The parameter dialog can be used to specify the maximum number of backward jumps the Watchdog counter allows in a single cycle. The parameter dialog can be opened only at run mode and only if the function block will perform a backward jump.

Signals:

Name

I/O

Type(s)

Function

MAKEJMP

I

BIT

Perform jump

MYDEST

O

DBCTRL

Connection to jump destination

Visualization:

A gray triangle, visible in run mode and online observation, indicates the jump direction. A forward jump points to the right and a backward jump points to the left.

During Online observation the arrows in the symbol are colored differently. Gray arrows indicate that this function block was never used. A green arrow to the right site indicates that the working sequence has not been modified and no jump was executed. A red arrow downwards indicates that the working sequence has been modified and the program continues at the destination function block. A yellow arrow downwards indicates that a modification of the working sequence is scheduled but in this program cycle the function block is not reachable. For example another jump function block could skip this program part.

If the function block is not connected properly, the symbol will be depicted red.

Comment:

The use of these jump blocks can lead to a very complex and complicated program execution. Therefore it is easily possible to create unwanted effects. So these jump blocks should only used with care.