Function Block Diagram Programming
Siemens PLC Programming This chapter covers the following topics (FBD, Bit Logic Instructions , Network Execution , AND instruction , OR instruction , FBD Exclusive OR (XOR) instruction)
Function Block Diagram
Function Block Diagram Programming Function block diagram programming (FBD) is a graphical programming language similar to LAD programming and like a LAD program an FBD program or program block is composed of numbered networks.
Bit Logic Instructions
- As shown in the graphic an FBD network is made up of instructions that use the same types of operands and tags as a LAD network.
- As with a LAD program in STEP 7 (TIA Portal) an absolute operand is preceded by % a global PLC tag is enclosed in quotation marks and a local tag which is a tag defined in a program block for use only by that program block is preceded by#.
- STEP 7 (TIA Portal) also provides the option to display absolute operands and tags at the same time as shown in the graphic.
- Because the FBD programming language includes many instructions STEP 7 groups instructions into a number of basic and extended instruction categories.
- These instructions provide FBD programs with similar capabilities to those of LAD programs and in some cases the instructions look the same.
- However there are some important differences.
- Some of those differences are shown in this lesson which provides examples of instructions in the bit logic category.
Network Execution
- As the PLC scans the user program from top to bottom in a program block each network is scanned from left to right.
- Just as with a LAD program the solution for a configuration of instructions is called the result of logic operation.
- Using the simple network shown in the graphic as an example the two instructions on the left are solved first.
- The logical solutions to these instructions are provided as inputs to the next instruction.
- The logical solution to this instruction is provided to the final instruction which in this example assigns the result to an output status bit in the process image.
- As shown in the graphic the assign instruction is the FBD equivalent to the LAD output coil instruction both of which store the logical result of the network in the memory location specified by the operand.
- When the RLO to the assign instruction is 1 the instruction sets the operand to 1.
- When the RLO to the assign instruction is 0 the instruction resets the operand to 0.
AND Instruction
- Some FBD bit logic instructions are derived from Boolean logic.
- One of most common of these instructions is the AND instruction.
- The graphic shows an AND instruction with two inputs but an AND instruction can have three or more inputs.
- The operand associated with each instruction input identifies the memory location where a 1 or O is stored.
- In this example only I operands are used however Q and M operands can also be used.
- As the associated truth table shows the result of the AND instruction is 1 when both the inputs to the instruction are 1 's.
- When there are more than two inputs to the AND instruction all inputs must be 1's for the result to be 1.
- The AND instruction can be combined with other instructions to form a network.
- In the graphic the AND instruction is combined with an assign instruction that controls the output Q5.2 status bit in the process image table.
- In this example output Q5.2 is 1 when I3.1 and I4.2 are both 1's.
OR Instruction
- The OR instruction is another FBD bit logic instruction.
- The graphic shows an OR instruction with two inputs but an OR instruction can have three or more inputs.
- In this example the instruction inputs are I operands however Q and M operands could have been used.
- As the truth table shows the result of the OR instruction is 1 when one or more of the inputs to the instruction are 1's.
- The OR instruction can be combined with other instructions to form a network.
- In the graphic the OR instruction is combined with an assign instruction that controls the output Q5.2 status bit in the process image table.
- In this example output Q5.2 is 1 when one or both of the inputs are 1's.
Exclusive OR (XOR) Instruction
- The graphic shows an FBD Exclusive OR (XOR) instruction with two inputs but an XOR instruction can have three or more inputs.
- In this example the instruction inputs are I operands however Q and M operands can also be used.
- As the truth table shows the result of the XOR instruction is 1 when one of the inputs to the instruction is a 1 but not when both are 1's.
- This rule must be expanded to take into consideration XOR instructions with more than two inputs.
- The broader rule is that when an odd number of instruction inputs are 1's the result is a 1 but when an even number of inputs are 1's or when all inputs are 0 the result is 0.
- FBD instructions are often combined to form networks that perform more complex functions.
- For example the graphic shows a network of five bit logic instructions.
- By analyzing the truth tables shown you can determine the status of output Q6.2 for any combination of operand statuses.
Inversion
- Inversion also called negation means to change a 1 to a 0 or vice versa.
- When applied to FBD programming an invert instruction is represented by a small circle adjacent to another FBD instruction.
- The graphic shows an example of an invert instruction on one input of an AND instruction but the invert instruction can be used with other FBD instructions as well.
- As the associated truth table shows the result of this logic combination is 1 only when I3.1 is 0 and I4.2 is 1.
- Without the invert instruction the result is 1 only when both inputs are 1's.
- Another type of inversion available for S7-1200 and S7-1500 PLC'S is the negate assign instruction.
- The negate assign instruction inverts the RL0 of a network.
- Therefore if the RLO of the network is a 1 without the negate assign instruction the RLO is a 0 with the instruction and vice versa.
- For example the graphic shows a network with an OR instruction connected to a negate assign instruction.
- As the associated truth table shows the result of this network is 1 only when both inputs to the instruction are O's.
- With an assign instruction instead of a negate assign instruction the result is a 0 only when both inputs to the instruction are O's.
Instructions that Set and Reset Bits
- There are a variety of FBD instructions that set and/or reset bits.
- For example the graphic shows a set instruction When the RLO to the left of the set instruction is 1 the instruction sets the specified bit to 1.
- In this example when I3.1 and Q2.1 are both 1's the set instruction sets output Q4.2 to 1.
- Output Q4.2 remains a 1 even after the result of the AND instruction returns to 0 The graphic also shows a reset instruction.
- When the RLO to the left of the reset instruction is 1 the instruction resets the specified bit to 0.
- In this example when either I3.2 or Q5.1 or both are 1's the reset instruction resets output Q4.2 to 0.
- Output Q4.2 remains a 0 even after the result of the OR instruction returns 01.
- The graphic shows two other instructions that set and reset bits.
- The top network includes a set reset flip-flop and the bottom network includes a reset set flip-flop.
- Both networks perform a similar function.
- When there is a 1 at the set (S) input the output (Q) and the memory bit specified by the operand at the top of the instruction are both set to 1.
- They remain a 1 even after the set input goes to 0 until there is a 1 at the reset (R) There is one important difference between these instructions.
- For the set reset flip-flop the reset input is dominant.
- For the reset set flip-flop the set input is dominant.
- If there is a 1 at both the set and reset inputs the dominant input controls the result.
Additional FBD instructions
- The instructions shown in this lesson are only a few of the many types of instructions that can be included in a Siemens PLC FBD program.
- An FBD program in a Siemens PLC can include a variety of basic and extended instructions.
- As you have seen some of the FBD instructions are different from corresponding LAD instructions but the instruction categories and overall capabilities of FBD and LAD are very similar.
Useful
ReplyDeleteBro Very very useful Post.. thank you for this post...
ReplyDelete