18.11.2014 Views

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 11<br />

PWM high pulse width, low pulse width, number of cycles<br />

Listing 11-4 uses the PWM output to control motor speed. <strong>The</strong> program prompts you for<br />

motor direction and the width of the high and low PWM pulses. For faster speeds, use large<br />

values for the high pulses (H) and small values for the low pulses (L). This results in a<br />

waveform with a high duty cycle, or ratio of the width of a high pulse to the width of a<br />

complete cycle (consisting of 1 high and 1 low pulse). With a high duty cycle, power is<br />

applied to the motor for a large proportion of the total time. For slower speeds, do the reverse:<br />

select small values for the high pulses and large values for the low ones, for a low duty cycle.<br />

<strong>The</strong> actual pulse width equals the value in the PWM statement multiplied by 12, divided by<br />

the frequency of the 8052-BASIC’s timing crystal. So, with a 12-Megahertz crystal, if<br />

H=1000 and L=10,000, high pulses will be 1000 microseconds, or 1 millisecond, wide, and<br />

Figure 11-6. A 4066B quad switch and 555 timer enable you to select up to<br />

16 motor speeds, with four port bits.<br />

196 <strong>The</strong> <strong>Microcontroller</strong> <strong>Idea</strong> <strong>Book</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!