Creating a Defined Function Block in Modicon Concept

by C. Stanley

This article will show how to create user defined function blocks. The first block, a summing junction, was chosen to be simple in nature to illustrate the steps in creation without unnecessary complication.  Future articles will not be as in depth with creation mechanics and spend more effort on the functionality. The culmination of these series of articles will be a functional turbine speed control. The programming package for this series is Modicon Concept v2.6s. 


Fig. 1

Summing junctions are found in control systems where a process set point is compared to the process variable and the difference is output. This summing junction will also include two additional inputs for feedback values. These values will be discussed in a later article.  Future articles will feature additional user defined blocks. These blocks will be combined to create a speed controller for a turbine.

Create the Summing Junction Function Block

Assuming that Concept programming package is installed and a shortcut is on the desktop, click on Concept DFB icon. Click on File and then New DFB as shown in fig. 1.


Fig. 2

Assigning Names to Function Block Variables

Next click on Project select Variable declarations on the drop down.   The variable dialog box will appear.  This step allows the programmer to define inputs and outputs of the function block.  The function block is only accessed through the input and output pins. In that respect the user defined block is like an integrated circuit. The inner workings of the block are hidden from the rest of the PLC program. The block can be thought of as a new PLC instruction.


Fig. 3

Click the input radio button and enter the variables shown in illustration 3. The SetPt is the first input and it represents the desired value for the process variable or second input to the block. The second input variable PrcVar represents the measured value of the quantity that we are trying to control. This function block uses the REAL data type for all inputs and outputs. There are many types available and it is possible to create compound data types made of more than one type.

Two additional input variables are shown:  FeedBk1 and FeedBk2. These represent feedback quantities.  I will defer a discussion of these until a later article where their purpose will be made clear.


Fig. 4

In fig. 4, clicking the output radio button will open the output variable dialog box. In this box we enter a single variable ProcErr. This variable will represents the difference between Setpt and PrcVar speed or the system error. Click on the OK button at the bottom of the viable dialog box to close the box.


Fig. 5

Create a Programming Sheet for the Function Block

Next click on the project drill down icon, as shown by the upper pointer on fig. 5. The drill down will appear without any sections or groups defined. Right click on the top item in the drill down named Project and the New section dialog box will appear.


Fig. 6

Name Programming Sheet for the Function Block

Type in the name of SummingJct. The code type defaults to FBD of function block. One could also select on of the other types of coding as well but we are programming in FDB in this article. Enter a section name of “Sum_Jct” as shown in fig. 6.

New Group, if selected, creates a folder like object which can contain more than one section of related code. One names the “Group” as one names a section. To create a section within a group click on the group icon just left of the group name.  Our function block is simple and only requires a single section.  Click OK to close the dialog box.


Fig. 7

Programming Sheet for the Function Block

Click on the FDB icon in the Project Browser window and a blank work sheet will appear. This sheet is like a CAD drawing. Using the icon on the tool bar, one can create a network of function blocks that resemble electronic drawings. With this blank sheet we will need to place some arithmetic predefined function blocks to process inputs and assign an output.


Fig. 8

Inserting Function Blocks on the Sheet

Click on the FBD selection icon on the tool bar (upper most arrow)  and then select the Arithmetic group and the ADD_REAL block. While on the block selection box the cursor will be the normal arrow. Moving off the box will cause the cursor to change to what is shown in fig. 9.

For the SumJct block we are creating, I will leave the FFB from Library IEC  dialog open and select the SUB_REAL block after dropping an ADD_REAL block with a left click on the sheet.

Finally, there are six buttons on the bottom of the dialog box: Library... allows selection of additional libraries.  There are quite a few libraries to select more specialized blocks but it is beyond the scope of this article to discuss these. DFB allows selection of user defined function blocks such as we are creating in this article. The others are self explanatory.


Fig. 9

Working with Predefined Blocks

Fig. 9 shows what was discussed in the last paragraph. Moving the cursor to the worksheet will cause the pointer to change to the cross hair and function block icon. Left clicking on the worksheet will drop the selected block on to the sheet at the location of the cross hair. Press ESC to return the cursor to a pointing device instead of a function dropping device mode. We are now in position to assign inputs and output variable previously defined to the function block pins.


Fig. 10

Expanding Inputs Available on Some Blocks

The ADD_REAL block in fig. 10 can take more than two inputs. This is indicated by the black square on the bottom of the block. Placing the cursor on the black square and dragging down will reveal more inputs. Add two more inputs. The SUB_REAL block does not have this property because it does not have the black square. User Defined Blocks in general do ot have the ability to have expanded inputs because there is no way to express this in the limited programing tool set provided.


Fig. 11

Assigning Variables to Input Pins:

To assign inputs to the ADD_REAL Function block, click on each input. This click will open a dialog box allowing you to select from the available input variables previous defined.


Fig. 12

Fig. 12 shows clicking on Lookup button to reveal a list of the previously defined input variables.


Fig. 13

Click on PrcVar to select the first input to the ADD_REAL function block by pointing to it and double clicking it as shown in fig. 13.


Fig. 14

Repeat the input selection for the remaining two inputs, FeedBk1 and FeedBk2, for the ADD_REAL function block. Shown in fig. 14.


Fig. 15

Assigning Variables to Output Pins

Fig. 15 shows clicking on the output pin on the SUB_REAL will bring up only one variable for selection. Chose ProcErr by double clicking it. Notice that clicking on an output pin only shows one variable. This variable was the only variable we previously defined as an output.  We are nearly done assigning variables.

The SUB_REAL block will be assigned the SetPt input variable on its first or upper input pin.

The second SUB_REAL pin will be “wired” to the output of the ADD_REAL block, the subject of our next topic.


Fig. 16

Wiring Between Output and Input Pins

In fig. 16 above, I select the function block wiring tool shown with the arrow.   This tool will allow me to connect the output of the ADD_REAL block to the lower input of the SUB_REAL block.  The function block programming allows outputs to be assigned to another function block without using intermediate named variables. This is great because it cuts down on the number of variables needed for a program.

Also, note that in fig. 16 the SUB_REAL block is surrounded by a blue box. This indicates that the block is “selected”. Hitting the delete key will delete the block. Press Ctrl-C and Ctrl-V to copy and paste the block. More than one block can be selected at a time. Wiring is preserved to and from the clip board. In fact the whole sheet can be selected with Ctrl-A and repasted back to the sheet. The execution order for the blocks on a sheet can be changed this way. More in later articles about execution order and changing the order.


Fig. 17

The cursor changes from the arrow to a wide cross hair when the wiring tool is selected. The wide cursor is shown on the above illustration as the upper most cross hair. The wide cross hair changes to a thin cross hair when the cursor is moved to a suitable function block pin. The check mark also indicates the cursor is over a suitable pin.  See Fig. 17 above.

To connect or wire pins together, one can click the first pin and either hold down the left mouse button and drag the cursor to the next pin or left click the first pin and move the cross hair to the next pin and left click. The outputs of an output pin can be connected to multiple inputs of other function blocks. There is no fan out limit. The pins must have the same type in order to make a connection, e.g. REAL to Real, INTEGER to INTEGER etc. The reader can see the first input to the SUB_REAL block was assigned to SetPt. This was done in a similar fashion as the inputs to the ADD_REAL block but not shown.

What we have at this stage is the summation of the PrcVar, FeedBk1 and FeedBk2. This summation is subtracted from the SetPt input and the result supplied as the output of the SUMJCT block.

The summation and subtraction process is common in a process controller. I will use this block in two different ways in the final composition of a turbine speed control.


Fig. 18

Saving the Completed Block

In fig. 18 I will save my newly created block by clicking on File and then on Save as...


Fig. 19

In fig. 19, I name this block “sumjct.dfb” and then click OK. This makes the sumjct DFB visible in the Concepts programming package DFB library. I can select it just like I selected the predefined ADD_REAL and SUB_REAL function blocks when writing a PLC program or user defined function block.

The sumjct block is generic in nature so that it can be used in various parts of our turbine governor.

The function it performs is comparing the Process set point to the Process controlled variable and outputting the difference. The process controlled variable value can be modified by one or both feed back inputs. This summation action forms the heart of a classic controller. In later articles, I will show how modification of the various quantities in the control system can be fed back in to the summation junction to create a stable controller.

The next articles will show the development of two additional user defined function blocks: PID and Reference. The PID will be developed in a couple forms. These blocks will be combined into a turbine speed or load controller. A bit of practical control theory will be covered to aid in understanding the controller. The final controller will fit on one PLC programming sheet because I am using user defined function blocks.