Skip to main content

Subsection 11.3.5 Part 5: Resolution, and What Comes Next

One number matters that the program never states outright: the channel’s resolution, the smallest change in pulse width we can ask for. The counter divides each period into a fixed number of steps and the compare register holds whole numbers, so the duty cycle moves in steps rather than continuously. Our period is 625 µs and the counter divides it into 1250 steps, so one step of CCR1 is 625 µs ÷ 1250 = 500 ns of pulse width, and 5 V ÷ 1250 = 4 mV of average voltage at the motor. That is what decides whether two speeds you ask for are actually different, and it is what your Lab 6 screenshot has to be able to show.
Figure 11.3.30. The narrowest pulse this program can ask for. The period is fixed by the value the counter runs up to, and one count of the compare register is one step of pulse width, \(T_0\text{,}\) so the number of steps sets how finely the speed can be adjusted. That is the channel’s resolution.
Now that we know how to control the motor’s speed along with all of the registers needed to do so, we’ll turn to measuring the motor’s speed to find out whether the motor is actually turning as fast as we asked for (under load it may not). The hardware we’ll use for measuring speed (a slotted wheel sensor) is already mounted on your motor.
Figure 11.3.32. Measuring motor speed with a slotted wheel on the shaft, and a photointerrupter that sees the light through it interrupted once per slot. Counting those pulses is how the display in the background knows the shaft is turning at 222 rpm. The wheel and the sensor are already part of the motor assembly in your kit.
Figure 11.3.33. The photointerrupter’s output on the oscilloscope while the motor speeds up from about 30 rpm to about 180 rpm. The pulses are the beam being interrupted by each slot in turn, and as the shaft turns faster they crowd together, which is the whole idea behind measuring speed this way: the rate the pulses arrive at is proportional to the speed of the shaft.