Friday 16 March 2018

Programming in Function Block Diagram (FBD)

Function Block Diagram

There are two popular methods of programming a PLC, FBD and LAD. In this post, FBD will be covered and purely logical task will be analysed. Tasks that depends on events that involve counters and timers will be explained in the another post. Task that depends only on the current states of the inputs can be defined or written as Boolean or Logical expressions. Writing the Boolean expressions correctly is the key to creating an accurate, working PLC program.


Important  logic function blocks 


Logic blocks perform logical operation. They can be combined to perform more complex task. The fundamental building blocks are NAO or NOT, AND and OR. Their symbol and operation are described in the diagram below. The input block and the basic logic blocks can be combined in various ways to perform many different tasks. Boolean expression is a way to represent logic blocks operation as statements. For AND operation all inputs must be logic 1 for the output to be 1. For OR, at least one input has to be a logic 1 and for NOT, the output is the inverted version of the input.


Input activation and signal propagation 

When the input devices are activated either manually (pressing/turning) or automatic sensing, the PLC input ports will receive the signals. For discrete devices such as pushbuttons, the signal will be a change in voltage values. When pushbuttons are pressed, the voltage will change from 0 to 24V in the case of normally open pushbuttons ( NO PB) or 24V to 0V for NC PB. The PLC will register this as logic level change and the CPU within will process according to the program that has been created for the task.




A FBD program is created for the hardware configuration above to perform the task of turning on the lamp when both P1 and P2 is pressed The technique of creating the program will be explained in the subsequent section but for now try to understand the behaviour of the program for different input activation.



P1 is connected to I1 block and P2 to I2 block. P1 is NO PB, thus when not pressed or inactive state it produced a logic 0 (LOW) but once it is activated (pressed), it produced a logic 1 (HIGH).  P2 is NC PB. When not pressed, it produce logic 1 because it is connected to 24V but when pressed, it opens up and sends logic 0 to I2. Try to follow and understand how the logic levels propagate throughout the block diagrams for the cases mentioned in diagram above.


Steps in creating a PLC program

  • Read the problem statement thoroughly and identify all the input and output devices required. 
  • Determine the input type and the I/O address to be used for the input and output 
  • Write the ON-statement for each of the output devices 
  • Determine the Boolean/logic expression from the ON-statement for each output devices 
  • Build the PLC program and simulate in order to check the operation.
  • Implement the real system.


Worked Example 1



Task: In a certain process, each packed box need to be weighed to ensure the weight does not exceed the set limit.The weighing system’s conveyor belt starts when pushbutton A is pressed and pushbutton B is not pressed. A green indicator turns on when the system is ON. A red indicator will turn on if the load sensor S1 detects weight greater than 100kg. The input devices type are: PB P1 is NO, PB P2 is NC , load sensor S1 is PNP type. 
Note:  The operation of PNP type is similar to NO PB. When sensor detects, it produces a logic HIGH at the input of the PLC. NPN type works like a NC PB.


I/O table



ON-statements /on-requirements


The on-statement is required for each output and in this task three statements are needed. One for the motor, one for the green indicator and finally one for the red indicator. There are two methods for writing the Boolean expression from the ON- statement. 

In the first method, key words from the on-statement are used to form the initial Boolean expression. Such key words are like press, not pressed, and, or, pushed, not pushed, sensor activated etc. The words like and, not and or indicates the type of logic block required. After forming the initial logic expression, the type of input device used must be checked. If any normally closed (NC)  or active-low devices are used, the respective literal in the expression need modification. If the literal in the initial expression has no over line or bar, then an overline must be added and vice versa. All the normally open (NO) or active-high devices remain same, unchanged!



Second method is very straight forward and seems much easier. In this method, the logic level of all concerning input devices that turns on the output in the on statement must be determined. If the logic level of the input device is high (1), then no overline or bar is required on the literal. However if the logic level is low (0), then an overline or bar must be applied on that particular input.



Programming the PLC

The next step will be creating the program in the LOGO! IDE. Once the program is completed, simulation can be done to ensure that the program works according to the intended task. In the simulation mode, the input can be set to switch, make (for NO type of inputs) or break (for NC type of input). This will enable the simulation to be done exactly same as the real hardware. During the simulation, sometimes it is hard if there are two push buttons that needed to be activated at the same time because using mouse we can only select one at a time. To overcome this temporarily change one of the input to be a switch. Once we are satisfied with the simulation, the program can be downloaded into the PLC.




Examples on writing logic expression





No comments:

Post a Comment