-

Connecting vs. Attaching (Debug On)

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
×‣ Safety Cockpit: Controlling the Safety Application
×‣ 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
×
".

Note
Poor internet connection? Performance problems due to VPN connection? You can adapt the TCP communication settings by increasing the handshake timeout value and the polling interval. See topic "TCP Communication Connection".

Note
Ad-hoc IP address instead of project-defined address
Instead of the IP address defined in the controller settings of the project, you can also connect to a controller with any other IP address (provided it can be accessed in the network). In this way, communication connections to several PLCnext devices can be established one after the other (e.g. in router scenarios) without having to change the IP address in the project settings and rebuild the project. How to do this is described under "Ad-hoc IP address instead of project-defined address".

Between PLCnext Engineer and the controller, two (hierarchical) connection levels are distinguished:

Also observe the section "Detaching and Disconnecting" below.

The state of the connection is indicated by the controller icon in the PLANT (see icon descriptions below). Additionally, the tooltip of the controller icon shows the current connection state.

Level 1: connected to the controller

To establish a communication connection, proceed as follows.
  1. Right-click the controller in the PLANT and select 'Connect/Disconnect' from the context menu, or
    select the command in the context menu of the controller in the ONLINE STATE window, or
    click the 'Connect to controller' button on the 'Cockpit' toolbar.

  2. If the controller involved implements a secure device concept, and if you are not yet logged on to the controller (black shield symbol beside the controller icon in the PLANT), the authentication dialog appears. Enter a user name of the desired and suitable role as well as the relating password and press <Enter> to log on. (Make sure that the user role you are entering allows writing and starting the project.)
    If an authentication error occurs during connection establishment (due to a rejected or unknown controller certificate), a dialog appears where you can instruct PLCnext Engineer to establish the ("unsecured") connection nevertheless.

    While you are logged on to the controller, this is indicated by a green shield symbol beside the controller icon in the PLANT.
    If you have accepted an "unsecured" connection, the following shield symbol is displayed:
    Refer to the topic "Network Security" for details.

While connected, the controller icon in the PLANT indicates the controller status. Examples:

= state On, no project is loaded
= Running

Being connected, the following operations are possible:

Note
Logging on to the controller (if a security concept is provided) by entering a user name and password into the authentication dialog automatically establishes a communication connection to the controller like the 'Connect' command described here.

Level 2: debug mode = attached to the application process

Attaching PLCnext Engineer to the running application on the controller means establishing an online connection and starting the debug mode. This is only possible if the controller is already connected (level 1). Activate the debug mode as follows:

Note
When activating the debug mode, a comparison of the project names and the CRCs of the local project loaded in PLCnext Engineer and the project executed on the controller is performed. If the project names and/or CRCs differ, a corresponding message appears informing you about the project differences. You can either abort the process or continue. If you continue, wrong online values may be displayed. If you cancel the dialog, the process is aborted and a corresponding warning is shown in the 'Online Log' in the 'MESSAGES' window.
 
Behavior with breakpoints set
If breakpoints are set (no matter whether the breakpoint is in enabled or disabled state) or the controller is in halt mode and the CRCs differ, debug mode cannot be enabled. A corresponding message appears where you can abort the process. The 'Online Log' shows a corresponding warning after aborting.
 
If you have entered the debug mode with different CRCs, the breakpoint will be disabled/in disabled state. When you set a breakpoint, the breakpoint will enter the disabled state.

In debug mode, the controller icon in the PLANT indicates the controller status. Examples:

= state On, no project is loaded
= Running

In debug mode, the following operations are possible:

Note
Both connection levels ("connected to" as well as "debug mode") are automatically established after executing one of the 'Write and Start' commands.

Detaching and Disconnecting

The debug mode can be terminated by detaching from the running application process. Terminating the debug mode means switching back to programming mode.
To exit the debug mode and detach PLCnext Engineer from the running application process, select 'Debug On/Off' from the context menu of the controller node (PLANT) or click the appropriate button on the 'Cockpit' toolbar (see icon left).

After detaching, PLCnext Engineer is still connected to the controller but no online values or debug commands are transmitted any longer. This is also indicated by the controller icon in the PLANT which represents the controller state.

To reattach to the application process, select the 'Debug On/Off' command again.

When selecting the 'Connect/Disconnect' command from the controller context menu in the PLANT or on the 'Cockpit' toolbar (see icon left) while debug mode is active, PLCnext Engineer detaches from the application process (programming mode becomes active) and then disconnects from the controller.

Note
If the controller involved implements a secure device concept, you have to be logged on while connected to the controller (green shield symbol beside the controller icon in the PLANT).
Disconnecting manually from the controller does not imply a logoff. Instead, you remain logged on with the current user role.
An unexpected disconnection, however, results in an automatic logoff which is indicated by the desktop alert "Credentials withdrawn". In this case, you have to re-logon as described below.