Exploring what flow control is
Similar to how your behavior varies based on certain conditions, so too will your program. Flow control is the mechanism by which your program will choose what route to take to get to the bottom. Consider the famous beer example that we explored earlier in the book:
Input age If age >= 21 then Let them drink heavily Else if age < 21 then Throw a shoe at them and call the cops
In this case, there are two paths that the program can take. One path will allow a person to drink heavily, while the other path will throw a shoe at the perpetrator and have the operator call the cops. This is the heart of flow control. Essentially, there are multiple paths, and the PLC will choose the correct path to take based on the given inputs: in the case of the beer program, the person’s age.
In terms of decision based flow control, there are two special keywords that the IEC 61131-3 standard...