next up previous
Next: What is an Interrupt Up: Background Previous: Background

What is Pulse Width Modulation?

When we look at something like a circuit, we characterize its behavior by determining the node voltages and branch currents. But if these voltages and currents are time-varying, then we can no longer use a single "number" to characterize the circuit's behavior, we must use a "function" that we'll refer to as a "signal". We define a signal as a function that maps time onto some real number. So, for instance, the voltage function $v$ is a rule that associates a time $t$ with an actual voltage measurement $v(t)$. The value that $v$ takes at a time $t$ is denoted as $v(t)$. Since both time and voltage are real numbers, we can denote the voltage function using the notation $v: \Re \rightarrow \Re$. This notation says that $v$ maps the real line back into itself.

We say a signal, $v$ is periodic if there exists a positive time $T$ such that $v(t)=v(t+T)$ for all $t \in
\Re$. In other words, at any moment, $t$, in time, the value of $v$ ($v(t)$) will always be repeated some specified time interval $T$ in the future. We refer to $T$ as the period of the signal. If $T$ is the smallest positive number such that $v(t)=v(t+T)$ (for all $t \in
\Re$), then we refer to $T$ as the signal's fundamental period. If $T$ is the period of a periodic signal $v$, we often refer to $v$ as being $T$-periodic.

A pulse-width modulated signal is a $T$-periodic signal, $v$, if there exists $0 < T_1 < T$ such that

$\displaystyle v(t) = \left\{ \begin{array}{cc} 1 & 0 \leq t < T_1\\
0 & T_1 \leq t < T \end{array} \right.$     (1)

for $t \in [0,T]$. We refer to the ratio $T_1/T$ as the duty cycle of the signal. We usually represent the duty cycle as a percentage. Equation 1 defines the values that $v$ takes over a single fundamental period, $T$. Since $v$ is $T$-periodic, we know that the pattern characterized in equation 1 will repeat itself at regular intervals of duration $T$. Figure 1 shows a pulse-width modulated signal whose duty cycle is $25 \%$.

Figure 1: Pulse Width Modulated Signal
\begin{figure}
\epsfxsize =3.in
\epsfclipon
%\centerline{\epsffile{../int...
...aps/fig/pwm.eps}}
\centerline{\epsffile{fig-root/pwm.eps}}
\end{figure}

This lab asks you to modify one of the output compare event interrupt handlers in the kernel so that pin PA4 generates a PWM signal whose duty cycle can be set from within the main program. In order to complete this lab you need to learn what an output compare event is and what an interrupt handler is.


next up previous
Next: What is an Interrupt Up: Background Previous: Background
Michael Lemmon 2009-02-01