beautypg.com

Udfb files, Main function – Watlow LogicPro User Manual

Page 188

background image

Chapter 11: User Defined Function Blocks

LogicPro User’s Guide

172

Watlow Anafaze

Doc.# 28002-00 Rev 3.00

UDFB

Files

As soon as a new UDFB is defined, LogicPro automatically
generates two files for the UDFB, one header file and one C
file. The header and C file have the short name of the UDFB
with a prefix indicating in which resource it has been defined.
For example,

PPCCNT.h

and

PPCCNT.c

are the names for

the header and C files if the UDFB has a short name of CNT
and is defined for PPC-2000.

The header file contains the definition of a structure for that
UDFB and function prototypes. The structure is similar to the
following example:

typedef struct {

/*Input and output symbols */

}XXXXStruct;

The

XXXX

will be replaced by the short name of the UDFB.

The members of the structure are the inputs, outputs and
internals. The user should not change these. However, the user
may add additional members into the structure as needed.
Note that Boolean variables are included in this structure.
These variables are used by Function Block instances.

The C file contains four functions which may look like the
following example:

int XXXX(bool EN,bool *Q,int *C,XXXXStruct *XXXXStructA);

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

void ResetXXXX(XXXXStruct *XXXXStructA);

void ExitXXXX(XXXXStruct *XXXXStructA);

The

XXXX

will again be replaced by the short name of the

UDFB.

Main Function

The main function, shown in the following example, is called
during evaluation of the user Program for every scan and
performs the task of the UDFB.

int XXXX(bool EN,bool *Q, all other variables defined,*XXXXStruc-

tA);

{

return 0

}