44
Creating Procedures
As a control program become more complex, it is often desirable to break it down into smaller more
manageable tasks. This is where procedures are used. For example in the case of the Bascule Bridge it
may be beneficial to break the process down as follows:
•
Detect ship approaching
• Open the bridge
• Wait for a preset time
• Lower the bridge
Some of these functions could become procedures within a flowchart (e.g. Open & Close the bridge).
In addition to making the control program easier to create it also makes it easier to read by avoiding
extremely long programs that seem to scroll down the page forever!
Procedures can also be used effectively where something needs to be repeated a set number of times.
By creating a procedure and then calling it up using the repeat x times feature, students can avoid
having to set up a variable to count the number of times a loop has gone round.
For example: To flash a light 20 times simply create a procedure that flashes the light once,
and then repeat twenty times.
All procedures must end with the Stop command.
To create a procedure:
1. Click on the Start symbol.
2. In the selection panel click on the Procedure button and enter a name
To run the procedure that you are currently working with in the edit area, select Run: Procedure:
xx from the Debug menu.
back to Table of Contents