Retrieve values - Manual - Structured Text Debugger - The SIMATIC Debugger. Enables debugging source code on the PLC and is needed to run the debugger extension. - Debugger (sdb),tool

Structured Text Debugger CLI Tool (sdb)

Portfolio
SIMATIC AX
Product
Structured Text Debugger
Software version
1.3.6
Edition
11/2024
Language
English (original)
Package Name
@ax/sdb

Variable values are retrieved using the 'watch add' command.

Logpoint in a function

The following line adds a logpoint at line 16 in the file 'func.st':

watch add ./src/funcProgram/func.st:16 in;const;temp;out;MyFunction

The output will look similar to this (depending on the current cycle):

>Scope: ./src/funcProgram/func.st -> Line:2 -> MyFunction - Installed successful
   Callpath: Not set
   Logpoints:
      Line:16 Id:1 - Installed
Scope: ./src/funcProgram/func.st -> Line:2 -> MyFunction
   Logpoints:
      Line:16 Id:1 Age:0
         in -> 4
         const -> UnknownSymbol
         temp -> 0
         out -> 0
         MyFunction -> 0

The first message is an update of the currently installed Logpoints on the PLC. Logpoints are grouped according to their scope. The scope is the equvilant to a program organization unit (Program, Method, Function, Function block) - in this case it is the function MyFunction which starts in line 2 of the file ./src/funcProgram/func.st.
A scope can have a trigger condition called Callpath, which is not set in this example. The callpath feature is described in detail below in the chapter trigger condition - callpath.

The second message contains the actual values - this message will be resend every 200 ms with updated values. The values are retrieved before line 16 is executed, so the value for temp will not have been written in the current cycle and will therefore still be the default value (0). The same is true for out and the return value MyFunction.
The value shown for in is the current value.
The variable const cannot be debugged because no debug information is created for constant variables.
The Age value of 0 shows that all values are from the current call of MyFunction.

The following line removes the logpoint and stops all output connected to it:

watch remove 1

The watch removed message is printed once the logpoint has been removed successfully:

Scope: ./src/funcProgram/func.st -> Line:2 -> MyFunction - Uninstalled successful
   Callpath: Not set
   Logpoints:
      Line:16 Id:1 - Removed

Logpoint in a class

The same can be done with a class. The following line adds a logpoint at line 14 in the file 'class.st':

watch add src/classProgram/class.st:14 Motor1;Motor2.is_running;is_running

The output will look like this:

>Scope: src/classProgram/class.st -> Line:11 -> Start - Installed successful
   Callpath: Not set
   Logpoints:
      Line:14 Id:2 - Installed
Scope: src/classProgram/class.st -> Line:11 -> Start
   Logpoints:
      Line:14 Id:2 Age:0
         Motor1:
            Motor1.is_running -> True
            Motor1.power_consumption -> 369
            Motor1.hours_operating -> 10
         Motor2.is_running -> True
         is_running -> False

The values are retrieved before line 14 is executed,
The variable Motor1 is resolved and displayed with all its members.
Motor1.is_running and Motor2.is_running are already set in the lines 12 and 13 and are therefore True. The variable is_running defined in the 'VAR PUBLIC' section still has the value False from the last call of the Stop method.
The Age value of 0 shows that all values are from the current call of the method Start.

The following line removes the logpoint and stops all output connected to it:

watch remove 2

Logpoint with an age > 0

This example uses the files in the folder 'fbProgram' - 'fbProgram.st' and 'fb.st'.
'fbProgram.st' simply counts the variable UpCounterInt and calls fb as defined in fb.st.
The function block fb sets returnValue to '1337' every 7th call, otherwise it is '42'.

The following line adds a logpoint at line 19 in the file 'fb.st':

watch add ./src/fbProgram/fb.st:19 temp;static

The output will look similar to this (depending on the current cycle):

>Scope: .src/fbProgram/fb.st -> Line:1 -> Fb - Installed successful
   Callpath: Not set
   Logpoints:
      Line:19 Id:3 - Installed
Scope: .src/fbProgram/fb.st -> Line:1 -> Fb
   Logpoints:
      Line:19 Id:3 Age:6
         temp -> 42
         static -> 0

The values are retrieved before line 19 is executed,
In this case, the Age is greater than '0'. This means that the values shown were retrieved in a previous call of the function block Fb. In this example, '6' calls of the Fb have been executed since the values were retrieved.
In this example, Age will never be higher than '6'. If line 15 of the 'fb.st' file is changed to 'MOD 4', for example, the highest possible Age will be '3'.

The following line removes the logpoint and stops all output connected to it:

watch remove 3