Programming Microcontrollers In C:Program Description Language (PDL)

Program Description Language (PDL)

There are many methods that a programmer may choose to describe the algorithm to be implemented by a program. Flow charts have been used extensively in the past in many computer programming tasks. Although flow charts are useful, they tend to create an unstructured code and also a lot of time is usually wasted drawing them, especially when developing complex programs. In this section we shall be looking at a different way of describing the operation of a program, namely by using a program description language (PDL).

A PDL is an English-like language which can be used todescribe the operation of a program. Although there are many variants of PDL, we shall be using simple constructs of PDL in our programming exercises, as described below.

START-END

Every PDL program (or sub-program) should start with a START statement and terminate with an END statement. The keywords in a PDL code should be highlighted in bold to make the code more clear. It is also good practice to indent program statements between the PDL keywords.

Programming-Microcontrollers-in-C-00

Programming-Microcontrollers-in-C-00[4]

Sequencing

For normal sequencing in a program, write the steps as short English text as if you are describing the program.

Example:

Turn on the valve Clear the buffer Turn on the LED

IF-THEN-ELSE-ENDIF

Use IF, THEN, ELSE, and ENDIF statements to describe the flow of control in your programs.

Programming-Microcontrollers-in-C-00[2]

REPEAT-UNTIL

This is another useful control construct which can be used in PDL codes. An example is shown below where the program waits until a switch value is equal to1.

REPEAT

Turn on buzzer Read switch value

UNTIL switch = 1

Leave a comment

Your email address will not be published. Required fields are marked *