Heartbeat

In this chapter you will find a description of the VIs with which you can create a Heartbeat connection monitoring between LabVIEWTM and TwinCAT. Further information on the parameters can be found in the Heartbeat Connection Monitoring section in the technical introduction. Connection monitoring can be created from the following Low-Level VIs:

The folder also contains the Heartbeat basic VI, in which the connection monitoring is summarized in a VI.

Heartbeat 1:

System requirements

The Heartbeat function is available from TwinCAT 3.1 Build 4026.

Init Heartbeat

The "Init Heartbeat" block creates a Heartbeat instance. Based on the client handle (see Init), a scan is performed for each registered target to determine whether an instance of FB_Heartbeat exists. If this is the case, connection monitoring is prepared for each heartbeat found. If no instance of FB_Heartbeat is found at any target, the VI returns the error -8114.

Heartbeat 2:

FB_Heartbeat

The FB_Heartbeat function block can be found in the Tc3_HeartbeatConnectionMonitoring library and must be created and called in the project for which connection monitoring is being set up.

The block also creates a Heartbeat event. This can then be used to query the status of the connection. As soon as the status of the connection changes, a Heartbeat event is generated. The Heartbeat event has the following event dates:

Heartbeat 3:

Input/output

Meaning

[0][4] Handle

Handle to the ADS client

[5] PollingTime in ms

Parameter Polling time in ms

[6] HeartbeatHandle

Handle to the Heartbeat instance

[7] UseRtdEstimation?

Parameter UseRtdEstimation

[9] Offset in ms

Parameter offset

[10] HeartbeatEvent

User Event Refnum on the generated Heartbeat event

Run Heartbeat

The Run Heartbeat block is used to start and continuously execute connection monitoring. This block is executed until the connection monitoring is stopped with the Stop Heartbeat.

Heartbeat 4:

Input/output

Meaning

[0][4] Handle

Handle to the ADS client

[5][6] HeartbeatHandle

Handle to the Heartbeat instance

Stop Heartbeat

The Stop Heartbeat block is used to stop connection monitoring.

Heartbeat 5:

Input/output

Meaning

[0][4] HeartbeatHandle

Handle to the Heartbeat instance

Release Heartbeat

The Release Heartbeat block releases the handle to the Heartbeat connection monitoring from the memory.

Heartbeat 6:

Input/output

Meaning

[0][4] Handle

Handle to the ADS client

[5] HeartbeatHandle

Handle to the Heartbeat instance

Get RTD Estimate

The Get RTD Estimate block returns the current (maximum) roundtrip delay (RTD) estimate for the selected target. The target can be selected via the "TargetAddr" string. If the string is empty, the target found first is automatically selected. To use this block, it is necessary to execute the Heartbeat connection monitoring (see VIs described above).

Heartbeat 7:

Input/output

Meaning

[0][4] Handle

Handle to the ADS client

[5][6] HeartbeatHandle

Handle to the Heartbeat instance

[7][8] TargetAddr

String with the address of the target

[10] RTDEstimate

Estimation of the maximum RTD in ms

Heartbeat

The Heartbeat block uses the Init Heartbeat, Run Heartbeat, Stop Heartbeat and Release Heartbeat blocks internally to enable the use of Heartbeat connection monitoring with just one block. The Heartbeat block also serves as an illustration of how Heartbeat connection monitoring can be used and edited.

Heartbeat connection monitoring is carried out continuously until it is stopped via a control. If the connection monitoring detects an interruption (timeout), an attempt is made to call up a VI (vi path timeout detected). If it is not possible to call the VI, the block and Heartbeat connection monitoring are stopped. At the output of the VI, the target for which an interruption was detected is then displayed via Timeout detected and the TargetAddr. If there are several interruptions, only the first interruption is displayed.

Heartbeat 8:

Input/output

Meaning

[0][4] Handle

Handle to the ADS client

[1] Stop Heartbeat

Reference to a Boolean control that is used to end the execution of the Heartbeat VI.

[2] vi path timeout detected

Path to a VI that is to be called if a connection interruption is detected.

[5] PollingTime in ms

Parameter Polling time in ms

[6] TargetAddr

String that specifies the target to which the possible timeout belongs.

[7] UseRtdEstimation?

Parameter UseRtdEstimation

[9] Offset in ms

Parameter offset

[10] Timeout detected

Indicates whether a connection interruption was detected.