# Use of function blocks for block search

The 4 subtasks for implementing block search are listed below including the associated function blocks used:

## Subtask 1: Acquire data at a breakpoint

The current data relating to NC program execution must be saved at every reset so that block search can start at the breakpoint. The FB MCV_ReadActualPathInfo supplied the required information. For this reason it should be called cyclically and always be enabled.

## Subtask 2: Parameter definition of block search

To ensure an NC program runs in block search mode, the parameters for the required block search type must be sent to the motion controller before the NC program starts. This is implemented by setting the “Execute” input to TRUE. An FB is defined in the library for every block search type available:

- Block search defined by block counter: MCV_BlockSearchSetBlockCount
- Block search defined by block number: MCV_BlockSearchSetBlockNumber
- Block search defined by file offset: MCV_BlockSearchSetFileOffset

## Subtask 3: Handshake with the motion controller

An NC program is started in block search in the same way as without block search. However, if a block search type is enabled by the parameters, the PLC is informed of this after NC program start-up and can then take the required measures. The PLC sends an acknowledgement to the motion controller at the end of these preparations. The motion controller then signals that the continuation position is found and this is again acknowledged by the PLC.

The FB MCV_BlockSearchCtrl is used for this task.

## Subtask 4: Disable block search

The block search type remains enabled after the NC program ends. To ensure that block search is not active at the next program start-up, it must be disabled. The FB MCV_BlockSearchDeselect is used for this purpose.