AN1215/D
MOTOROLA
11
Many extensions to the routines are simple yet interesting. The command voltage level can be read from
one of the seven unused A/D channels to give real-time control points. The MC68HC11N4 version could
have analog output instead of PWM with the use of an 8-bit D/A channel. The N4 version could also use an
infinite impulse response (IIR) filter implemented by means of the math coprocessor multiply-and-accumu-
late capability, rather than utilizing the noise-canceling effect of the derivative term's four point central dif-
ference.
CONCLUSION
With the 16.383 millisecond sampling rate chosen, the floating point C routine cannot service all four
MC68HC11K4 PWM channels. It could, however, service one higher-rate channel and several less time-
critical processes. The assembly math coprocessor routine can service all the MC68HC11N4 PWM chan-
nels (four 8-bit and two 12-bit) in 4.2 milliseconds, leaving 75% of execution time for other tasks. If the
MC68HC11N4 D/A channels were also used, six independent PID controllers could be run in 5.6 millisec-
onds — this routine would use less than a third of the allowable processing time and require only half of the
twelve MC68HC11N4 A/D input channels.
The two approaches to PID control outlined in this note encompass a wide range of useful and cost-effective
applications. The simplicity of the coded C algorithm is very appealing. Since the C routine carries virtually
no code-space overhead, it is very well-suited to an application where floating-point math is already re-
quired, and a sampling rate in the 20-millisecond range is acceptable. Because it uses a number format
adapted to the application and to use of on-chip resources, the assembly routine generally yields higher,
more cost-effective performance than the C routine.
A final word of caution. There is no substitute for thorough mathematical analysis of the system to be con-
trolled in the discrete time domain. References 2 and 3 contain detailed discussions of control systems and
analytic techniques.
REFERENCES
1.
Andrews, Michael. Programming Microprocessor Interfaces for Control and Instrumentation.
Prentice Hall; 1982
Kuo, Benjamin. Digital Control Systems. Holt, Rinehart and Winston Inc.; 1980
3.Kuo, Benjamin. Automatic Control Systems. Prentice Hall; 1987
4.Motorola. MC68HC11K4 Technical Summary, BR751/D
5.Motorola. MC68HC11N4 Technical Summary, MC68HC11N4TS/D
6.Motorola. M68HC11 Reference Manual, M68HC11RM/AD Rev. 3
7.Motorola. M68HC11K4EVS Evaluation System User's Manual, M68HC11K4EVS/D1
2.
3.
4.
5.
6.
7.