You are on page 1of 3

Generated by Jive SBS on 2014-06-11-05:00

1
Pulse Width Modulation
Purpose:

This document discusses basic concepts of pulse width modulation (PWM) and how to use the NI myDAQ or ELVIS II
series to generate a PWM signal.
Background:

Pulse width modulation (PWM) is a technique in which a series of digital pulses is used to control an analog circuit. The
length and frequency of these pulses determines the total power delivered to the circuit. PWM signals are most commonly
used to control DC and servo motors, but have many other applications ranging from controlling valves or pumps to
adjusting the brightness of an LED. The digital pulse train that makes up a PWM signal has a fixed frequency and varies
the pulse width to alter the average power of the signal. The ratio of the pulse width to the period is referred to as the duty
cycle of the signal. For example, if a PWM signal has a 10 ms period and its pulses are 2 ms long, that signal is said to
have a 20 percent duty cycle. Figure 1 shows three PWM signals with different duty cycles.
Figure 1: PWM Signals with Different Duty Cycles
Pulse Width Modulation
Generated by Jive SBS on 2014-06-11-05:00
2
PWM signals can be generated as a digital signal, using counters or digital output line(s), or as an analog signal, using
for instance, an arbitrary waveform generator or an RF signal generator. Several National Instruments multifunction data
acquisition (DAQ) devices are capable of producing PWM signals. These include the E, S, B, M and the new X Series
devices, which represent the next generation of multifunction DAQ from National Instruments, in addition to the NI myDAQ
and ELVIS II series.
What you need:
NI myDAQ or NI ELVIS II series
NI LabVIEW
Wire
Protoboard
Set Up Hardware:

We will measure the PWM signal with the oscilloscope on the NI ELVISmx Instrument Launcher. Simply connect the AO0
to AI0+, and AGND to AI0- on the myDAQ or ELVIS II series. If you want to use the output to drive a servo motor, refer to
the Proximity-Controlled Servo Motor document.
Figure 2: NI myDAQ Wiring Diagram
Software Instructions:

The LabVIEW graphical development environment, combined with NI-DAQmx, gives you the tools needed to easily
construct applications using counters to generate PWM signals. The first step to create a PWM signal is to produce a
simple digital pulse train. Below is an example of using LabVIEW to create a digital pulse train signal using NI-DAQmx.
Each step of the program, indicated by a number at the bottom of the figure, is described in the VI shown below. The VI
can be downloaded from the bottom of the page.
Figure 3: Block diagram of PWM.vi
The user controls, explained in the following section, are shown below in the front panel.
Figure 4: Front panel of PWM.vi
Pulse Width Modulation
Generated by Jive SBS on 2014-06-11-05:00
3
How It Works:

With the PWM VI open and the hardware all set up, open the oscilloscope from the NI ELVISmx Instrument
Launcher, and click Run. In PWM.vi, adjust a control inside of the Waveform Information cluster to ensure
the cluster is not grayed out, make sure you are using the proper physical channel, and run the program.
You should see a digital waveform (square wave) in the oscilloscope. Adjust the duty cycle, amplitude, and
frequency of the waveform, and note any visible changes. The other parameters (timing, buffer, and max/
min) do not need adjustment if you are simply viewing the waveform.

You might also like