INTRODUCTION TO CONTROLLER PROGRAMMING
It is beyond the scope of this text to present a detailed discussion of how to program a microprocessor in machine language. Still,
it is useful to investigate in a general way what the software must do. A digital controller is a computer operating in real time.This means that the program is running all the time—repeatedly taking in the newest sensor data and then calculating a new output for the actuator.
The basic structure of a controller program is a loop. In a loop structure, the same sequence of instructions is executed over and over again, and each pass through the loop is called an iteration, or scan. Figure 14 shows a generalized controller program,and an explanation of the program follows:
- The program reads in the set-point data (recall that the set point is the desired position of the controlled variable). This data could be read in from an input port or from memory.
- The program directs the computer to read (from a sensor) the actual value of the controlled variable.
- The actual data are subtracted from the set point to get the error.
- Based on the error data, the computer calculates a new actuator control signal.
- The new output is sent to the actuator.
- The programs loops back to step 1 and starts over again.