CANNY Lab Simulator
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
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.
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 on the toolbar. When the simulator is running, the button takes the following form .
|Note:||The items "Start" and "Pause" in the submenu "Simulator" and buttons and 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 , which it is by default when activating the simulator mode, it will 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 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.
Pause and reset
Pause the execution of the diagram within the simulator by selecting «Simulator» → «Pause» in the main menu or clicking the button on the toolbar. The button will change into the following form 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.
To enable auto-tracking option for the current diagram block, select «Simulator» → «Show block» in the main menu or click the button 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.
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.
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.
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.
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.
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.
Values that were forcibly set for the network are displayed with a black background.
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.
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.