Calling a Function
A function ( ) calculates a result according to the current value of its inputs. A function has no internal data and is not linked to declared instances, unlike a function block. A function has only one output: the result of the function. Examples of standard functions include AND, SHL, SIN, etc..
ST Language
(* the following statement converts any odd integer value into the nearest even integer *)
iEvenVal := SEL ( ODD( iValue ), iValue, iValue+1 );
FBD and FFLD Languages
To call a function in FBD "Function block diagram" A function block diagram describes a function between input variables and output variables. A function is described as a set of elementary blocks or FFLD languages, you just need to insert the function in the diagram and to connect its inputs and output.
IL Language:
To call a function in IL "Instruction list" This is a low-level language and resembles assembly language, you must load its first input parameter before the call, and then use the function name as an instruction, followed by the other input parameters, separated by comas. The result of the function is then the current result. The following example demonstrates a call to "ODD" and "SEL" functions:
(* the following statement converts any odd integer into "0" *)
Op1: LD "Ladder diagram" Ladder logic is a method of drawing electrical logic schematics. It is now a very popular graphical language for programming Programmable Logic Controllers (PLCs). It was originally invented to describe logic made from relays. The name is based on the observation that programs in this language resemble ladders, with two vertical "rails" and a series of horizontal "rungs" between them iValue
ODD
SEL iValue, 0
ST iResult
See also: