This documentation is out of date.

The new version of the documentation is here: https://cannylogic.com/docs

Difference between revisions of "CANNY Lab Simulator"

From CANNY Wiki
Jump to: navigation, search
[unchecked revision][unchecked revision]
(Pause and reset)
(Initial edit)
 
Line 1: Line 1:
CannyLab simulator mode performs actions with data of the diagram, equivalent to those to be executed by a controller computing kernel when running diagram on it, thus allowing simulation of the controller operation on a PC.
+
Working in simulator mode, CannyLab performs actions to diagram data that are equivalent to the compute actions that would be carried out on them by the controller kernel, which allows the user to simulate the operation of the controller on the PC.  
  
The user can run the simulation of executing the functional diagram for debugging and testing at any stage of its creation. Simulation mode enables cycling and stepping through diagram, setting the conditions to pause the execution, forced setting inputs and outputs values of function blocks, and control of intermediate values.
+
The user has the ability to simulate the execution of the function diagram for debugging and testing at any stage of its development. In simulator mode, it is possible to run the diagram on a per-cycle and per-step basis, set the conditions for suspension of execution, forcibly set the input and output values of the function blocks, control intermediate values.  
  
 
{|
 
{|
 
|valign="top" style="padding-left:0.5em;"|''Note:''
 
|valign="top" style="padding-left:0.5em;"|''Note:''
|valign="top" style="padding-left:0.5em;"|''In the current version of CannyLab simulator there is no support of controller hardware resources, so the reading results from addresses and write to the address in the simulator may differ from the results obtained in diagram execution by the controller.''
+
|valign="top" style="padding-left:0.5em;"|''In the current version of CannyLab simulator there is no support for controller hardware resources, so the results of reads/writes from/to registers in the simulator may differ from the results obtained when the diagram is executed by the controller.''
 
|}
 
|}
  
=== Enabling simulation mode ===
+
=== Enabling simulator mode ===
  
Enabling and disabling the simulation mode is done by selecting the appropriate item in the ''«Simulator»'' of main menu, or by pressing [[File:4_7_1_1.png]] of toolbar.
+
Enabling and disabling the simulator mode is done by selecting the appropriate item in the ''«Simulator»'' submenu in the main menu, or by pressing [[File:4_7_1_1.png]] on the toolbar.
  
In simulation mode, the appearance of the main window and diagram changes - removed not available in this mode dialog elements, debugging information is added on the diagram.
+
The layout of the application changes when entering simulator mode. Control elements unavailable in this mode are replaced with ones specific to simulator mode, debugging information is added on the diagram.
  
 
[[File:4_7_1_2.png]]
 
[[File:4_7_1_2.png]]
  
When the simulation is activated, consistency diagram check, count memory (RAM) and program memory (ROM) that the controller required to run will be performed. The user will be warned about any issues. Functional blocks order of execution will be automatically detected and displayed. All intermediate values of inputs and outputs of functional blocks, blocks internal memory and the value of all the networks will be reset to 0, a pointer to the next block in the execution queue will be set to the first block of the diagram, setting simulation clocking to real time. The user can also freely move around the diagram and change scale, but editing diagram elements in simulator mode is restricted.
+
When simulator mode is activated, a consistency check is performed on the diagram. Then the amount of random access memory (RAM) and program memory (ROM) that the controller requires to run will be calculated. The user will be warned about any issues.  
 +
 
 +
The function block execution order will be automatically detected and displayed. All intermediate values of inputs and outputs of function blocks, function block internal memory and the value of all the networks will be reset to 0. The pointer to the next block in the execution queue will be set to the first block of the diagram. Simulation timescale is bound to real time.  
 +
 
 +
The user can also freely move around the diagram and change the display scale, however, editing diagram elements in simulator mode is impossible.
  
 
=== Continuous diagram execution ===
 
=== Continuous diagram execution ===
  
Running a continuous diagram execution by simulator is performed by selecting ''«Simulator»'' → ''«Start»'' of main menu or click the button [[File:4_7_2_1.png]] toolbar, which in this case takes the following form [[File:4_7_2_6.png]].
+
Continuously execute the diagram within the simulator by selecting ''«Simulator»'' → ''«Start»'' in the main menu or click the button [[File:4_7_2_1.png]] on the toolbar. When the simulator is running, the button takes the following form [[File:4_7_2_6.png]].
  
 
{|
 
{|
 
|valign="top" style="padding-left:0.5em;"|''Note:''
 
|valign="top" style="padding-left:0.5em;"|''Note:''
|valign="top" style="padding-left:0.5em;"|''The items "Start" and "Pause" of menu "Simulator" and buttons [[File:4_7_2_1.png]] and [[File:4_7_2_6.png]] of toolbar are combined and are activated depending on the current state of the simulator.''
+
|valign="top" style="padding-left:0.5em;"|''The items "Start" and "Pause" in the submenu "Simulator" and buttons [[File:4_7_2_1.png]] and [[File:4_7_2_6.png]] on the toolbar both serve to activate the same functionality, it doesn’t matter which one you use.''
 
|}
 
|}
  
When binding simulator clock to real time [[File:4_7_2_2.png]], which is enabled by default in the simulation mode, the simulator clock [[File:4_7_2_3.png]] start the countdown looping diagram execution with a speed of PC system clock. If disable this binding, simulator internal clock will go as fast as possible, determined by the performance of the PC.
+
When the simulator clock is bound to real time [[File:4_7_2_2.png]], which it is by default when activating the simulator mode, it will [[File:4_7_2_3.png]] start the countdown for the diagram execution loop at the speed of the PC system clock. If this binding is disabled, the simulator clock will run as fast as possible, with the maximum speed being determined by performance of your PC.
  
The scale of diagram time [[File:4_7_2_4.png]] sets the increment that will be added to simulator clock after each pass of the diagram. This parameter can be seen as the time the controller takes to one full execute of users diagram.
+
The diagram timescale [[File:4_7_2_4.png]] sets the increment that will be added to the simulator clock after each loop of the diagram. Essentially, this parameter determines the time the controller takes to perform one full execution of the user’s diagram.
  
 
{|
 
{|
 
|valign="top" style="padding-left:0.5em;"|''Note:''
 
|valign="top" style="padding-left:0.5em;"|''Note:''
|valign="top" style="padding-left:0.5em;"|''To debug a large user diagrams, implementing critical runtime algorithms for PLC CANNY 7 time scale is recommended by setting the rate of 1 ms for every 30 function blocks.''
+
|valign="top" style="padding-left:0.5em;"|''When debugging large user diagrams, which implement time-sensitive algorithms, it’s recommended to add 1ms to the timescale for every 30 function blocks present on the diagram. This recommendation applies to PLC CANNY 7, other products may require a different timescale.''
 
|}
 
|}
  
When changing the values of inputs and outputs of the functional blocks during the execution of the diagram, new values are displayed on diagram immediately beside them. For clarity, the network connected to the outputs of blocks having a value other than zero, will be highlighted.
+
When function block input and output values are changed during the execution of the diagram, their new values are displayed on the diagram right beside the function block. For the sake of visual clarity, networks connected to the outputs of blocks that have a value other than zero, will be highlighted.
  
 
[[File:4_7_2_5.png]]
 
[[File:4_7_2_5.png]]
Line 42: Line 46:
 
=== Pause and reset ===
 
=== Pause and reset ===
  
Pausing execution of diagram by simulator - select ''«Simulator»'' → ''«Pause»'' of main menu or click the button [[File:4_7_3_1.png]] of toolbar, which in this case takes the following form [[File:4_7_3_4.png]].
+
Pause the execution of the diagram within the simulator by selecting ''«Simulator»'' → ''«Pause»'' in the main menu or clicking the button [[File:4_7_3_1.png]] on the toolbar. The button will change into the following form [[File:4_7_3_4.png]] when the simulator is paused.
  
A functional block in which diagram execution has been suspended, will be highlighted in yellow. Networks, with the values changed in the last step will also be highlighted, simulator clock will be stopped.
+
The specific function block at which the execution of the diagram was suspended, is highlighted in yellow. Networks, whose values changed at the last step are also highlighted and the simulator clock is stopped.
 
+
{|
+
|valign="top" style="padding-left:0.5em;"|''Note:''
+
|valign="top" style="padding-left:0.5em;"|''The items "Start" and "Pause" of menu "Simulator" and buttons [[File:4_7_3_4.png]] and [[File:4_7_3_1.png]] of toolbar are combined and are activated depending on the current state of the simulator.''
+
|}
+
  
 
[[File:4_7_3_2.png]]
 
[[File:4_7_3_2.png]]
  
To enable auto-tracking option for the current diagram block, select ''«Simulator»'' → ''«Show block»'' of main menu or click the button [[File:4_7_3_3.png]] of toolbar, display diagram in the workspace is shifted so that the working area contain a functional block on which execution was suspended.
+
To enable auto-tracking option for the current diagram block, select ''«Simulator»'' → ''«Show block»'' in the main menu or click the button [[File:4_7_3_3.png]] on the toolbar. Whenever the execution is suspended, the option makes the display area of the workspace shift to the block at which the execution of the diagram was suspended.
  
Continuing diagram execution at a point where it was interrupted, by selecting ''«Simulator»'' → ''«Start»'' of main menu or click the button [[File:4_7_3_4.png]] of toolbar.
+
Continue diagram execution at the point where it was suspended by selecting ''«Simulator»'' → ''«Start»'' in the main menu or clicking the button [[File:4_7_3_4.png]] on the toolbar.
  
Fully stop diagram execution process and reset simulator to the initial state by selecting ''«Simulator»'' → ''«Reset»'' of main menu or click the button [[File:4_7_3_5.png]] of toolbar.
+
Fully stop the diagram execution process and reset the simulator to its initial state by selecting ''«Simulator»'' → ''«Reset»'' in the main menu or clicking the button [[File:4_7_3_5.png]] on the toolbar.
  
 
=== Conditional pausing ===
 
=== Conditional pausing ===
  
The simulator provides the ability to automatically pause the execution of the diagram on the following conditions:
+
The simulator has the ability to automatically pause the execution of the diagram when meeting one of the following conditions:
  
* when any value on the diagram has changed;
+
* when a value on the diagram changes;
* when the value of a particular network on the diagram has changed;
+
* when the value of a particular network on the diagram changes;
* after execution of the next functional block on the diagram (step mode);  
+
* when the next function block is executed (step mode);  
* before the execution of a specific function block on the diagram;
+
* before execution of a specific function block on the diagram;
* on completion of a full cycle of the diagram;
+
* on completion of a full cycle of the diagram.
  
Enabling and disabling automatic suspension of execution for any data changes performed by selecting ''«Simulator»'' → ''«Watch Changes»'' of main menu or click the button [[File:4_7_4_1.png]] of toolbar.
+
Enable and disable automatic suspension of execution when any data is changed by selecting ''«Simulator»'' → ''«Watch Changes»'' in the main menu or clicking the button [[File:4_7_4_1.png]] on the toolbar.
  
Execution of the next function block, followed by suspension of diagram execution performed by selecting ''«Simulator»'' → ''«Next»'' of main menu or click the button [[File:4_7_4_2.png]] of toolbar.
+
Execute the next function block and immediately suspend the diagram afterwards by selecting ''«Simulator»'' → ''«Next»'' in the main menu or clicking the button [[File:4_7_4_2.png]] on the toolbar.
  
Performing one full diagram cycle with the suspension of execution of the current function block performed by selecting ''«Simulator»'' → ''«Loop»'' of main menu or click the button [[File:4_7_4_3.png]] of toolbar.
+
Perform one full diagram cycle with the suspension of execution at a specific breakpoint by selecting ''«Simulator»'' → ''«Loop»'' in the main menu or clicking the button [[File:4_7_4_3.png]] on the toolbar.
  
Installing and removing a breakpoint on a particular functional block is performed by selecting the appropriate context menu item, available at the click of the right mouse button on the block. Background of the function block header declared breakpoint in simulator mode will be highlighted in red.
+
Set or remove a breakpoint at a specific function block by selecting the appropriate context menu item, available when right-clicking any function block. Header background of the function block that was declared a breakpoint will be highlighted in red in simulator mode.
  
 
[[File:4_7_4_4.png]]
 
[[File:4_7_4_4.png]]
  
In the presence on the function block declared as breakpoint on the diagram, execution of the diagram will be suspended before each execution of each such block.
+
If function block or blocks that were previously declared breakpoints exist on the diagram, the execution of the diagram will be suspended before the execution of each such block.
  
Installing and removing a breakpoint on a specific network is performed by selecting the appropriate context menu item, available at the click of the right mouse button on any network segment. The color of all segments of the network declared a breakpoint in simulator mode will be changed to red.
+
Set or remove a breakpoint at a specific network by selecting the appropriate context menu item, available when right-clicking any network segment. The color of all network segments that were declared a breakpoint will be changed to red in simulator mode.
  
 
[[File:4_7_4_5.png]]
 
[[File:4_7_4_5.png]]
  
In the presence of networks on the diagram declared breakpoints, diagram execution is suspended each time the value of each such network has changed.
+
If a network or networks were previously declared breakpoints on the diagram, diagram execution is suspended every time the value of each such network changes.
  
 
{|
 
{|
 
|valign="top" style="padding-left:0.5em;"|''Note:''
 
|valign="top" style="padding-left:0.5em;"|''Note:''
|valign="top" style="padding-left:0.5em;"|''Set or remove a breakpoint in the network or function block can be done also by double-clicking the left mouse button on these diagram elements.''
+
|valign="top" style="padding-left:0.5em;"|''You can also set or remove a breakpoint at a network or function block by double-clicking the left mouse button on these diagram elements.''
 
|}
 
|}
  
=== Forced change values ===
+
A breakpoint can also set at a write register. In this case the execution of the diagram will stop once the value of the register changes.
  
To simulate external influences on the diagram during simulation, the simulator provides the ability to manually forced change the current network values.
+
Remove all previously set breakpoints by right-clicking any free spot within the workspace and selecting the appropriate context menu item.
  
[[File:4_7_5_1.png]]
+
=== Forcibly changing values ===
  
Forced change network values is done by selecting the context menu item ''«Lock Value»'' available by right-clicking on any network segment.
+
To simulate external influences on the diagram during simulation, the simulator allows the user to to manually set the current network values.
  
In the dialog box, opened after selecting this item, entering forcibly setting value.
+
[[File:4_7_5_1.png]]
 +
 
 +
Forcibly change a given network’s value by selecting the context menu item ''«Lock Value»'' available when right-clicking on any network segment in simulator mode. Enter the desired value into the dialog box.
  
 
[[File:4_7_5_2.png]]
 
[[File:4_7_5_2.png]]
  
Value forcibly set for the network, displayed as a label on a black background.
+
Values that were forcibly set for the network are displayed with a black background.
  
 
[[File:4_7_5_3.png]]
 
[[File:4_7_5_3.png]]
  
Assigned forced value of the network will be used by functional blocks connected to this network, instead of its real value until released manually.
+
The assigned forced value of the network will be used by all function blocks connected to this network instead of its real value, until either the value is unlocked or the user exits simulator mode.
 +
 
 +
{|
 +
|valign="top" style="padding-left:0.5em;"|''Note:''
 +
|valign="top" style="padding-left:0.5em;"|''All forced values within the current simulator session are lost when the user exits simulator mode.''
 +
|}
  
Return the network to obtain the values determined by diagram operation is performed by selecting the context menu item ''«Unlock Value»'' available by right-clicking on any network segment with forcing set value.
+
Switch the network back to using the values determined by diagram operation by selecting the context menu item ''«Unlock Value»'' available when right-clicking any network segment that has a forced value.
  
 
[[File:4_7_5_4.png]]
 
[[File:4_7_5_4.png]]
  
Quickly force the value of a network equal to one, or a quick release the network value can also be a by double-clicking the left mouse button on the network, holding down the ''«Ctrl»'' button.
+
Quickly force the value of a network to one, or quickly release the network value by double-clicking the left mouse button on a network while holding down the ''«Ctrl»'' key.
  
 
=== Changing numeral system of displayed values ===
 
=== Changing numeral system of displayed values ===
  
By default, all values are displayed in the simulator as a decimal. However, the value numeral system can be changed at any time, such as hexadecimal, selecting the appropriate submenu item ''«Simulator»'' → ''«Values Format»'' of main menu.
+
By default, all values are displayed in the simulator in the decimal system. The numeral system used for displaying values can be changed at any time by selecting the appropriate submenu item ''«Simulator»'' → ''«Values Format»'' in main menu or by clicking the appropriate button on the toolbar.
  
 
[[File:4_7_6_1.png]]
 
[[File:4_7_6_1.png]]

Latest revision as of 11:03, 11 December 2020

Working in simulator mode, CannyLab performs actions to diagram data that are equivalent to the compute actions that would be carried out on them by the controller kernel, which allows the user to simulate the operation of the controller on the PC.

The user has the ability to simulate the execution of the function diagram for debugging and testing at any stage of its development. In simulator mode, it is possible to run the diagram on a per-cycle and per-step basis, set the conditions for suspension of execution, forcibly set the input and output values of the function blocks, control intermediate values.

Note: In the current version of CannyLab simulator there is no support for controller hardware resources, so the results of reads/writes from/to registers in the simulator may differ from the results obtained when the diagram is executed by the controller.

Enabling simulator mode

Enabling and disabling the simulator mode is done by selecting the appropriate item in the «Simulator» submenu in the main menu, or by pressing 4 7 1 1.png on the toolbar.

The layout of the application changes when entering simulator mode. Control elements unavailable in this mode are replaced with ones specific to simulator mode, debugging information is added on the diagram.

4 7 1 2.png

When simulator mode is activated, a consistency check is performed on the diagram. Then the amount of random access memory (RAM) and program memory (ROM) that the controller requires to run will be calculated. The user will be warned about any issues.

The function block execution order will be automatically detected and displayed. All intermediate values of inputs and outputs of function blocks, function block internal memory and the value of all the networks will be reset to 0. The pointer to the next block in the execution queue will be set to the first block of the diagram. Simulation timescale is bound to real time.

The user can also freely move around the diagram and change the display scale, however, editing diagram elements in simulator mode is impossible.

Continuous diagram execution

Continuously execute the diagram within the simulator by selecting «Simulator»«Start» in the main menu or click the button 4 7 2 1.png on the toolbar. When the simulator is running, the button takes the following form 4 7 2 6.png.

Note: The items "Start" and "Pause" in the submenu "Simulator" and buttons 4 7 2 1.png and 4 7 2 6.png on the toolbar both serve to activate the same functionality, it doesn’t matter which one you use.

When the simulator clock is bound to real time 4 7 2 2.png, which it is by default when activating the simulator mode, it will 4 7 2 3.png start the countdown for the diagram execution loop at the speed of the PC system clock. If this binding is disabled, the simulator clock will run as fast as possible, with the maximum speed being determined by performance of your PC.

The diagram timescale 4 7 2 4.png sets the increment that will be added to the simulator clock after each loop of the diagram. Essentially, this parameter determines the time the controller takes to perform one full execution of the user’s diagram.

Note: When debugging large user diagrams, which implement time-sensitive algorithms, it’s recommended to add 1ms to the timescale for every 30 function blocks present on the diagram. This recommendation applies to PLC CANNY 7, other products may require a different timescale.

When function block input and output values are changed during the execution of the diagram, their new values are displayed on the diagram right beside the function block. For the sake of visual clarity, networks connected to the outputs of blocks that have a value other than zero, will be highlighted.

4 7 2 5.png

Pause and reset

Pause the execution of the diagram within the simulator by selecting «Simulator»«Pause» in the main menu or clicking the button 4 7 3 1.png on the toolbar. The button will change into the following form 4 7 3 4.png when the simulator is paused.

The specific function block at which the execution of the diagram was suspended, is highlighted in yellow. Networks, whose values changed at the last step are also highlighted and the simulator clock is stopped.

4 7 3 2.png

To enable auto-tracking option for the current diagram block, select «Simulator»«Show block» in the main menu or click the button 4 7 3 3.png on the toolbar. Whenever the execution is suspended, the option makes the display area of the workspace shift to the block at which the execution of the diagram was suspended.

Continue diagram execution at the point where it was suspended by selecting «Simulator»«Start» in the main menu or clicking the button 4 7 3 4.png on the toolbar.

Fully stop the diagram execution process and reset the simulator to its initial state by selecting «Simulator»«Reset» in the main menu or clicking the button 4 7 3 5.png on the toolbar.

Conditional pausing

The simulator has the ability to automatically pause the execution of the diagram when meeting one of the following conditions:

  • when a value on the diagram changes;
  • when the value of a particular network on the diagram changes;
  • when the next function block is executed (step mode);
  • before execution of a specific function block on the diagram;
  • on completion of a full cycle of the diagram.

Enable and disable automatic suspension of execution when any data is changed by selecting «Simulator»«Watch Changes» in the main menu or clicking the button 4 7 4 1.png on the toolbar.

Execute the next function block and immediately suspend the diagram afterwards by selecting «Simulator»«Next» in the main menu or clicking the button 4 7 4 2.png on the toolbar.

Perform one full diagram cycle with the suspension of execution at a specific breakpoint by selecting «Simulator»«Loop» in the main menu or clicking the button 4 7 4 3.png on the toolbar.

Set or remove a breakpoint at a specific function block by selecting the appropriate context menu item, available when right-clicking any function block. Header background of the function block that was declared a breakpoint will be highlighted in red in simulator mode.

4 7 4 4.png

If function block or blocks that were previously declared breakpoints exist on the diagram, the execution of the diagram will be suspended before the execution of each such block.

Set or remove a breakpoint at a specific network by selecting the appropriate context menu item, available when right-clicking any network segment. The color of all network segments that were declared a breakpoint will be changed to red in simulator mode.

4 7 4 5.png

If a network or networks were previously declared breakpoints on the diagram, diagram execution is suspended every time the value of each such network changes.

Note: You can also set or remove a breakpoint at a network or function block by double-clicking the left mouse button on these diagram elements.

A breakpoint can also set at a write register. In this case the execution of the diagram will stop once the value of the register changes.

Remove all previously set breakpoints by right-clicking any free spot within the workspace and selecting the appropriate context menu item.

Forcibly changing values

To simulate external influences on the diagram during simulation, the simulator allows the user to to manually set the current network values.

4 7 5 1.png

Forcibly change a given network’s value by selecting the context menu item «Lock Value» available when right-clicking on any network segment in simulator mode. Enter the desired value into the dialog box.

4 7 5 2.png

Values that were forcibly set for the network are displayed with a black background.

4 7 5 3.png

The assigned forced value of the network will be used by all function blocks connected to this network instead of its real value, until either the value is unlocked or the user exits simulator mode.

Note: All forced values within the current simulator session are lost when the user exits simulator mode.

Switch the network back to using the values determined by diagram operation by selecting the context menu item «Unlock Value» available when right-clicking any network segment that has a forced value.

4 7 5 4.png

Quickly force the value of a network to one, or quickly release the network value by double-clicking the left mouse button on a network while holding down the «Ctrl» key.

Changing numeral system of displayed values

By default, all values are displayed in the simulator in the decimal system. The numeral system used for displaying values can be changed at any time by selecting the appropriate submenu item «Simulator»«Values Format» in main menu or by clicking the appropriate button on the toolbar.

4 7 6 1.png

See also

CANNY Lab