Page 26 - ARM Based Microcontroller Projects Using MBED
P. 26
12 2. MICROCONTROLLER-BASED PROJECT DEVELOPMENT CYCLE
modules. The actual coding becomes an easy task after the algorithm is available. An algo-
rithm describes the operational steps of a program and it can be in the form of graphical
or text based, such as flow charts, data flow diagrams, structure charts, program description
languages (PDLs), and unified modeling languages (UMLs). Flow charts can be very useful
tools to describe the flow of control in small programs where there are no more than a few
pages of diagrams. The problem with graphical tools is that it can be time consuming to draw
or to modify them, especially if there is more than one diagram extending over several pages.
PDL is not a programming language. It is a collection of text-based keywords and actions that
help the programmer to describe the flow of control and data in a program in a stepwise and
logical manner. The main advantage of the PDL is that it is very easy to modify a given PDL
since it only consists of text.
In this book we shall be using PDLs wherever possible, and flow charts will also be given
where it is felt to be useful. In the next section we shall be looking at the basic constructs of
PDL and at the same time show the equivalent flow chart of each PDL construct.
Note: There are many free of charge programs available on the Internet that can be used to
help draw flow chart easily. Some of these programs are as follows: Microsoft Visio, Dia, yEd
Graph Editor, ThinkComposer, Pencil Project, LibreOffice, Diagram Designer, LucidChart, etc.
2.2.1 BEGIN-END
Every PDL description must start with a BEGIN and terminate with an END. The
keywords should be in bold and the statements inside these keywords should be indented
to make the reading easier. An example is shown in Fig. 2.3.
2.2.2 Sequencing
In normal program flow, statements are executed in sequence one after the other. The
operations to be performed in each step are written in plain text. An example of sequencing
is shown in Fig. 2.4 together with its flow chart equivalent.
2.2.3 IF-THEN-ELSE-ENDIF
The IF-THEN-ELSE-ENDIF statements are used to create conditional statements and thus
to change the flow of control in a program. Every IF statement must be terminated with an
ENDIF statement. The ELSE statement is optional and if used it must be terminated with an
ENDIF statement. It is also permissible to use ELSE IF statements in programs where multiple
decisions have to be made. Figs. 2.5–2.7 show various examples of using the IF-THEN-ELSE-
ENDIF statements.
FIG. 2.3 BEGIN-END statement and its equivalent flow chart.