It's example of FB in FB. All variables in VAR section are FB type. When I define instance DB2 for FB2, all FB variables are created automatically. Take into accordance: IN, OUT and IN_OUT variables of this FBs present in DB2. This means you must to keep in mind place occupied by it when create HMI tags.
Code:
FUNCTION_BLOCK "MA2DevDrv"
TITLE =
//This function control MA2 devices in accordance with it's commands.
VERSION : 0.1
VAR
ConvToPress2 : "DrvBidirectional";
ConvFromPress : "DrvBidirectional";
ConvOut : "DrvBidirectional";
BattConv : "DrvUnidirectional";
BattElev : "DrvUnidirectional";
BattConv2 : "DrvUnidirectional";
CageConv1 : "DrvBidirectional";
CageConv2 : "DrvBidirectional";
PackPump : "DrvUnidirectional";
PackPumpHeat : "DrvUnidirectional";
PressPump : "DrvUnidirectional";
BattElevBottom : "DrvUpDown";
BattSeparator : "DrvUpDown";
BattCageFillStop : "DrvUpDown";
ConvOutCylinder : "DrvUpDown";
END_VAR
BEGIN
NETWORK
TITLE =
//Most of devices of this area are enabled when system is enabled.
A "SystemEnabled";
= "DeviceEnabled";
NETWORK
TITLE =
//Device work with VFD; command to VFD is sended from corresponding DB field.
CALL #ConvToPress2 ;
NETWORK
TITLE =
//Device work with VFD; command to VFD is sended from corresponding DB field.
CALL #ConvFromPress ;
NETWORK
TITLE =
CALL #ConvOut (
qRunForw := "pqPackConvForw",
qRunBack := "pqPackConvBack");
NETWORK
TITLE =
//Because device hasn't attached VFD, command qRun is send directly to
//corresponding peripheral output.
CALL #BattConv (
qRun := "pqBattenConv");// Q2.2
NETWORK
TITLE =
//Because device hasn't attached VFD, command qRun is send directly to
//corresponding peripheral output.
CALL #BattElev (
qRun := "pqBattenElev");
NETWORK
TITLE =
//Because device hasn't attached VFD, command qRun is send directly to
//corresponding peripheral output.
CALL #BattConv2 (
qRun := "pqBattenConv2");
NETWORK
TITLE =
//Because device hasn't attached VFD, command qRun is send directly to
//corresponding peripheral output.
CALL #CageConv1 (
qRunForw := "pqBattenCageConv1Forw",
qRunBack := "pqBattenCageConv1Back");
NETWORK
TITLE =
//Because device hasn't attached VFD, command qRun is send directly to
//corresponding peripheral output.
CALL #CageConv2 (
qRunForw := "pqBattenCageConv2Forw",
qRunBack := "pqBattenCageConv2Back");
NETWORK
TITLE =
CALL #PackPumpHeat (
qRun := "pqPackPumpHeater");// Q3.0
NETWORK
TITLE =
//Next devices are enabled always.
SET ;
= "DeviceEnabled";
NETWORK
TITLE =
//Because device hasn't attached VFD, command qRun is send directly to
//corresponding peripheral output.
CALL #PackPump (
qRun := "pqPackPump");// Q2.7
NETWORK
TITLE =
//Because device hasn't attached VFD, command qRun is send directly to
//corresponding peripheral output.
CALL #PressPump (
qRun := "pqPackPressPump");// Q3.1
NETWORK
TITLE =
//Next devices are enabled when system is enabled.
A "SystemEnabled";
= "DeviceEnabled";
NETWORK
TITLE =
CALL #BattElevBottom (
qRunUp := "pqBatElevBottomOpen",// Q5.6 Open
qRunDown := "pqBatElevBottomClose");// Q5.7 Close
NETWORK
TITLE =
CALL #BattSeparator (
qRunUp := "pqBatSepUp",// Q6.0 Up
qRunDown := "pqBatSepDown");// Q6.1 Down
NETWORK
TITLE =
CALL #BattCageFillStop (
qRunUp := "pqBatCageFSNarrow",// Q6.2 Narrow
qRunDown := "pqBatCageFSWider");// Q6.3 Wider
NETWORK
TITLE =
CALL #ConvOutCylinder (
qRunUp := "pqPackConvUp",// Q6.4 Up
qRunDown := "pqPackConvDown");// Q6.5 Down
END_FUNCTION_BLOCK