Accessing the Values of System Variables

While running an application online, access diagnostic information from system variables for individual controllers, updated by the running code or simulation code. When running an application online, the cycle timing system variables are also available from the
Cycle Timing
dialog box, accessed from the
Online
menu.
System variables hold the values of information relating to cycle count, timing, kernel bindings, and controller information. Monitor system variables from the dictionary instances for resources. Read from and write to system variables. Available system variables are:
Variable name
Type
Read/Write
Description
__SYSVA_CYCLECNT
DINT
Read
Cycle counter
__SYSVA_CYCLEDATE
UDINT
Read
Timestamp of the beginning of the cycle in milliseconds
__SYSVA_KVBPERR
BOOL
Read/Write
Kernel variable binding producing error (production error)
__SYSVA_KVBCERR
BOOL
Read/Write
Kernel variable binding consuming error (consumption error)
__SYSVA_RESNAME
STRING
Read
Resource name (max length=255)
__SYSVA_SCANCNT
DINT
Read
Input scan counter
__SYSVA_TCYCYCTIME
TIME
Read/Write
Programmed cycle time. The defined cycle time for the controller.
__SYSVA_TCYCURRENT
TIME
Read
Current cycle time. The time spent with the virtual machine.
__SYSVA_TCYMAXIMUM
TIME
Read
Maximum cycle time. The longest period of time used for a current cycle (__SYSVA_TCYCURRENT), since connecting to the controller.
__SYSVA_TCYOVERFLOW
DINT
Read
Cycle overflow. The number of current cycles (__SYSVA_TCYCURRENT) that have exceeded the programmed cycle time.
__SYSVA_RESMODE
SINT
Read
Resource execution mode. Possible modes are:
  • -5: Non-fatal error
  • -4: Stopped in stepping mode after bound check exception
  • -3: Stopped in stepping mode after division by zero exception
  • -2: Stopped in stepping mode after exception
  • -1: Fatal error
  • 0: No resource available
  • 1: Stored resource available NOT USED (CMG)
  • 2: Ready to run
  • 3: Running in real time
  • 4: Running in cycle by cycle
  • 5: Stopped from encountering an SFC breakpoint
  • 7: Stopped while in stepping mode
__SYSVA_CCEXEC
BOOL
Write
Execute one cycle when application is in cycle to cycle mode
__SYSVA_TCYTRUECURRENT
TIME
Read
True cycle time. The real duration of a cycle.
To access the values of system variables in design mode
  • From a program organization unit (POU), right-click the required variable, and select
    Variable Monitoring
    (or press
    Ctrl+I
    ).
To access the values of system variables in online or simulation mode
  1. Create a spy list.
  2. Open the
    Variable Selector
    from a language editor.
  3. Select the
    System Variables
    tab.
  4. Select all variables.
  5. Right-click and select
    Add to
    <name of created spy list>
    .
  6. Run the application online or simulate the application.
  7. Open the created spy list.
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.
Normal