Programming the PIC Microcontroller with MBasic

In earlier chapters, we learned how to control both bipolar and unipolar stepper motors. It's time now to look at a much older motor type, the permanent magnet DC motor. Simply turning a DC motor off and on with a PIC is not conceptually different than controlling any inductive load and the techniques of Chapter 3 may be used. We'll look at a more challenging aspect of DC motor control; a pulse-width modulated variable speed motor with tachometer feedback. Motors suitable for the techniques in this chapter are permanent magnet brush-type DC motors. Brushless and other specialized DC motors will not necessarily function with this chapter's circuits.
Before tackling this chapter, one small confession is in order. When tackling a new subject, whether in a formal classroom setting or at home, at the outset most of us are a bit puzzled. Then, at some magic moment, it all comes together and learning becomes a pleasure. In my undergraduate electrical engineering days, I had two classes where that gestalt moment never arrived. One was rotating machinery class (motors and generators) and the second was control systems. After the final exam in both, I said to myself, "I sure hope I never have to work with this stuff for real." As, by now you might suspect, this chapter deals with motors, generators and control theory. We'll dip our toes into the pool of learning, but we're definitely sticking to the shallow end.
We're going to control a small...