This documentation is out of date.

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

CANNY Lab Simulator

From CANNY Wiki
Revision as of 11:03, 11 December 2020 by Marat (Talk | contribs) (Initial edit)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Jump to: navigation, search

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