beautypg.com

BECKHOFF CP-Link3 User Manual

Page 56

background image

Page 56

Note

Configuration of Clients

Setting the HID Focus manually is only possible for clients which are configured for HID
Focus "Manual" (see also Client Configuration - HID-Focus).

Note

CP-Link 3 Service

Settings the HID Focus manually is only possible if the CP-Link 3 Service is running
(see also CP-Link 3 Service ).

Example Program: Controlling the HID focus through special keys

Manually setting the HID focus can, for instance, be controlled by a clients special key. The special key is linked to the
corresponding input variable in the PLC program through the TwinCAT System Manager. An instance of
FB_CPLink3_AcquireHidFocus is generated for each client, and configured with the client's IP address. After the special
key at a client is pressed, where the rising edge will be detected by the R_TRIG function block, the PLC program will
attempt to set the HID focus through the corresponding instance of FB_CPLink3_AcquireHidFocus . The function block
can, in addition, control an output (e.g. a LED) that indicates whether the HID focus has successfully been set, or
whether it is still attempting to obtain the focus. Pressing the special key again resets the HID focus.

The three instances of the FB_CPLink3_AcquireHidFocus function block use the hFocus variable to exchange
information between each other. This is used, for instance, to ensure that only the instance that has successfully set the
HID focus is able to reset it.

The PLC program for three clients looks like this:

PROGRAM MAIN
VAR
button1 AT%IX0.0 : BOOL;
button2 AT%IX0.1 : BOOL;
button3 AT%IX0.2 : BOOL;

led1 AT%QX0.0 : BOOL;
led2 AT%QX0.1 : BOOL;
led3 AT%QX0.2 : BOOL;

hFocus : T_HCPLink3HidFocus;
fbPanel1 : FB_CPLink3_AcquireHidFocus := ( setIP := '192.168.1.1' );
fbPanel2 : FB_CPLink3_AcquireHidFocus := ( setIP := '192.168.1.2' );
fbPanel3 : FB_CPLink3_AcquireHidFocus := ( setIP := '192.168.1.3' );

trigger1 : R_TRIG;
trigger2 : R_TRIG;
trigger3 : R_TRIG;
END_VAR

(* Panel 1 *)

trigger1( CLK := button1 );
IF trigger1.Q THEN
fbPanel1.bEnable := NOT fbPanel1.bEnable;
END_IF
fbPanel1( hFocus:= hFocus, bLED=>LED1);

(* Panel 2 *)

trigger2( CLK := button2 );