-

Debugging Code: Forcing/Overwriting

Note
This topic only applies to the standard (non-safety-related) controller. The steps for the Safety PLC are described in the help chapter "Safety PLC Commissioning: From Compiling to Debugging ‣ Safety PLC Commissioning: From Compiling to Debugging
×‣ Connecting vs. Monitoring Mode vs. Debug Mode
×‣ Controlling the Safety Application from the Safety Cockpit
×‣ Safety PLC Diagnostics out of the Safety Cockpit
×‣ Monitoring/Debugging the Safety PLC
×‣ Monitoring Mode: Displaying Online Values
×‣ Debugging Safety-Related Code: Forcing/Overwriting
×‣ WATCHES: Monitoring/Debugging the Safety-Related Application
×‣ Safety PLC Simulation
×
".

To supplement the function test, the editors provide several debug features in debug mode. For example, instead of pressing a button at the machine, you can force the corresponding input variable/port in the graphical editor. This enables monitoring the reaction of the application.

Debug functions are only available while PLCnext Engineer is attached to the application process, i.e., switched to debug mode.

In debug mode, the system provides the possibility of

WARNING
Unintended machine operation
  • Prior to forcing/overwriting variables during runtime, make certain that suitable organizational measures (according to applicable sector standards) have been taken to avoid hazardous situations if the application logic functions in an unintended or incorrect way.
  • Verify the impact of forcing or overwriting variables.
  • Do not enter the zone of operation while the machine is operating.
  • Ensure that no other persons can access the zone of operation while the machine is operating.
  • Observe the regulations given by relevant sector standards while the machine is running in any other operating mode than "operational".
  • Use appropriate safety interlocks where personnel and/or equipment hazards exist.

Forcing and overwriting variables in debug mode

Both, forcing and overwriting means assigning a new value to a variable. Both operations are only possible while the software runs in debug mode.

What is the difference between forcing and overwriting?

  • Overwriting is possible for local and global variables (marker variables without assigned process data item) as well as for I/O variables (assigned to process data items). The value is overwritten (set) only once at the beginning of the task execution cycle. Then, the variable is processed normally. Thus, the new value of the variable remains until a write access is performed. A write access can be performed by a programmed store operation or by remote access (e.g., by the OPC server) or by initializing the variable in case of a controller cold start.
  • Forcing is possible for variables and ports which are connected to process data items, i.e., I/O variables/ports. Forcing means setting the I/O variable/port permanently to the force value until forcing is reset by the user.

    Forcing takes place at the beginning and at the end of a program cycle. Within a cycle, the application may change the variable value by a write access. In this case, it is set to the force value again at the end of the cycle (until you unforce it).

    Example

    Note
    Depending on the controller type used, forcing may not be supported in the current version.

Forcing/overwriting can be done in online code worksheets, online variables tables/Data Lists/Port Lists, and in the WATCHES window.
To modify a force value or unforce variables/ports, additionally the FORCELIST window can be used.

What do you want to do?

Note
In order to debug user-defined functions/methods and/or to show the execution value (actual value at the code position) in online worksheets, you have to select the required extended debug option in the controller Cockpit. Refer to the sections "Extended debugging: execution values vs. "normal" online values" and "Extended debugging of user-defined functions, methods, and SFC actions/transitions" for details.

Force/overwrite a variable in an online code worksheet

Force/overwrite a variable in an online variables table or Data List

Force/overwrite a variable in the WATCHES window

Force/unforce a variable in the FORCELIST window

Unforce (reset) a forced variable