Forcing the values of variables

How to force a value for a →Variable within the Values of Variables view in order to permanently write it onto the →PLC:

  1. If the variable is included within a collapsed level, expand this collapsed level.
    To speed the expanding up: Filter the view. The levels with found matches are automatically expanded.

  2. Double-click the field within the column Prepared value for the variable in the view. Alternative: Select the variable, then p ress and hold the Ctrl-key and press the Enter-Key .
    Result: A dialog is opened to edit or change the value. Here the dialog for the INT variable count:

    images/download/attachments/414778879/VariablesValue_Edit-version-1-modificationdate-1534413394242-api-v2.png
  3. In the dialog, enter a value or select it from a list and click images/download/attachments/405733757/SetVar-version-1-modificationdate-1529910884916-api-v2.png . If you want to enter special characters, such as umlauts, for STRING or CHAR variables, you have to enter a three-character combination of the dollar sign ($) followed by two hexadecimal digits (details: see examples under →character string literal).
    Result: The prepared value is now displayed in the column Prepared value. It has not been written to the PLC yet.

  4. If required, enter prepared values for other variables as well.

  5. Click onto images/download/thumbnails/457572895/ForceValue-version-2-modificationdate-1612255245129-api-v2.png (Force prepared values) in the toolbar of the view. Alternative: Press Ctrl+F .
    Result: The prepared values of the variables are forced, i.e. they are written to the PLC by force. Subsequently, the column Value displays this force value with the preceding icon images/download/thumbnails/457572887/ForcedValue-version-2-modificationdate-1612253482976-api-v2.png . If you are monitoring the values within a viewer or an editor, this ST-viewer or FBD-editor with →instance context also displays these force values (but without an appropriate icon that it is a force value).

Compare:

The value 1 is prepared for Counter.count but not written to the PLC yet:
images/download/attachments/457572984/ExampleForcing1EN-version-1-modificationdate-1612272073866-api-v2.png

Now the value 1 has been written as force value for Counter.count to the PLC:
images/download/attachments/457572989/ExampleForcing2EN-version-1-modificationdate-1612272129128-api-v2.png

Good to know

images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/lightbulb.svg If you are temporarily changing the values of forced variables (see "Changing the values of variables: writing values to PLC"), these values will be overwritten by the →runtime system at the beginning and the end of a task cycle by the specified force value.
A cycle of the user task incl. forcing consists of these steps:

  1. reading the hardware inputs of the target system, if there is an IO-task

  2. writing all forced values to the variables

  3. executing all →programs that are assigned to the task

  4. writing all forced values to the variables

  5. writing the hardware outputs of the target system, if there is an IO-task

images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/lightbulb.svg For forcing, you need a runtime system that supports forcing (e.g. the built-in PLC). Ask the manufacturer of the runtime system whether forcing is supported.

images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/lightbulb.svg You are able to force the variables for which logi.CAD 3 displays values within the Values of Variables view – but not for →reference variables and not for →in-/out variables . Hence, forcing is supported for these variable sections:

  • the hardware IOs (= inputs/outputs) of the target system

  • the internal →variables of a program or a →function block

  • the →global variables of a program

  • the →external variables of a program or a function block
    images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/information.svg As an e xternal variable allows accessing the global variable with the same name, the best practice is to force either the global variable or the external variable. If you force both variables anyway and you prepare different values, there is no deterministic order which prepared value will be used for forcing .

  • the →input variables of a function block

  • the →output variables of a function block

How to deactivate the forcing of the variables:

  • For all connected PLC for which variables are displayed within the Values of Variables view: Click onto the button images/download/thumbnails/457572918/ForceValueStop-version-2-modificationdate-1612254950120-api-v2.png (Deactivate forcing) in the toolbar of the view. Alternative: Press Ctrl+D . Then click Yes to answer the prompt.

  • Only for one PLC: Disconnect from this PLC or load the application onto the PLC again.

Result of the deactivated forcing: The column Value of the Values of Variables view displays the values of the variables as they are read/written due to the execution – without the preceding icon images/download/thumbnails/457572887/ForcedValue-version-2-modificationdate-1612253482976-api-v2.png . The ST-viewer and the FBD-editor with instance context display these actual values as well.

Good to know

images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/lightbulb.svg When the forcing is deactivated, the prepared values entered within the column Prepared value are kept . Hence, you are able to force the variables again at any time by clicking onto images/download/thumbnails/457572895/ForceValue-version-2-modificationdate-1612255245129-api-v2.png .

images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/lightbulb.svg If the connection to the PLC is lost e.g. by a network error, forcing remains activated .

There is a special variant for deactivating the forcing:

  1. For some variables only, delete the prepared value that is entered in the column Prepared value. For other variables, keep the prepared value in the column.

  2. Click onto images/download/thumbnails/457572895/ForceValue-version-2-modificationdate-1612255245129-api-v2.png (Force prepared values) in the toolbar of the view.
    Result: Forcing is deactivated for those variables for which you deleted the prepared value. In contrast to this deactivation, the other variables are still forced.