Introduction:
Function Block design is the most fundamental control object design in PLC controls. A FB may be a device driver for sensor IO which scales the IO card/module counts into a real physical signal (i.e. pressure or flow), it may be a FB that is a communication (i.e. Modbus, Profinet) interface between function blocks or control objects where data is correctly mapped between one object and the next, or it may have direct control of a piece of hardware, equipment, or process with an integral or finite event state machine. We will talk about different state machines in a later post and the pros and cons of each state machine. A FB will have some primary purpose and how one arranges FBs to communicate in a parent to child tree structure is critically important as discussed in the previous blog. Data declaration: Typical FB data consists of input, output, and process or var in-out data which is bi-directional to communicate data between upper, lower, and lateral function blocks. This data is declared in the FB header. It may also have implicit Pointers or References to other function blocks to receive feedback from and control other function blocks. Pointers or refences (to objects) are used to reduce memory during run-time but pointers also allow you to refer to the same space in memory from multiple locations allowing data to be shared seamlessly without manually passing input and output data between function blocks. This means that you can update memory in one location and the change can be seen from another location in your program or FB. Typically, Input and Output data should be limited to only critical data (i.e. System data such as an E-Stop flag) that needs to be communicated directly between FBs. Also, a FB may contain regular variables contained only within that FB that cannot be seen by other function blocks, these variables are called FB or member variables and should have prefix that differentiates these variables from input and output or bi-directional data. FB code structure: Like a book, a function block has a beginning, middle (premise/purpose) and end. In the actual function block code, it is typical to read all the inputs of the function block first, then in the middle do any state machine control such as event triggers and timers that trigger a state transition in your state machine or integral case state machine logic. It may also contain methods to set values in lower function blocks or controller logic such as PID function block calls for pump or valve control or motion control based on certain conditional logic. We will talk about Methods and Actions and the difference between the two in a later blog post and the Pros and Cons between the two when structuring your FB. At the end of the FB code, the outputs of the function block will be set by the logic in your function block. I hope this gives a general overview of FB design! See below Beckhoff reference on Function Blocks as well: https://infosys.beckhoff.com/english.php?content=../content/1033/tc3_plc_intro/9007201785020555-1.html&id=
0 Comments
|
AuthorGraham is a control system engineer enthusiastic about controls, design, hockey, and art! Archives
April 2023
Categories |