Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/258546468

Inexpensive Data Acquisition with a Sound Card

Article  in  The Physics Teacher · December 2011


DOI: 10.1119/1.3661095

CITATIONS READS

6 5,452

3 authors:

Umer Hassan Saad Pervaiz


University of Illinois, Urbana-Champaign University of Colorado Boulder
38 PUBLICATIONS   672 CITATIONS    39 PUBLICATIONS   634 CITATIONS   

SEE PROFILE SEE PROFILE

Sabieh Anwar
Lahore University of Management Sciences
109 PUBLICATIONS   1,718 CITATIONS   

SEE PROFILE

Some of the authors of this publication are also working on these related projects:

Magneto-optical effects in Graphene Family View project

Special Issue "Point-of-Care (PoC) Technologies for Health Care" - Open for Submission View project

All content following this page was uploaded by Sabieh Anwar on 01 April 2015.

The user has requested enhancement of the downloaded file.


Inexpensive data acquisition with the sound card
Umer Hassan, Saad Pervaiz, and Muhammad Sabieh Anwar
School of Science & Engineering, Lahore University of Management
Sciences (LUMS), Opposite Sector U, D.H.A, Lahore 54792,
Pakistan

(Dated: 29 June 2010)

1
I. INTRODUCTION

Signal generators, oscilloscopes and data acquisition (DAQ) systems are standard compo-
nents of the modern experimental physics laboratory. The sound card, a built-in component
in the ubiquitous personal computer, can be utilized for all three of these tasks1,2 and offers
an attractive option for labs in developing countries, such as ours–Pakistan–where afford-
ability is always of prime concern. In this note, we describe in a recipe fashion, how the
sound card is used for DAQ and signal generation.
The sound card facilitates the input and output of audio signals with frequencies ranging
between 20 and 20 KHz. The card works as a simple analog to digital convertor3 . The
maximum sampling rate at which the common sound card acquires data is around 44 KHz.
Thus we can acquire and generate the signals upto frequencies of about 20 KHz while
satisfying the Nyquist criterion4 .
One can use the 3.5 mm TRS stereo jack connector, shown in Figure 1, for generating
and acquiring signals. The TRS stereo connector provides access to both the right and left
channels of the sound card. Thus we can utilize both channels as Analog Inputs (AI) or
Analog Outputs (AO), or one as an AI and the other as an AO. The male TRS stereo jack
connector is connected with the female counterpart already available in the computer.
Ring
(Right-hand Channel)

Sleeve Insulating Tip


(Ground) Rings (Left-hand Channel)

FIG. 1. The TRS stereo jack connector that plugs into the PC.

Personal computers and most laptops have sound cards having line-in, line-out, and
microphone sockets. Usually they are color coded with light blue, lime green and pink color
respectively. The difference between the line-in and microphone inputs is that they are used
for different input signal levels. Weaker or smaller amplitude signals are generally given to
the microphone input of sound card, which includes a built-in pre-amplifier boosting the
incoming signal, whereas the line-in socket must be supplied with stronger input signals. In
our case, we demonstrate that for data acquisition, the TRS connector is plugged into the
microphone socket of sound card and into the line-out socket for signal generation.

2
The second component to sound card based DAQ is the software. For this purpose, there
are already free applications that are available from the internet, such as Daqarta 5 and
Winscope 6 . Students or teachers having background in programming languages can even
write their own computer programs, such as in C or Java. For example, the Hansen et al.3
describes an application written in DOS. Matlab is another popular application suite that
utilizes a friendly graphical-user-interface and will be used as example in the present article,
but it should be remembered that the choice of the software is either based on the traditions
of the lab or the taste of the teacher.

II. DATA ACQUISITION (OSCILLOSCOPE) USING THE SOUND CARD

Usually, sound cards have a maximum operating voltage of 3-5 Volts, therefore, a simple
circuit can be designed to limit the voltage fed into the sound card. There are two basic
types of protection circuitry.

1. The voltage limiter limits the amplitude of the input voltage. For example, the circuit,
shown in Figure 2 limits the input signal to ±1.4 V, since we have used two silicon
diodes in series7 . Any input voltage outside this range will be clipped, hence the shape
of excessively large input signals will be distorted. This also protects the sound card

D1 D3
Input Output Signal
Signal to Sound Card

D2 D4

FIG. 2. Voltage Limiter circuit for protection of the sound card.

from accidental voltage surges.

2. The high input impedance attenuation circuit, shown in Figure 3, uses a simple oper-
ational amplifier as an inverting amplifier7 . The output of the circuit is given as,

R2
Vout = − × Vin (1)
R1

3
The circuit attenuates the input signal by (R1/R2), protecting the sound card from
higher voltages. Thus, depending on the application we can select the suitable atten-
uation ratio. The output of the inverting attenuator is 180 degree out of phase with
the input. If required, this can be rectified by adding another inverting amplifier with
unity gain. The major advantage of this attenuator (as opposed to the limiter) is its

R2

R1 Output Signal
to Sound Card
Input Signal 741
Vout
Vin

FIG. 3. High input impedance attenuation circuit for protection of the sound card.

high input impedance and preservation of the shape of the original signal.

A. Matlab Oscilloscope

The Data Acquisition toolbox of Matlab provides built-in oscilloscopes called Daqscope
and Softscope. We describe Softscope since we believe that it provides more functionalities.
Softscope can be initiated by typing the following command in the command window: À
sof tscope. A dialog box, entitled “Hardware Configuration” appears which shown by Figure
4. We specify winsound as the Adaptor, adjust the desired sampling rate and select the left
or right channel as the case may be. We can also access both channels simultaneously. After
configuring the hardware, the “Oscilloscope” opens as shown in Figure 5. It shows the left
and right display channels, horizontal and vertical adjustments scrolling knobs and different
triggering options. For real time experimental signals we use ‘continuous triggering’. We
can also perform different measurements (e.g. max, rms, period, frequency, mean) of the
incoming signal by selecting ‘Measurements’ from the Edit Menu.

B. Examples

1. We generate a sine wave of frequency 500 Hz and a triangular wave of fundamental


frequency 1000 Hz using ordinary lab signal generators and connect these to the right
and left channels of the TRS connector respectively. The signals are then acquired

4
FIG. 4. Hardware Configuration for SoftScope.

FIG. 5. SoftScope display panel.

using Softscope, illustrated in Figure 6. The display panel also shows the frequency of
the incoming signals.

2. The sound card based data acquisition system also well with the real time experi-
mental setups. For example, in one of our freshmen experiments we measure the the
EMF’s generated in four solenoids wound around a pipe through which disk shaped
magnets are released and freely fall under gravity. The experimental scheme is shown
in Figure 7 and maybe used to determine the velocity of the falling magnets or the

5
FIG. 6. SoftScope showing the two signals simultaneously.

determination of the acceleration due to gravity, g. The output signal, acquired using
the sound card, is shown in Figure 8. It is evident that with the increasing velocity of
magnet, the EMF generated by magnetic induction increases in intensity, the disper-
sive curves get sharper and narrower and the time spacing decreases. These results
not only make complete physical sense but also invite students to perform quantitative
measurements8 .

III. SIGNAL GENERATION USING SOUND CARD

The sound card can also be used for generating many types of signals, limited by the
allowed ranges of maximum amplitude and maximum frequency. The Data Acquisition tool
box of Matlab also provides us with a built-in signal generator which can be initiated by
typing in: À daqf cngen. This command launches the function generator window shown
in Figure 9. We can generate many types of signals including sine, square, random, chirp,
sawtooth etc. The software provides the freedom to choose important signal properties
notably frequency, amplitude, phase and DC Offset. Once the ‘Start’ button is pressed,
sound card starts outputting the signal through the specified channel.

6
Disk Magnet

To sound Card in
Computer

FIG. 7. Experimental setup for demonstrating sound card based signal acquisition from falling
magnets.

FIG. 8. SoftScope showing the output EMF.

IV. CONCLUSIONS

The sound card, is an integral component of the personal computer can be used in
experimental sciences projects for data acquisition and signal generation. This can lead to
cost-effective experimental setups transforming the sound card from a lonely bystander into
the workhorse of the physics lab.

7
View publication stats

FIG. 9. Matlab’s Signal Generator.

REFERENCES

1
A A Azooz, “Operating a GeigerMller tube using a PC sound card”, Eur. J. Phys., 30,
57-67 (2009).
2
W. C. Magnoa, A. E. P. de Arajo, M. A. Lucena, E. Montarroyos, and C. Chesman,
“Probing a resonant circuit with a PC sound card”, Am. J. Phys., 75 (2), 161-162 (2007).
3
Kirk Hansen, Mark Harnetiaux, and Peter B. Siegel “Using the Sound Board as an Analog-
to-Digital Card”, Phys. Teach. 36, 231-232 (1998).
4
John G. Proakis, Dimitris G. Manolakis, Digital signal processing : Principles, Algorithms,
and Applications (Prentice Hall Pearson Education, 2006).
5
http://www.daqarta.com/
6
http://www.comap.cz/questionnaire/winscope/
7
P. Horowitz and Hill, The Art of Electronics (Cambridge University Press, 1989).
8
P. Carpena, “Velocity measurements through magnetic induction”, Am. J. Phys., 65 (2),
135 (1997).

You might also like