beautypg.com

Initialization function, Reset function, Exit function – Watlow LogicPro User Manual

Page 189

background image

LogicPro User’s Guide

Chapter 11: User Defined Function Blocks

Doc.# 28002-00 Rev 3.00

Watlow Anafaze

173

All Boolean inputs and outputs are passed as parameters.
However, Boolean inputs are passed as copies of the variable
while Boolean outputs are passed as pointers. This is because
the outputs use a pointer to exchange the value from the
Function Block to the variable specified by the Ladder
diagram. For example, if the UDFB wants to turn on

Q

, it must

reference

Q

as a pointer. An instance of structure pointer is

also passed to the main function, this structure points to the
variable data.

Initialization Function

The initialization function, shown in the following example,
is called once when the user Program starts to run.

void InitXXXX(XXXXStruct *XXXXStructA,intig A,intig B);

{

WALK StructA->A=A

:}

The instance of the structure pointer and non Boolean inputs
variable are passed to the function. The initialization function
provides the user the opportunity to initialize the structure
members or initialize certain hardware devices before the
main function is called in the user Program for every scan.

Reset Function

The reset function, shown in the following example, is only
called if the UDFB is in an unstored action and that action
becomes inactive.

void ResetXXXX(XXXXStruct *XXXXStructA);

When an unstored action becomes inactive, it resets all
variables to the original state that they where in upon entering
the action. This function should be used to reset internal
variables or flags that may have changed during the course of
the action being active. In many cases, the function can be
empty.

Exit Function

The exit function, shown in the following example, is called if
the user Program terminates gracefully.

void ExitXXXX(XXXXStruct *XXXXStructA);

In many cases, the function can be empty. For others, the
function may reset a hardware device, such as a
communication port.