Udfb in simulation – Watlow LogicPro User Manual
Page 191
LogicPro User’s Guide
Chapter 11: User Defined Function Blocks
Doc.# 28002-00 Rev 3.00
Watlow Anafaze
175
The library is stored in the following directory:
\logicpro\user\bc
After the UDFB library is successfully built up, you can use
the UDFB in a Ladder diagram or Function Block Diagram
Program as a standard Function Block. When your Program is
compiled and linked for execution, the library is automatically
linked by LogicPro. All the functionality in LogicPro which
is available to standard Function Blocks is also available to
User Defined Function Blocks.
UDFB in Simulation
UDFBs are most often used to perform some application
specific tasks. Some of them may be hardware specific.
However, simulation in LogicPro can run on a PC that may
not be able to perform such hardware specific tasks. The user
may want to simulate hardware which is not available in
simulation mode.
In order to overcome the problem, a pre-defined macro,
SIMULATION
, is automatically inserted if
Compile for
Simulation
or
Build Simulation Lib
is selected from the
UDFB menu. You must use:
•
#ifndef SIMULATION
•
#
endif
to exclude all hardware and target operation system specific
code for conditional compiling. The pre-defined macro,
SIMULATION
, also allows you to write code in order to make
the UDFB behave the way you want it to in simulation.
To have a UDFB run in both simulation and the execution
environment, refer to the following example:
int XXXX(bool EN,bool *Q,int *C,XXXXStruct *XXXXStructA)
{
#ifndef SIMULATION
all the hardware and target operation specific code
#endif
#ifdef SIMULATION
code that user wants in simulation
#endif
}