Methods: After discussing parent and child function blocks for a PLC controls project. I would like to discuss Methods which are used in function blocks. A method contains a sequence of statements that may have explicit inputs, outputs, internal variables, or a method return, and this method is assigned to a specific function block or program. Methods may also have implicit access to internal variables of the function block where it is assigned to. It is important to note, the data of a method is temporary and ONLY VALID when the method is executed or called. After the method is called, data within the method is defaulted to False if a Boolean variable or 0 for a REAL or UINT variable until the next call of the method. Some other general considerations with Methods are the following, you cannot access VAR_TEMP variables of the function where the method is assigned and access to VAR_IN_OUT variables of function block is possible when using a method. Methods are a great way of storing specific logic associated with calculating certain values, getting a sensor scaled value, populating an array, setting specific equipment Set-points with limits, and getting certain statuses of equipment. A Get method for getting a power status with a Boolean return status for a piece of equipment is shown below (code comments not shown): Using methods allows the PLC controls engineer to make compact logic statements that are called within the function block without cluttering the code of the actual function block. It allows one location where specific logic is defined and controlled by the controls engineer. If child function blocks are called as Pointers by Parent function blocks, then these child Get and Set methods can also be accessed by the parent function blocks allowing feedback flow and control of information from the bottom low-level to upper higher level function blocks. This allows for a standard way of managing and debugging PLC controls code from one project to the next.
Actions: Actions can also be used which only uses the data defined within the action. In other words, it uses the input/output and local variables of the basic implementation. You can think of actions as pre-defined recipes as designed by the controls engineer. More information on creating programming objects can be found from the Beckhoff website: https://infosys.beckhoff.com/english.php?content=../content/1033/tc3_plc_intro/9007201785048459-2.html&id=
0 Comments
|
AuthorGraham is a control system engineer enthusiastic about controls, design, hockey, and art! Archives
April 2023
Categories |