You are on page 1of 346

Measurement Guide and Programming

Examples
PSA and ESA Series Spectrum Analyzers
This manual provides documentation for the following instruments:
Agilent Technologies PSA Series
E4443A (3Hz - 6.7GHz)
E4445A (3Hz - 13.2GHz)
E4440A (3Hz - 26.5GHz)
E4446A (3Hz - 44GHz)
E4448A (3Hz - 50GHz)
Agilent Technologies ESA-E Series
E4401B (9kHz - 1.5GHz)
E4402B (9kHz - 3.0GHz)
E4404B (9kHz - 6.7GHz)
E4405B (9kHz - 13.2GHz)
E4407B (9kHz - 26.5GHz)
Agilent Technologies ESA-L Series
E4411B (9kHz - 1.5GHz)
E4403B (9kHz - 3.0GHz)
E4408B (9kHz - 26.5GHz)
Manufacturing Part Number: E4401-90482
Supersedes: E4401-90466
Printed in USA
April 2004
Copyri ght 1999 - 2004 Agi l ent Technol ogi es
2
Notice
The i nformati on contai ned i n thi s document i s subject to change
wi thout noti ce.
Agi l ent Technol ogi es makes no warr anty of any ki nd wi th regard to thi s
materi al , i ncl udi ng but not l i mi ted to, the i mpl i ed warranti es of
merchantabi l i ty and fi tness for a parti cul ar purpose. Agi l ent
Technol ogi es shal l not be l i abl e for errors contai ned herei n or for
i nci dental or consequenti al damages i n connecti on wi th the furni shi ng,
performance, or use of thi s materi al .
Safety Information
The fol l owi ng safety symbol s ar e used throughout thi s manual .
Fami l i ari ze yoursel f wi th the symbol s and thei r meani ng before
operati ng thi s i nstrument.
WARNING Warni ng denotes a hazard. It calls attention to a procedure
which, if not correctly performed or adhered to, could result in
injury or loss of life. Do not proceed beyond a warning note
until the indicated conditions are fully understood and met.
CAUTION Caution denotes a hazard. I t cal l s attenti on to a pr ocedure that, i f not
cor r ectl y per for med or adher ed to, coul d r esul t i n damage to or
destructi on of the i nstrument. Do not pr oceed beyond a cauti on si gn
unti l the i ndi cated condi ti ons are ful l y understood and met.
NOTE Note cal l s out speci al i nformati on for the users attenti on. I t pr ovi des
operati onal i nformati on or addi ti onal i nstructi ons of whi ch the user
shoul d be aware.
The i nstructi on documentati on symbol . The pr oduct i s
mar ked wi th thi s symbol when i t i s necessar y for the
user to r efer to the i nstr ucti ons i n the documentati on.
Thi s symbol i s used to mark the on posi ti on of the
power l i ne swi tch.
Thi s symbol i s used to mark the standby posi ti on of the
power l i ne swi tch.
Thi s symbol i ndi cates that the i nput power requi red i s
AC.
3
WARNING This is a Safety Class 1 Product (provided with a protective
earth ground incorporated in the power cord). The mains plug
shall be inserted only in a socket outlet provided with a
protected earth contact. Any interruption of the protective
conductor inside or outside of the product is likely to make the
product dangerous. Intentional interruption is prohibited.
WARNING No operator serviceable parts inside. Refer servicing to
qualified personnel. To prevent electrical shock do not remove
covers.
WARNING If this product is not used as specified, the protection provided
by the equipment could be impaired. This product must be used
in a normal condition (in which all means for protection are
intact) only.
CAUTION Al ways use the thr ee-pr ong AC power cor d suppl i ed wi th thi s pr oduct.
Fai l ure to ensure adequate gr oundi ng may cause pr oduct damage.
Where to Find the Latest Information
Documentati on i s updated peri odi cal l y. For the l atest i nformati on about
Agi l ent Technol ogi es PSA and ESA spectrum anal yzers, i ncl udi ng
fi rmware upgrades and appl i cati on i nformati on, pl ease vi si t the
fol l owi ng I nternet URL:
http://www.agi l ent.com/fi nd/psa
http://www.agi l ent.com/fi nd/esa
Mi crosoft i s a U.S. regi stered trademark of Mi crosoft Corporati on.
Bl uetooth i s a trademark owned by i ts pr opri etor and used under
l i cense.
4
Contents
5
T
a
b
l
e

o
f

C
o
n
t
e
n
t
s
1. Recommended Test Equipment
2. Measuring Multiple Signals
Comparing Signals on the Same Screen Using Marker Delta . . . . . . . . . . . . . . . . . . . . . . . 12
Comparing Signals on the Same Screen Using Marker Delta Pair . . . . . . . . . . . . . . . . . . . . 14
Comparing Signals not on the Same Screen Using Marker Delta . . . . . . . . . . . . . . . . . . . . 15
Resolving Signals of Equal Amplitude . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Resolving Small Signals Hidden by Large Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Decreasing the Frequency Span Around the Signal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3. Measuring a LowLevel Signal
Reducing Input Attenuation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Decreasing the Resolution Bandwidth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Using the Average Detector and Increased Sweep Time . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Trace Averaging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4. Improving Frequency Resolution and Accuracy
Using a Frequency Counter to Improve Frequency Resolution and Accuracy . . . . . . . . . . 32
5. Tracking Drifting Signals
Measuring a Sources Frequency Drift . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Tracking a Signal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
6. Making Distortion Measurements
Identifying Analyzer Generated Distortion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Third-Order Intermodulation Distortion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Measuring TOI Distortion with a One-Button Measurement . . . . . . . . . . . . . . . . . . . . . . . . 44
Measuring Harmonics and Harmonic Distortion with a One-Button Measurement . . . . . . 45
7. Measuring Noise
Measuring Signal-to-Noise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Measuring Noise Using the Noise Marker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Measuring Noise-Like Signals Using Marker Pairs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Measuring Noise-Like Signals Using the Channel Power Measurement . . . . . . . . . . . . . . . 54
8. Making Time-Gated Measurements
Generating a Pulsed-RF FM Signal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Connecting the Instruments to Make Time-Gated Measurements . . . . . . . . . . . . . . . . . . . . 61
Gated LO Measurement (PSA) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Gated Video Measurement (ESA) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Gated FFT Measurement (PSA) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
6
Contents
T
a
b
l
e

o
f

C
o
n
t
e
n
t
s
9. Measuring Digital Communications Signals
Making Burst Power Measurements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .68
Making Statistical Power Measurements (CCDF) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .71
Making Adjacent Channel Power (ACP) Measurements . . . . . . . . . . . . . . . . . . . . . . . . . . .74
Making Multi-Carrier Power (MCP) Measurements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .77
10.Using External Millimeter Mixers (Option AYZ)
Making Measurements With Agilent 11970 Series Harmonic Mixers . . . . . . . . . . . . . . . . .82
Setting Harmonic Mixer Bias Current . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .84
Entering Conversion-Loss Correction Data for Harmonic Mixers . . . . . . . . . . . . . . . . . . . .85
Making Measurements with Agilent 11974 Series Preselected Harmonic Mixers . . . . . . . .86
Frequency Tracking Calibration with Agilent 11974 Series Preselected Harmonic Mixers .88
11.Demodulating AM and FM Signals
Measuring the Modulation Rate of an AM Signal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .92
Measuring the Modulation Index of an AM Signal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .94
Demodulating an AM Signal Using the ESA Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .96
Demodulating an FM Signal Using the ESA-E Series (Requires Option BAA) . . . . . . . . . .98
12.Using Segmented Sweep (ESA-E Series Spectrum Analyzers)
Measuring Harmonics Using Standard Sweep . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .102
Measuring Harmonics Using Segmented Sweep . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .104
Using Segmented Sweep With Limit Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .106
Using Segmented Sweep to Monitor the Cellular Activity of a cdmaOne Band . . . . . . . .108
13.Stimulus Response Measurements (ESA Options 1DN and 1DQ)
Making a Stimulus Response Transmission Measurement . . . . . . . . . . . . . . . . . . . . . . . . .112
Calculating the N dB Bandwidth Using Stimulus Response . . . . . . . . . . . . . . . . . . . . . . . .114
Measuring Stop Band Attenuation Using Log Sweep (ESA-E Series) . . . . . . . . . . . . . . . .116
Making a Reflection Calibration Measurement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .118
Measuring Return Loss using the Reflection Calibration Routine . . . . . . . . . . . . . . . . . . .120
14.Demodulating and Viewing Television Signals
(ESA-E Series Option B7B)
Demodulating and Viewing Television Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .122
Measuring Depth of Modulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .126
15.Concepts
Resolving Closely Spaced Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .130
Harmonic Distortion Calculations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .132
Time Gating Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .133
Trigger Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .153
Contents
7
T
a
b
l
e

o
f

C
o
n
t
e
n
t
s
AM and FM Demodulation Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
Stimulus Response Measurement Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
16.ESA/PSA Programming Examples
Examples Included in this Chapter: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
Finding Additional Examples and More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
Programming Examples Information and Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . 166
Programming in C Using the VTL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
Using C to Make a Power Suite ACPR Measurement on a cdmaOne Signal . . . . . . . . . . 176
Using C to Serial Poll the Analyzer to Determine when an Auto-alignment is Complete . 179
Using C and Service Request (SRQ) to Determine When a Measurement is Complete . . 182
Using Visual Basic 6 to Capture a Screen Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
Using Visual Basic 6 to Transfer Binary Trace Data . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
Using Agilent VEE to Transfer Trace Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
17.ESA Programming Examples
Examples Included in this Chapter: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
Programming Examples System Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
Using C with Marker Peak Search and Peak Excursion Measurement Routines . . . . . . . 202
Using C for Marker Delta Mode and Marker Minimum Search Functions . . . . . . . . . . . . 206
Using C to Perform Internal Self-Alignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
Using C to Read Trace Data in an ASCII Format (over GPIB) . . . . . . . . . . . . . . . . . . . . . 214
Using C to Read Trace Data in a 32-Bit Real Format (over GPIB) . . . . . . . . . . . . . . . . . . 218
Using C to Read Trace Data in an ASCII Format (over RS-232) . . . . . . . . . . . . . . . . . . . 223
Using C to Read Trace Data in a 32-bit Real Format (over RS-232) . . . . . . . . . . . . . . . . . 228
Using C to Add Limit Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
Using C to Measure Noise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
Using C to Enter Amplitude Correction Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
Using C to Determine if an Error has Occurred . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
Using C to Measure Harmonic Distortion (over GPIB) . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
Using C to Measure Harmonic Distortion (over RS-232) . . . . . . . . . . . . . . . . . . . . . . . . . 261
Using C to Make Faster Power Averaging Measurements . . . . . . . . . . . . . . . . . . . . . . . . . 269
18.PSA Programming Examples
Examples Included in this Chapter: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
Programming Examples Information and Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . 279
Using C with Marker Peak Search and Peak Excursion Measurement Routines . . . . . . . . 280
Using C for Saving and Recalling Instrument State Data . . . . . . . . . . . . . . . . . . . . . . . . . 283
Using C to Save Binary Trace Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
Using C to Make a Power Calibration Measurement for a GSM Mobile Handset . . . . . . 291
Using C with the CALCulate:DATA:COMPress? RMS Command . . . . . . . . . . . . . . . . . 297
Using C Over Socket LAN (UNIX) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
8
Contents
T
a
b
l
e

o
f

C
o
n
t
e
n
t
s
Using C Over Socket LAN (Windows NT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .323
Using Java Programming Over Socket LAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .326
Using the VXI Plug-N-Play Driver in LabVIEW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .335
Using LabVIEW 6 to Make an EDGE GSM Measurement . . . . . . . . . . . . . . . . . . . . . . .336
Using Visual Basic .NET with the IVI-Com Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . .338
Using Agilent VEE to Capture the Equivalent SCPI Learn String . . . . . . . . . . . . . . . . . . .342
9
R
e
c
o
m
m
e
n
d
e
d

T
e
s
t

E
q
u
i
p
m
e
n
t
1 Recommended Test Equipment
10 Chapter 1
Recommended Test Equipment
R
e
c
o
m
m
e
n
d
e
d

T
e
s
t

E
q
u
i
p
m
e
n
t
NOTE To fi nd descri pti ons of speci fi c anal yzer functi ons, for the ESA, refer to
the Agilent Technologies ESA Series Spectrum Analyzers
Users/ Programmers Reference Guide and for the PSA, refer to the
Agilent Technologies PSA Series Spectrum Analyzers Users and
Programmers Reference Guide.

Test Equipment Specifications Recommended Model
Signal Sources
Si gnal Generator (2) 0.25 MHz to 4.0 GHz
Ext Ref I nput
E443XB seri es or
E4438C
Adapters
Type-N (m) to BNC (f) (3) 1250-0780
Termi nati on, 50
Type-N (m)
908A
Cables
(3) BNC, 122-cm (48-i n) 10503A
Miscellaneous
Di recti onal Bri dge 86205A
Bandpass Fi l ter Center Frequency:
200 MHz
Bandwi dth: 10 MHz
Lowpass Fi l ter (2) Cutoff Frequency:
300 MHz
0955-0455
RF Antenna 08920-61060
11
M
e
a
s
u
r
i
n
g

M
u
l
t
i
p
l
e

S
i
g
n
a
l
s
2 Measuring Multiple Signals
12 Chapter 2
Measuring Multiple Signals
Comparing Signals on the Same Screen Using Marker Delta
M
e
a
s
u
r
i
n
g

M
u
l
t
i
p
l
e

S
i
g
n
a
l
s
Comparing Signals on the Same Screen Using
Marker Delta
Usi ng the anal yzer, you can easi l y compare fr equency and ampl i tude
di fferences between si gnal s, such as radi o or tel evi si on si gnal spectra.
The anal yzer del ta marker functi on l ets you compare two si gnal s when
both appear on the scr een at one ti me.
I n thi s pr ocedure, the anal yzer 10 MHz si gnal i s used to measure
fr equency and ampl i tude di ffer ences between two si gnal s on the same
screen. Del ta marker i s used to demonstrate thi s compari son.
Figure2-1 An Example of Comparing Signals on the Same Screen
Step 1. Pr eset the anal yzer :
Press Preset, Factory Preset (i f pr esent).
Step 2. (PSA)
a. Enabl e the rear panel 10 MHz output.
Press System, Reference, 10 MHz Out (On).
b. Connect the 10 MHz OUT (SWITCHED) from the rear panel to the fr ont
panel RF i nput.
(ESA)
Connect the rear panel 10 MHz REF OUT to the fr ont panel RF i nput.
Step 3. Set the anal yzer center fr equency, span and reference l evel to vi ew the
10 MHz si gnal and i ts harmoni cs up to 50 MHz:
Press FREQUENCY Channel, Center Freq, 30, MHz.
Press SPAN X Scale, Span, 50, MHz.
Press AMPLITUDE Y Scale, Ref Level, 10, dBm.
Chapter 2 13
Measuring Multiple Signals
Comparing Signals on the Same Screen Using Marker Delta
M
e
a
s
u
r
i
n
g

M
u
l
t
i
p
l
e

S
i
g
n
a
l
s
Step 4. Pl ace a marker at the hi ghest peak on the di spl ay (10 MHz):
Press Peak Search.
The Next Pk Right and Next Pk Left softkeys are avai l abl e to move the
marker fr om peak to peak. The marker shoul d be on the 10 MHz
reference si gnal :
Step 5. Anchor the fi rst mar ker and acti vate a second mar ker:
Press Marker, Delta.
The l abel on the fi rst marker now reads 1R, i ndi cati ng that i t i s the
reference poi nt.
Step 6. Move the second marker to another si gnal peak usi ng the fr ont-panel
knob or by usi ng the Peak Search key:
Press Peak Search, Next Peak or
Press Peak Search, Next Pk Right or Next Pk Left.
The ampl i tude and fr equency difference between the mar ker s i s
di spl ayed i n the acti ve functi on bl ock. For ESA see the l eft si de of
Fi gur e 2-2 and the r i ght si de for PSA.
Figure2-2 Using the Delta Marker Function (ESA left, PSA right)
NOTE The resol uti on of the marker readi ngs can be i ncreased by turni ng on
the fr equency count functi on.
14 Chapter 2
Measuring Multiple Signals
Comparing Signals on the Same Screen Using Marker Delta Pair
M
e
a
s
u
r
i
n
g

M
u
l
t
i
p
l
e

S
i
g
n
a
l
s
Comparing Signals on the Same Screen Using
Marker Delta Pair
I n thi s pr ocedure, the anal yzer 10 MHz si gnal i s used to measure
fr equency and ampl i tude di ffer ences between two si gnal s on the same
screen usi ng the del ta pai r marker functi on.
Step 1. Refer to the pr evi ous procedur e Compar i ng Si gnal s on the Same
Scr een Usi ng Mar ker Del ta on page 12 and fol l ow steps 1, 2 and 3.
Step 2. Turn on Delta Pair r eference mar ker to compar e the 10 MHz si gnal and
the 30 MHz si gnal :
Press Peak Search, Marker, Delta Pair (r ef).
Note that the Delta Pair marker does not anchor the fi r st marker.
Step 3. Use the knob or Peak Search to move the second mar ker (l abel ed 1) to
the 30 MHz peak:
Press Peak Search, Next Peak or Next Pk Right.
Step 4. Use the fr ont panel knob to move the ref mar ker to the 20 MHz peak:
The acti ve functi on di spl ays the ampl i tude and fr equency di fference
between the 20 MHz and 30 MHz peaks as shown i n Fi gur e 2-3.
Figure2-3 Using the Delta Pair Marker Function (ESA left, PSA right)
NOTE I n Fi gure 2-3 noti ce that the acti ve functi on readout has moved to the
top l eft of the anal yzer di spl ay. The acti ve functi on posi ti on has three
posi ti ons: top, center and bottom. To modi fy the acti ve functi on posi ti on:
Press Display, Active Fctn Position, Top (Center, or Bottom).
Center posi ti on i s the factor y defaul t setti ng.
Chapter 2 15
Measuring Multiple Signals
Comparing Signals not on the Same Screen Using Marker Delta
M
e
a
s
u
r
i
n
g

M
u
l
t
i
p
l
e

S
i
g
n
a
l
s
Comparing Signals not on the Same Screen
Using Marker Delta
Measure the fr equency and ampl i tude di fference between two si gnal s
that do not appear on the screen at one ti me. (Thi s techni que i s useful
for harmoni c di storti on tests when narrow span and narrow bandwi dth
are necessar y to measure the l ow l evel harmoni cs.)
I n thi s pr ocedure, the anal yzer 10 MHz si gnal i s used to measure
fr equency and ampl i tude di ffer ences between one si gnal on screen and
one si gnal off screen. Del ta marker i s used to demonstrate thi s
compar i son.
Figure2-4 Comparing One Signal on Screen with One Signal Off Screen
Step 1. Pr eset the anal yzer :
Press Preset, Factory Preset (i f pr esent).
Step 2. (PSA)
a. Enabl e the rear panel 10 MHz output:
Press System, Reference, 10 MHz Out (On).
b. Connect the 10 MHz OUT (SWITCHED) from the rear panel to the fr ont
panel RF i nput:
(ESA)
Connect the rear panel 10 MHz REF OUT to the fr ont panel RF i nput.
16 Chapter 2
Measuring Multiple Signals
Comparing Signals not on the Same Screen Using Marker Delta
M
e
a
s
u
r
i
n
g

M
u
l
t
i
p
l
e

S
i
g
n
a
l
s
Step 3. Set the center fr equency, span and reference l evel to vi ew onl y the
10 MHz si gnal :
Press FREQUENCY Channel, Center Freq, 10, MHz.
Press SPAN X Scale, Span, 5, MHz.
Press AMPLITUDE Y Scale, Ref Level, 10, dBm.
Step 4. Pl ace a marker on the 10 MHz peak and then set the center fr equency
step si ze equal to the marker fr equency (10 MHz):
Press Peak Search.
Press Marker , Mkr CF Step.
Step 5. Acti vate the mar ker del ta functi on:
Press Marker, Delta.
Step 6. I ncrease the center frequency by 10 MHz:
Press FREQUENCY Channel, Center Freq, .
The fi rst marker moves to the l eft edge of the screen, at the ampl i tude
of the fi rst si gnal peak.
Fi gur e 2-5 shows the reference annotati on for the del ta marker (1R) at
the l eft si de of the di spl ay, i ndi cati ng that the 10 MHz refer ence si gnal
i s at a l ower fr equency than the fr equency range currentl y di spl ayed.
The del ta marker appears on the peak of the 20 MHz component. The
del ta marker annotati on di spl ays the ampl i tude and frequency
di fference between the 10 and 20 MHz si gnal peaks.
Figure2-5 Delta Marker with Reference Signal Off-Screen (ESA)
Step 7. Turn the mar kers off:
Press Marker, Off.
Chapter 2 17
Measuring Multiple Signals
Resolving Signals of Equal Amplitude
M
e
a
s
u
r
i
n
g

M
u
l
t
i
p
l
e

S
i
g
n
a
l
s
Resolving Signals of Equal Amplitude
I n thi s pr ocedure a decrease i n resol uti on bandwi dth i s used i n
combi nati on wi th a decr ease i n vi deo bandwi dth to resol ve two si gnal s
of equal ampl i tude wi th a fr equency separati on of 100 kHz. Noti ce that
the fi nal RBW sel ecti on to resol ve the si gnal s i s the same wi dth as the
si gnal separati on whi l e the VBW i s sl i ghtl y narrower than the RBW.
Step 1. Connect two sources to the anal yzer i nput as shown i n Fi gure 2-6.
Figure2-6 Setup for Obtaining Two Signals
Step 2. Set one sour ce to 300 MHz. Set the fr equency of the other sour ce to
300.1 MHz. Set both sour ce ampl i tudes to 20 dBm. The ampl i tude of
both si gnal s shoul d be appr oxi matel y 20 dBm at the output of the
bri dge.
Step 3. Setup the anal yzer to vi ew the si gnal s:
Press Preset, Factory Preset (i f present).
Press FREQUENCY Channel, Center Freq, 300, MHz.
Press BW/Avg, Res BW, 300, kHz.
Press SPAN X Scale, Span, 2, MHz.
A si ngl e si gnal peak i s vi si bl e. See Fi gure 2-7 for an ESA exampl e.
NOTE I f the si gnal peak i s not pr esent on the di spl ay, span out to 20 MHz,
turn si gnal tracki ng on, span back to 2 MHz and turn si gnal tr acki ng
off.:
Press SPAN, Span, 20, MHz.
Press Peak Search, FREQUENCY, Signal Track (On).
Press SPAN, 2, MHz.
Press FREQUENCY, Signal Track (Off)
18 Chapter 2
Measuring Multiple Signals
Resolving Signals of Equal Amplitude
M
e
a
s
u
r
i
n
g

M
u
l
t
i
p
l
e

S
i
g
n
a
l
s
Figure2-7 Unresolved Signals of Equal Amplitude (ESA)
Step 4. Change the resol uti on bandwi dth (RBW) to 100 kHz so that the RBW
setti ng i s l ess than or equal to the frequency separati on of the two
si gnal s:
Press BW/Avg, Res BW, 100, kHz.
Noti ce that the peak of the si gnal has become fl attened i ndi cati ng that
two si gnal s may be present.
Step 5. Decr ease the vi deo bandwi dth to 10 kHz:
Press Video BW, 10, kHz.
Two si gnal s are now vi si bl e as shown wi th the ESA on the l eft si de i n
Fi gur e 2-8 and the PSA on the r i ght si de. Use the fr ont-panel knob or
step keys to fur ther reduce the resol uti on bandwi dth and better r esol ve
the si gnal s.
Figure2-8 Resolving Signals of Equal Amplitude (ESA left, PSA right)
Chapter 2 19
Measuring Multiple Signals
Resolving Signals of Equal Amplitude
M
e
a
s
u
r
i
n
g

M
u
l
t
i
p
l
e

S
i
g
n
a
l
s
As the resol uti on bandwi dth i s decr eased, resol uti on of the i ndi vi dual
si gnal s i s i mpr oved and the sweep ti me i s i ncreased. For fastest
measurement ti mes, use the wi dest possi bl e resol uti on bandwi dth.
Under factor y pr eset condi ti ons, the r esol uti on bandwi dth i s coupl ed
(or l i nked) to the span.
Si nce the r esol uti on bandwi dth has been changed from the coupl ed
val ue, a # mark appears next to Res BW i n the l ower-l eft corner of the
screen, i ndi cati ng that the resol uti on bandwi dth i s uncoupl ed. (For
mor e i nfor mati on on coupl i ng, r efer to the Auto Couple key descri pti on
i n the Agi l ent Technol ogi es ESA Spectrum Anal yzers
Users/Programmers Reference Gui de and the PSA Spectrum
Anal yzers Users/Programmers Reference Gui de.)
NOTE To resol ve two si gnal s of equal ampl i tude wi th a fr equency separati on
of 200 kHz, the resol uti on bandwi dth must be l ess than the si gnal
separati on so a resol uti on bandwi dth of 100 kHz must be used. (For
anal yzer s that use a 1-3-10 RBW step sequence, a 100 kHz RBW i s the
best choi ce for si gnal separ ati on, but for hi gh perfor mance anal yzers,
l i ke the PSA, a 180 kHz RBW can be sel ected by fi ne tuni ng the RBW
fi l ter s at 10% i ncrements.) Fi l ter wi dths above 200 kHz exceed the
200 kHz si gnal separati on and woul d not resol ve the si gnal s.
20 Chapter 2
Measuring Multiple Signals
Resolving Small Signals Hidden by Large Signals
M
e
a
s
u
r
i
n
g

M
u
l
t
i
p
l
e

S
i
g
n
a
l
s
Resolving Small Signals Hidden by Large
Signals
Thi s procedure uses narrow resol uti on bandwi dths to resol ve two i nput
si gnal s wi th a frequency separati on of 155 kHz and an ampl i tude
di ffer ence of 60 dB.
Step 1. Connect two sources to the anal yzer i nput as shown i n Fi gure 2-6.
Step 2. Set one sour ce to 300 MHz at 10 dBm. Set the second source to
300.05 MHz, so that the si gnal i s 50 kHz hi gher than the fi rst si gnal .
Set the ampl i tude of the si gnal to 70 dBm (60 dB bel ow the fi rst
si gnal ).
Step 3. Set the anal yzer as fol l ows:
Press Preset, Factory Preset (i f pr esent).
Press FREQUENCY Channel, Center Freq, 300, MHz.
Press BW/Avg, 30, kHz.
Press SPAN X Scale, Span, 500, kHz.
NOTE I f the si gnal peak i s not pr esent on the di spl ay, span out to 20 MHz,
turn si gnal tracki ng on, span back to 2 MHz and turn si gnal tr acki ng
off:
Press SPAN, Span, 20, MHz.
Press Peak Search, FREQUENCY, Signal Track (On).
Press SPAN, 2, MHz.
Press FREQUENCY, Signal Track (Off).
Step 4. Set the 300 MHz si gnal to the reference l evel :
Press Peak Search, Mkr , Mkr Ref Lvl.
NOTE The ESA 30 kHz fi l ter shape factor of 15:1 (PSA i s 4.1:1) has a
bandwi dth of 450 kHz at the 60 dB poi nt (PSA has a BW of 123 kHz).
The hal f-bandwi dth (225 kHz for ESA and 61.5 kHz for PSA) i s NOT
narr ower than the fr equency separati on of 50 kHz, so the i nput si gnal s
can not be resol ved.
Chapter 2 21
Measuring Multiple Signals
Resolving Small Signals Hidden by Large Signals
M
e
a
s
u
r
i
n
g

M
u
l
t
i
p
l
e

S
i
g
n
a
l
s
Figure2-9 Signal Resolution with a 30 kHz RBW (ESA left, PSA right)
Step 5. Reduce the resol uti on bandwi dth fi l ter to vi ew the smal l er hi dden
si gnal . Pl ace a del ta marker on the smal l er si gnal :
Press BW/Avg, 1, kHz.
Press Peak Search, Marker, 50, kHz.
NOTE The ESA 1 kHz fi l ter shape factor of 15:1 (PSA i s 4.1:1) has a
bandwi dth of 15 kHz at the 60 dB poi nt (PSA has a BW of 4.1 kHz). The
hal f-bandwi dth (7.5 kHz for ESA and 2.05 kHz for PSA) i s narr ower
than 50 kHz, so the i nput si gnal s can be r esol ved.
Figure2-10 Signal Resolution with a 1 kHz RBW (ESA left, PSA right)
NOTE To determi ne the resol uti on capabi l i ty for i ntermedi ate ampl i tude
di fferences, assume the fi l ter ski rts between the 3 dB and 60 dB poi nts
are parabol i c, l i ke an i deal Gaussi an fi l ter. The resol uti on capabi l i ty i s
approxi matel y:
where f i s the separati on between the si gnal s.
12.04 dB
f
RBW
-------------

2
22 Chapter 2
Measuring Multiple Signals
Decreasing the Frequency Span Around the Signal
M
e
a
s
u
r
i
n
g

M
u
l
t
i
p
l
e

S
i
g
n
a
l
s
Decreasing the Frequency Span Around the
Signal
Usi ng the anal yzer si gnal track functi on, you can qui ckl y decr ease the
span whi l e keepi ng the si gnal at center frequency. Thi s i s a fast way to
take a cl oser l ook at the area around the si gnal to i denti fy si gnal s that
woul d otherwi se not be resol ved.
Thi s pr ocedure uses si gnal tr acki ng and span zoom to vi ew the anal yzer
50 MHz reference si gnal i n a 200 kHz span.
Step 1. Per for m a factor y pr eset:
Press Preset, Factory Preset (i f pr esent).
Step 2. Enabl e the i nternal 50 MHz ampl i tude reference si gnal of the anal yzer
as fol l ows:
(PSA)
Press Input/Output, Input Port, Amptd Ref.
(ESA E4401B and E4411B)
Press Input/Output, Amptd Ref (On).
(ESA E4402B, E4403B, E4404B, E4405B, E4407B and E4408B)
Connect a cabl e from the front panel AMPTD REF OUT to the anal yzer
RF i nput:
Press Input/Output, Amptd Ref Out (On).
Step 3. Set the start fr equency to 20 MHz and the stop frequency to 1 GHz:
Press FREQUENCY Channel, Start Freq, 20, MHz.
Press FREQUENCY Channel, Stop Freq, 1, GHz.
Step 4. Pl ace a marker at the peak:
Press Peak Search.
Step 5. Turn on the si gnal tracki ng functi on to move the si gnal to the center of
the screen (i f i t i s not al ready posi ti oned ther e):
Press FREQUENCY Channel, Signal Track (On).
See the l eft-si de of fi gur e Fi gure 2-11. (Note that the marker must be on
the si gnal before turni ng si gnal track on.)
NOTE Because the si gnal tr ack functi on automati cal l y mai ntai ns the si gnal at
the center of the screen, you can reduce the span qui ckl y for a cl oser
l ook. I f the si gnal dri fts off of the screen as you decrease the span, use a
wi der frequency span. (You can al so use Span Zoom, i n the SPAN menu,
as a qui ck way to perform the Peak Search, FREQUENCY, Signal Track,
SPAN key sequence.)
Chapter 2 23
Measuring Multiple Signals
Decreasing the Frequency Span Around the Signal
M
e
a
s
u
r
i
n
g

M
u
l
t
i
p
l
e

S
i
g
n
a
l
s
Step 6. Reduce span and resol uti on bandwi dth to zoom i n on the marked
si gnal :
Press SPAN X Scale, Span, 200, kHz.
NOTE I f the span change i s l arge enough, the span decr eases i n steps as
automati c zoom i s compl eted. See Fi gure 2-11 on the r i ght si de. You can
al so use the fr ont-panel knob or step keys to decr ease the span and
resol uti on bandwi dth val ues.
Step 7. Turn off si gnal tr acki ng:
Press FREQUENCY Channel, Signal Track (Off).
Figure2-11 Signal Tracking
LEFT: Si gnal tracki ng on before span decrease
RI GHT: After zoomi ng i n on the si gnal
24 Chapter 2
Measuring Multiple Signals
Decreasing the Frequency Span Around the Signal
M
e
a
s
u
r
i
n
g

M
u
l
t
i
p
l
e

S
i
g
n
a
l
s
25
M
e
a
s
u
r
i
n
g

a

L
o
w

L
e
v
e
l

S
i
g
n
a
l
3 Measuring a LowLevel Signal
26 Chapter 3
Measuring a LowLevel Signal
Reducing Input Attenuation
M
e
a
s
u
r
i
n
g

a

L
o
w

L
e
v
e
l

S
i
g
n
a
l
Reducing Input Attenuation
The abi l i ty to measure a l ow-l evel si gnal i s l i mi ted by i nternal l y
gener ated noi se i n the spectrum anal yzer. The measurement setup can
be changed i n several ways to i mpr ove the anal yzer sensi ti vi ty.
The i nput attenuator affects the l evel of a si gnal passi ng through the
i nstrument. I f a si gnal i s very cl ose to the noi se fl oor, reduci ng i nput
attenuati on can bri ng the si gnal out of the noi se.
CAUTION Ensure that the total power of al l i nput si gnal s at the anal yzer RF
i nput does not exceed +30 dBm (1 watt).
Step 1. Pr eset the anal yzer :
Press Preset, Factory Preset (i f pr esent).
Step 2. Set the frequency of the si gnal sour ce to 300 MHz. Set the source
ampl i tude to 80 dBm. Connect the source RF OUTPUT to the anal yzer
RF I NPUT.
Step 3. Set the center fr equency, span and reference l evel :
Press FREQUENCY Channel, Center Freq, 300, MHz.
Press SPAN X Scale, Span, 5, MHz.
Press AMPLITUDE Y Scale, Ref Level, 40, dBm.
Step 4. Move the desi red peak (i n thi s exampl e, 300 MHz) to the center of the
di spl ay:
Press Peak Search, Marker , Mkr CF.
Step 5. Reduce the span to 1 MHz (as shown i n Fi gure 3-1) and i f necessary
re-center the peak:
Press Span, 1, MHz.
Figure 3-1 Measuring a Low-Level Signal (ESA Display)
Chapter 3 27
Measuring a LowLevel Signal
Reducing Input Attenuation
M
e
a
s
u
r
i
n
g

a

L
o
w

L
e
v
e
l

S
i
g
n
a
l
Step 6. Set the attenuati on to 20 dB:
Press AMPLITUDE Y Scale, Attenuation, 20, dB.
Note that i ncreasi ng the attenuati on moves the noi se fl oor cl oser to the
si gnal l evel .
A # mark appears next to the Atten annotati on at the top of the
di spl ay, i ndi cati ng that the attenuati on i s no l onger coupl ed to other
anal yzer setti ngs.
Step 7. To see the si gnal mor e cl ear l y, set the attenuati on to 0 dB:
Press AMPLITUDE, Attenuation, 0, dB.
See Fi gure 3-2 shows 0 dB i nput attenuati on.
Figure 3-2 Measuring a Low-Level Signal Using 0 dB Attenuation (ESA)
CAUTION When you fi ni sh thi s exampl e, i ncr ease the attenuati on to protect the
anal yzer s RF i nput:
Press AMPLITUDE Y Scale, Attenuation (Auto) or pr ess Auto Couple.
NOTE Al l fi gur es i n thi s chapter ar e scr een captur es fr om an ESA. Di spl ay
and numeri cal resul ts may be di ffer ent for a PSA.
28 Chapter 3
Measuring a LowLevel Signal
Decreasing the Resolution Bandwidth
M
e
a
s
u
r
i
n
g

a

L
o
w

L
e
v
e
l

S
i
g
n
a
l
Decreasing the Resolution Bandwidth
Resol uti on bandwi dth setti ngs affect the l evel of i nternal noi se wi thout
affecti ng the l evel of conti nuous wave (CW) si gnal s. Decreasi ng the
RBW by a decade reduces the noi se fl oor by 10 dB.
Step 1. Refer to the fi rst procedur e Reduci ng I nput Attenuati on on page 26 of
thi s chapter and fol l ow steps 1, 2 and 3.
Step 2. Decr ease the resol uti on bandwi dth:
Press BW/Avg, .
The l ow-l evel si gnal appear s more cl earl y because the noi se l evel i s
reduced (see Fi gur e 3-3).
Figure 3-3 Decreasing Resolution Bandwidth
A # mark appears next to the Res BW annotati on i n the l ower l eft
corner of the screen, i ndi cati ng that the resol uti on bandwi dth i s
uncoupl ed.
RBW Selections You can use the step keys to change the RBW i n a 1310 sequence.
For ESA, RBWs bel ow 1 kHz are di gi tal and have a sel ecti vi ty rati o of
5:1 whi l e RBWs at 1 kHz and hi gher have a 15:1 sel ecti vi ty rati o. The
ESAs maxi mum RBW i s 5 MHz and the mi ni mum i s 1 Hz (opti onal ).
Al l PSA RBWs are di gi tal and have a sel ecti vi ty rati o of 4.1:1. For PSA,
choosi ng the next l ower RBW for better sensi ti vi ty i ncreases the sweep
ti me by about 10:1 for swept measurements, and about 3:1 for FFT
measurements (wi thi n the l i mi ts of RBW). Usi ng the knob or keypad,
you can sel ect RBWs from 1 Hz to 3 MHz i n approxi matel y 10%
i ncr ements, pl us 4, 5, 6 and 8 MHz. Thi s enabl es you to make the trade
off between sweep ti me and sensi ti vi ty wi th fi ner r esol uti on.
Chapter 3 29
Measuring a LowLevel Signal
Using the Average Detector and Increased Sweep Time
M
e
a
s
u
r
i
n
g

a

L
o
w

L
e
v
e
l

S
i
g
n
a
l
Using the Average Detector and
Increased Sweep Time
When the anal yzers noi se masks l ow-l evel si gnal s, changi ng to the
average detector and i ncr easi ng the sweep ti me smooths the noi se and
i mproves the si gnal s vi si bi l i ty. Sl ower sweeps are requi red to average
more noi se vari ati ons.
Step 1. Refer to the fi rst procedur e Reduci ng I nput Attenuati on on page 26 of
thi s chapter and fol l ow steps 1, 2 and 3.
Step 2. Sel ect the aver age detector:
Press Det/Demod, Detector, Average.
A # mark appears next to the Avg annotati on, i ndi cati ng that the
detector has been chosen manual l y (see Fi gur e 3-4).
Step 3. I ncrease the sweep ti me to 100 ms:
Press Sweep, Sweep Time, .
Note how the noi se smooths out, as ther e i s more ti me to average the
val ues for each of the di spl ayed data poi nts.
Step 4. Wi th the sweep ti me at 100 ms, change the aver age type to
l og aver agi ng:
(ESA) Pr ess BW/Avg, Avg Type, Video Avg.
(PSA) Pr ess BW/Avg, Avg/VBW Type, Log-Pwr.
Figure 3-4 Varying the Sweep Time with the Average Detector
30 Chapter 3
Measuring a LowLevel Signal
Trace Averaging
M
e
a
s
u
r
i
n
g

a

L
o
w

L
e
v
e
l

S
i
g
n
a
l
Trace Averaging
Aver agi ng i s a di gi tal process i n whi ch each trace poi nt i s averaged wi th
the pr evi ous average for the same trace poi nt. Sel ecti ng aver agi ng,
when the anal yzer i s autocoupl ed, changes the detecti on mode (fr om
peak i n ESA and normal i n PSA) to sampl e, smoothi ng the di spl ayed
noi se l evel . ESA sampl e mode di spl ays the i nstantaneous val ue of the
si gnal at the end of the ti me or frequency i nterval repr esented by each
di spl ay poi nt (for PSA i t i s the center of the ti me or frequency i nterval ),
rather than the val ue of the peak duri ng the i nterval . Sampl e mode
may not measure a si gnal s ampl i tude as accuratel y as normal mode,
because i t may not fi nd the true peak.
NOTE Thi s i s a tr ace pr ocessi ng functi on and i s not the same as usi ng the
average detector (as descr i bed on page 29).
Step 1. Refer to the fi rst procedur e Reduci ng I nput Attenuati on on page 26 of
thi s chapter and fol l ow steps 1, 2 and 3.
Step 2. Turn vi deo aver agi ng on:
Press BW/Avg, Average (On).
As the aver agi ng routi ne smooths the trace, l ow l evel si gnal s become
mor e vi si bl e. Average 100 appears i n the acti ve functi on bl ock.
Step 3. Wi th average as the acti ve functi on, set the number of aver ages to 25:
Press 25, Enter.
Annotati on on the l eft si de of the grati cul e shows the type of aver agi ng
(the annotati on for ESA i s VAvg and i s LgAv for PSA), and the number
of tr aces aver aged.
Changi ng most acti ve functi ons restarts the averagi ng, as does toggl i ng
the Average key. Once the set number of sweeps compl etes, the anal yzer
conti nues to provi de a runni ng average based on thi s set number.
NOTE I f you want the measurement to stop after the set number of sweeps,
use si ngl e sweep: Press Sweep, Sweep (to sel ect Single), or pr ess Single
and then toggl e the Average key.
31
I
m
p
r
o
v
i
n
g

F
r
e
q
u
e
n
c
y

R
e
s
o
l
u
t
i
o
n

a
n
d

A
c
c
u
r
a
c
y
4 Improving Frequency Resolution
and Accuracy
32 Chapter 4
Improving Frequency Resolution and Accuracy
Using a Frequency Counter to Improve Frequency Resolution and Accuracy
I
m
p
r
o
v
i
n
g

F
r
e
q
u
e
n
c
y

R
e
s
o
l
u
t
i
o
n

a
n
d

A
c
c
u
r
a
c
y
Using a Frequency Counter to Improve
Frequency Resolution and Accuracy
Thi s procedure uses the spectrum anal yzer i nternal frequency counter
to i ncr ease the resol uti on and accuracy of the frequency r eadout.
Step 1. Pr eset the anal yzer :
Press Preset, Factory Preset (i f pr esent).
Step 2. Enabl e the i nternal 50 MHz ampl i tude reference si gnal as fol l ows:
(PSA)
Press Input/Output, Input Port, Amptd Ref.
(ESA E4401B and E4411B)
Press Input/Output, Amptd Ref (On).
(ESA E4402B, E4403B, E4404B, E4405B, E4407B and E4408B)
Connect a cabl e from the front panel AMPTD REF OUT to the anal yzer
RF i nput:
Press Input/Output, Amptd Ref Out (On).
Step 3. Set the center fr equency to 50 MHz and the span to 80 MHz:
Press FREQUENCY Channel, Center Freq, 50, MHz.
Press SPAN X Scale, Span, 80, MHz.
Step 4. Turn the fr equency counter on:
(ESA) Pr ess Freq Count.
(PSA) Pr ess Marker Fctn, Marker Count, Marker Count (On).
NOTE The frequency and ampl i tude of the marker and the word Marker
appears i n the acti ve functi on area (thi s i s not the counted resul t). The
counted resul t appear s i n the upper-r i ght cor ner of the di spl ay to the
ri ght-si de of Cntr1.
Step 5. Move the marker, wi th the fr ont-panel knob, hal f-way down the ski rt of
the si gnal r esponse.
Noti ce that the readout i n the acti ve fr equency functi on changes whi l e
the counted frequency r esul t (upper-ri ght cor ner of di spl ay) does not.
See Fi gure 4-1. To get an accur ate count, you do not need to pl ace the
mar ker at the exact peak of the si gnal r esponse.
NOTE Marker count pr operl y functi ons onl y on CW si gnal s or di screte spectr al
components. The marker must be > 25 dB above the di spl ayed noi se
l evel .
Chapter 4 33
Improving Frequency Resolution and Accuracy
Using a Frequency Counter to Improve Frequency Resolution and Accuracy
I
m
p
r
o
v
i
n
g

F
r
e
q
u
e
n
c
y

R
e
s
o
l
u
t
i
o
n

a
n
d

A
c
c
u
r
a
c
y
Figure4-1 Using Marker Counter (ESA Display)
Step 6. Change counter resol uti on:
ESA frequency-counter resol uti on can be set from 1 Hz to 100 kHz by
pr essi ng Freq Count, Resolution.
PSA frequency-counter resol uti on i s fi xed at 0.001 Hz for 2 ms and
l onger gate ti mes. Longer gate ti mes al l ow for greater averagi ng of
si gnal s whose frequency i s "noi sy", at the expense of throughput.
NOTE For PSA, i f the Gate Time (under the Marker Count menu) i s an i nteger
mul ti pl e of the l ength of a power-l i ne cycl e (20 ms for 50 Hz power,
16.67 ms for 60 Hz power), the counter rejects i nci dental modul ati on at
the power l i ne r ate. The shor test Gate Time that rejects both 50 and 60
Hz modul ati on i s 100 ms (100 ms i s the defaul t Gate Time setti ng when
set to Auto).
Step 7. The marker counter remai ns on unti l turned off. Turn off the marker
counter:
(ESA) Pr ess Freq Count, Marker Count (Off). Or Press Marker, Off.
(PSA) Pr ess Marker Fctn, Marker Count, Marker Count (Off). Or Pr ess
Marker, Off.
NOTE When usi ng the bui l t-i n frequency counter functi on wi th the ESA, i f the
rati o of the resol uti on bandwi dth to the span i s too smal l (l ess than or
equal to 0.002), the Marker Count: Widen Res BW message appears on
the di spl ay. I t i ndi cates that the resol uti on bandwi dth i s too narrow.
34 Chapter 4
Improving Frequency Resolution and Accuracy
Using a Frequency Counter to Improve Frequency Resolution and Accuracy
I
m
p
r
o
v
i
n
g

F
r
e
q
u
e
n
c
y

R
e
s
o
l
u
t
i
o
n

a
n
d

A
c
c
u
r
a
c
y
35
T
r
a
c
k
i
n
g

D
r
i
f
t
i
n
g

S
i
g
n
a
l
s
5 Tracking Drifting Signals
36 Chapter 5
Tracking Drifting Signals
Measuring a Sources Frequency Drift
T
r
a
c
k
i
n
g

D
r
i
f
t
i
n
g

S
i
g
n
a
l
s
Measuring a Sources Frequency Drift
The anal yzer can measure the short- and l ong-term stabi l i ty of a
source. The maxi mum ampl i tude l evel and the frequency dri ft of an
i nput si gnal tr ace can be di spl ayed and hel d by usi ng the
maxi mum-hol d functi on. You can al so use the maxi mum hol d functi on i f
you want to determi ne how much of the fr equency spectrum a si gnal
occupi es.
Thi s procedure usi ng si gnal tr acki ng to keep the dr i fti ng si gnal i n the
center of the di spl ay. The dri fti ng i s captured by the anal yzer usi ng
maxi mum hol d.
Step 1. Connect the si gnal generator to the anal yzer i nput.
Step 2. Set the si gnal generator frequency to 300 MHz wi th an ampl i tude of
20 dBm.
Step 3. Set the anal yzer center fr equency, span and reference l evel .
Press Preset, Factory Preset (i f pr esent).
Press FREQUENCY Channel, Center Freq, 300, MHz.
Press SPAN X Scale, Span, 10, MHz.
Press AMPLITUDE Y Scale, Ref Level, 10, dBm.
Step 4. Pl ace a marker on the peak of the si gnal and turn si gnal tracki ng on:
Press Peak Search.
Press FREQUENCY Channel, Signal Track (On).
Reduce the span to 500 kHz:
Press SPAN, Span Zoom, 500, kHz.
Noti ce that the si gnal i s hel d i n the center of the di spl ay.
Step 5. Turn off the si gnal track functi on:
Press FREQUENCY Channel, Signal Track (Off).
Step 6. Measure the excursi on of the si gnal wi th maxi mum hol d:
(ESA) Pr ess View/Trace, Max Hold.
(PSA) Pr ess Trace/View, Max Hold.
As the si gnal vari es, maxi mum hol d mai ntai ns the maxi mum r esponses
of the i nput si gnal .
NOTE Annotati on on the l eft si de of the scr een i ndi cates the tr ace mode. For
exampl e, M1 S2 S3 i ndi cates trace 1 i s i n maxi mum-hol d mode, tr ace 2
and tr ace 3 are i n store-bl ank mode.
Chapter 5 37
Tracking Drifting Signals
Measuring a Sources Frequency Drift
T
r
a
c
k
i
n
g

D
r
i
f
t
i
n
g

S
i
g
n
a
l
s
Step 7. Acti vate trace 2 (trace 2 shoul d be under l i ned) and change the mode to
conti nuous sweepi ng:
(ESA) Pr ess View/Trace, Trace (2).
(PSA) Pr ess Trace/View, Trace (2).
Press Clear Write.
Trace 1 remai ns i n maxi mum hol d mode to show any dr i ft i n the si gnal .
Step 8. Sl owl y change the fr equency of the si gnal gener ator 50 kHz i n 1 kHz
i ncr ements. Your anal yzer di spl ay shoul d l ook si mi l ar to Fi gur e 5-1.
Figure5-1 Viewing a Drifting Signal With Max Hold and Clear Write
38 Chapter 5
Tracking Drifting Signals
Tracking a Signal
T
r
a
c
k
i
n
g

D
r
i
f
t
i
n
g

S
i
g
n
a
l
s
Tracking a Signal
The si gnal tr ack functi on i s useful for tracki ng dr i fti ng si gnal s that
dr i ft rel ati vel y sl owl y by keepi ng the si gnal centered on the di spl ay as
the si gnal dri fts. Thi s procedure tr acks a dri fti ng si gnal .
Note that the pri mary functi on of the si gnal tr ack functi on i s to tr ack
unstabl e si gnal s, not to track a si gnal as the center fr equency of the
anal yzer i s changed. I f you choose to use the si gnal tr ack functi on when
changi ng center fr equency, check to ensure that the si gnal found by the
tr acki ng functi on i s the cor r ect si gnal .
Step 1. Set the source fr equency to 300 MHz wi th an ampl i tude of 20 dBm.
Step 2. Set the anal yzer center fr equency at a 1 MHz offset:
Press Preset, Factory Preset (i f pr esent).
Press FREQUENCY Channel, Center Freq, 301, MHz.
Press SPAN X Scale, Span, 10, MHz.
Step 3. Turn the si gnal tracki ng functi on on:
Press FREQUENCY Channel, Signal Track (On).
Noti ce that si gnal tr acki ng pl aces a marker on the hi ghest ampl i tude
peak and then bri ngs the sel ected peak to the center of the di spl ay.
After each sweep the center fr equency of the anal yzer i s adjusted to
keep the sel ected peak i n the center.
Step 4. Turn the del ta marker on to read si gnal dr i ft:
Press Marker, Delta.
Step 5. Tune the fr equency of the si gnal generator i n 100 kHz i ncr ements.
Noti ce that the center fr equency of the anal yzer al so changes i n
100 kHz i ncr ements, center i ng the si gnal wi th each i ncr ement.
Figure5-2 Tracking a Drifting Signal (ESA left, PSA right)
39
M
a
k
i
n
g

D
i
s
t
o
r
t
i
o
n

M
e
a
s
u
r
e
m
e
n
t
s
6 Making Distortion
Measurements
40 Chapter 6
Making Distortion Measurements
Identifying Analyzer Generated Distortion
M
a
k
i
n
g

D
i
s
t
o
r
t
i
o
n

M
e
a
s
u
r
e
m
e
n
t
s
Identifying Analyzer Generated Distortion
Hi gh l evel i nput si gnal s may cause anal yzer di storti on pr oducts that
coul d mask the real di storti on measured on the i nput si gnal . Usi ng
tr ace 2 and the RF attenuator, you can determi ne whi ch si gnal s, i f any,
are i nternal l y generated di storti on pr oducts.
Usi ng a si gnal from a si gnal generator, determi ne whether the
harmoni c di storti on pr oducts are generated by the anal yzer.
Step 1. Connect the si gnal generator to the anal yzer i nput.
Step 2. Set the source fr equency to 200 MHz wi th an ampl i tude of 0 dBm.
Step 3. Set the anal yzer center fr equency and span:
Press Preset, Factory Preset (i f pr esent).
Press FREQUENCY Channel, Center Freq, 400, MHz.
Press SPAN X Scale, Span, 500, MHz.
The si gnal pr oduces harmoni c di storti on products (spaced 200 MHz
fr om the or i gi nal 200 MHz si gnal ) i n the anal yzer i nput mi xer as shown
i n Fi gur e 6-1.
Figure6-1 Harmonic Distortion (ESA left, PSA right)
Step 4. Change the center fr equency to the val ue of the fi rst harmoni c:
Press Peak Search, Next Peak, Marker, MkrCF.
Step 5. Change the span to 50 MHz and re-center the si gnal :
Press SPAN X Scale, Span, 50, MHz.
Press Peak Search, Marker, MkrCF.
Step 6. Set the attenuati on to 0 dB:
Press AMPLITUDE Y Scale, Attenuation, 0, dB.
Chapter 6 41
Making Distortion Measurements
Identifying Analyzer Generated Distortion
M
a
k
i
n
g

D
i
s
t
o
r
t
i
o
n

M
e
a
s
u
r
e
m
e
n
t
s
Step 7. To determi ne whether the harmoni c di storti on products are generated
by the anal yzer, fi rst save the trace data i n tr ace 2 as fol l ows:
(ESA) Pr ess View/Trace, Trace (2), Clear Write.
(PSA) Pr ess Trace/View, Trace (2), Clear Write.
Step 8. Al l ow trace 2 to update (mi ni mum two sweeps), then store the data
fr om tr ace 2 and pl ace a del ta marker on the harmoni c of tr ace 2:
Press View.
Press Peak Search, Marker, Delta.
The anal yzer di spl ay shows the stored data i n tr ace 2 and the measured
data i n trace 1. The Mkr1 ampl i tude readi ng i s the di fference i n
ampl i tude between the reference and acti ve markers.
Step 9. I ncrease the RF attenuati on to 10 dB:
Press AMPLITUDE Y Scale, Attenuation, 10, dB.
Noti ce the Mkr1 ampl i tude readi ng. Thi s i s the di fference i n the
di storti on product ampl i tude readi ngs between 0 dB and 10 dB i nput
attenuati on setti ngs. I f the Mkr1 ampl i tude absol ute val ue i s
approxi matel y 1 dB for an i nput attenuator change, the di stor ti on i s
bei ng generated, at l east i n part, by the anal yzer. I n thi s case more
i nput attenuati on i s necessary. See Fi gur e 6-2.
Figure6-2 RF Attenuation of 10dB
The Mkr1 ampl i tude readi ng comes fr om two sour ces:
1) I ncreased i nput attenuati on causes poor er si gnal -to-noi se rati o. Thi s
can cause the Mkr1 to be posi ti ve.
2) The reduced contri buti on of the anal yzer ci rcui ts to the harmoni c
measur ement can cause the Mkr1 to be negati ve.
Large Mkr1 measurements i ndi cate si gni fi cant measurement errors.
Set the i nput attenuator to mi ni mi ze the absol ute val ue of Mkr1.
42 Chapter 6
Making Distortion Measurements
Third-Order Intermodulation Distortion
M
a
k
i
n
g

D
i
s
t
o
r
t
i
o
n

M
e
a
s
u
r
e
m
e
n
t
s
Third-Order Intermodulation Distortion
Two-tone, thi rd-order i ntermodul ati on di storti on i s a common test i n
communi cati on systems. When two si gnal s are present i n a non-l i near
system, they can i nteract and cr eate thi rd-or der i ntermodul ati on
di storti on products that are l ocated cl ose to the or i gi nal si gnal s. These
di stor ti on products are gener ated by system components such as
ampl i fi ers and mi xers.
For the qui ck setup TOI measurement exampl e, refer to Measur i ng
TOI Di storti on wi th a One-Button Measurement on page 44.
Thi s procedure tests a devi ce for thi rd-or der i ntermodul ati on usi ng
markers. Two sources are used, one set to 300 MHz and the other to
301 MHz.
Step 1. Connect the equi pment as shown i n Fi gur e 6-3. Thi s combi nati on of
si gnal generators, l ow pass fi l ters, and di recti onal coupl er (used as a
combi ner ) resul ts i n a two-tone sour ce wi th very l ow i nter modul ati on
di stor ti on. Al though the di stor ti on fr om thi s setup may be better than
the speci fi ed performance of the anal yzer, i t i s useful for determi ni ng
the TOI performance of the source/anal yzer combi nati on. After the
performance of the source/anal yzer combi nati on has been veri fi ed, the
devi ce-under-test (DUT) (for exampl e, an ampl i fi er) woul d be i nser ted
between the di recti onal coupl er output and the anal yzer i nput.
Figure6-3 Third-Order Intermodulation Equipment Setup
NOTE The coupl er shoul d have a hi gh degree of i sol ati on between the two
i nput por ts so the sour ces do not i ntermodul ate.
Step 2. Set one sour ce (si gnal generator) to 300 MHz and the other sour ce to
301 MHz, for a fr equency separati on of 1 MHz. Set the sources equal i n
ampl i tude as measured by the anal yzer (i n thi s exampl e, they are set to
5 dBm).
Chapter 6 43
Making Distortion Measurements
Third-Order Intermodulation Distortion
M
a
k
i
n
g

D
i
s
t
o
r
t
i
o
n

M
e
a
s
u
r
e
m
e
n
t
s
Step 3. Set the anal yzer center fr equency and span:
Press Preset, Factory Preset (i f pr esent).
Press FREQUENCY Channel, Center Freq, 300.5, MHz.
Press SPAN X Scale, Span, 5, MHz.
Step 4. Reduce the RBW unti l the di storti on products are vi si bl e:
Press BW/Avg, Res BW, .
Step 5. Set the mi xer l evel to i mprove dynami c range:
(ESA) Pr ess AMPLITUDE Y Scale, More, Max Mixer Lvl, 30, dBm.
(PSA) Pr ess AMPLITUDE Y Scale, More, More, Max Mixer Lvl, 30, dBm.
The anal yzer automati cal l y sets the attenuati on so that a si gnal at the
reference l evel has a maxi mum val ue of 30 dBm at the i nput mi xer.
Step 6. Move the si gnal to the r efer ence l evel :
Press Peak Search, Mkr , Mkr Ref Lvl.
Step 7. Reduce the RBW unti l the di storti on products are vi si bl e:
Press BW/Avg, Res BW, .
Step 8. Acti vate the second marker and pl ace i t on the peak of the di stor ti on
pr oduct (besi de the test si gnal ) usi ng the Next Peak key.
Press Marker, Delta, Peak Search, Next Peak.
Step 9. Measure the other di storti on pr oduct:
Press Marker, Normal, Peak Search, Next Peak.
Step 10. Measur e the di ffer ence between thi s test si gnal and the second
di stor ti on product (see Fi gure 6-4):
Press Delta, Peak Search, Next Peak.
Figure6-4 Measuring the Distortion Product
44 Chapter 6
Making Distortion Measurements
Measuring TOI Distortion with a One-Button Measurement
M
a
k
i
n
g

D
i
s
t
o
r
t
i
o
n

M
e
a
s
u
r
e
m
e
n
t
s
Measuring TOI Distortion with a One-Button
Measurement
One-button power measurements are a part of the Power Sui te
measurement uti l i ty and are standard on al l ESA and PSA model s.
Power Sui te uses pr eset anal yzer states to measure some of the more
common RF power tests. You can modi fy the pr eset states i n the Power
Sui te measurements, gi vi ng you the fl exi bi l i ty to modi fy anal yzer
setti ngs. Power Sui te al so has preset states for cel l ul ar, Bl uetooth and
Wi Fi r adi o formats for fast, accur ate and r epeatabl e measurements.
Thi s procedure uses the i ntermodul ati on one-button test fr om the
Power Sui te Measure menu to automate the TOI measurement. I t i s
measuri ng the TOI performance as i n the pr evi ous procedure
Thi rd-Order I ntermodul ati on Di storti on on page 42.
Step 1. Refer to the second procedur e Thi r d-Or der I ntermodul ati on
Di storti on on page 42 of thi s chapter and fol l ow steps 1 and 2.
Step 2. Set the anal yzer center fr equency to 300.5 MHz:
Press Preset, Factory Preset (i f pr esent).
Press FREQUENCY Channel, Center Freq, 300.5, MHz.
Step 3. Measure the i ntermodul ati on pr oducts usi ng the Power Sui te
measurement tool s:
Press Measure, More, Intermod (TOI ).
Figure6-5 Measuring the Distortion Products with Power Suite
Chapter 6 45
Making Distortion Measurements
Measuring Harmonics and Harmonic Distortion with a One-Button
Measurement
M
a
k
i
n
g

D
i
s
t
o
r
t
i
o
n

M
e
a
s
u
r
e
m
e
n
t
s
Measuring Harmonics and Harmonic
Distortion with a One-Button Measurement
Thi s procedure measures the harmoni cs of the 10 MHz reference output
si gnal . The harmoni cs and total harmoni c di storti on are measured
usi ng the one-button automated harmoni c measur ement.
Step 1. Pr eset the anal yzer :
Press Preset, Factory Preset (i f pr esent).
Step 2. Connect the ESA 10 MHz reference output from the rear of the
anal yzer to the I NPUT. For PSA turn the i nternal 10 MHz reference
si gnal on:
(PSA) Pr ess System, Reference, 10MHz Out (On).
Step 3. Set the anal yzer reference l evel , center fr equency and RBW:
Press AMPLITUDE Y Scale, Ref Level, 10, dBm.
Press FREQUENCY Channel, Center Freq, 10, MHz.
Press BW/Avg, Res BW, 300, kHz.
Step 4. Run the Power Sui te harmoni c di storti on measurement:
Press Measure, More, Harmonic Distortion.
Step 5. Set the number of harmoni c di storti on measurement averages to 3:
Press Meas Setup, Avg Number (On), 3, Enter
Step 6. Set the average mode to exponenti al to conti nuousl y update the resul t
after each subsequent sweep:
Press Meas Setup, Avg Mode (Exp).
Repeat average mode cl ears the averaged resul t after the speci fi ed
number of averages i s compl ete.
Step 7. Opti mi ze the anal yzer s dynami c range setti ngs:
Press Meas Setup, Optimize Ref Level.
Step 8. Di spl ay the total harmoni c di storti on:
(ESA) Pr ess View/Trace, Harmonics & THD.
(ESA) Pr ess Trace/View, Harmonics & THD.
46 Chapter 6
Making Distortion Measurements
Measuring Harmonics and Harmonic Distortion with a One-Button
Measurement
M
a
k
i
n
g

D
i
s
t
o
r
t
i
o
n

M
e
a
s
u
r
e
m
e
n
t
s
Figure6-6 Measuring the Harmonic Distortion
The ampl i tudes of the harmoni cs are l i sted rel ati ve to the fundamental
fr equency.
NOTE An asteri sk (*) appeari ng next to the total harmoni c di storti on val ue
i ndi cates that the i deal resol uti on bandwi dths for one or more
harmoni cs coul d not be set. These harmoni cs for whi ch the resol uti on
bandwi dths coul d not be set ar e fl agged wi th an asteri sk besi de thei r
ampl i tude val ue. The measurement i s sti l l accurate as l ong as the
si gnal has l i ttl e or no modul ati on.
Step 9. Exi t out of the harmoni c di storti on measurement:
Press MEASURE, Meas Off.
47
M
e
a
s
u
r
i
n
g

N
o
i
s
e
7 Measuring Noise
48 Chapter 7
Measuring Noise
Measuring Signal-to-Noise
M
e
a
s
u
r
i
n
g

N
o
i
s
e
Measuring Signal-to-Noise
Si gnal -to-noi se i s a rati o used i n many communi cati on systems as an
i ndi cati on of noi se i n a system. Typi cal l y the more si gnal s added to a
system adds to the noi se l evel , reduci ng the si gnal -to-noi se rati o
maki ng i t more di ffi cul t for modul ated si gnal s to be demodul ated. Thi s
measur ement i s al so r eferr ed to as carr i er-to-noi se i n some
communi cati on systems.
The si gnal -to-noi se measurement pr ocedure bel ow may be adapted to
measure any si gnal i n a system i f the si gnal (carri er) i s a di screte tone.
I f the si gnal i n your system i s modul ated, i t i s necessary to modi fy the
pr ocedure to correctl y measure the modul ated si gnal l evel .
I n thi s exampl e the 50 MHz ampl i tude reference si gnal i s used as the
fundamental si gnal . The ampl i tude reference si gnal i s assumed to be
the si gnal of i nterest and the i nternal noi se of the anal yzer i s measured
as the system noi se. To do thi s, you need to set the i nput attenuator
such that both the si gnal and the noi se are wel l wi thi n the cal i brated
regi on of the di spl ay.
Step 1. Pr eset the anal yzer :
Press Preset, Factory Preset (i f pr esent).
Step 2. Enabl e the i nternal 50 MHz ampl i tude reference si gnal as fol l ows:
(PSA)
Press Input/Output, Input Port, Amptd Ref.
(ESA E4401B and E4411B)
Press Input/Output, Amptd Ref (On).
(ESA E4402B, E4403B, E4404B, E4405B, E4407B and E4408B)
Connect a cabl e from the front panel AMPTD REF OUT to the anal yzer
RF i nput:
Press Input/Output, Amptd Ref Out (On).
Step 3. Set the center fr equency, span, reference l evel and attenuati on:
Press FREQUENCY Channel, Center Freq, 50, MHz.
Press SPAN X Scale, Span, 1, MHz.
Press AMPLITUDE Y Scale, Ref Level, 10, dBm.
Press AMPLITUDE Y Scale, Attenuation, 40, dB.
Step 4. Pl ace a marker on the peak of the si gnal and then pl ace a del ta marker
i n the noi se at a 200 kHz offset:
Press Peak Search.
Press Marker, Delta, 200, kHz.
Step 5. Turn on the marker noi se functi on to vi ew the si gnal -to-noi se
Chapter 7 49
Measuring Noise
Measuring Signal-to-Noise
M
e
a
s
u
r
i
n
g

N
o
i
s
e
measurement resul ts:
(ESA) Pr ess Marker, More, Function, Marker Noise.
(PSA) Pr ess Marker Fctn, Marker Noise.
Figure7-1 Measuring the Signal-to-Noise
Read the si gnal -to-noi se i n dB/Hz, that i s wi th the noi se val ue
determi ned for a 1 Hz noi se bandwi dth. I f you wi sh the noi se val ue for a
di fferent bandwi dth, decrease the rati o by . For exampl e, i f
the anal yzer readi ng i s 70 dB/Hz but you have a channel bandwi dth of
30 kHz:
NOTE The di spl ay detecti on mode i s now aver age. I f the del ta marker i s cl oser
than one quarter of a di vi si on away fr om the edge of the response to the
di scr ete si gnal , the ampl i tude r efer ence si gnal i n thi s case, ther e i s a
potenti al for error i n the noi se measurement. See Measur i ng Noi se
Usi ng the Noi se Marker on page 50.
10 log BW ( )
S/N 70 dB/Hz 10 30 kHz ( ) log + 25.23 dB 30 kHz ( ) = =
50 Chapter 7
Measuring Noise
Measuring Noise Using the Noise Marker
M
e
a
s
u
r
i
n
g

N
o
i
s
e
Measuring Noise Using the Noise Marker
Thi s procedure uses the marker functi on, Marker Noise, to measur e
noi se i n a 1 Hz bandwi dth. I n thi s exampl e the noi se marker
measurement i s made near the 50 MHz reference si gnal to i l l ustr ate
the use of Marker Noise.
Step 1. Enabl e the i nternal 50 MHz reference si gnal of the anal yzer:
(PSA)
Press Input/Output, Input Port, Amptd Ref.
(ESA E4401B and E4411B)
Press Input/Output, Amptd Ref (On).
(ESA E4402B, E4403B, E4404B, E4405B, E4407B and E4408B)
Connect a cabl e fr om the fr ont panel AMPTD REF OUT to the I NPUT:
Press Input/Output, Amptd Ref Out (On).
Step 2. Preset the anal yzer and modi fy the anal yzer setti ngs:
Press Preset, Factory Preset (i f pr esent).
Press FREQUENCY Channel, Center Freq, 49.98, MHz.
Press SPAN X Scale, Span, 100, kHz.
Press AMPLITUDE Y Scale, Ref Level, 10, dBm.
Press AMPLITUDE Y Scale, Attenuation, 40, dB.
Step 3. Acti vate the noi se mar ker :
(ESA) Pr ess Marker, More, Function, Marker Noise.
(PSA) Pr ess Marker Fctn, Marker Noise.
Note that di spl ay detecti on automati cal l y changes to Avg; aver age
detecti on cal cul ates the noi se marker fr om an average val ue of the
di spl ayed noi se. Noti ce that the noi se mar ker fl oats between the
maxi mum and the mi ni mum di spl ayed noi se poi nts. The marker
readout i s i n dBm (1 Hz) or dBm per uni t bandwi dth.
For noi se power i n a di ffer ent bandwi dth, add . For exampl e,
for noi se power i n a 1 kHz bandwi dth, dBm (1 kHz), add or
30 dB to the noi se marker val ue.
NOTE ESA average detecti on i s avai l abl e for fi rmware revi si ons A.08.00 and
l ater. Earl i er fi rmware revi si ons earl i er use sampl e detecti on for
marker noi se cal cul ati ons.
Step 4. Reduce the var i ati ons of the sweep-to-sweep mar ker val ue by
i ncr easi ng the sweep ti me:
Press Sweep, Sweep Time, 3, s.
10 log BW ( )
10 log 1000 ( )
Chapter 7 51
Measuring Noise
Measuring Noise Using the Noise Marker
M
e
a
s
u
r
i
n
g

N
o
i
s
e
I ncreasi ng the sweep ti me when the average detector i s enabl ed al l ows
the tr ace to aver age over a l onger ti me i nterval , thus reduci ng the
vari ati ons i n the resul ts (i ncreases measurement repeatabi l i ty).
Step 5. Move the marker to 50 MHz (l eft di spl ay Fi gur e 7-2):
Press Marker.
Rotate the fr ont-panel knob unti l the noi se marker reads 50 MHz.
The noi se marker val ue i s based on the mean of 5% of the total number
of sweep poi nts centered at the marker. The poi nts that are averaged
span one-hal f of a di vi si on. Noti ce that the mar ker does not go to the
peak of the si gnal because there are not enough poi nts at the peak of
the si gnal . The noi se marker i s al so averagi ng poi nts bel ow the peak
due to the narrow RBW.
Step 6. Wi den the resol uti on bandwi dth to al l ow the marker to make a more
accur ate peak power measur ement usi ng the noi se marker:
Press BW/Avg, Res BW, 10, kHz.
Press Marker.
Figure7-2 Noise Marker (Left - ESA 1 kHz RBW, Right - PSA 10 kHz RBW))
Step 7. Set the anal yzer to zer o span at the marker fr equency:
Press Mkr , Mkr CF.
Press SPAN X Scale, Zero Span.
Press Marker.
Note that the marker ampl i tude val ue i s now correct si nce al l poi nts
averaged are at the same fr equency and not i nfl uenced by the shape of
the bandwi dth fi l ter.
Remember that the noi se marker cal cul ates a val ue based on an
average of the poi nts around the fr equency of i nterest. General l y when
maki ng power measurements usi ng the noi se marker on di screte
si gnal s, fi r st tune to the fr equency of i nter est and then make your
measurement i n zero span (ti me-domai n).
52 Chapter 7
Measuring Noise
Measuring Noise-Like Signals Using Marker Pairs
M
e
a
s
u
r
i
n
g

N
o
i
s
e
Measuring Noise-Like Signals Using Marker
Pairs
Marker pai rs l et you measure power over a fr equency span. The
markers al l ow you to easi l y and conveni entl y sel ect any arbi trary
porti on of the di spl ayed si gnal . However, whi l e the anal yzer, when
autocoupl ed, makes sure the anal ysi s i s power-respondi ng (r ms
vol tage-respondi ng), you must set al l of the other parameters.
Step 1. Pr eset the anal yzer :
Press Preset, Factory Preset (i f pr esent).
Step 2. Set the center fr equency, span, reference l evel and attenuati on:
Press FREQUENCY Channel, Center Freq, 50, MHz.
Press SPAN X Scale, Span, 100, kHz.
Press AMPLITUDE Y Scale, Ref Level, 20, dBm.
Press AMPLITUDE Y Scale, Attenuation, 40, dB.
Step 3. Turn on the marker span pai r to setup the band power measurement i n
step 5:
Press Marker, Span Pair, Span Pair (Span), 40, kHz.
Step 4. Set the resol uti on and vi deo bandwi dths:
Press BW/Avg, Res BW, 1, kHz.
Press BW/Avg, Video BW, 10, kHz.
Common pr acti ce i s to set the resol uti on bandwi dth from 1% to 3% of
the measurement (marker) span, 40 kHz i n thi s exampl e. For ESA, the
vi deo bandwi dth shoul d be at l east ten ti mes wi der than the resol uti on
bandwi dth.
Step 5. Measure the total noi se power between the markers:
(ESA) Marker, More, Function, Band Power.
(PSA) Marker Fctn, Band/Intvl.
Step 6. Add a di screte tone to see the effects on the readi ng. Enabl e the i nternal
50 MHz ampl i tude reference si gnal of the anal yzer as fol l ows:
(PSA)
Press Input/Output, Input Port, Amptd Ref.
(ESA E4401B and E4411B)
Press Input/Output, Amptd Ref (On).
(ESA E4402B, E4403B, E4404B, E4405B, E4407B and E4408B)
Connect a cabl e from the front panel AMPTD REF OUT to the anal yzer
RF i nput:
Press Input/Output, Amptd Ref Out (On).
Chapter 7 53
Measuring Noise
Measuring Noise-Like Signals Using Marker Pairs
M
e
a
s
u
r
i
n
g

N
o
i
s
e
Figure7-3 Band Power Marker Power Measurement (ESA left, PSA right)
Step 7. Set the mar ker span pai r to Center to move the mar kers (set at 40 kHz
span) ar ound wi thout changi ng the span. Use the front-panel knob to
move the band power marker s and note the change i n the power
readi ng:
Press Marker, Span Pair (Center ), then r otate fr ont-panel knob.
NOTE You can al so use Delta Pair to set the measurement start and stop poi nts
i ndependentl y.
54 Chapter 7
Measuring Noise
Measuring Noise-Like Signals Using the Channel Power Measurement
M
e
a
s
u
r
i
n
g

N
o
i
s
e
Measuring Noise-Like Signals Using the
Channel Power Measurement
You may want to measure the total power of a noi se-l i ke si gnal that
occupi es some bandwi dth. Typi cal l y, channel power measurements are
used to measure the total (channel ) power i n a sel ected bandwi dth for a
modul ated (noi se-l i ke) si gnal . Al ternati vel y, to manual l y cal cul ate the
channel power for a modul ated si gnal , use the noi se marker val ue and
add . However, i f you are not certai n of the
characteri sti cs of the si gnal , or i f ther e are di screte spectral components
i n the band of i nterest, you can use the channel power measurement.
Thi s exampl e uses the noi se of the anal yzer, adds a di screte tone, and
assumes a channel bandwi dth of 50 kHz. I f desi red, a speci fi c si gnal
may be substi tuted.
Step 1. Pr eset the anal yzer :
Press Preset, Factory Preset (i f pr esent).
Step 2. Set the center fr equency:
Press FREQUENCY Channel, Center Freq, 50, MHz.
Step 3. Star t the channel power measur ement:
Press MEASURE, Channel Power.
Step 4. Confi gur e the di spl ay to show the combi ned spectr um vi ew wi th
channel power l i mi ts (span hi ghl i ghted i n bl ue):
(ESA) Pr ess View/Trace, Combined.
(PSA) Pr ess Trace/View, Combined.
Step 5. Turn averagi ng on:
Press Meas Setup, Avg Number (On).
Step 6. Add a di screte tone to see the effects on the readi ng. Enabl e the i nternal
50 MHz ampl i tude reference si gnal of the anal yzer as fol l ows:
(PSA)
Press Input/Output, Input Port, Amptd Ref.
(ESA E4401B and E4411B)
Press Input/Output, Amptd Ref (On).
(ESA E4402B, E4403B, E4404B, E4405B, E4407B and E4408B)
Connect a cabl e from the front panel AMPTD REF OUT to the anal yzer
RF i nput:
Press Input/Output, Amptd Ref Out (On).
10 log channel BW ( )
Chapter 7 55
Measuring Noise
Measuring Noise-Like Signals Using the Channel Power Measurement
M
e
a
s
u
r
i
n
g

N
o
i
s
e
Step 7. Opti mi ze the anal yzer r eference l evel setti ng:
Press Meas Setup, Optimize Ref Level.
Your di spl ay shoul d be si mi l ar to Fi gur e 7-4.
Figure7-4 Measuring Channel Power (ESA left, PSA right)
The power readi ng i s essenti al l y that of the tone; that i s, the total noi se
power i s far enough bel ow that of the tone that the noi se power
contri butes very l i ttl e to the total .
The al gori thm that computes the total power works equal l y wel l for
si gnal s of any stati sti cal vari ant, whether tone-l i ke, noi se-l i ke, or
combi nati on.
56 Chapter 7
Measuring Noise
Measuring Noise-Like Signals Using the Channel Power Measurement
M
e
a
s
u
r
i
n
g

N
o
i
s
e
57
M
a
k
i
n
g

T
i
m
e
-
G
a
t
e
d

M
e
a
s
u
r
e
m
e
n
t
s
8 Making Time-Gated
Measurements
58 Chapter 8
Making Time-Gated Measurements
Generating a Pulsed-RF FM Signal
M
a
k
i
n
g

T
i
m
e
-
G
a
t
e
d

M
e
a
s
u
r
e
m
e
n
t
s
Generating a Pulsed-RF FM Signal
Tradi ti onal frequency-domai n spectrum anal ysi s provi des onl y l i mi ted
i nformati on for certai n si gnal s. Exampl es of these di ffi cul t-to-anal yze
si gnal i ncl ude the fol l owi ng:
Pul sed-RF
Ti me mul ti pl exed
I nterl eaved or i ntermi ttent
Ti me domai n mul ti pl e access (TDMA) radi o formats
Modul ated burst
The ti me gati ng measurement exampl es use a si mpl e
fr equency-modul ated, pul sed-RF si gnal . The goal i s to el i mi nate the
pul se spectrum and then vi ew the spectrum of the FM carri er as i f i t
were conti nual l y on, rather than pul sed. Thi s reveal s l ow-l evel
modul ati on components that are hi dden by the pul se spectrum.
Refer back to these fi rst three steps to setup the pul se si gnal , the
pul sed-RF FM si gnal and the osci l l oscope setti ngs when performi ng the
gated LO pr ocedur e (page 62), the gated vi deo pr ocedure (page 64) and
gated FFT pr ocedure (page 66).
For an i nstrument bl ock di agram and i nstrument connecti ons see
Connecti ng the I nstruments to Make Ti me-Gated Measur ements on
page 61.
Step 1. Setup the pul se si gnal wi th a peri od of 5 ms and a wi dth of 4 ms:
There are many ways to cr eate a pul se si gnal . Thi s exampl e
demonstr ates how to create a pul se si gnal usi ng a pul se generator or by
usi ng the i nternal functi on generator i n the ESG. See Tabl e 8-1 for
setup i nformati on of a pul se generator and Tabl e 8-2 for setup
i nformati on of the i nternal generator of the ESG. Sel ect ei ther the pul se
generator or a second ESG to cr eate the pul se si gnal . You need two
ESGs i f you want to use the ESG i nter nal functi on gener ator to cr eate a
pul se si gnal .
Table 8-1 81100 Family Pulse Generator Settings
Peri od 5 ms (or pul se frequency equal to 200 Hz)
Pul se wi dth 4 ms
Hi gh output l evel 2.5 V
Waveform pul se
Low output l evel -2.5 V
Del ay 0 or mi ni mum
Chapter 8 59
Making Time-Gated Measurements
Generating a Pulsed-RF FM Signal
M
a
k
i
n
g

T
i
m
e
-
G
a
t
e
d

M
e
a
s
u
r
e
m
e
n
t
s
Step 2. Set up ESG #1 to tr ansmi t a pul sed-RF si gnal wi th fr equency
modul ati on. Set the FM devi ati on to 1 kHz and the FM r ate to 50 kHz:
ESG #1 generates the pul sed FM si gnal by frequency modul ati ng the
car r i er si gnal and then pul se modul ati ng the FM si gnal . The pul se
si gnal cr eated i n step 1 i s connected to the EXT 2 INPUT (on the fr ont of
ESG #1). The ESG RF OUTPUT i s the pul sed-RF FM si gnal to be
anal yzed by the spectrum anal yzer.
Table 8-2 ESG #2 Internal Function Generator (LF OUT) Settings
LF Out Source FuncGen
LF Out Waveform Pul se
LF Out Peri od 5 ms
LF Out Wi dth (pul se
wi dth)
4 ms
LF Out Ampl i tude 2.5 Vp
LF Out On
RF On/Off Off
Mod On/Off On
Table 8-3 ESG #1 Instrument Connections
Frequency 40 MHz
Ampl i tude 0 dBm
Pul se On
Pul se Source Ext2 DC
FM On
FM Path 1
FM Dev 1 kHz
FM Source I nternal
FM Rate 50 kHz
RF On/Off On
Mod On/Off On
60 Chapter 8
Making Time-Gated Measurements
Generating a Pulsed-RF FM Signal
M
a
k
i
n
g

T
i
m
e
-
G
a
t
e
d

M
e
a
s
u
r
e
m
e
n
t
s
Step 3. Set up the osci l l oscope to vi ew the tri gger, gate and RF si gnal s (see
Fi gur e 8-1 for an exampl e of the osci l l oscope di spl ay):
Figure 8-1 Viewing the Gate Timing with an Oscilloscope
Fi gur e 8-1 osci l l oscope channel s:
1. Channel 1 (l eft di spl ay, top trace) - the tri gger si gnal .
2. Channel 2 (l eft di spl ay, bottom trace) - the gate si gnal (gate si gnal i s
not be acti ve unti l the gate i s on i n the spectr um anal yzer ).
3. Channel 3 (ri ght di spl ay) - the RF output of the si gnal generator.
Table 8-4 Agilent Infiniium Oscilloscope with 3 or more input channels:
Instrument Connections
Ti mebase 1 ms/di v
Channel 1 ON, 2 V/di v, OFFSET = 2 V, DC coupl ed, 1 M i nput,
connect to the pul se si gnal (ESG LF OUTPUT or pul se
generator OUTPUT). Adjust channel 1 setti ngs as
necessary.
Channel 2 ON, 500 mV/di v, OFFSET = 2 V, DC coupl ed, 1 M
i nput, connect to the ESA GATE/HI SWP OUT
connector or PSA TRIGGER 2 OUT connector on the
spectrum anal yzer. Adjust channel 2 setti ngs as
needed when gate i s acti ve.
Channel 3 ON, 500 mV/di v, OFFSET = 0 V, DC coupl ed, 50
i nput, connect to the ESG RF OUTPUT pul sed-RF
si gnal . Adjust channel 3 setti ngs as necessary.
Channel 4 OFF
Tri gger Edge, channel 1, l evel = 1.5 V, or as needed
Chapter 8 61
Making Time-Gated Measurements
Connecting the Instruments to Make Time-Gated Measurements
M
a
k
i
n
g

T
i
m
e
-
G
a
t
e
d

M
e
a
s
u
r
e
m
e
n
t
s
Connecting the Instruments to Make
Time-Gated Measurements
Fi gur e 8-2 shows a bl ock di agram of the test setup. ESG #1 pr oduces a
pul sed FM si gnal by usi ng an external pul se si gnal . The external pul se
si gnal i s connected to the fr ont of the ESG #1 to the EXT 2 INPUT to
control the pul si ng. The pul se si gnal i s al so used as the tri gger si gnal .
The osci l l oscope i s useful for i l l ustr ati ng ti mi ng i nter acti ons between
the tr i gger si gnal and the gate. PSA Gate View coul d be used i n pl ace of
the osci l l oscope.
Usi ng thi s measurement setup al l ows you to vi ew al l si gnal spectra on
the spectrum anal yzer and al l ti mi ng si gnal s on the osci l l oscope. Thi s
setup i s hel pful when you perform gated measurements on unknown
si gnal s.
Figure 8-2 Instrument Connection Diagram
62 Chapter 8
Making Time-Gated Measurements
Gated LO Measurement (PSA)
M
a
k
i
n
g

T
i
m
e
-
G
a
t
e
d

M
e
a
s
u
r
e
m
e
n
t
s
Gated LO Measurement (PSA)
Thi s procedure uti l i zes gated LO to gate the FM si gnal . For concept and
theory i nformati on about gated LO see How Ti me Gati ng Works on
page 135.
Step 1. Set the PSA center frequency, span and reference l evel :
Press FREQUENCY Channel, Center Freq, 40, MHz.
Press SPAN X Scale, Span, 500, kHz.
Press AMPLITUDE Y Scale, Ref Level, 15, dBm.
I n Fi gur e 8-4 (l eft), the movi ng si gnal s are a resul t of the pul sed si gnal .
Usi ng del ta marker s wi th a ti me readout, noti ce that the peri od of the
spi kes i s at 5 ms (the same peri od as the pul se si gnal ). Usi ng ti me
gati ng, these si gnal s are be bl ocked out, l eavi ng the or i gi nal FM si gnal .
Step 2. Set the gate sour ce to the r ear exter nal tr i gger i nput:
Press Sweep, Gate Setup, Gate Source, Ext Rear.
Step 3. Set the gate del ay to 2 ms and the gate l ength to 1 ms. Check that the
gate tr i gger i s set to posi ti ve:
Press Sweep, Gate Setup, Delay, 2, ms.
Press Sweep, Gate Setup, Length, 1, ms.
Press Sweep, Gate Setup, Polarity (Pos).
Step 4. Use the PSA gate vi ew di spl ay to confi rm the gate on ti me i s duri ng
the RF burst i nterval (al ternati vel y you coul d al so use the osci l l oscope
to vi ew the gate setti ngs):
Press Sweep, Gate Setup, Gate View (On).
Figure 8-3 Viewing the PSA Gate Settings with Gated LO
I n Fi gure 8-3 the gray verti cal l i ne (the far l eft l i ne outsi de of the RF
envel ope) repr esents the l ocati on equi val ent to a zero gate del ay.
Chapter 8 63
Making Time-Gated Measurements
Gated LO Measurement (PSA)
M
a
k
i
n
g

T
i
m
e
-
G
a
t
e
d

M
e
a
s
u
r
e
m
e
n
t
s
I n Fi gure 8-3 the verti cal gr een paral l el bars represent the gate
setti ngs. The fi rst (l eft) bar i s set at the del ay ti me whi l e the second
(r i ght) bar i s set at the gate l ength, measured fr om the fi r st bar. The
tr ace of the si gnal i n thi s ti me-domai n vi ew i s the RF envel ope. The
gate si gnal i s tri gger ed off of the posi ti ve edge of the tri gger si gnal .
When posi ti oni ng the gate, a good star ti ng poi nt i s to have i t extend
fr om 20% to 80% of the way through the pul se (for the PSA wi th
l i near-phase RBW fi l ters).
Whi l e gate vi ew mode i s on, move the gate del ay, l ength and pol ari ty
around. Noti ce the changes i n the verti cal gate bars whi l e maki ng your
changes. Set the gate del ay, l ength and pol ar i ty back to the step 3
setti ngs.
NOTE The PSA ti me gate tr i ggeri ng mode uses posi ti ve and negati ve edge
tr i gger i ng. Level tr i ggeri ng i s not avai l abl e.
Step 5. Turn the gate vi ew off and enabl e the gate setti ngs (see the ri ght-si de
di spl ay i n Fi gur e 8-4):
Press Sweep, Gate Setup, Gate View (Off).
Press Sweep, Gate (On).
Figure 8-4 Pulsed-RF FM Signal (Left), Gated FM Signal (Right)
Step 6. Turn off the pul se modul ati on on ESG #1 by pressi ng Pulse, Pulse so
that Off i s sel ected.
Noti ce that the gated spectr um i s much cl eaner than the ungated
spectrum (as seen i n Fi gur e 8-4). The spectrum you see wi th the gate on
i s the same as a frequency modul ated si gnal wi thout bei ng pul sed. The
di spl ayed spectrum does not change and i n both cases, you can see the
two l ow-l evel modul ati on si debands caused by the narr ow-band FM.
64 Chapter 8
Making Time-Gated Measurements
Gated Video Measurement (ESA)
M
a
k
i
n
g

T
i
m
e
-
G
a
t
e
d

M
e
a
s
u
r
e
m
e
n
t
s
Gated Video Measurement (ESA)
Thi s procedure uti l i zes gated vi deo to gate the FM si gnal . For concept
and theory i nformati on about gated vi deo see How Ti me Gati ng
Wor ks on page 135.
Step 1. Set the ESA center frequency, span and reference l evel :
Press FREQUENCY Channel, Center Freq, 40, MHz.
Press SPAN X Scale, Span, 500, kHz.
Press AMPLITUDE Y Scale, Ref Level, 0, dBm.
Step 2. Set anal yzer sweep ti me to 2005 ms:
Press Sweep, Sweep Time, 2005, ms.
For gated vi deo, the cal cul ated sweep ti me shoul d be set to at l east
to ensure that the gate i s on at l east
once duri ng each of the 401 sweep poi nts. I n thi s exampl e, the PRI i s
5 ms, so you shoul d set the sweep ti me to 401 ti mes 5 ms, or 2005 ms. I f
the sweep ti me i s set too fast, some tr ace poi nts may show val ues of
zero power or other i ncorrect l ow readi ngs. I f the trace seems
i ncompl ete or er rati c, tr y a l onger sweep ti me.
NOTE Good practices for determining the minimum sweep time for
gated video:
I n the event that the si gnal i s not noi sy, the sweep ti me can be set to
l ess than (as cal cul ated above).
I nstead of usi ng PRI i n the pr evi ous sweep ti me cal cul ati on, we can use
the gate off ti me where sweep ti me equal s . I n
our exampl e we coul d use a sweep ti me of 401 poi nts ti mes 4 ms or
1.604 s. I ncr ease the wi dth of vi deo bandwi dth to i mpr ove the
pr obabi l i ty of capturi ng the pul se usi ng gate off ti me. I f tr ace poi nts
are sti l l showi ng val ues of zero power, i ncrease the sweep ti me by smal l
i ncr ements unti l there are no more dropouts.
Figure 8-5 Viewing the Pulsed-RF FM Signal (without gating)
# sweep points PRI (pulse repetition interval )
# sweep points PRI (pulse repetition interval )
# sweep points gate off time
Chapter 8 65
Making Time-Gated Measurements
Gated Video Measurement (ESA)
M
a
k
i
n
g

T
i
m
e
-
G
a
t
e
d

M
e
a
s
u
r
e
m
e
n
t
s
Step 3. Set the gate del ay to 2 ms and the gate l ength to 1 ms. Check that the
gate control i s set to edge wi th a posi ti ve tr i gger :
Press Sweep, Gate, Gate Control (Edge).
Press Edge Gate, Slope (Pos).
Press Gate Delay, 2, ms.
Press Gate Length, 1, ms.
Step 4. Turn the gate on:
Press Sweep, Gate, Gate (On).
Figure 8-6 Viewing the FM Signal of a Pulsed RF Signal using Gated Video
Step 5. Noti ce that the gated spectr um i s much cl eaner than the ungated
spectrum (as seen i n Fi gur e 8-5). The spectrum you see i s the same as a
fr equency modul ated si gnal wi thout bei ng pul sed. To pr ove thi s, turn
off the pul se modul ati on on ESG #1 by pressi ng Pulse, Pulse so that Off
i s sel ected. The di spl ayed spectr um does not change.
Step 6. Check the osci l l oscope di spl ay and ensure that the gate i s posi ti oned
under the pul se. The gate shoul d be set so that i t i s on somewher e
between 25% to 80% of the pul se. I f necessary, adjust gate l ength and
gate del ay. Fi gure 8-7 shows the osci l l oscope di spl ay when the gate i s
posi ti oned corr ectl y (the bottom tr ace).
Figure 8-7 The Oscilloscope Display
66 Chapter 8
Making Time-Gated Measurements
Gated FFT Measurement (PSA)
M
a
k
i
n
g

T
i
m
e
-
G
a
t
e
d

M
e
a
s
u
r
e
m
e
n
t
s
Gated FFT Measurement (PSA)
Thi s procedure uti l i zes gated FFT to gate the FM si gnal . For concept
and theory i nformati on about gated FFT see How Ti me Gati ng Works
on page 135.
Step 1. Set the PSA center frequency, span and reference l evel :
Press FREQUENCY Channel, Center Freq, 40, MHz.
Press SPAN X Scale, Span, 500, kHz.
Press AMPLITUDE Y Scale, Ref Level, 15, dBm.
Step 2. Set the tri gger to the external rear tr i gger i nput:
Press Trig, Ext Rear.
Step 3. Sel ect the mi ni mum resol uti on bandwi dth requi red:
Press BW/Avg, Res BW (Auto).
The durati on of the anal ysi s requi red i s determi ned by the RBW. Di vi de
1.83 (al ways constant) by 4 ms to cal cul ate the mi ni mum RBW. The
pul se wi dth i n our case i s 4 ms so we need a mi ni mum RBW of 458 Hz.
I n thi s case because the RBW i s so narrow l et the anal yzer choose the
RBW for the current anal yzer setti ngs (span). Check that the RBW i s
gr eater than 458 Hz.
Wi th the above PSA setti ngs, the RBW shoul d be 4.7 kHz. Note that the
measurement speed i s faster than the gated LO exampl e. Typi cal l y
gated FFT i s faster than gated LO for spans l ess than 10 MHz.
Vary the RBW setti ngs and note the si gnal changes shape as the RBW
tr ansi ti ons from 1 kHz to 300 Hz.
Figure 8-8 Viewing the Gated FFT Measurement Results from the PSA
NOTE I f the tri gger event needs to be del ayed use the Trig Delay functi on under
the Trig menu. I t i s r ecommended to appl y some smal l amount of tri gger
del ay to al l ow ti me for the pul se modul ator to settl e.
67
M
e
a
s
u
r
i
n
g

D
i
g
i
t
a
l

C
o
m
m
u
n
i
c
a
t
i
o
n
s

S
i
g
n
a
l
s
9 Measuring Digital
Communications Signals
68 Chapter 9
Measuring Digital Communications Signals
Making Burst Power Measurements
M
e
a
s
u
r
i
n
g

D
i
g
i
t
a
l

C
o
m
m
u
n
i
c
a
t
i
o
n
s

S
i
g
n
a
l
s
Making Burst Power Measurements
PSA and ESA spectr um anal yzer s make power measur ements on
di gi tal communi cati on si gnal s fast and repeatabl e by provi di ng a
comprehensi ve sui te of power-based one-button automated
measurements wi th pre-set standards-based format setups. The
automated measurements al so i ncl ude pass/fai l functi onal i ty that al l ow
the user to qui ckl y check i f the si gnal passed the measur ement.
NOTE ESA spectr um anal yzer sweep ti mes: I n zero-span, ESA can sweep as
fast as 10 s wi th 2 poi nts di spl ayed. For 101 poi nts, the mi ni mum
sweep ti me i s 1 ms. Opti on AYX or B7D i s recommended when faster
sweep ti mes ar e r equi r ed.
The fol l owi ng exampl e demonstrates how to make a burst power
measurement on a Bl uetooth si gnal broadcasti ng at 2.402 GHz.
Step 1. Usi ng an ESG, setup a Bl uetooth si gnal transmi tti ng DH1 packets
conti nuousl y at 2.402 GHz and 10 dBm and connect the RF OUTPUT
to the spectr um anal yzer RF I NPUT.
Step 2. Preset the anal yzer, set the anal yzer center fr equency to 2.402 GHz:
Press Preset, Factory Preset (i f pr esent).
Press FREQUENCY Channel, Center Freq, 2.402, GHz.
Step 3. Set the anal yzer radi o mode to Bl uetooth and check to make sur e
packet type DH1 i s sel ected:
Press Mode Setup, Radio Std, More, Bluetooth.
Press Mode Setup, Radio Std Setup, Packet Type (DH1).
Step 4. Sel ect the burst power one-button measurement from the measure
menu and opti mi ze the reference l evel :
Press MEASURE, More, Burst Power.
Press Meas Setup, Optimize Ref Level.
Step 5. Vi ew the resul ts of the burst power measurement usi ng the ful l screen
(See Fi gur e 9-1):
Press Display, Full Screen.
Chapter 9 69
Measuring Digital Communications Signals
Making Burst Power Measurements
M
e
a
s
u
r
i
n
g

D
i
g
i
t
a
l

C
o
m
m
u
n
i
c
a
t
i
o
n
s

S
i
g
n
a
l
s
Figure9-1 Full Screen Display of Burst Power Measurement Results
NOTE Press the Return key to exi t the ful l scr een di spl ay wi thout changi ng
any parameter val ues.
Step 6. Sel ect one of the fol l owi ng three tri gger methods to capture the bursted
si gnal (RF burst i s recommended, i f avai l abl e):
Press Trig, RF Burst.
For mor e i nformati on on tr i gger sel ecti ons see Tri gger Concepts on
page 153.
NOTE Al though the tri gger l evel al l ows the anal yzer to detect the pr esence of
a burst, the ti me sampl es contri buti ng to the burst power measurement
are determi ned by the threshol d l evel , as descri bed next.
Step 7. Set the r el ati ve threshol d l evel above whi ch the bur st power
measurement i s cal cul ated:
Press Meas Setup, Threshold Lvl (Rel ), 10, dB.
The burst power measurement i ncl udes al l poi nts above the threshol d
and no poi nts bel ow. The threshol d l evel i s i ndi cated on the di spl ay by
the green hori zontal l i ne (for vi deo tri ggeri ng i t i s the upper l i ne). I n
thi s exampl e, the threshol d l evel has been set to be 10 dB bel ow the
rel ati ve l evel of the burst. The mean power of the burst i s measured
fr om al l data above the threshol d l evel .
Step 8. Set the burst wi dth to measure the central 200 s of the burst:
Press Meas Setup, Meas Method, Measured Burst Width, Burst Width
(Man), 200, s.
The burst wi dth i s i ndi cated on the screen by two verti cal whi te l i nes.
Manual l y setti ng the burst wi dth al l ows you to make i t a l ong ti me
i nterval (to i ncl ude the ri si ng and fal l i ng edges of the burst) or to make
i t a short ti me i nterval , measuri ng a smal l central secti on of the burst.
70 Chapter 9
Measuring Digital Communications Signals
Making Burst Power Measurements
M
e
a
s
u
r
i
n
g

D
i
g
i
t
a
l

C
o
m
m
u
n
i
c
a
t
i
o
n
s

S
i
g
n
a
l
s
NOTE I f you set the bur st wi dth manual l y to be wi der than the screens
di spl ay, the verti cal whi te l i nes move off the edges of the screen. Thi s
coul d gi ve mi sl eadi ng resul ts as onl y the data on the screen can be
measur ed.
NOTE The Bl uetooth standard states that power measurements shoul d be
taken over at l east 20% to 80% of the dur ati on of the bur st.
Step 9. I ncrease the sweep ti me to di spl ay more than one burst at a ti me:
Press Sweep, Sweep Time, 6200, s (or 6.2, ms).
The scr een di spl ay shows several bur sts i n a si ngl e sweep as i n
Fi gur e 9-2. The burst power measurement measures the mean power of
the fi rst burst, i ndi cated by the verti cal whi te l i nes.
Figure9-2 Setting Burst Width (Left) Displaying Multiple Bursts (Right)
NOTE Al though the bur st power measur ement sti l l runs corr ectl y when
sever al bur sts ar e di spl ayed si mul taneousl y, the ti mi ng accur acy of the
measurement i s degraded. For the best resul ts (i ncl udi ng the best
tr ade-off between measurement vari ati ons and averagi ng ti me), i t i s
recommended that the measurement be performed on a si ngl e burst.
Chapter 9 71
Measuring Digital Communications Signals
Making Statistical Power Measurements (CCDF)
M
e
a
s
u
r
i
n
g

D
i
g
i
t
a
l

C
o
m
m
u
n
i
c
a
t
i
o
n
s

S
i
g
n
a
l
s
Making Statistical Power Measurements
(CCDF)
NOTE CCDF can be measured wi th ESA-E seri es anal yzers wi th opti on AYX
or B7D and wi th al l PSA seri es anal yzers.
Compl ementary cumul ati ve di stri buti on functi on (CCDF) curves
characteri ze a si gnal by provi di ng i nformati on about how much ti me
the si gnal spends at or above a gi ven power l evel . The CCDF
measurement shows the percentage of ti me a si gnal spends at a
parti cul ar power l evel . Percentage i s on the verti cal axi s and power (i n
dB) i s on the hori zontal axi s.
Al l CDMA si gnal s, and W-CDMA si gnal s i n parti cul ar, are
characteri zed by hi gh power peaks that occur i nfr equentl y. I t i s
i mpor tant that these peaks ar e preser ved other wi se separ ate data
channel s can not be recei ved pr operl y. Too many peak si gnal s can al so
cause spectr al regr owth. I f a CDMA system wor ks wel l most of the ti me
and onl y fai l s occasi onal l y, thi s can often be caused by compressi on of
the hi gher peak si gnal s.
The fol l owi ng exampl e shows how to make a CCDF measurement on a
W-CDMA si gnal broadcasti ng at 1.96 GHz.
Step 1. Usi ng an ESG, setup a W-CDMA si gnal transmi tti ng at 1.96 GHz and
10 dBm. Connect the RF OUTPUT to the spectrum anal yzer RF
I NPUT.
Step 2. Preset the anal yzer and set the center fr equency to 1.96 GHz:
Press Preset, Factory Preset (i f pr esent).
Press FREQUENCY Channel, Center Freq, 1.96, GHz.
Step 3. Set the anal yzer radi o mode to 3GPP W-CDMA as a base stati on devi ce:
Press Mode Setup, Radio Std, 3GPP W-CDMA.
Press Mode Setup, Radio Std Setup, Device (BTS).
Step 4. Sel ect the CCDF one-button measurement fr om the measure menu and
then opti mi ze the refer ence l evel and attenuati on setti ngs sui tabl e for
the CCDF measurement:
Press MEASURE, Power Stat CCDF.
Press Meas Setup, Optimize Ref Level.
72 Chapter 9
Measuring Digital Communications Signals
Making Statistical Power Measurements (CCDF)
M
e
a
s
u
r
i
n
g

D
i
g
i
t
a
l

C
o
m
m
u
n
i
c
a
t
i
o
n
s

S
i
g
n
a
l
s
Figure9-3 Power Stat CCDF Measurement on a W-CDMA Signal
Step 5. Stor e your cur r ent measurement tr ace for futur e refer ence:
Press Display, Store Ref Trace.
When the power stat CCDF measurement i s fi rst made, the gr aphi cal
di spl ay shoul d show a si gnal typi cal of pure noi se. Thi s i s l abel l ed
Gaussi an, and i s shown i n aqua. Your CCDF measurement i s di spl ayed
as a yel l ow pl ot. You have stored thi s measurements pl ot to make for
easy compari son wi th subsequent measurements.
Step 6. Di spl ay the stored trace:
Press Display, Ref Trace (On).
The stored trace from your l ast measur ement i s di spl ayed as a magenta
pl ot (as shown i n Fi gur e 9-4), and al l ows di rect compari son wi th your
cur r ent measur ement.
Figure9-4 Storing and Displaying a Power Stat CCDF Measurement
Chapter 9 73
Measuring Digital Communications Signals
Making Statistical Power Measurements (CCDF)
M
e
a
s
u
r
i
n
g

D
i
g
i
t
a
l

C
o
m
m
u
n
i
c
a
t
i
o
n
s

S
i
g
n
a
l
s
Step 7. Change the measurement bandwi dth to 1 MHz:
Press Meas Setup, Meas BW, 1, MHz.
Figure9-5 Reducing the measurement bandwidth to 1 MHz
NOTE I f you choose a measurement bandwi dth setti ng that the anal yzer
cannot di spl ay, i t automati cal l y sets i tsel f to the cl osest avai l abl e
bandwi dth setti ng.
Step 8. Change the number of measured poi nts from 100,000 (100k) to 1,000
(1k):
Press Meas Setup, Counts, 1, kpoints.
Reduci ng the number of poi nts decr eases the measurement ti me,
however the number of poi nts i s a factor i n determi ni ng measurement
uncertai nty and repeatabi l i ty. Noti ce how the di spl ayed pl ot l oses a l ot
of i ts smoothness. You are gai ni ng speed but reduci ng repeatabi l i ty and
i ncr easi ng measurement uncertai nty.
NOTE The number of poi nts col l ected per sweep i s dependent on the sampl i ng
rate and the measurement i nterval . The number of sampl es that have
been processed are i ndi cated at the top of the screen. The graphi cal pl ot
i s conti nuousl y updated so you can see i t getti ng smoother as
measurement uncertai nty i s reduced and repeatabi l i ty i mproves.
Step 9. Change the scal i ng of the X-axi s to 1 dB per di vi si on to opti mi ze your
parti cul ar measurement:
Press SPAN X Scale, Scale/Div, 1, dB.
74 Chapter 9
Measuring Digital Communications Signals
Making Adjacent Channel Power (ACP) Measurements
M
e
a
s
u
r
i
n
g

D
i
g
i
t
a
l

C
o
m
m
u
n
i
c
a
t
i
o
n
s

S
i
g
n
a
l
s
Making Adjacent Channel Power (ACP)
Measurements
The adjacent channel power (ACP) measur ement i s al so r eferr ed to as
the adjacent channel power rati o (ACPR) and adjacent channel l eakage
rati o (ACLR). We use the term ACP to refer to thi s measurement.
ACP measures the total power (r ms vol tage) i n the speci fi ed channel
and up to si x pai rs of offset fr equenci es. The measurement resul t
reports the rati os of the offset powers to the mai n channel power.
The fol l owi ng exampl e shows how to make an ACP measurement on a
W-CDMA base stati on si gnal broadcasti ng at 1.96 GHz.
Step 1. Usi ng an ESG, setup a W-CDMA si gnal transmi tti ng at 1.96 GHz and
10 dBm. Connect the RF OUTPUT to the spectrum anal yzer RF
I NPUT.
Step 2. Preset the anal yzer, set the anal yzer center fr equency to 1.96 GHz.
Press Preset, Factory Preset (i f pr esent).
Press FREQUENCY Channel, Center Freq, 1.96, GHz.
Step 3. Set the anal yzer radi o mode to 3GPP W-CDMA as a base stati on devi ce:
Press Mode Setup, Radio Std, 3GPP W-CDMA.
Press Mode Setup, Radio Std Setup, Device (BTS).
Step 4. Sel ect the adjacent channel power one-button measurement fr om the
measure menu and then opti mi ze the reference l evel and attenuati on
setti ngs sui tabl e for the ACP measurement (see Fi gure 9-6):
Press MEASURE, ACP.
Press Meas Setup, Optimize Ref Level.
NOTE Optimize Ref Level protects agai nst i nput si gnal over l oads, but does not
necessari l y set the i nput attenuati on and r eference l evel for opti mum
measur ement dynami c range.
To i mprove the measurement repeatabi l i ty, i ncrease the sweep ti me to
smooth out the tr ace (aver age detector must be sel ected). Measur ement
repeatabi l i ty can be tr aded off wi th sweep ti me.
To i ncrease dynami c range, Noise Correction can be used to factor out
the added power of the noi se fl oor effects. Noi se corr ecti on i s very useful
when measuri ng si gnal s near the noi se fl oor of the anal yzer.
Chapter 9 75
Measuring Digital Communications Signals
Making Adjacent Channel Power (ACP) Measurements
M
e
a
s
u
r
i
n
g

D
i
g
i
t
a
l

C
o
m
m
u
n
i
c
a
t
i
o
n
s

S
i
g
n
a
l
s
Figure9-6 ACP Measurement on a Base Station W-CDMA Signal
The frequency offsets, channel i ntegrati on bandwi dths, and span
setti ngs can al l be modi fi ed fr om the defaul t setti ngs sel ected by the
radi o standar d.
Two verti cal whi te l i nes i ndi cate the bandwi dth l i mi ts of the central
channel bei ng measured.
Offsets A and B are desi gnated by the adjacent pai rs of red and yel l ow
l i nes, i n thi s case: 5 MHz and 10 MHz from the center fr equency
respecti vel y.
Step 5. Sel ect the combi ned spectrum and bar graph vi ew of the resul ts:
(ESA) Pr ess View/Trace, Combined.
(PSA) Pr ess Trace/View, Combined.
Step 6. Vi ew the resul ts usi ng the ful l screen:
Press Display, Full Screen.
NOTE Press the Return key to exi t the ful l scr een di spl ay wi thout changi ng
any parameter val ues.
Step 7. Defi ne a new thi r d pai r of offset frequenci es:
Press Meas Setup, Offset/Limits, Offset (C), Offset Freq (On), 15, MHz.
Thi s thi rd pai r of offset fr equenci es i s offset by 15.0 MHz from the
center frequency (the outsi de offset pai r) as shown i n Fi gur e 9-7. Three
further pai rs of offset fr equenci es (D, E and F) are al so avai l abl e.
76 Chapter 9
Measuring Digital Communications Signals
Making Adjacent Channel Power (ACP) Measurements
M
e
a
s
u
r
i
n
g

D
i
g
i
t
a
l

C
o
m
m
u
n
i
c
a
t
i
o
n
s

S
i
g
n
a
l
s
Figure9-7 Measuring a Third Adjacent Channel
Step 8. Set pass/fai l l i mi ts for each offset:
Press Meas Setup, Offset/Limits, Offset (A), Neg Offset Limit, 55, dB, Pos
Offset Limit, 55, dB, Offset (B), Neg Offset Limit, 65, dB, Pos Offset Limit,
65, dB, Offset (C), Neg Offset Limit, 65, dB, Pos Offset Limit, 65, dB.
Step 9. Turn the l i mi t test on:
Press Meas Setup, More, Limit Test (On).
I n Fi gure 9-8 noti ce that offset A has passed, however offsets B and C
have fai l ed. Power l evel s that fal l bel ow our speci fi ed 65 dB for offsets
B and C, fai l . Fai l ures are i denti fi ed by the red l etter F next to the
l evel s (dBc and dBm) l i sted i n the l ower porti on of the wi ndow cal l ed,
RMS Resul ts. The offset bar graph i s al so shaded red to i denti fy a
fai l ure.
Figure9-8 Setting Offset Limits
NOTE You may i ncrease the repeatabi l i ty by i ncr easi ng the sweep ti me.
Chapter 9 77
Measuring Digital Communications Signals
Making Multi-Carrier Power (MCP) Measurements
M
e
a
s
u
r
i
n
g

D
i
g
i
t
a
l

C
o
m
m
u
n
i
c
a
t
i
o
n
s

S
i
g
n
a
l
s
Making Multi-Carrier Power (MCP)
Measurements
The mul ti -carr i er power measurement measures the total power of up
to 12 car r i er s and thei r adjacent channel s for up to three pai rs of offset
fr equenci es. The offset fr equency pr operti es can be modi fi ed, i ncl udi ng
the offset fr equency, the i ntegrati on bandwi dth and upper/l ower l i mi ts.
The carr i er par ameter s can al so be modi fi ed i ncl udi ng car ri er wi dth,
carri er i ntegr ati on bandwi dth and whether the carr i er i s on or off. MCP
can be setup wi th no r adi o standar d sel ected or wi th radi o standar d
setti ngs for I S-95 and W-CDMA. Resul ts for car r i er s wi thout power
pr esent ar e di spl ayed r el ati ve to the refer ence car ri er. Resul ts for
adjacent channel s are di spl ayed i n absol ute power (dBm).
The fol l owi ng exampl e shows how to make an MCP measurement on a
W-CDMA base stati on broadcasti ng wi th 8 carri ers on and wi th two
carri er s off. The transmi tti ng carri er s are spaced at 5 MHz i nterval s at
the fol l owi ng fr equenci es: 977.5 MHz, 982.5 MHz, 987.5 MHz,
992.5 MHz, 1.0075 GHz, 1.0125 GHz, 1.0175 GHz and 1.0225 GHz.
NOTE Recommended equipment: The Agi l ent ESG si gnal generators can
be used to transmi t W-CDMA mul ti -carri er si gnal s of up to 4 carri ers.
The mul ti -carr i er si gnal parameters can be modi fi ed i ncl udi ng channel
setup, frequency offset and car r i er power. An al ter nati ve way to setup
mul ti pl e carr i ers i s to use mul ti pl e ESGs, each transmi tti ng one
W-CDMA si gnal .
Step 1. Connect a W-CDMA si gnal wi th mul ti pl e carri ers broadcasti ng at the
fr equenci es stated above.
Step 2. Set the center fr equency of the anal yzer to the mi dpoi nt of al l the
carri er s:
Press Preset, Factory Preset (i f pr esent).
Press FREQUENCY Channel, Center Freq, 1, GHz.
Step 3. Set the anal yzer radi o mode to 3GPP W-CDMA as a base stati on devi ce:
Press Mode Setup, Radio Std, 3GPP W-CDMA.
Press Mode Setup, Radio Std Setup, Device (BTS).
Step 4. Sel ect the mul ti -carri er power one-button measurement fr om the
measure menu and then opti mi ze the reference l evel and attenuati on
setti ngs sui tabl e for the MCP measurement:
Press MEASURE, Multi Carrier Power.
Press Meas Setup, Optimize Ref Level.
Step 5. Set the carr i er number to 10 (i n our mul ti -carri er setup we have 8
carri er s wi thout 2 mi ddl e carr i ers):
78 Chapter 9
Measuring Digital Communications Signals
Making Multi-Carrier Power (MCP) Measurements
M
e
a
s
u
r
i
n
g

D
i
g
i
t
a
l

C
o
m
m
u
n
i
c
a
t
i
o
n
s

S
i
g
n
a
l
s
Press Meas Setup, Carrier Setup, Carriers, 10, Enter.
Step 6. Confi gure carr i er 5 to have no power pr esent:
Press Meas Setup, Carrier Setup, Configure Carriers, Carrier, 5, Enter,
Carrier Pwr Present (No).
Step 7. Repeat step 6, confi guri ng carri er 6 to have no power present.
Step 8. Di spl ay the resul ts i n ful l screen vi ew (see Fi gur e 9-9):
Press Display, Full Screen.
Figure9-9 MCP Measurement on a Base Station W-CDMA Signal
I n thi s exampl e, the i ntermodul ati on fal l s outsi de the transmi t
channel s whi ch are marked by the col ored verti cal l i nes. The whi te set
i ndi cates the refer ence car ri er. The red sets contai n the car ri er s wi th
power present and the bl ue l i nes mark the car r i er s wi thout power
pr esent. Li mi ts for the upper and l ower offsets can al so be set as shown
i n the exampl e: Maki ng Adjacent Channel Power (ACP)
Measurements on page 74.
NOTE Press the Return key to exi t the ful l scr een di spl ay wi thout changi ng
any parameter val ues.
Step 9. Vi ew the resul ts tabl e of carri ers 7-10:
Press Meas Setup, Carrier Result, 7, Enter.
Step 10. Vi ew the resul ts i n a combi ned spectr um and bar graph (see
Fi gure 9-10):
(ESA) Pr ess View/Trace, Combined.
(PSA) Pr ess Trace/View, Combined.
Chapter 9 79
Measuring Digital Communications Signals
Making Multi-Carrier Power (MCP) Measurements
M
e
a
s
u
r
i
n
g

D
i
g
i
t
a
l

C
o
m
m
u
n
i
c
a
t
i
o
n
s

S
i
g
n
a
l
s
Figure9-10 Combined Spectrum and Bar Graph View
Step 11. Save the resul ts fi l e to a di sk.
Press File, Save, Type, More, Measurement Results, Save Now.
The resul ts ar e stored i n a comma separated val ues format to be vi ewed
by any personal computer spreadsheet appl i cati on. Al l data shown on
the di spl ay i s i ncl uded i n thi s fi l e.
80 Chapter 9
Measuring Digital Communications Signals
Making Multi-Carrier Power (MCP) Measurements
M
e
a
s
u
r
i
n
g

D
i
g
i
t
a
l

C
o
m
m
u
n
i
c
a
t
i
o
n
s

S
i
g
n
a
l
s
81
U
s
i
n
g

E
x
t
e
r
n
a
l

M
i
l
l
i
m
e
t
e
r

M
i
x
e
r
s

(
O
p
t
i
o
n

A
Y
Z
)
10 Using External Millimeter
Mixers (Option AYZ)
82 Chapter 10
Using External Millimeter Mixers (Option AYZ)
Making Measurements With Agilent 11970 Series Harmonic Mixers
U
s
i
n
g

E
x
t
e
r
n
a
l

M
i
l
l
i
m
e
t
e
r

M
i
x
e
r
s

(
O
p
t
i
o
n

A
Y
Z
)
Making Measurements With Agilent 11970
Series Harmonic Mixers
External harmoni c mi xers can be used to extend the fr equency range of
the E4407B, E4440A, E4446A and E4448A spectrum anal yzers. Agi l ent
Technol ogi es manufactur es external mi xers that do not requi re bi asi ng
and cover frequency ranges from 18 GHz to 110 GHz. For fr equency
ranges from 110 GHz up to 325 GHz, other mi xers are avai l abl e fr om
other manufacturers (these mi xers may requi re bi asi ng). The Agi l ent
Technol ogi es E4407B, E4440A, E4446A, and E4448A spectr um
anal yzer s support harmoni c mi xers and pr esel ected harmoni c mi xers.
When usi ng harmoni c mi xers, mul ti pl e mi xi ng pr oducts ar e shown on
the anal yzer di spl ay. The output of a harmoni c mi xer contai ns the sum
and di fference fr equenci es of the i nput si gnal wi th the LO and al l of i ts
harmoni cs. To di spl ay the cor rect si gnal , si gnal i denti fi cati on can be
used to remove al l undesi red mi xi ng products. Once the corr ect si gnal i s
i denti fi ed, si gnal i denti fi cati on must be turned off to measure the
ampl i tude accuratel y.
Step 1. Connect the si gnal source and harmoni c mi xer to the anal yzer as shown
i n Fi gure 10-1.
Figure10-1 Instrument Connections with a 11970 Series Harmonic Mixer
CAUTION The anal yzer l ocal osci l l ator output power i s approxi matel y +16 dBm.
Be sure that your external har moni c mi xer can accommodate the power
l evel before connecti ng i t to the anal yzer.
NOTE Agi l ent 5061-5458 SMA type cabl es shoul d be used to connect the mi xer
I F and LO ports to the anal yzer. Do not over-ti ghten the cabl es. The
maxi mum torque shoul d not exceed 112 N-cm (10 i n-l b.)
Chapter 10 83
Using External Millimeter Mixers (Option AYZ)
Making Measurements With Agilent 11970 Series Harmonic Mixers
U
s
i
n
g

E
x
t
e
r
n
a
l

M
i
l
l
i
m
e
t
e
r

M
i
x
e
r
s

(
O
p
t
i
o
n

A
Y
Z
)
Step 2. Per for m a factor y pr eset:
Press Preset, Factory Preset (i f pr esent).
Step 3. Set up a hi gh fr equency si gnal on a mi crowave si gnal generator (no
modul ati on requi red). Set the fr equency to 35 GHz and the ampl i tude
to 0 dBm.
Step 4. Sel ect external mi xi ng, and then sel ect band A (from 26.5 to 40 GHz):
Press Input/Output, Input Mixer, Input Mixer (Ext).
Press Ext Mix Band, 26.540 GHz (A).
The I F output of a harmoni c mi xer contai ns a si gnal at the
i ntermedi ate fr equency of the anal yzer whenever the harmoni c
fr equency of the LO and the frequency of the RF di ffer by the
i ntermedi ate fr equency. As a resul t, wi thi n a si ngl e harmoni c band, a
si ngl e i nput si gnal can produce mul ti pl e responses on the anal yzer
di spl ay, onl y one of whi ch i s val i d (see the l eft di spl ay i n Fi gure 10-2).
These responses come i n pai rs, where members of the val i d response
pai r are separated by 642.8 MHz and ei ther the ri ght-most (for negati ve
harmoni cs) or l eft-most (for posi ti ve harmoni cs) member of the pai r i s
the cor rect response.
Step 5. Turn on the si gnal i denti fi cati on feature to show the real si gnal
response at 35 GHz (by defaul t, the type of si gnal i denti fi cati on i s
I mage Suppress):
Press Input/Output, Input Mixer, Signal ID (On).
Step 6. Pl ace a marker on the real si gnal and turn off si gnal i denti fi cati on
before maki ng the fi nal ampl i tude measurement:
Press Peak Search.
Press Signal Ident (Off).
Figure10-2 Signal Identification (Left - Signal Id Off; Right - Signal Id On)
84 Chapter 10
Using External Millimeter Mixers (Option AYZ)
Setting Harmonic Mixer Bias Current
U
s
i
n
g

E
x
t
e
r
n
a
l

M
i
l
l
i
m
e
t
e
r

M
i
x
e
r
s

(
O
p
t
i
o
n

A
Y
Z
)
Setting Harmonic Mixer Bias Current
The Agi l ent 11970 Seri es harmoni c mi xers do not requi re an external
bi as current. Harmoni c mi xers that requi re bi as can al so be used. The
conversi on l oss cal i brati on data for mi xers requi ri ng an external bi as
cur r ent ar e most accur ate when the cor rect bi as condi ti ons ar e appl i ed.
Step 1. Before conti nui ng, compl ete the pr evi ous procedure Maki ng
Measurements Wi th Agi l ent 11970 Seri es Harmoni c Mi xers on page 82
to set up the anal yzer for exter nal mi xi ng i n the band of i nter est.
Step 2. Acti vate the bi as:
Press Input/Output, Input Mixer, Mixer Config, Mixer Bias (On)
A +I or I appears i n the di spl ay annotati on i ndi cati ng bi as i s on.
Step 3. Enter the desi red bi as cur r ent i n mA.
The mi xer bi as i s suppl i ed from the IF INPUT port of the anal yzer.
CAUTION The open-ci rcui t bi as vol tage can be as great as 3.5 V through a source
resi stance of 500 ohms. Such vol tage l evel s may appear when recal l i ng
an i nstrument state i n whi ch a bi as setti ng has been stored.
NOTE The bi as val ue that appears on the anal yzer di spl ay i s expressed i n
terms of short-ci rcui t current (that i s, the current that woul d fl ow i f the
IF INPUT were shorted to gr ound). The actual current fl owi ng i nto the
mi xer i s l ess.
Chapter 10 85
Using External Millimeter Mixers (Option AYZ)
Entering Conversion-Loss Correction Data for Harmonic Mixers
U
s
i
n
g

E
x
t
e
r
n
a
l

M
i
l
l
i
m
e
t
e
r

M
i
x
e
r
s

(
O
p
t
i
o
n

A
Y
Z
)
Entering Conversion-Loss Correction Data for
Harmonic Mixers
You may want to correct your measurement for the conver si on-l oss of
the exter nal harmoni c mi xer that you ar e usi ng. The ampl i tude
correcti on feature can be used for thi s.
Step 1. Access the correcti on factor tabl es for edi ti ng:
Press AMPLITUDE Y Scale, More, Corrections, Other.
You must enter a set of ampl i tude correcti on val ues for the desi red
fr equency range. Sel ect a corr ecti on set for use wi th external mi xi ng.
The r ecommended cor recti on set i s Other.
Step 2. Edi t the conver si on l oss data for the mi xer i n use. For Agi l ent 11970
Seri es harmoni c mi xers and Agi l ent 11974 Seri es pr esel ected harmoni c
mi xers, these val ues are l i sted on the mi xer:
Press Edit.
The data consi sts of fr equency/ampl i tude pai rs. You can enter a si ngl e
average val ue for corr ecti on over the enti re frequency band. Or you can
i mprove fr equency r esponse accur acy by enteri ng mul ti pl e cor r ecti on
poi nts acr oss the band. Up to 200 poi nts may be defi ned for each set.
Step 3. Once the desi r ed cor recti on poi nts ar e enter ed, you must tur n on the
correcti on functi on to i mprove di spl ay cal i brati on:
Press Return, Correction (On).
Veri fy that the cor recti on factor s have been appl i ed to the di spl ay data
poi nts by checki ng under the Corrections menu that Apply Corrections i s
set to Yes.
Once you have entered the cor r ecti on set, save the cor r ecti on set i n
i nter nal memor y or on fl oppy di sk for futur e r eference.
86 Chapter 10
Using External Millimeter Mixers (Option AYZ)
Making Measurements with Agilent 11974 Series Preselected Harmonic
Mixers
U
s
i
n
g

E
x
t
e
r
n
a
l

M
i
l
l
i
m
e
t
e
r

M
i
x
e
r
s

(
O
p
t
i
o
n

A
Y
Z
)
Making Measurements with Agilent 11974
Series Preselected Harmonic Mixers
Pr esel ected mi xer s appl y a tr acki ng fi l ter to the i nput si gnal before
sendi ng i t to the mi xer. Thi s makes the di spl ayed resul ts easi er to
understand because i t el i mi nates the mul ti pl e mi xi ng pr oducts that are
di spl ayed usi ng harmoni c mi xers (see Maki ng Measur ements Wi th
Agi l ent 11970 Seri es Harmoni c Mi xers on page 82).
Step 1. Connect the si gnal source and pr esel ected mi xer to the anal yzer as
shown i n Fi gure 10-3.
Figure10-3 Instrument Connections with a Preselected Harmonic Mixer
Step 2. Confi gur e the anal yzer for pr esel ected exter nal mi xi ng:
Press Input/Output, Input Mixer, Input Mixer (Ext), Mixer Config, Mixer Type
(Pr esel ).
Step 3. I f necessary, adjust the tr acki ng of the presel ected harmoni c mi xer
usi ng the procedure Fr equency Tracki ng Cal i brati on wi th Agi l ent
11974 Seri es Presel ected Harmoni c Mi xers on page 88.
Step 4. Sel ect the desi red mi xi ng band. I n thi s exampl e an Agi l ent 11974Q (33
to 50 GHz mi xer ) i s used:
Press Input/Output, Input Mixer, Ext Mix Band, 3350 GHz (Q).
Step 5. Set the mi cr owave source to a fr equency of 40 GHz and an ampl i tude of
15 dBm.
Step 6. Enter the conver si on-l oss data for the mi xer, to cal i br ate the ampl i tude
Chapter 10 87
Using External Millimeter Mixers (Option AYZ)
Making Measurements with Agilent 11974 Series Preselected Harmonic
Mixers
U
s
i
n
g

E
x
t
e
r
n
a
l

M
i
l
l
i
m
e
t
e
r

M
i
x
e
r
s

(
O
p
t
i
o
n

A
Y
Z
)
of the di spl ay. The conversi on-l oss versus frequency data i s on the
cal i brati on l abel on the bottom of the Agi l ent 11974, or on the suppl i ed
cal i br ati on sheet.
Use the pr ocedure Enteri ng Conver si on-Loss Corr ecti on Data for
Harmoni c Mi xers on page 85.
Step 7. To compl ete the ampl i tude cal i brati on pr ocess, the presel ector must be
adjusted at each frequency of i nterest. Before maki ng fi nal ampl i tude
measurements wi th the anal yzer, perfor m the fol l owi ng:
Press Peak Search.
Press SPAN X Scale, Span Zoom, 10, MHz.
Press AMPLITUDE Y Scale, Presel Center.
The fi nal ampl i tude measurement can now be read out wi th a marker.
See Fi gure 10-4.
Figure10-4 Amplitude Reading of the Preselected Response
88 Chapter 10
Using External Millimeter Mixers (Option AYZ)
Frequency Tracking Calibration with Agilent 11974 Series Preselected
Harmonic Mixers
U
s
i
n
g

E
x
t
e
r
n
a
l

M
i
l
l
i
m
e
t
e
r

M
i
x
e
r
s

(
O
p
t
i
o
n

A
Y
Z
)
Frequency Tracking Calibration with Agilent
11974 Series Preselected Harmonic Mixers
Thi s procedure i s used to al i gn the fr equency of the presel ector fi l ter of
the Agi l ent 11974 to the tuned frequency of the anal yzer. Thi s
pr ocedure shoul d be fol l owed any ti me that the Agi l ent 11974 i s
connected to a di fferent anal yzer. The cal i brati on shoul d be peri odi cal l y
checked.
Step 1. Connect the si gnal source and pr esel ected mi xer to the anal yzer as
shown i n Fi gure 10-3.
Step 2. Set the Agi l ent 11974 rear-panel swi tches Agi l ent 70907B and
LEDS to the ON posi ti on, and the other two swi tches to the OFF
posi ti on, i n or der for the Agi l ent 11974 to properl y scal e to the tune
si gnal of the anal yzer.
Step 3. Confi gur e the anal yzer for a presel ected exter nal mi xer :
Press Preset, Factory Preset (i f pr esent).
Press Input/Output, Input Mixer, Input Mixer (Ext), Mixer Config, Mixer Type
(Pr esel ).
Step 4. Set the desi red frequency band of oper ati on for your mi xer:
Press Input/Output, Input Mixer, Ext Mix Band, then sel ect external mi xi ng
band (bands A, Q, U or V).
Step 5. Set the presel ector adjustment to 0 MHz:
Press AMPLITUDE Y Scale, Presel Adjust, 0, MHz.
Step 6. Set the anal yzer to zero span:
Press SPAN X Scale, Zero Span.
Step 7. Set the center fr equency to the val ue i n Tabl e 10-1 for your mi xer:
Press FREQUENCY Channel, Center Freq, fr equency val ue.
On the rear panel of the Agi l ent 11974, adjust the correspondi ng
potenti ometer unti l one or both of the green LEDs are l i t.
Table 10-1 Start Frequency Preselector Adjustment
Mixer
Agilent P/N
Analyzer Center
Frequency
Potentiometer
11974A 26.5 GHz 26.5 GHz Adjust
11974Q 33.0 GHz 33.0 GHz Adjust
11974U 40.0 GHz 40.0 GHz Adjust
Chapter 10 89
Using External Millimeter Mixers (Option AYZ)
Frequency Tracking Calibration with Agilent 11974 Series Preselected
Harmonic Mixers
U
s
i
n
g

E
x
t
e
r
n
a
l

M
i
l
l
i
m
e
t
e
r

M
i
x
e
r
s

(
O
p
t
i
o
n

A
Y
Z
)
Step 8. Change the anal yzer center fr equency to the val ue i ndi cated i n
Tabl e 10-2 and agai n adjust the corr espondi ng potenti ometer on the
rear panel of the Agi l ent 11974 unti l one or both of the green LEDs are
l i t.
Step 9. Repeat steps 6 and 7 unti l the green LEDs are l i t at both frequenci es.
11974V 50.0 GHz 50.0 GHz Adjust
Table 10-2 Stop Frequency Preselector Adjustment
Mixer
Agilent P/N
Analyzer Center
Frequency
Potentiometer
11974A 40.0 GHz 40.0 GHz Adjust
11974Q 50.0 GHz 50.0 GHz Adjust
11974U 60.0 GHz 60.0 GHz Adjust
11974V 75.0 GHz 75.0 GHz Adjust
Table 10-1 Start Frequency Preselector Adjustment (Continued)
Mixer
Agilent P/N
Analyzer Center
Frequency
Potentiometer
90 Chapter 10
Using External Millimeter Mixers (Option AYZ)
Frequency Tracking Calibration with Agilent 11974 Series Preselected
Harmonic Mixers
U
s
i
n
g

E
x
t
e
r
n
a
l

M
i
l
l
i
m
e
t
e
r

M
i
x
e
r
s

(
O
p
t
i
o
n

A
Y
Z
)
91
D
e
m
o
d
u
l
a
t
i
n
g

A
M

a
n
d

F
M

S
i
g
n
a
l
s
11 Demodulating AM and FM
Signals
92 Chapter 11
Demodulating AM and FM Signals
Measuring the Modulation Rate of an AM Signal
D
e
m
o
d
u
l
a
t
i
n
g

A
M

a
n
d

F
M

S
i
g
n
a
l
s
Measuring the Modulation Rate of an AM
Signal
Thi s secti on demonstr ates how to deter mi ne parameters of an AM
si gnal , such as modul ati on r ate and modul ati on i ndex (depth) by usi ng
fr equency and ti me domai n measurements (see the concepts chapter
AM and FM Demodul ati on Concepts on page 157 for mor e
i nformati on). Usi ng the ESA bui l t-i n AM demodul ator, you can al so
tune-i n and l i sten to an AM si gnal (Demodul ati ng an AM Si gnal Usi ng
the ESA Seri es on page 96).
To obtai n an AM si gnal , you can ei ther connect a source transmi tti ng
an AM si gnal , or connect an antenna to the anal yzer i nput and tune to a
commerci al AM broadcast stati on. For thi s demonstr ati on an RF source
i s used to emul ate an AM si gnal .
Step 1. Connect an Agi l ent ESG RF si gnal source to the anal yzer I NPUT. Set
the ESG frequency to 300 MHz and the ampl i tude to 10 dBm. Set the
AM depth to 80%, the AM r ate to 1 kHz and tur n AM on.
Step 2. Pr eset the anal yzer and then set the center fr equency, span, RBW and
the sweep ti me:
Press Preset, Factory Preset (i f pr esent).
Press FREQUENCY Channel, Center Freq, 300, MHz.
Press SPAN X Scale, Span, 500, kHz.
Press BW/Avg, Res BW, 30, kHz.
Press Sweep, Sweep Time, 20, ms.
Step 3. Set the y-axi s uni ts to vol ts:
Press AMPLITUDE Y Scale, More, Y-Axis Units, Volts.
Step 4. Posi ti on the si gnal peak near the reference l evel :
Press AMPLITUDE Y Scale, Ref Level, (r otate front-panel knob).
Step 5. Change the y-scal e type to l i near:
Press AMPLITUDE Y Scale, Scale Type (Li n).
Step 6. Set the anal yzer i n zero span to make ti me-domai n measurements:
Press SPAN X Scale, Zero Span.
Press Sweep, Sweep Time, 5, ms.
Step 7. Use the vi deo tri gger to stabi l i ze the trace:
Press Trig, Video.
Si nce the modul ati on i s a steady tone, you can use vi deo tr i gger to
tr i gger the anal yzer sweep on the waveform and stabi l i ze the trace,
much l i ke an osci l l oscope. See Fi gure 11-1.
Chapter 11 93
Demodulating AM and FM Signals
Measuring the Modulation Rate of an AM Signal
D
e
m
o
d
u
l
a
t
i
n
g

A
M

a
n
d

F
M

S
i
g
n
a
l
s
NOTE I f the tr i gger l evel i s set too hi gh or too l ow when vi deo tr i gger mode i s
acti vated, the sweep stops. You need to adjust the tr i gger l evel up or
down wi th the fr ont-panel knob unti l the sweep begi ns agai n.
Step 8. Measur e the AM r ate usi ng del ta mar ker s:
Press Peak Search, Marker, Delta, Peak Search, Next Pk Right or Next Pk
Left.
Use mar ker s and del ta mar kers to measur e the AM r ate. Pl ace the
marker on a peak and then use a del ta marker to measur e the ti me
di fference between the peaks (thi s i s the AM rate of the si gnal )
NOTE Make sure the del ta markers above are pl aced on adjacent peaks. See
Fi gure 11-1. The frequency or the AM rate i s 1 di vi ded by the ti me
between adjacent peaks:
AM Rate = 1/1.0 ms = 1 kHz
The spectrum anal yzer can al so make thi s rate cal cul ati on by changi ng
the mar ker readout to i nver se ti me.
Press Marker, More, Readout, Inverse Time.
I n thi s exampl e we cal cul ated the ti me between ti me-domai n peaks at
the frequency of the peak of the AM si gnal . To make thi s measur ement
more accuratel y, set the center frequency to a poi nt on the AM si gnal
where the sl ope of the AM si gnal s ski rt i s steep and then set the
anal yzer i n zero span. Set the anal yzer sweep ti me to about 2 ti mes the
modul ati on r ate and i ncrease the number of sweep poi nts.
Another way to cal cul ate the modul ati on rate woul d be to vi ew the
si gnal i n the frequency domai n and measure the del ta frequency
between the peak of the car ri er and the fi r st si deband.
Figure11-1 Measuring Time Parameters
94 Chapter 11
Demodulating AM and FM Signals
Measuring the Modulation Index of an AM Signal
D
e
m
o
d
u
l
a
t
i
n
g

A
M

a
n
d

F
M

S
i
g
n
a
l
s
Measuring the Modulation Index of an AM
Signal
Thi s procedure demonstrates how to use the spectr um anal yzer as a
fi xed-tuned (ti me-domai n) recei ver to measure the modul ati on i ndex as
a percent AM val ue of an AM si gnal . Usi ng the ESA bui l t-i n AM
demodul ator, you can al so tune-i n and l i sten to an AM si gnal
(Demodul ati ng an AM Si gnal Usi ng the ESA Seri es on page 96).
Step 1. Fol l ow steps 1 through 7 of the pr ocedure Measur i ng the Modul ati on
Rate of an AM Si gnal on page 92.
Step 2. Turn off al l markers and pl ace the anal yzer i n free run tri gger mode:
Press Marker, Off.
Press Trig, Free Run.
Step 3. I ncrease the sweep ti me and decrease the VBW so that the waveform i s
di spl ayed as a fl at hori zontal si gnal :
Press Sweep, Sweep Time, 5, s.
Press BW/Avg, Video BW, 30, Hz.
Step 4. Center the fl at waveform at the mi d-poi nt of the y-axi s and then wi den
the VBW and decr ease the sweep ti me to di spl ay the wavefor m as a si ne
wave:
Press AMPLITUDE Y Scale, Ref Level.
Press BW/Avg, Video BW, 100, kHz.
Press Sweep, Sweep Time, 5, ms.
Step 5. Measure the modul ati on i ndex of the AM si gnal :
To measur e the modul ati on i ndex as % AM, read the trace as fol l ows
(see Fi gure 11-2 for di spl ay exampl es): 100% AM extends fr om the top
grati cul e down to the bottom grati cul e. 80% AM (as i n thi s exampl e) i s
when the top of the si gnal i s at 1 di vi si on bel ow the top grati cul e and 1
di vi si on above the bottom grati cul e. To determi ne % AM of your si gnal
count each y-axi s di vi si on as 10%.
Chapter 11 95
Demodulating AM and FM Signals
Measuring the Modulation Index of an AM Signal
D
e
m
o
d
u
l
a
t
i
n
g

A
M

a
n
d

F
M

S
i
g
n
a
l
s
Figure11-2 AM Signal Measured in the Time Domain
LEFT: 100% AM Si gnal (Modul ati on I ndex = 1)
RI GHT: 80% AM Si gnal (Modul ati on I ndex = 0.8)
96 Chapter 11
Demodulating AM and FM Signals
Demodulating an AM Signal Using the ESA Series
D
e
m
o
d
u
l
a
t
i
n
g

A
M

a
n
d

F
M

S
i
g
n
a
l
s
Demodulating an AM Signal Using the ESA
Series
The demodul ati on functi ons l i sted i n the menu under Det/Demod al l ow
you to demodul ate and hear si gnal i nformati on di spl ayed on the
anal yzer. Si mpl y pl ace a marker on a si gnal of i nterest, set the anal yzer
i n zero span, acti vate AM demodul ati on, turn the speaker on, and then
l i sten.
NOTE AM demodul ati on i s not avai l abl e on the PSA Seri es spectrum
anal yzer s.
Step 1. Per for m a factor y pr eset:
Press Preset, Factory Preset (i f pr esent).
Step 2. Connect an antenna to the anal yzer i nput.
Step 3. Sel ect a fr equency range on the anal yzer, such as the range for AM
radi o broadcasts. For exampl e, the fr equency range for AM broadcasts
i n the Uni ted States i s 550 kHz to 1650 kHz:
Press FREQUENCY, Start Freq, 550, kHz, Stop Freq, 1650, kHz.
Step 4. Pl ace a marker on the si gnal of i nterest (see Fi gure 11-3):
Press Peak Search, Next Pk Right or Next Pk Left.
Figure11-3 AM Broadcast Signals
Step 5. Set the frequency of the si gnal of i nterest to center frequency:
Press Peak Search, Next Pk Right or Next Pk Left (as necessary), Marker,
and MkrCF.
Step 6. Reduce the span to 1 MHz by usi ng the step down key () and MkrCF
Chapter 11 97
Demodulating AM and FM Signals
Demodulating an AM Signal Using the ESA Series
D
e
m
o
d
u
l
a
t
i
n
g

A
M

a
n
d

F
M

S
i
g
n
a
l
s
mul ti pl e ti mes, keepi ng the si gnal of i nterest i n the center of the
di spl ay unti l the span i s 1 MHz:
Press SPAN X Scale, Span, (), MkrCF.
Step 7. Set the anal yzer i nto ti me-domai n wi th zero span:
Press SPAN X Scale, Zero Span.
Step 8. Change the resol uti on bandwi dth to 100 kHz:
Press BW/Avg, Res BW, 100, kHz.
Step 9. Set the top of the si gnal near the top of the di spl ay by changi ng the
reference l evel wi th the fr ont-panel knob:
Press AMPLITUDE Y Scale, rotate fr ont-panel knob.
Step 10. Set the ampl i tude scal e to l i near and then re-adjust the reference l evel
to keep the si gnal centered i n the di spl ay:
Press AMPLITUDE Y Scale, Scale Type (Li n).
Press AMPLITUDE Y Scale, Ref Level, rotate fr ont-panel knob.
Step 11. Set the detector type to sampl e and tur n on AM demodul ati on:
Press Det/Demod, Detector, Sample.
Press Det/Demod, Demod, AM.
Step 12. Li sten to the demodul ated AM si gnal (adjust the vol ume as necessar y):
Press Det/Demod, Demod, Speaker (On).
Step 13. Measure the modul ati on i ndex (AM depth as a percentage):
Press Sweep Time, 5, s.
Press BW/Avg, Video BW, 30, Hz.
Press AMPLITUDE Y Scale, Ref Level (use the front-panel knob to adjust
the tr ace to the mi ddl e of the scr een).
Press BW/Avg, Video BW, 100, kHz.
Press Sweep, Sweep Time, 5, ms.
The mi ddl e hori zontal gr ati cul e l i ne represents 0% AM; the top and
bottom hori zontal l i nes repr esent 100% AM.
NOTE The si gnal to the speaker i s i nter rupted duri ng retrace because the
anal yzer i s perfor mi ng automati c al i gnment routi nes. To el i mi nate the
i nterrupti on and cl i cks between sweeps, turn the auto al i gnment
functi on off by pressi ng System, Alignments, Auto Align, Off.
Refer to the speci fi cati ons for i nformati on about oper ati ng the anal yzer
wi th the al i gnments turned off.
98 Chapter 11
Demodulating AM and FM Signals
Demodulating an FM Signal Using the ESA-E Series (Requires Option BAA)
D
e
m
o
d
u
l
a
t
i
n
g

A
M

a
n
d

F
M

S
i
g
n
a
l
s
Demodulating an FM Signal Using the ESA-E
Series (Requires Option BAA)
Thi s secti on demonstr ates how to demodul ate and l i sten to an FM
si gnal usi ng the ESA bui l t-i n FM demodul ator wi th opti on BAA.
Usi ng the ESAs bui l t i n FM demodul ator you can tune to an FM si gnal
and vi ew the r esul ts of the detector output as di spl ayed i n the ti me
domai n. Al ternati vel y, the demodul ated si gnal i s al so avai l abl e as an
audi o output (to the speaker or headphone jack) and as vi deo output (on
the rear panel of the ESA).
NOTE FM demodul ati on i s not avai l abl e on the PSA Seri es spectrum
anal yzer s.
Step 1. Per for m a factor y pr eset:
Press Preset, Factory Preset (i f pr esent).
Step 2. Use an ESG RF source or an antenna for an FM si gnal to anal yze. I n
thi s exampl e an ESG i s used transmi tti ng at 300 MHz wi th FM
devi ati on of 10 kHz and FM rate of 1 kHz.
NOTE I f you are usi ng a broadcast FM si gnal i n the Uni ted States, for
exampl e, the FM channel s are broadcasti ng between 87.7 MHz to
107.7 MHz.
Step 3. Before conti nui ng wi th the demodul ati on of the FM si gnal , cal i brate the
demodul ator :
Press System, Alignments, Align Now, FM demod.
Step 4. Set the center fr equency to the center of the FM si gnal (i n thi s case
300 MHz):
Press FREQUENCY Channel, Center Freq, 300, MHz.
Step 5. Set the anal yzer to zero span for ti me-domai n anal ysi s:
Press SPAN X Scale, Zero Span.
Press Sweep, Sweep Time, 4, ms.
Step 6. Set the resol uti on bandwi dth to capture the ful l bandwi dth of the FM
si gnal . To cal cul ate the requi red bandwi dth use
I n our case the RBW shoul d be: (2 x 10 kHz) + (2 x 1 kHz) = 22 kHz
Wi th ESAs 1-3-10 sequence RBW sel ecti ons, choose the next hi ghest
RBW of 30 kHz:
RBW 2 x Frequency Deviation ( ) 2 x Modulation Rate ( ) + ( ) =
Chapter 11 99
Demodulating AM and FM Signals
Demodulating an FM Signal Using the ESA-E Series (Requires Option BAA)
D
e
m
o
d
u
l
a
t
i
n
g

A
M

a
n
d

F
M

S
i
g
n
a
l
s
Press BW/Avg, Res BW, 30, kHz.
Step 7. Turn on the FM demodul ator:
Press Det/Demod, Demod, FM.
Step 8. Change the verti cal scal i ng:
Press AMPLITUDE Y Scale, Scale/Div, 5, kHz.
Figure11-4 FM Demodulation (ESG FM Signal with 10 kHz Deviation)
Step 9. Cal cul ate the FM devi ati on usi ng markers wi th max hol d and mi n hol d
functi onal i ty (al so note that each di vi si on has 5 kHz of FM devi ati on i f
you wanted to vi sual l y cal cul ate the devi ati on):
Press View/Trace, Max Hold.
Wai t unti l the trace appears to be a fl at l i ne before conti nui ng to the
next button sequence bel ow:
Press Marker, Delta, View/Trace, Min Hold.
The val ue on the screen fr om the del ta val ue of max hol d and mi n hol d
i s the peak-to-peak devi ati on val ue. We are i nterested i n the average
val ue whi ch we can cal cul ate by di vi di ng the peak-to-peak val ue by 2.
I n our case i t shoul d be appr oxi matel y 20 kHz/2 or 10 kHz.
100 Chapter 11
Demodulating AM and FM Signals
Demodulating an FM Signal Using the ESA-E Series (Requires Option BAA)
D
e
m
o
d
u
l
a
t
i
n
g

A
M

a
n
d

F
M

S
i
g
n
a
l
s
Figure11-5 Calculating Frequency Deviation
Step 10. Take a si ngl e sweep of the demodul ated si gnal and then cal cul ate the
FM rate usi ng del ta markers on adjacent peaks. Change the marker
readout val ue to i nverse ti me for a frequency cal cul ati on of the FM rate:
Press Marker, Off.
Press View/Trace, Clear Write.
Press Single, Peak Search, Marker, Delta, Peak Search, Next Pk Right (or
Next Pk Left).
Press Marker, More, Readout, Inverse Time.
Figure11-6 Calculating Modulation Rate
Step 11. Li sten to the FM si gnal (fi rst put the anal yzer back i nto conti nuous
sweepi ng mode):
Press Sweep, Sweep (Cont).
Press Det/Demod, Demod, Speaker (On).
Adjust the vol ume of the i nternal speaker wi th the vol ume knob on the
fr ont-panel . Al ternati vel y you can al so use the headphone jack (l ocated
bel ow the 3.5 i nch fl oppy di sk dr i ve).
101
U
s
i
n
g

S
e
g
m
e
n
t
e
d

S
w
e
e
p

(
E
S
A
-
E

S
e
r
i
e
s

S
p
e
c
t
r
u
m

A
n
a
l
y
z
e
r
s
)
12 Using Segmented Sweep (ESA-E
Series Spectrum Analyzers)
102 Chapter 12
Using Segmented Sweep (ESA-E Series Spectrum Analyzers)
Measuring Harmonics Using Standard Sweep
U
s
i
n
g

S
e
g
m
e
n
t
e
d

S
w
e
e
p

(
E
S
A
-
E

S
e
r
i
e
s

S
p
e
c
t
r
u
m

A
n
a
l
y
z
e
r
s
)
Measuring Harmonics Using Standard Sweep
Thi s procedure measures the fundamental 50 MHz si gnal pl us the
second and thi r d harmoni cs. Compar e the measur ement ti mes wi th thi s
pr ocedure, sweepi ng fr om 20 MHz to 170 MHz versus the next
pr ocedure Measuri ng Harmoni cs Usi ng Segmented Sweep on page
104.
Step 1. Pr eset the i nstr ument:
Press Preset, Factory Preset (i f pr esent).
Step 2. Use the anal yzer i nternal 50 MHz ampl i tude reference si gnal :
For ESA model numbers E4401B and E4411B, use the i nternal 50 MHz
ampl i tude reference si gnal .
Press Input/Output, Amptd Ref (On).
For al l other ESA model numbers connect a cabl e between the
fr ont-panel AMPTD REF OUT to the anal yzer I NPUT.
Press Input/Output, Amptd Ref Out (On).
Step 3. Set the frequency span to vi ew the fundamental si gnal , second
harmoni c and thi rd harmoni c:
Press FREQUENCY Channel, Start Freq, 20, MHz, Stop Freq, 170, MHz.
Press AMPLITUDE Y Scale, Ref Level, 20, dBm.
Step 4. Set the resol uti on bandwi dth and vi deo bandwi dth:
Press BW/Avg, Res BW, 1, kHz.
Press BW/Avg, Video BW, 1, kHz.
Step 5. Pl ace a marker at the 50 MHz si gnal (you may need to wai t for a
mi nute unti l the anal yzer sweeps past 50 MHz):
Press Peak Search.
Refer to Fi gure 12-1 to see the resul t of thi s fi rst measur ement i n thi s
exampl e. Noti ce the mi ni mum sweep ti me i s set at 193.3 seconds i n
order to pr ovi de accur ate data. I f you attempt to enter a faster sweep
ti me, the Meas Uncal message i s shown i n the upper ri ght corner of the
di spl ay.
Chapter 12 103
Using Segmented Sweep (ESA-E Series Spectrum Analyzers)
Measuring Harmonics Using Standard Sweep
U
s
i
n
g

S
e
g
m
e
n
t
e
d

S
w
e
e
p

(
E
S
A
-
E

S
e
r
i
e
s

S
p
e
c
t
r
u
m

A
n
a
l
y
z
e
r
s
)
Figure12-1 Measuring Harmonics with Standard Sweep
104 Chapter 12
Using Segmented Sweep (ESA-E Series Spectrum Analyzers)
Measuring Harmonics Using Segmented Sweep
U
s
i
n
g

S
e
g
m
e
n
t
e
d

S
w
e
e
p

(
E
S
A
-
E

S
e
r
i
e
s

S
p
e
c
t
r
u
m

A
n
a
l
y
z
e
r
s
)
Measuring Harmonics Using Segmented
Sweep
Segmented sweep al l ows you to defi ne many bands of i nter est and
di spl ay them as a si ngl e trace. Al though the fol l owi ng exampl es onl y
i nvol ve a maxi mum of 3 segments, you can set up the tr ace to di spl ay 32
segments si mul taneousl y.
Thi s pr ocedur e uses segmented sweep to measure the 50 MHz
fundamental si gnal , the second harmoni c and the thi r d harmoni c.
Compare the measurement ti me di ffer ences between the previ ous
pr ocedure, Measuri ng Harmoni cs Usi ng Standard Sweep on page 102
and thi s pr ocedure usi ng segmented sweep. Segmented sweep i s faster
than sweepi ng the ful l span to captur e the fundamental si gnal to the
thi r d harmoni c.
Step 1. Pr eset the i nstr ument:
Press Preset, Factory Preset (i f pr esent).
Step 2. Turn on the i nternal 50 MHz ampl i tude reference si gnal as i n step 2
fr om the Measuri ng Harmoni cs Usi ng Standard Sweep on page 102,
secti on above.
Step 3. Set the reference l evel and attenuati on:
Press AMPLITUDE Y Scale, Ref Level, 20, dBm.
Press AMPLITUDE Y Scale, Attenuation, 5, dB.
Step 4. Open the segmented sweep edi tor:
Press Sweep, Segmented, Modify, Edit.
Three segments are goi ng to be set up, as i n Fi gure 12-2 bel ow, to vi ew
the fundamental si gnal , second harmoni c and thi rd harmoni c.
Step 5. Set the fi r st segment parameters:
Press Segment, 1, Enter.
Press Center Freq, 50, MHz.
Press Span, 100, kHz.
Press Video BW, 30, Hz.
Step 6. Set the second segment parameters:
Press Segment, 2, Enter.
Press Center Freq, 100, MHz.
Press Span, 100, kHz.
Press Video BW, 30, Hz.
Step 7. Set the thi rd segment par ameter s:
Press Segment, 3, Enter.
Chapter 12 105
Using Segmented Sweep (ESA-E Series Spectrum Analyzers)
Measuring Harmonics Using Segmented Sweep
U
s
i
n
g

S
e
g
m
e
n
t
e
d

S
w
e
e
p

(
E
S
A
-
E

S
e
r
i
e
s

S
p
e
c
t
r
u
m

A
n
a
l
y
z
e
r
s
)
Press Center Freq, 150, MHz.
Press Span, 100, kHz.
Press Video BW, 30, Hz.
Noti ce that the total sweep ti me for the 3 segments i s onl y 8.13 seconds
(pl us a mi ni mal ti me for transi ti ons between segments). Thi s i s
consi derabl y shorter than the 193.3 seconds requi red to vi ew the same
si gnal s wi thout segmented sweep.
Figure12-2 Reducing Sweep Time with Segmented Sweep
106 Chapter 12
Using Segmented Sweep (ESA-E Series Spectrum Analyzers)
Using Segmented Sweep With Limit Lines
U
s
i
n
g

S
e
g
m
e
n
t
e
d

S
w
e
e
p

(
E
S
A
-
E

S
e
r
i
e
s

S
p
e
c
t
r
u
m

A
n
a
l
y
z
e
r
s
)
Using Segmented Sweep With Limit Lines
Segmented sweep can al so use other standard spectr um anal yzer
functi onal i ty, such as l i mi t l i nes. I n thi s pr ocedure three segments ar e
used. I n the fi r st segment, the l i mi t l i nes ar e used to ver i fy that the
si gnal phase noi se i s acceptabl e. The second and thi rd segments are
used to veri fy the harmoni c si gnal s ar e bel ow a speci fi ed ampl i tude.
Step 1. Connect the 10 MHz REF OUT from the rear panel to the front-panel
I NPUT. Preset the i nstrument:
Press Preset, Factory Preset (i f pr esent).
Step 2. Pl ace the peak of the fundamental si gnal at the top of the grati cul e:
Press AMPLITUDE Y Scale, Ref Level, 8, dBm.
Step 3. Open the segmented sweep edi tor:
Press Sweep, Segmented, Modify, Edit.
Step 4. Di spl ay the fundamental si gnal i n the fi rst segment:
Press Segment, 1, Enter.
Press Center Freq, 10, MHz.
Press Span, 500, kHz.
Press Res BW, 3, kHz.
Press Video BW, 30, Hz.
Press Points, 1000, Enter.
Step 5. Di spl ay the second harmoni c i n the second segment:
Press Segment, 2, Enter.
Press Center Freq, 20, MHz.
Press Span, 100, kHz.
Step 6. Di spl ay the thi r d harmoni c i n the thi rd segment:
Press Segment, 3, Enter.
Press Center Freq, 30, MHz.
Press Span, 100, kHz.
Step 7. Open the l i mi t l i ne edi tor:
Press Display, Limits, Limit 1, Type (Upper ), Edit.
Step 8. Enter the l i mi t l i ne data fr om Tabl e 12-1 bel ow. To enter the tabl e data:
Press Point, 1, Enter, Frequency, 9.75, MHz, Amplitude, 80, dBm,
Connected (Yes).
Step 9. Begi n the next l i mi t l i ne poi nt:
Press Tab |.
Chapter 12 107
Using Segmented Sweep (ESA-E Series Spectrum Analyzers)
Using Segmented Sweep With Limit Lines
U
s
i
n
g

S
e
g
m
e
n
t
e
d

S
w
e
e
p

(
E
S
A
-
E

S
e
r
i
e
s

S
p
e
c
t
r
u
m

A
n
a
l
y
z
e
r
s
)
Step 10. Enter poi nts 2 through 11 from Tabl e 12-1:
Step 11. Turn the l i mi ts on:
Press Return, Limit (On).
Step 12. Turn the l i mi t test on to deter mi ne i f the fundamental si gnal and
harmoni cs pass:
Press Test (On).
Figure12-3 Segmented Sweep with Limit Line Test
Thi s pr ocedure can veri fy compl i ance wi th phase noi se and harmoni cs
speci fi cati ons. You can save thi s i nstrument state and l i mi t l i nes i n a
setup type fi l e for future appl i cati ons (File, Save, Type, Setup,
Save Now). Repl ace the 10 MHz reference si gnal of the anal yzer wi th
the devi ce under test (DUT) to create a si mi l ar measurement.
Table 12-1 Limit Line Data
Point Frequency Amplitude Connected
1 9.75 MHz 80 dBm Yes
2 9.8 MHz 75 dBm Yes
3 9.9 MHz 70 dBm Yes
4 9.95 MHz 6 dBm Yes
5 10.05 MHz 6 dBm Yes
6 10.1 MHz 70 dBm Yes
7 10.2 MHz 75 dBm Yes
8 10.25 MHz 80 dBm Yes
9 19.95 MHz 30 dBm Yes
10 29.95 MHz 15 dBm Yes
11 30.05 MHz 15 dBm Yes
108 Chapter 12
Using Segmented Sweep (ESA-E Series Spectrum Analyzers)
Using Segmented Sweep to Monitor the Cellular Activity of a cdmaOne Band
U
s
i
n
g

S
e
g
m
e
n
t
e
d

S
w
e
e
p

(
E
S
A
-
E

S
e
r
i
e
s

S
p
e
c
t
r
u
m

A
n
a
l
y
z
e
r
s
)
Using Segmented Sweep to Monitor the
Cellular Activity of a cdmaOne Band
I n thi s exampl e set up two segments to moni tor the forwar d and r everse
l i nks of a U.S. I S-95A cel l ul ar band. The thi rd segment i s used to zoom
i n on an ar ea of i nterest. You can use any communi cati ons band of
i nter est i n your ar ea to dupl i cate thi s exampl e.
Step 1. Per for m a factor y pr eset:
Press Preset, Factory Preset (i f pr esent).
Step 2. Turn on the i nternal pr eamp (i f i nstal l ed):
Press AMPLITUDE Y Scale, More, Int Preamp (On).
Step 3. Open the segmented sweep edi tor:
Press Sweep, Segmented, Modify, Edit.
Step 4. Moni tor the acti vi ty i n the cdmaOne band wi th the fi rst segment:
Press Center Freq, 836.5, MHz.
Press Span, 25, MHz.
Press Res BW, 10, kHz.
Step 5. Set the reference l evel to pl ace the si gnal i n the mi ddl e of the di spl ay:
Press AMPLITUDE Y Scale, Ref Level, 40, dBm.
Step 6. Moni tor the acti vi ty of the base stati on wi th the second segment:
Press Sweep, Segmented, Modify, Edit, Segment, 2, Enter.
Press Center Freq, 881.5, MHz.
Press Span, 25, MHz.
Press Res BW, 10, kHz.
Figure12-4 Monitoring the Reverse and Forward Links
Chapter 12 109
Using Segmented Sweep (ESA-E Series Spectrum Analyzers)
Using Segmented Sweep to Monitor the Cellular Activity of a cdmaOne Band
U
s
i
n
g

S
e
g
m
e
n
t
e
d

S
w
e
e
p

(
E
S
A
-
E

S
e
r
i
e
s

S
p
e
c
t
r
u
m

A
n
a
l
y
z
e
r
s
)
Step 7. Locate the fr equency of the cdmaOne si gnal wi th a marker:
Press Marker, then r otate front-panel knob.
Noti ce that i n thi s exampl e, there are two cdmaOne carr i ers l ocated at
882.23 MHz, as shown i n Fi gure 12-4.
Step 8. Set the center fr equency of segment 3 to 882.23 MHz:
Press Sweep, Segmented, Modify, Edit, Segment, 3, Enter.
Press Center Freq, 882.23, MHz.
Step 9. Set the span to gr eater than twi ce the cdmaOne bandwi dth (2 ti mes
1.2288 MHz) si nce ther e are two cdma carr i ers si de-by-si de:
Press Span, 2.7, MHz.
Press Res BW, 10, kHz.
Step 10. Set tr ace 1 to maxi mum hol d and set tr ace 2 to mi ni mum hol d:
Press Trace/View, Trace 1, Max Hold.
Press Trace/View, Trace 2, Min Hold.
Figure12-5 Monitoring Cellular Bands in Segmented Sweep
Fi gure 12-5 di spl ays the resul ts of thi s setup over an extended per i od of
ti me. As expected, the mi ni mum hol d trace of segment 1 shows no
conti nuousl y present carr i ers. Thi s i s i ndi cati ve of cel l ul ar acti vi ty. I f a
persi stent si gnal exi sts, i t may repr esent the presence of an i nterferi ng
car r i er. I n thi s exampl e, segment 3 shows conti nuous tr ansmi ssi on of
the carri er wi thout i nterference.
110 Chapter 12
Using Segmented Sweep (ESA-E Series Spectrum Analyzers)
Using Segmented Sweep to Monitor the Cellular Activity of a cdmaOne Band
U
s
i
n
g

S
e
g
m
e
n
t
e
d

S
w
e
e
p

(
E
S
A
-
E

S
e
r
i
e
s

S
p
e
c
t
r
u
m

A
n
a
l
y
z
e
r
s
)
111
S
t
i
m
u
l
u
s

R
e
s
p
o
n
s
e

M
e
a
s
u
r
e
m
e
n
t
s

(
E
S
A

O
p
t
i
o
n
s

1
D
N

a
n
d

1
D
Q
)
13 Stimulus Response
Measurements (ESA Options 1DN
and 1DQ)
112 Chapter 13
Stimulus Response Measurements (ESA Options 1DN and 1DQ)
Making a Stimulus Response Transmission Measurement
S
t
i
m
u
l
u
s

R
e
s
p
o
n
s
e

M
e
a
s
u
r
e
m
e
n
t
s

(
E
S
A

O
p
t
i
o
n
s

1
D
N

a
n
d

1
D
Q
)
Making a Stimulus Response Transmission
Measurement
The procedure bel ow descri bes how to use a bui l t-i n tr acki ng generator
to measure the rejecti on of a band pass fi l ter, a type of transmi ssi on
measur ement. Refer to the concepts chapter Sti mul us Response
Measurement Concepts on page 158 for more i nformati on a maki ng
sti mul us response measurements i ncl udi ng adjusti ng the tracki ng
generator output power and measuri ng the N dB bandwi dth.
Step 1. To measur e the r ejecti on of a band pass fi l ter, connect the equi pment as
shown i n Fi gure 13-1. A 200 MHz bandpass fi l ter as the DUT.
Figure13-1 Transmission Measurement Test Setup
Step 2. Per for m a factor y pr eset:
Press Preset, Factory Preset (i f pr esent).
Step 3. Vi ew the rejecti on of the bandpass fi l ter. Set a wi de RBW:
Press FREQUENCY Channel, Center Freq, 200, MHz.
Press SPAN X Scale, Span, 100, MHz.
Press BW/Avg, Res BW, 3, MHz.
Step 4. Turn on the tr acki ng generator:
Press Source, Amplitude (On), 10, dBm.
CAUTION Excessi ve si gnal i nput may damage the DUT. Do not exceed the
maxi mum power that the devi ce under test can tol erate.
NOTE To r educe r i ppl es caused by sour ce return l oss, use 10 dB (E4401B or
E4411B) or 8 dB (al l other model s) or greater tracki ng generator output
attenuati on. Tracki ng generator output attenuati on i s normal l y a
functi on of the source power sel ected. However, the output attenuati on
may be control l ed i n the Source menu.
Chapter 13 113
Stimulus Response Measurements (ESA Options 1DN and 1DQ)
Making a Stimulus Response Transmission Measurement
S
t
i
m
u
l
u
s

R
e
s
p
o
n
s
e

M
e
a
s
u
r
e
m
e
n
t
s

(
E
S
A

O
p
t
i
o
n
s

1
D
N

a
n
d

1
D
Q
)
Step 5. Put the sweep ti me i nto sti mul us r esponse auto coupl ed mode:
Press Sweep, Swp Coupling (SR).
Step 6. I ncrease measurement sensi ti vi ty and smooth the noi se:
Press BW/Avg, Res BW, 30, kHz.
Press BW/Avg, Video BW, 300, Hz.
A decr ease i n di spl ayed ampl i tude i s caused by tracki ng error.
Step 7. Use peak tracki ng to cor rect the fr equency offset:
Press Source, Tracking Peak.
Tracki ng error occurs when the output fr equency of the tracki ng
generator i s not exactl y matched to the i nput fr equency of the anal yzer.
The ampl i tude shoul d return to the val ue that was di spl ayed pr i or to
the decrease i n resol uti on bandwi dth.
Step 8. Connect the cabl e from the tracki ng generator output to the anal yzer
i nput. Store the frequency response i n trace 3 and normal i ze:
Press View/Trace, More, Normalize, Store Ref (13), Normalize (On).
See Normal i zati on Concepts on page 159 for i nfor mati on on
normal i zati on.
Step 9. Reconnect the DUT to the anal yzer and change the normal i zed
reference posi ti on:
Press View/Trace, More, Normalize, Norm Ref Posn.
Step 10. Measure the rejecti on of the bandpass fi l ter:
Press Marker, 200, MHz, Delta, 45, MHz.
The marker readout di spl ays the rejecti on of the fi l ter at 45 MHz above
the center of the bandpass. See Fi gure 13-2.
Figure13-2 Measure the Rejection Range
114 Chapter 13
Stimulus Response Measurements (ESA Options 1DN and 1DQ)
Calculating the N dB Bandwidth Using Stimulus Response
S
t
i
m
u
l
u
s

R
e
s
p
o
n
s
e

M
e
a
s
u
r
e
m
e
n
t
s

(
E
S
A

O
p
t
i
o
n
s

1
D
N

a
n
d

1
D
Q
)
Calculating the N dB Bandwidth Using
Stimulus Response
Thi s pr ocedur e uses the tracki ng generator for transmi ssi on sti mul us
response measurements to cal cul ate the 3 dB bandwi dth of a 200 MHz
bandpass fi l ter. See the concepts secti on Measuri ng Devi ce
Bandwi dth on page 160 for more i nformati on on thi s measurement.
Step 1. To measure the rejecti on of a bandpass fi l ter, connect the equi pment as
shown i n Fi gure 13-3. Thi s exampl e uses a 200 MHz bandpass fi l ter.
Figure13-3 Transmission Measurement Test Setup
Step 2. Per for m a factor y pr eset:
Press Preset, Factory Preset (i f pr esent).
Step 3. Set the center fr equency, span and the resol uti on bandwi dth:
Press FREQUENCY Channel, Center Freq, 200, MHz.
Press SPAN X Scale, Span, 100, MHz.
Press BW/Avg, Res BW, 10, kHz.
Step 4. Turn on the tr acki ng gener ator and set the output power to 10 dBm:
Press Source, Amplitude (On), 10, dBm.
CAUTION Excessi ve si gnal i nput may damage the DUT. Do not exceed the
maxi mum power that the devi ce under test can tol erate.
NOTE To r educe r i ppl es caused by sour ce return l oss, use 10 dB (E4401B or
E4411B) or 8 dB (al l other model s) or greater tracki ng generator output
attenuati on. Tracki ng generator output attenuati on i s normal l y a
functi on of the source power sel ected.
Chapter 13 115
Stimulus Response Measurements (ESA Options 1DN and 1DQ)
Calculating the N dB Bandwidth Using Stimulus Response
S
t
i
m
u
l
u
s

R
e
s
p
o
n
s
e

M
e
a
s
u
r
e
m
e
n
t
s

(
E
S
A

O
p
t
i
o
n
s

1
D
N

a
n
d

1
D
Q
)
Step 5. Put the sweep ti me of the anal yzer i nto sti mul us response auto coupl ed
mode:
Press Sweep, Swp Coupling (SR).
Auto coupl ed sweep ti mes are usual l y much faster for sti mul us
response measurements than they are for spectrum anal yzer (SA)
measurements. I f necessar y, adjust the reference l evel to pl ace the
si gnal on screen.
Step 6. Acti vate the N dB bandwi dth functi on (See Fi gure 13-4):
Press Peak Search, More, N dB Points (On).
Figure13-4 AM Signal Measured in the Time Domain
LEFT: N dB Bandwi dth Measurement at 3 dB
RI GHT: N dB Bandwi dth Measurement at 60 dB
NOTE The knob or the data entry keys can be used to change the N dB val ue
fr om 3 dB to 60 dB to measure the 60 dB bandwi dth of the fi l ter.
Step 7. Turn off the N db Poi nts measur ement:
Press N dB Points (Off).
116 Chapter 13
Stimulus Response Measurements (ESA Options 1DN and 1DQ)
Measuring Stop Band Attenuation Using Log Sweep (ESA-E Series)
S
t
i
m
u
l
u
s

R
e
s
p
o
n
s
e

M
e
a
s
u
r
e
m
e
n
t
s

(
E
S
A

O
p
t
i
o
n
s

1
D
N

a
n
d

1
D
Q
)
Measuring Stop Band Attenuation Using Log
Sweep (ESA-E Series)
When measuri ng fi l ter characteri sti cs, i t i s useful to l ook at the
sti mul us response over a wi de frequency range. Setti ng the anal yzer
x-axi s (frequency) to di spl ay l ogari thmi cal l y provi des thi s functi on.
The fol l owi ng exampl e uses the tracki ng generator to measure the stop
band attenuati on of a 10 MHz l ow pass fi l ter.
Step 1. To measur e the response of a l ow pass fi l ter, connect the equi pment as
shown i n Fi gure 13-5. Thi s exampl e uses a 10 MHz l ow pass fi l ter.
Figure13-5 Transmission Measurement Test Setup
Step 2. Per for m a factor y pr eset:
Press Preset, Factory Preset (i f pr esent).
Step 3. Set the star t and stop fr equenci es:
Press FREQUENCY Channel, Start Freq, 100, kHz.
Press FREQUENCY Channel, Stop Freq, 1, GHz.
Press FREQUENCY Channel, Scale Type (Log).
Step 4. Set the resol uti on bandwi dth to 10 kHz:
Press BW/Avg, Res BW, 10, kHz.
Step 5. For E4407B anal yzers wi th opti on UKB, set the i nput coupl i ng to DC:
Press Input, Coupling (DC).
Step 6. Turn on the tracki ng generator and i f necessary, set the output power to
10 dBm:
Press Source, Amplitude (On), 10, dBm.
CAUTION Excessi ve si gnal i nput may damage the DUT. Do not exceed the
maxi mum power that the devi ce under test can tol erate.
Chapter 13 117
Stimulus Response Measurements (ESA Options 1DN and 1DQ)
Measuring Stop Band Attenuation Using Log Sweep (ESA-E Series)
S
t
i
m
u
l
u
s

R
e
s
p
o
n
s
e

M
e
a
s
u
r
e
m
e
n
t
s

(
E
S
A

O
p
t
i
o
n
s

1
D
N

a
n
d

1
D
Q
)
Step 7. Put the sweep ti me i nto sti mul us r esponse auto coupl ed mode:
Press Sweep, Swp Coupling (SR).
Adjust the reference l evel i f necessary to pl ace the si gnal on screen.
Step 8. Connect the cabl e (but not the DUT) from the tr acki ng generator output
to the anal yzer i nput. Store the fr equency response i nto tr ace 3 and
normal i ze:
Press View/Trace, More, Normalize, Store Ref (13), Normalize (On).
Step 9. Reconnect the DUT to the anal yzer. Note that the uni ts of the reference
l evel have changed to dB, i ndi cati ng that thi s i s now a rel ati ve
measurement.
Step 10. To change the normal i zed reference posi ti on:
Press View/Trace, More, Normalize, Norm Ref Posn, 9, Enter.
Step 11. Pl ace the reference marker at the speci fi ed cutoff fr equency:
Press Marker, Delta Pair (Ref), 10, MHz.
Step 12. Pl ace the second marker at 20 MHz:
Press Delta Pair (Del ta), 20, MHz.
I n thi s exampl e, the attenuati on over thi s fr equency range i s
63.32 dB/octave (one octave above the cutoff fr equency).
Step 13. Use the front-panel knob to pl ace the marker at the hi ghest peak i n the
stop band to determi ne the mi ni mum stop band attenuati on. I n thi s
exampl e, the peak occurs at 708.76 MHz. The attenuati on i s 54.92 dB.
Figure13-6 Minimum Stop Band Attenuation
118 Chapter 13
Stimulus Response Measurements (ESA Options 1DN and 1DQ)
Making a Reflection Calibration Measurement
S
t
i
m
u
l
u
s

R
e
s
p
o
n
s
e

M
e
a
s
u
r
e
m
e
n
t
s

(
E
S
A

O
p
t
i
o
n
s

1
D
N

a
n
d

1
D
Q
)
Making a Reflection Calibration Measurement
The fol l owi ng procedure makes a refl ecti on measurement usi ng a
coupl er or di recti onal bri dge to measure the return l oss of a fi l ter. Thi s
exampl e uses a 200 MHz bandpass fi l ter as the DUT.
The cal i brati on standard for refl ecti on measur ements i s usual l y a short
ci rcui t connected at the reference pl ane (the poi nt at whi ch the devi ce
under test (DUT) i s connected.) See Fi gure 13-7. A short ci rcui t has a
refl ecti on coeffi ci ent of 1 (0 dB return l oss). I t refl ects al l i nci dent power
and pr ovi des a conveni ent 0 dB reference.
Step 1. Connect the DUT to the di recti onal bri dge or coupl er as shown i n
Fi gure 13-7. Termi nate the unconnected por t of the DUT.
Figure13-7 Reflection Measurement Short Calibration Test Setup
NOTE I f possi bl e, use a coupl er or br i dge wi th the corr ect test port connector
for both cal i br ati ng and measuri ng. Any adapter between the test port
and DUT degr ades coupl er/bri dge di recti vi ty and system source match.
I deal l y, you shoul d use the same adapter for the cal i brati on and the
measur ement. Be sure to termi nate the second port of a two por t devi ce.
Step 2. Connect the tracki ng generator output of the anal yzer to the di recti onal
bri dge or coupl er.
Step 3. Connect the anal yzer i nput to the coupled port of the di recti onal bri dge
or coupl er.
Step 4. Per for m a factor y pr eset:
Press Preset, Factory Preset (i f pr esent).
Chapter 13 119
Stimulus Response Measurements (ESA Options 1DN and 1DQ)
Making a Reflection Calibration Measurement
S
t
i
m
u
l
u
s

R
e
s
p
o
n
s
e

M
e
a
s
u
r
e
m
e
n
t
s

(
E
S
A

O
p
t
i
o
n
s

1
D
N

a
n
d

1
D
Q
)
Step 5. Turn on the tr acki ng gener ator and set the output power to 10 dBm:
Press Source, Amplitude (On), 10, dBm.
CAUTION Excessi ve si gnal i nput may damage the DUT. Do not exceed the
maxi mum power that the devi ce under test can tol erate.
Step 6. Set the center fr equency, span and resol uti on bandwi dth:
Press FREQUENCY Channel, Center Freq, 200, MHz.
Press SPAN X Scale, Span, 100, MHz.
Press BW/Avg, Res BW, 3, MHz.
Step 7. Repl ace the DUT wi th a short ci rcui t.
Step 8. Normal i ze the trace:
View/Trace, More, Normalize, Store Ref (13), Normalize (On).
Thi s acti vates the tr ace 1 mi nus trace 3 functi on and di spl ay the resul ts
i n tr ace 1 (see Fi gure 13-8). The normal i zed trace or fl at l i ne repr esents
0 dB return l oss. Normal i zati on occurs each sweep. Repl ace the short
ci r cui t wi th the DUT.
NOTE Si nce the reference trace i s stor ed i n trace 3, changi ng trace 3 to
Clear Write i nval i dates the normal i zati on.
Figure13-8 Short Circuit Normalized
120 Chapter 13
Stimulus Response Measurements (ESA Options 1DN and 1DQ)
Measuring Return Loss using the Reflection Calibration Routine
S
t
i
m
u
l
u
s

R
e
s
p
o
n
s
e

M
e
a
s
u
r
e
m
e
n
t
s

(
E
S
A

O
p
t
i
o
n
s

1
D
N

a
n
d

1
D
Q
)
Measuring Return Loss using the Reflection
Calibration Routine
Thi s pr ocedure uses the refl ecti on cal i brati on routi ne i n the proceedi ng
pr ocedure Maki ng a Refl ecti on Cal i brati on Measur ement on page 118
to cal cul ate the return l oss of the 200 MHz bandpass fi l ter. See the
concepts secti on Converti ng Return Loss to VSWR on page 160 to fi nd
the VSWR for the measur ed return l oss.
Step 1. After cal i br ati ng the system wi th the above pr ocedur e, r econnect the
fi l ter i n pl ace of the short ci rcui t wi thout changi ng any anal yzer
setti ngs.
Step 2. Use the mar ker to read r etur n l oss. Posi ti on the marker wi th the
fr ont-panel knob to r ead the return l oss at that fr equency:
Press Marker, rotate front-panel knob.
NOTE Or you can use the Mi n Search functi on to measure return l oss by
pr essi ng Peak Search, Min Search, a marker i s pl aced at the poi nt wher e
the return l oss i s maxi mi zed. See Fi gure 13-9.
Figure13-9 Measuring the Return Loss of the Filter
121
D
e
m
o
d
u
l
a
t
i
n
g

a
n
d

V
i
e
w
i
n
g

T
e
l
e
v
i
s
i
o
n

S
i
g
n
a
l
s

(
E
S
A
-
E

S
e
r
i
e
s

O
p
t
i
o
n
B
7
B
)
14 Demodulating and Viewing
Television Signals
(ESA-E Series Option B7B)
122 Chapter 14
Demodulating and Viewing Television Signals (ESA-E Series Option B7B)
Demodulating and Viewing Television Signals
D
e
m
o
d
u
l
a
t
i
n
g

a
n
d

V
i
e
w
i
n
g

T
e
l
e
v
i
s
i
o
n

S
i
g
n
a
l
s

(
E
S
A
-
E

S
e
r
i
e
s

O
p
t
i
o
n
B
7
B
)
Demodulating and Viewing Television Signals
ESA-E Seri es wi th opti on B7B (TV tri gger and pi cture on screen) al l ows
you to tr i gger the sweep of the anal yzer on a speci fi c tel evi si on l i ne of a
demodul ated TV wavefor m. Opti on B7B al so al l ows you to vi ew the
tel evi si on pi cture represented by the TV waveform on the col or LCD
di spl ay of the anal yzer.
Thi s procedure sets up the anal yzer to tri gger on the TV vi deo
waveform and to vi ew the pi cture of the TV si gnal on the anal yzer.
For more i nfor mati on on TV tri gger setup see the concepts chapter TV
Tri gger Setup Menu Functi ons on page 154.
Step 1. Connect a source whi ch contai ns sui tabl e TV carri er si gnal s (for
exampl e, terrestri al broadcast or CATV si gnal s).
Step 2. Di sabl e the background al i gnment process whi l e vi ewi ng TV pi ctures:
Press System, Alignments, Auto Align, Off.
Thi s i s necessar y to prevent the backgr ound al i gnment pr ocess fr om
i nter rupti ng the si gnal paths of the anal yzer duri ng the sweep retrace
per i od so as to mai ntai n a constant, uni nterr upted vi deo wavefor m.
NOTE After vi ewi ng the TV waveform or pi cture, re-enabl e the background
al i gnment pr ocess by pr essi ng System, Alignments, Auto Align, All. I f the
background al i gnment has been di sabl ed for more than 60 mi nutes or
the ambi ent temper atur e has changed more than 3 degrees centi grade,
pr ess System, Alignments, Align Now, All to ensure measurement
accuracy. See the Speci fi cati ons and Char acteri sti cs Chapter for your
anal yzer model i n the speci fi cati ons gui de, for i nformati on about
al i gnment requi rements.
Step 3. Set the center fr equency of the anal yzer to match the TV vi deo carr i er
fr equency and set the span to 20 MHz to captur e the TV channel :
Press FREQUENCY Channel, then enter the desi red val ue and uni ts.
Press SPAN X Scale, Span, 20, MHz.
Step 4. Auto coupl e the anal yzer setti ngs:
Press Auto Couple, Auto All (i f pr esent, newer software onl y).
Step 5. Adjust the reference l evel of the anal yzer to the peak vi deo carri er l evel :
Press AMPLITUDE Y Scale, then use the knob or step keys.
NOTE I f the si gnal i s weak and accompani ed by excessi ve noi se, you may
choose to enabl e the i nternal preamp, i f i nstal l ed, to i mpr ove the
si gnal -to-noi se rati o. Press AMPLITUDE, More, Int Preamp (On).
Chapter 14 123
Demodulating and Viewing Television Signals (ESA-E Series Option B7B)
Demodulating and Viewing Television Signals
D
e
m
o
d
u
l
a
t
i
n
g

a
n
d

V
i
e
w
i
n
g

T
e
l
e
v
i
s
i
o
n

S
i
g
n
a
l
s

(
E
S
A
-
E

S
e
r
i
e
s

O
p
t
i
o
n
B
7
B
)
When vi ewi ng the spectrum, for anal og TV channel s, there shoul d be a
strong, noi se-l i ke vi deo carr i er at the center fr equency, a weaker,
noi se-l i ke chromi nance sub-carri er l ocated 3.58 MHz (NTSC
standard) or 4.3 to 4.4 MHz (PAL or SECAM standards) above the vi deo
car r i er, and a ti ghtl y-grouped sound car ri er l ocated 4.5 to 6.5 MHz
above the vi deo carr i er. I f you ar e vi ewi ng broadcast or cabl e TV
si gnal s, the l ower adjacent channel sound carr i er may be very cl ose to
the vi deo carr i er at the center fr equency.
Step 6. Change the RBW to 3 MHz:
Press BW/Avg, Res BW, 3, MHz.
I f the test si gnal does not have adjacent channel s pr esent, change the
resol uti on bandwi dth to 5 MHz. I f strong adjacent channel si gnal s are
pr esent (pri mari l y the sound carri er of the l ower adjacent channel ), set
the RBW to 1 MHz.
Step 7. Set the ampl i tude scal e type of the anal yzer to l i near:
Press AMPLITUDE Y Scale, Scale Type (Li n).
Step 8. Set the detector mode of the anal yzer to sampl e:
Press Det/Demod, Detector, Sample.
Step 9. Set the anal yzer i n ti me-domai n span:
Press SPAN X Scale, Zero Span.
Step 10. Adjust the reference l evel so that the si gnal peaks are wi thi n hal f of a
di vi si on of the top of the di spl ay.
Press AMPLITUDE Y Scale, then use the knob or arrow keys.
Step 11. Set up the TV tr i gger proper ti es:
Press Trig, TV Trig Setup.
Press Field, Entire Frame, Sync (Pos) (or Sync (Neg) for SECAM si gnal s.
Press Standard, then sel ect the appropri ate standar d for the vi deo
si gnal .
Press TV Source, SA.
Step 12. Enabl e the TV tri gger:
Press Trig, TV.
The defaul t l i ne number for tri ggeri ng can be changed to any val ue
fr om 1 to 525 or fr om 1 to 625, dependi ng on the sel ected vi deo
standar d.
Step 13. Decr ease the sweep ti me to vi ew several TV l i nes (i f you have opti on
AYX or B7D):
Press Sweep, Sweep Time, 500, s.
124 Chapter 14
Demodulating and Viewing Television Signals (ESA-E Series Option B7B)
Demodulating and Viewing Television Signals
D
e
m
o
d
u
l
a
t
i
n
g

a
n
d

V
i
e
w
i
n
g

T
e
l
e
v
i
s
i
o
n

S
i
g
n
a
l
s

(
E
S
A
-
E

S
e
r
i
e
s

O
p
t
i
o
n
B
7
B
)
A ti me domai n di spl ay of the demodul ated TV wavefor m wi l l now be
vi si bl e. The si gnal s used for Fi gure 14-1 were produced by a Phi l l i ps
PM 5518-TX Col or TV Pattern Generator.
Figure14-1 Demodulated RF Waveform
LEFT: NTSC; PAL i s Si mi l ar
RI GHT: SECAM
I f Trig, TV i s the acti ve functi on, the l i ne number used to tri gger the
anal yzer sweep can be changed to exami ne the di fferent parts of the
vi deo waveform. The l i ne numberi ng scheme vari es wi th TV standard,
but TV test patterns wi l l often be i nserted i n or near l i ne 17.
Step 14. Set a l ong sweep ti me of 100 seconds to mi ni mi ze di sr upti on of the
anal og si gnal path duri ng the i nstrument retrace to opti mi ze pi cture
qual i ty:
Press Sweep, Sweep Time, 100, s.
Step 15. To obtai n the best col or pi cture qual i ty wi th NTSC and PAL si gnal s, set
the center frequency 1.75 MHz above the vi deo carri er fr equency:
Press FREQUENCY Channel, CF Step, 1.75, MHz, Center Freq, .
Setti ng the center fr equency above the vi deo carri er frequency centers
the anal yzers tuned frequency between the vi deo car r i er and the col or
subcarri er.
Step 16. Turn on the spectrum anal yzer di spl ay i nto a TV moni tor:
Press Trig, TV Trig Setup, TV Monitor.
Chapter 14 125
Demodulating and Viewing Television Signals (ESA-E Series Option B7B)
Demodulating and Viewing Television Signals
D
e
m
o
d
u
l
a
t
i
n
g

a
n
d

V
i
e
w
i
n
g

T
e
l
e
v
i
s
i
o
n

S
i
g
n
a
l
s

(
E
S
A
-
E

S
e
r
i
e
s

O
p
t
i
o
n
B
7
B
)
Figure14-2 TV Picture Display
When the pi cture i s acti ve, you can adjust the val ue of the functi on that
was acti ve pr i or to enabl i ng the pi ctur e. For exampl e, i f center
fr equency was the acti ve functi on and the fr equency step si ze was set to
the TV channel frequency spaci ng, you can i ncrement or decrement
through the TV channel s by pr essi ng the step keys ( ) of the anal yzer.
I f resol uti on bandwi dth was the acti ve functi on, you can i ncr ease or
decrease the amount of fi l teri ng to deal wi th strong adjacent channel
si gnal s.
NOTE When usi ng the knob to vary the val ue of the acti ve functi on, be aware
that the i nstrument setti ngs wi l l not be updated unti l you stop turni ng
the knob. Make smal l movements of the knob wi th frequent pauses.
126 Chapter 14
Demodulating and Viewing Television Signals (ESA-E Series Option B7B)
Measuring Depth of Modulation
D
e
m
o
d
u
l
a
t
i
n
g

a
n
d

V
i
e
w
i
n
g

T
e
l
e
v
i
s
i
o
n

S
i
g
n
a
l
s

(
E
S
A
-
E

S
e
r
i
e
s

O
p
t
i
o
n
B
7
B
)
Measuring Depth of Modulation
The depth of modul ati on pr ovi des a measure of the percentage of
ampl i tude modul ati on (AM) on the vi sual carri er. Wi th Opti on B7B, the
anal yzer can be used to measure the hori zontal synchroni zati on pul se
l evel and verti cal i nterval test si gnal (VI TS) whi te l evel on an
i ndi vi dual TV l i ne from whi ch a cal cul ati on of percent AM can be made.
Note that thi s measurement method wi l l not be val i d for some types of
scrambl ed vi deo si gnal s.
Thi s procedure measures depth of modul ati on on an i ndi vi dual TV l i ne.
For more i nfor mati on on TV tri gger setup see the concepts chapter TV
Tri gger Setup Menu Functi ons on page 154.
NOTE Before conti nui ng, be sure you have perfor med the steps i n
Demodul ati ng and Vi ewi ng Tel evi si on Si gnal s on page 122 at the
begi nni ng of the secti on to di spl ay a TV waveform wi th l i near scal i ng.
Step 1. Tri gger on a TV l i ne that has a test si gnal contai ni ng the reference
whi te l evel wi thi n the waveform (100 I RE) such as the FCC, NTC-7 or
I TU Composi te Test Si gnal (typi cal l y found at or near l i ne 17 wi thi n
fi el d 1 or fi el d 2):
Press Trig, TV, and enter a l i ne number.
Step 2. Set the sweep ti me to 80 s (opti on AYX or B7D requi red) to vi ew a
compl ete TV l i ne:
Press Sweep, Sweep Time, 80, s.
Step 3. Set the resol uti on bandwi dth and the vi deo bandwi dth to 1 MHz:
Press BW/Avg, Res BW, 1, MHz.
Press BW/Avg, Video BW, 1, MHz.
Step 4. Turn on vi deo averagi ng to 10 averages:
Press BW/Avg, Average (On), 10, Enter.
Thi s mi ni mi zes the waveform vari ati ons caused by the presence of
addi ti onal RF si gnal s near the pi cture carri er, as wel l as waveform
noi se or ji tter.
Step 5. Enabl e a normal marker and usi ng the fr ont-panel knob move the
marker wi thi n the sync ti p (NTSC or PAL waveforms) or the whi te l evel
(SECAM wavefor ms) at the top of the wavefor m:
Press Marker, Normal, then r otate the fr ont-panel knob (or pr ess Peak
Search).
Chapter 14 127
Demodulating and Viewing Television Signals (ESA-E Series Option B7B)
Measuring Depth of Modulation
D
e
m
o
d
u
l
a
t
i
n
g

a
n
d

V
i
e
w
i
n
g

T
e
l
e
v
i
s
i
o
n

S
i
g
n
a
l
s

(
E
S
A
-
E

S
e
r
i
e
s

O
p
t
i
o
n
B
7
B
)
Step 6. Enabl e a del ta marker and usi ng the fr ont-panel knob move the del ta
marker wi thi n the whi te l evel (NTSC or PAL waveforms) or the sync ti p
(SECAM waveforms) at the bottom of the waveform:
Press Marker, Delta, then rotate fr ont-panel knob (or pr ess Peak Search,
Min Search).
Figure14-3 Measuring Marker Delta (%) for Depth of Modulation (NTSC)
The depth of modul ati on (i n percent) can now be determi ned by
subtracti ng the marker readout (i n percent) from 100. A typi cal val ue
woul d be 87.5%.
128 Chapter 14
Demodulating and Viewing Television Signals (ESA-E Series Option B7B)
Measuring Depth of Modulation
D
e
m
o
d
u
l
a
t
i
n
g

a
n
d

V
i
e
w
i
n
g

T
e
l
e
v
i
s
i
o
n

S
i
g
n
a
l
s

(
E
S
A
-
E

S
e
r
i
e
s

O
p
t
i
o
n
B
7
B
)
129
C
o
n
c
e
p
t
s
15 Concepts
130 Chapter 15
Concepts
Resolving Closely Spaced Signals
C
o
n
c
e
p
t
s
Resolving Closely Spaced Signals
Resolving Signals of Equal Amplitude
Two equal -ampl i tude i nput si gnal s that are cl ose i n frequency can
appear as a si ngl e si gnal trace on the anal yzer di spl ay. Respondi ng to a
si ngl e-frequency si gnal , a swept-tuned anal yzer tr aces out the shape of
the sel ected i nternal I F (i ntermedi ate fr equency) fi l ter (typi cal l y
referr ed to as the r esol uti on bandwi dth or RBW fi l ter). As you change
the fi l ter bandwi dth, you change the wi dth of the di spl ayed r esponse. I f
a wi de fi l ter i s used and two equal -ampl i tude i nput si gnal s are cl ose
enough i n frequency, then the two si gnal s wi l l appear as one si gnal . I f a
narr ow enough fi l ter i s used, the two i nput si gnal s can be di scri mi nated
and appear as separate peaks. Thus, si gnal resol uti on i s determi ned by
the I F fi l ters i nsi de the anal yzer.
The bandwi dth of the I F fi l ter tel l s us how cl ose together equal
ampl i tude si gnal s can be and sti l l be di sti ngui shed from each other. The
resol uti on bandwi dth functi on sel ects an I F fi l ter setti ng for a
measurement. Typi cal l y, resol uti on bandwi dth i s defi ned as the 3 dB
bandwi dth of the fi l ter. However, resol uti on bandwi dth may al so be
defi ned as the 6 dB or i mpul se bandwi dth of the fi l ter.
General l y, to resol ve two si gnal s of equal ampl i tude, the resol uti on
bandwi dth must be l ess than or equal to the fr equency separati on of the
two si gnal s. I f the bandwi dth i s equal to the separati on and the vi deo
bandwi dth i s l ess than the resol uti on bandwi dth, a di p of
approxi matel y 3 dB i s seen between the peaks of the two equal si gnal s,
and i t i s cl ear that more than one si gnal i s present.
For ESA spectr um anal yzer s when the r esol uti on bandwi dth i s 1 kHz
and for PSA spectr um anal yzer s i n swept mode, to keep the anal yzer
measur ement cal i br ated, sweep ti me i s automati cal l y set to a val ue
that i s i nversel y proporti onal to the square of the resol uti on bandwi dth
(1/BW
2
). So, i f the resol uti on bandwi dth i s reduced by a factor of 10, the
sweep ti me i s i ncr eased by a factor of 100 when sweep ti me and
bandwi dth setti ngs are coupl ed. For the shortest measur ement ti mes,
use the wi dest resol uti on bandwi dth that sti l l permi ts di scri mi nati on of
al l desi red si gnal s. Sweep ti me i s al so a functi on of whi ch detector i s i n
use, peak detector sweeps as fast or mor e qui ckl y than sampl e or
average detectors. The ESA al l ows you to sel ect fr om 1 kHz to 3 MHz
resol uti on bandwi dths i n a 1, 3, 10 sequence and sel ect a 5 MHz
resol uti on bandwi dth. The PSA al l ows RBW sel ecti ons up to 8 MHz i n
the same steps as ESA and i t has the fl exi bi l i ty to fi ne tune RBWs i n
i ncr ements of 10% for a total of 160 RBW setti ngs. The ESA and PSA
have CI SPR bandwi dths (200 Hz, 9 kHz and 120 kHz at 6 dB) for
maxi mum measurement fl exi bi l i ty. The PSA al so has MI L EMI
bandwi dths of 10 Hz, 100 Hz, 1 kHz, 10 kHz, 100 kHz and 1 MHz.
Chapter 15 131
Concepts
Resolving Closely Spaced Signals
C
o
n
c
e
p
t
s
For best sweep ti mes and keepi ng the anal yzer cal i brated set the sweep
ti me (Sweep, Sweep Time) to Auto, and the auto sweep ti me (Sweep, Auto
Sweep Time) to Norm. Use the wi dest resol uti on bandwi dth that sti l l
permi ts resol uti on of al l desi red si gnal s.
NOTE For ESA-E Series Spectrum Analyzers:
Opti on 1DR adds narr ower resol uti on bandwi dths, from 10 Hz to
300 Hz, i n a 1-3-10 sequence and 200 Hz CI SPR bandwi dth. These
bandwi dths are di gi tal l y i mpl emented and have a much narrower
shape factor than the wi der, anal og resol uti on bandwi dths. Al so, the
auto coupl ed sweep ti mes when usi ng the di gi tal resol uti on bandwi dths
are much faster than anal og bandwi dths of the same wi dth. For
anal yzer s wi th Opti on 1DR, fi rmware revi si on A.08.00 and greater, and
Opti on 1D5 whi ch adds a hi gh-stabi l i ty frequency pr eci si on reference to
the anal yzer, resol uti on bandwi dths of 1 Hz and 3 Hz are al so avai l abl e.
Resolving Small Signals Hidden by Large Signals
When deal i ng wi th the resol uti on of si gnal s that are cl ose together and
not equal i n ampl i tude, you must consi der the shape of the I F fi l ter of
the anal yzer, as wel l as i ts 3 dB bandwi dth. (See Resol vi ng Si gnal s of
Equal Ampl i tude on page 130 for more i nformati on.) The shape of a
fi l ter i s defi ned by the sel ecti vi ty, whi ch i s the rati o of the 60 dB
bandwi dth to the 3 dB bandwi dth. I f a smal l si gnal i s too cl ose to a
l arger si gnal , the smal l er si gnal can be hi dden by the ski rt of the l arger
si gnal .
To vi ew the smal l er si gnal , sel ect a r esol uti on bandwi dth such that k i s
l ess than a (see Fi gure 15-1). The separati on between the two si gnal s
(a) must be greater than hal f the fi l ter wi dth of the l arger si gnal (k),
measured at the ampl i tude l evel of the smal l er si gnal .
The di gi tal fi l ters i n the ESA and PSA have fi l ter wi dths about
one-thi rd as wi de as typi cal anal og RBW fi l ters. Thi s enabl es you to
resol ve cl ose si gnal s wi th a wi der RBW (for a faster sweep ti me).
Figure 15-1 RBW Requirements for Resolving Small Signals
132 Chapter 15
Concepts
Harmonic Distortion Calculations
C
o
n
c
e
p
t
s
Harmonic Distortion Calculations
The anal yzer pr ovi des a one-button automated measurement for
harmoni c measurements (from the second to the tenth harmoni c) and
pr ovi des a cal cul ati on of the total harmoni c di storti on for conti nuous
wave si gnal s or compl ex di gi tal l y modul ated carr i ers.
When the harmoni c di storti on measurement i s acti vated, the anal yzer
searches for the fundamental and determi nes the fr equenci es of the
harmoni cs. The anal yzer then changes to zero span, and measures the
ampl i tude of each harmoni c. The anal yzer cal cul ates the total harmoni c
di storti on by di vi di ng the root-sum-squares of the harmoni c vol tages by
the fundamental si gnal vol tage and then provi des the resul t as a
percentage.
Wher e:
%THD = Total Harmoni c Di storti on as a percentage
h = harmoni c number
H
max
= Maxi mum Harmoni c Val ue l i sted
E
h
= vol tage of harmoni c h
E
f
= vol tage of fundamental si gnal
Example of a THD calculation:
I f the number of harmoni cs sel ected i s 5 (H
max
= 5) and the measured
val ues are as fol l ows:
then,
%THD 100
E
h
2
h 2 =
H
max





E
f
---------------------------- =
E
f
5 dBm 3.162 mW 397.6 mV = = =
E
2
42 dBc 37 dBm 199.5 nW 3.159 mV = = = =
E
3
26 dBc 21 dBm 7.943 W 19.93 mV = = = =
E
4
49 dBc 44 dBm 39.81 nW 1.411 mV = = = =
E
5
36 dBc 31 dBm 794.3 nW 6.302 mV = = = =
THD 100
3.159 mV
2
19.93 mV
2
1.411mV
2
6.301 mV
2
+ + +
397.6 mV
--------------------------------------------------------------------------------------------------------------------------------- 5.33% = =
Chapter 15 133
Concepts
Time Gating Concepts
C
o
n
c
e
p
t
s
Time Gating Concepts
Introduction: Using Time Gating on a Simplified
Digital Radio Signal
Thi s secti on shows you the concepts of usi ng ti me gati ng on a si mpl i fi ed
di gi tal r adi o si gnal . Maki ng Ti me-Gated Measurements on page 57
demonstr ates ti me gati ng exampl es usi ng the ESA and PSA.
Fi gure 15-2 shows a si gnal wi th two radi os, radi o 1 and radi o 2, that are
ti me-shari ng a si ngl e fr equency channel . Radi o 1 transmi ts for 1 ms
then radi o 2 transmi ts for 1 ms.
Figure 15-2 Simplified Digital Mobile-Radio Signal in Time Domain
We want to measure the uni que fr equency spectr um of each
tr ansmi tter.
A spectr um anal yzer wi thout ti me gati ng cannot do thi s. By the ti me
the spectrum anal yzer has compl eted i ts measur ement sweep, whi ch
l asts about 50 ms, the radi o tr ansmi ssi ons swi tch back and forth 25
ti mes. Because the radi os are both transmi tti ng at the same frequency,
thei r frequency spectr a over l ap, as shown i n Fi gure 15-3. The spectr um
anal yzer shows the combi ned spectrum; you cannot tel l whi ch part of
the spectrum r esul ts from whi ch si gnal .
134 Chapter 15
Concepts
Time Gating Concepts
C
o
n
c
e
p
t
s
Figure 15-3 Frequency Spectra of the Combined Radio Signals
Ti me gati ng al l ows you to see the separ ate spectr um of r adi o 1 or
radi o 2 to determi ne the source of the spuri ous si gnal , as shown i n
Fi gure 15-4.
Figure 15-4 Time-Gated Spectrum of Radio 1
Figure 15-5 Time-Gated Spectrum of Radio 2
Ti me gati ng l ets you defi ne a ti me wi ndow (or ti me gate) of when a
measurement i s performed. Thi s l ets you speci fy the part of a si gnal
that you want to measure, and excl ude or mask other si gnal s that
mi ght i nter fer e.
Chapter 15 135
Concepts
Time Gating Concepts
C
o
n
c
e
p
t
s
How Time Gating Works
Ti me gati ng i s achi eved by the spectrum anal yzer sel ecti vel y
i nter rupti ng the path of the detected si gnal , wi th a gate, as shown i n
Fi gure 15-7 and Fi gure 15-8. The gate determi nes the ti mes at whi ch i t
captur es measurement data (when the gate i s turned on, under the
Gate menu, the si gnal i s bei ng passed, otherwi se when the gate i s off,
the si gnal i s bei ng bl ocked). Under the r i ght condi ti ons, the onl y si gnal s
that the anal yzer measures are those present at the i nput to the
anal yzer when the gate i s on. Wi th the cor rect spectr um anal yzer
setti ngs, al l other si gnal s are masked out.
There are typi cal l y two mai n types of gati ng condi ti ons, edge and level:
Wi th edge gati ng, the gate ti mi ng i s contr ol l ed by user parameters
(gate del ay and gate l ength) fol l owi ng the sel ected (r i si ng or fal l i ng)
edge of the tri gger si gnal . The gate passes a si gnal on the edge of the
tr i gger si gnal (after the gate del ay ti me has been met) and bl ocks the
si gnal at the end of the gate l ength.
Wi th edge gati ng, the gate control si gnal i s usual l y an external
peri odi c TTL si gnal that ri ses and fal l s i n synchroni zati on wi th the
ri se and fal l of the pul sed radi o si gnal . The gate del ay i s the ti me the
anal yzer wai ts after the tri gger event to enabl e the gate (see Fi gur e
15-6).
Wi th l evel gati ng, the gate wi l l pass a si gnal when the gate si gnal
meets the speci fi ed l evel (hi gh or l ow). The gate bl ocks the si gnal
when the l evel condi ti ons ar e no l onger sati sfi ed (l evel gati ng does
not use gate l ength or gate del ay par ameter s).
Figure 15-6 Edge Trigger Timing Relationships
Wi th Agi l ent PSA and ESA spectrum anal yzers, there are three
di fferent i mpl ementati ons for ti me gati ng; gated LO, gated vi deo and
gated FFT. Gated LO and gated FFT are onl y avai l abl e on the PSA
spectrum anal yzers whi l e gated vi deo i s onl y avai l abl e on the ESA.
136 Chapter 15
Concepts
Time Gating Concepts
C
o
n
c
e
p
t
s
Gated LO Concepts (PSA Spectrum Analyzers)
Gated LO i s a very sophi sti cated type of ti me gati ng that sweeps the LO
onl y whi l e the gate i s on and the gate i s passi ng a si gnal . See Fi gur e
15-7 for a si mpl i fi ed bl ock di agram of gated LO oper ati on. Noti ce that
the gate contr ol si gnal control s when the scan gener ator i s sweepi ng
and when the gate passes or bl ocks a si gnal . Thi s al l ows the anal yzer to
sweep onl y duri ng the peri ods when the gate passes a si gnal . Si nce
gated LO onl y sweeps duri ng peri ods when the gate i s on and the gate
i s passi ng a si gnal , gated LO resul ts i n faster measurements than gated
vi deo.
Figure 15-7 Gated LO PSA Spectrum Analyzer Block Diagram
NOTE Gated LO i s avai l abl e on al l PSA model s wi th fi rmware rel ease A.04.12
or greater and the appr opri ate hardware. See servi ce notes E4440A-09,
E4443A-08, E4445A-08, E4446A-06 or E4448A-07 for more i nformati on
on the hardware requi rements.
Gated Video Concepts (ESA Spectrum Analyzers)
Gated vi deo may be thought of as a si mpl e gate swi tch, whi ch connects
the si gnal to the i nput of the spectrum anal yzer. When the gate i s on
(under the Gate menu) the gate i s passi ng a si gnal . When the gate i s
off, the gate i s bl ocki ng the si gnal . Whenever the gate i s passi ng a
si gnal , the anal yzer sees the si gnal . I n Fi gure 15-8 noti ce that the gate
i s pl aced after the envel ope detector and before the vi deo bandwi dth
fi l ter i n the I F path (hence gated vi deo).
The RF secti on of the spectrum anal yzer responds to the si gnal . The
sel ecti ve gati ng occur s before the vi deo pr ocessi ng. Thi s means that
there are some l i mi tati ons on the gate setti ngs because of si gnal
response ti mes i n the RF si gnal path.
Chapter 15 137
Concepts
Time Gating Concepts
C
o
n
c
e
p
t
s
Wi th vi deo gati ng the anal yzer i s conti nual l y sweepi ng, i ndependent of
the posi ti on and l ength of the gate. The anal yzer must be swept at a
mi ni mum sweep ti me (see the sweep ti me cal cul ati ons l ater i n thi s
chapter) to capture the si gnal when the gate i s passi ng a si gnal .
Because of thi s, vi deo gati ng i s typi cal l y sl ower than gated LO and
gated FFT.
Figure 15-8 Gated Video ESA Spectrum Analyzer Block Diagram
NOTE Gated vi deo i s avai l abl e onl y on the Agi l ent ESA-E Seri es spectrum
anal yzer s (E4401B, E4402B, E4404B, E4405B and E4407B) wi th opti on
1D6.
Gated FFT Concepts (PSA Spectrum Analyzer)
Gated FFT (Fast-Fouri er Transfor m) i s an FFT measurement whi ch
begi ns when the tr i gger condi ti ons ar e sati sfi ed.
The process of maki ng a spectrum measurement wi th FFTs i s
i nherentl y a gated pr ocess, i n that the spectr um i s computed fr om a
ti me r ecord of shor t dur ati on, much l i ke a gate si gnal i n swept-gated
anal ysi s.
Usi ng the PSA i n FFT mode, the durati on of the ti me record to be gated
i s:
The durati on of the ti me record i s wi thi n a tol erance of approxi matel y
3% for resol uti on bandwi dths up through 1 MHz. Unl i ke swept gated
anal ysi s, the durati on of the anal ysi s i n gated FFT i s fi xed by the RBW,
not by the gate si gnal . Because FFT anal ysi s i s faster than swept
anal ysi s (up to 10 MHz), the gated FFT measurements can have better
fr equency resol uti on (a narr ower RBW) than swept anal ysi s for a gi ven
durati on of the si gnal to be anal yzed.
FFT Time Record (to be gated)
1.83
RBW
------------- =
138 Chapter 15
Concepts
Time Gating Concepts
C
o
n
c
e
p
t
s
Figure 15-9 Gated FFT Timing Diagram
Time Gating Basics (Gated LO and Gated Video)
The gate passes or bl ocks a si gnal wi th the fol l owi ng condi ti ons:
Tri gger condi ti on - Usual l y an external transi stor-transi stor l ogi c
(TTL) peri odi c si gnal for edge tri gger i ng and a hi gh/l ow TTL si gnal
for l evel tri ggeri ng.
Gate del ay - The ti me after the tr i gger condi ti on i s met when the
gate wi l l pass a si gnal (for edge tri gger i ng).
Gate l ength - The gate l ength setti ng determi nes the l ength of ti me a
gate wi l l pass a si gnal (for edge tri gger i ng).
To under stand ti me gati ng better, consi der a spectr um measurement
performed on two pul sed-RF si gnal s shar i ng the same frequency
spectrum. You wi l l need to consi der the ti mi ng i nteracti on of three
si gnal s wi th thi s exampl e:
The composi te of the two pul sed-RF si gnal s.
Chapter 15 139
Concepts
Time Gating Concepts
C
o
n
c
e
p
t
s
The gate tri gger si gnal (a peri odi c TTL l evel si gnal ).
The gate si gnal . Thi s TTL si gnal i s l ow when the gate i s "off"
(bl ocki ng) and hi gh when the gate i s "on" (passi ng).
The ti mi ng i nteracti ons between the three si gnal s are best understood
i f you observe them i n the ti me domai n (see Fi gure 15-10).
The mai n goal i s to measure the spectr um of si gnal 1 and determi ne i f i t
has any l ow-l evel modul ati on or spuri ous si gnal s.
Because the pul se tr ai ns of si gnal 1 and si gnal 2 have al most the same
carri er frequency, thei r spectr a overl ap. Si gnal 2 wi l l domi nate i n the
fr equency domai n due to i ts gr eater ampl i tude. Wi thout gati ng, you
won't see the spectrum of si gnal 1; i t i s masked by si gnal 2.
To measur e si gnal 1, the gate must be on onl y duri ng the pul ses from
si gnal 1. The gate wi l l be off at al l other ti mes, thus excl udi ng al l other
si gnal s. To posi ti on the gate, set the gate del ay and gate l ength, as
shown i n Fi gure 15-10, so that the gate i s on onl y dur i ng some centr al
par t of the pul se. Car eful l y avoi d posi ti oni ng the gate over the r i si ng or
fal l i ng pul se edges. When gati ng i s acti vated, the gate output si gnal
wi l l i ndi cate actual gate posi ti on i n ti me, as shown i n the l i ne l abel ed
"Gate."
Figure 15-10 Timing Relationship of Signals During Gating
Once the spectrum anal yzer i s set up to perform the gate measurement,
the spectrum of si gnal 1 i s vi si bl e and the spectr um of si gnal 2 i s
excl uded, as shown i f Fi gure 15-12. I n addi ti on, when vi ewi ng si gnal 1,
you al so wi l l have el i mi nated the pul se spectrum generated fr om the
pul se edges. Gati ng has al l owed you to vi ew spectral components that
otherwi se woul d be hi dden.
140 Chapter 15
Concepts
Time Gating Concepts
C
o
n
c
e
p
t
s
Figure 15-11 Signal within pulse #1 (time-domain view)
Figure 15-12 Using Time Gating to View Signal 1 (spectrum view)
Movi ng the gate so that i t i s posi ti oned over the mi ddl e of si gnal 2
pr oduces a r esul t as shown i n Fi gure 15-14. Her e, you see onl y the
spectrum wi thi n the pul ses of si gnal 2; si gnal 1 i s excl uded.
Figure 15-13 Signal within pulse #2 (time-domain view)
Figure 15-14 Using Time Gating to View Signal 2 (spectrum view)
Chapter 15 141
Concepts
Time Gating Concepts
C
o
n
c
e
p
t
s
Measuring a Complex/Unknown Signal
NOTE The steps bel ow hel p to determi ne the spectr um anal yzer setti ngs when
usi ng ti me gati ng. The steps appl y to the ti me gati ng approaches usi ng
gated LO on the PSA and gated vi deo on the ESA.
Thi s exampl e shows you how to use ti me gati ng to measure a very
speci fi c si gnal . Most si gnal s requi ri ng ti me gati ng are fai r l y compl ex
and i n some cases extra steps may be r equi r ed to per form a
measurement.
Step 1. Deter mi ne how your si gnal under test appear s i n the ti me domai n and
how i t i s synchroni zed to the tri gger si gnal .
You need to do thi s to posi ti on the ti me gate by setti ng the del ay
rel ati ve to the tri gger si gnal . To set the del ay, you need to know the
ti mi ng rel ati onshi p between the tr i gger and the si gnal under test.
Unl ess you al r eady have a good i dea of how the two si gnal s l ook i n the
ti me domai n, you can exami ne the si gnal s wi th an osci l l oscope to
determi ne the fol l owi ng parameters:
Tri gger type (edge or l evel tri ggeri ng)
Pul se repeti ti on i nterval (PRI ), whi ch i s the l ength of ti me between
tr i gger events (the tr i gger per i od).
Pul se wi dth, or
Si gnal del ay (SD), whi ch i s the l ength of ti me occurri ng between the
tr i gger event and when the si gnal i s present and stabl e. I f your
tr i gger occurs at the same ti me as the si gnal , si gnal del ay wi l l be
zero.
142 Chapter 15
Concepts
Time Gating Concepts
C
o
n
c
e
p
t
s
Figure 15-15 Time-domain Parameters
I n Fi gure 15-15, the parameters ar e:
Pul se repeti ti on i nterval (PRI ) i s 5 ms.
Pul se wi dth () i s 3 ms.
Si gnal del ay (SD) i s 1 ms for posi ti ve edge tr i gger (0.8 ms for
negati ve edge tri gger ).
Gate del ay (D) i s 2.5 ms.
Setup ti me (SUT) i s 1.5 ms.
Step 2. Set the spectr um anal yzer sweep ti me:
PSA: Sweep ti me does not affect the r esul ts of gated LO unl ess the
sweep ti me i s set too fast. I n the event the sweep ti me i s set too fast,
Meas Uncal appears on the screen and the sweep ti me wi l l need to be
i ncr eased.
ESA: Sweep ti me does affect the r esul ts fr om gated vi deo. The sweep
ti me must be set accor di ngl y for cor r ect ti me gati ng r esul ts. The sweep
ti me shoul d be set to at l east the number of sweep points - 1 mul ti pl i ed
by the PRI (pulse repetition interval).
Step 3. Locate the si gnal under test on the di spl ay of the spectrum anal yzer.
Set the center fr equency and span to vi ew the si gnal char acter i sti cs
that you are i nterested i n measur i ng. Al though the anal yzer i s not yet
confi gured for corr ect gated measurements, you wi l l want to determi ne
the approxi mate frequency and span i n whi ch to di spl ay the si gnal of
i nter est. I f the si gnal i s er r ati c or i nter mi ttent, you may want to hol d
the maxi mum val ue of the si gnal wi th Max Hold (l ocated under the
Chapter 15 143
Concepts
Time Gating Concepts
C
o
n
c
e
p
t
s
View/Trace (ESA) or Trace/View (PSA) menu) to determi ne the frequency
of peak energy.
To opti mi ze measurement speed, set the span narrow enough so that
the di spl ay wi l l sti l l show the si gnal characteri sti cs you want to
measure. For exampl e, i f you wanted to l ook for spuri ous si gnal s wi thi n
a 200 kHz frequency range, you mi ght set the fr equency span to just
over 200 kHz.
Step 4. Determi ne the setup ti me and si gnal del ay to set up the gate si gnal .
Turn on the gate and adjust the gate parameters i ncl udi ng gate del ay
and gate l ength as shown bel ow.
General l y, the gate shoul d be posi ti oned over a part of the si gnal that i s
stabl e, not over a pul se edge or other transi ti on that mi ght di sturb the
spectrum. Starti ng the gate at the center of the pul se gi ves a setup ti me
of about hal f the pul se wi dth. Setup ti me descri bes the l ength of ti me
duri ng whi ch that si gnal i s present and stabl e before the gate comes on.
The setup ti me (SUT) must be adequatel y l ong enough for the RBW
fi l ter s to settl e fol l owi ng the burst-on transi ents. Si gnal del ay (SD) i s
the l ength of ti me after the tr i gger, but before the si gnal of i nterest
occurs and becomes stabl e. I f the tri gger occurs si mul taneousl y wi th the
si gnal of i nterest, SD i s equal to zero, and SUT i s equal to the gate
del ay. Otherwi se, SUT i s equal to the gate del ay mi nus SD. See Fi gur e
15-16.
Figure 15-16 Positioning the Gate
There i s fl exi bi l i ty i n posi ti oni ng the gate, but some posi ti ons offer a
wi der choi ce of resol uti on bandwi dths. A good rul e of thumb i s to
posi ti on the gate fr om 20% to 80% of the burst for PSA, and 25% to 80%
of the burst for ESA. Doi ng so provi des a reasonabl e compromi se
between setup ti me and gate l ength.
144 Chapter 15
Concepts
Time Gating Concepts
C
o
n
c
e
p
t
s
Figure 15-17 Best Position for Gate
As a general rul e, you wi l l obtai n the best measurement resul ts i f you
posi ti on the gate rel ati vel y l ate wi thi n the si gnal of i nterest, but
wi thout extendi ng the gate over the tr ai l i ng pul se edge or si gnal
tr ansi ti on. Doi ng so maxi mi zes setup ti me and provi des the resol uti on
bandwi dth fi l ter s of the spectr um anal yzer the most ti me to settl e
before a gated measur ement i s made. "Rel ati vel y l ate," i n thi s case,
means al l owi ng a setup ti me of approxi matel y 2 di vi ded by the
resol uti on bandwi dth (see step 5 for RBW cal cul ati ons).
As an exampl e, i f you want to use a 1 kHz resol uti on bandwi dth for
measurements, you wi l l need to al l ow a setup ti me of at l east 2 ms.
Note that the si gnal need not be an RF pul se. I t coul d be si mpl y a
parti cul ar peri od of modul ati on i n a si gnal that i s conti nuousl y
operati ng at ful l power, or i t coul d even be duri ng the off ti me between
pul ses. Dependi ng on your speci fi c appl i cati on, adjust the gate posi ti on
to al l ow for progressi vel y l onger setup ti mes (ensuri ng that the gate i s
not l eft on over another si gnal change such as a pul se edge or
tr ansi ent), and sel ect the gate del ay and l ength that offer the best
si gnal -to-noi se rati o on the di spl ay.
I f you were measuri ng the spectr um occurri ng between pul ses, you
shoul d use the same (or l onger) setup ti me after the pul se goes away,
but before the gate goes on. Thi s l ets the resol uti on bandwi dth fi l ters
ful l y di scharge the l arge pul se before the measurement i s made on the
l ow-l evel i nterpul se si gnal .
Figure 15-18 Setup Time for Interpulse Measurement
Chapter 15 145
Concepts
Time Gating Concepts
C
o
n
c
e
p
t
s
Step 5. The resol uti on bandwi dth wi l l need to be adjusted for gated LO and
gated vi deo. The vi deo bandwi dth wi l l onl y need to be adjusted for gated
vi deo.
Resolution Bandwidth:
The resol uti on bandwi dth you can choose i s determi ned by the gate
posi ti on, so you can tr ade off l onger setup ti mes for nar r ower r esol uti on
bandwi dths. Thi s trade-off i s due to the ti me requi r ed for the
resol uti on-bandwi dth fi l ter s to ful l y charge before the gate comes on.
Setup ti me, as menti oned, i s the l ength of ti me that the si gnal i s
pr esent and stabl e before the gate comes on.
Figure 15-19 Resolution Bandwidth Filter Charge-Up Effects
Because the resol uti on-bandwi dth fi l ters are band-l i mi ted devi ces, they
requi r e a fi ni te amount of ti me to react to changi ng condi ti ons.
Speci fi cal l y, the fi l ters take ti me to charge ful l y after the anal yzer i s
exposed to a pul sed si gnal .
Because setup ti me shoul d be greater than fi l ter char ge ti mes, be sur e
that: and

where SUT i s the same as the gate del ay i n thi s exampl e. I n thi s
exampl e wi th SUT equal to 1.5 ms, for ESA, RBW i s greater than 2/1.5
ms; that i s, RBW i s greater than 1333 Hz. The resol uti on bandwi dth
shoul d be set to the next l arger val ue, 3 kHz.
Video Bandwidth:
Just as the resol uti on bandwi dth fi l ter needs a fi ni te amount of ti me to
charge and di scharge, so does the vi deo fi l ter, whi ch i s a post-detecti on
fi l ter used mai nl y to smooth the measurement trace. Regardl ess of the
l ength of the real RF pul se, the vi deo fi l ter sees a pul se no l onger than
the gate l ength, and the fi l ter wi l l spend part of that ti me chargi ng up.
ESA ( )SUT
2
RBW
------------ - > PSA ( )SUT
2.16
RBW
------------- 3.3s + >
PSA ( )Gate Length
3
RBW
------------- 1.5s + >
146 Chapter 15
Concepts
Time Gating Concepts
C
o
n
c
e
p
t
s
Reduci ng the vi deo-bandwi dth fi l ter too fast causes the si gnal to appear
to dr op i n ampl i tude on the screen.
I f you are i n doubt about the pr oper vi deo bandwi dth to choose, set i t to
i ts maxi mum and reduce i t gradual l y unti l the detected si gnal l evel
dr ops sl i ghtl y. Then reset i t to the val ue i t was at just before the si gnal
dr opped.
Leave both RBW and VBW i n the manual mode, not Auto. Thi s i s
i mpor tant so that they wi l l not change i f the span i s changed. The
setti ng readout on the bottom l i ne of the anal yzer screen shoul d show a
"#" si gn next to the functi on names (for exampl e, #Res BW, #VBW, and
#Sweep), i ndi cati ng that they have been set manual l y.
Setting the ESA VBW:
To ensure that a true peak val ue i s obtai ned before the gate goes off, the
vi deo fi l ter must have a char ge ti me of l ess than the gate l ength. For
thi s purpose, you can approxi mate the charge ti me of the vi deo fi l ter as
1/VBW, where VBW i s the 3 dB bandwi dth of the vi deo fi l ter.
Therefor e, you wi l l want to be sure that:
For exampl e usi ng ESA, i f you use a 1 kHz vi deo bandwi dth for noi se
smoothi ng, you need a gate l ength gr eater than 1 ms. Al ternati vel y, i f
you use a gate as narrow as 1 s, you shoul d use a vi deo fi l ter of 1 MHz.
Setting the PSA VBW:
For gated LO measurements the VBW fi l ter acts as a track-and-hol d
between sweep ti mes. Wi th thi s behavi or, the VBW does not need to
resettl e on each r estar t of the sweep.
Step 6. Adjust span as necessary, and perform your measurement.
The anal yzer i s set up to perform accurate measurements. Fr eeze the
tr ace data by acti vati ng si ngl e sweep, or by pl aci ng your acti ve trace i n
vi ew mode. Use the markers to measure the si gnal parameters you
chose i n step 1. I f necessary, adjust span, but do not decr ease resol uti on
bandwi dth, vi deo bandwi dth, or sweep ti me.
gate length
1
ESA ( )VBW
----------------------------- >
Chapter 15 147
Concepts
Time Gating Concepts
C
o
n
c
e
p
t
s
"Quick Rules" for Making Time-Gated Measurements
Thi s secti on summar i zes the r ul es descr i bed i n the pr evi ous secti ons.
Table 15-1 Determining Spectrum Analyzer Settings for Viewing a Pulsed
RF Signal
Spectrum
Analyzer
Function
Spectrum Analyzer Setting Comments
Sweep Ti me
(gated vi deo
onl y - ESA)
Set the sweep ti me to be equal
to or greater than
(number of sweep poi nts - 1)
pul se repeti ti on i nterval (PRI ):
Because the gate must be on at l east
once per trace poi nt, the sweep ti me
shoul d be set such that the sweep ti me
for each trace poi nt i s greater than or
equal to the pul se repeti ti on i nterval .
Gate Del ay The gate del ay i s equal to the
si gnal del ay pl us one-fourth the
pul se wi dth:
Gate Del ay = Si gnal Del ay + /4
The gate del ay must be set so that the
gati ng captures the pul se. I f the gate
del ay i s too short or too l ong, the gati ng
can mi ss the pul se or i ncl ude resol uti on
bandwi dth transi ent responses.
Gate Length The gate l ength mi ni mum i s
equal to one-fourth the pul se
wi dth (maxi mum about
one-hal f):
Gate Length = /4
(PSA) Gate Length > 3/RBW +
1.5 s
I f the gate l ength i s too l ong, the si gnal
di spl ay can i ncl ude transi ents caused by
the spectrum anal yzer fi l ters.
The recommendati on for gate pl acement
can be between 20% to 80% of the pul se
for PSA and 25% to 80% of the pul se for
ESA.
Resol uti on
Bandwi dth
Set the resol uti on bandwi dth:
(ESA) RBW > 2/(Gate Del ay
Si gnal Del ay)
(PSA) RBW > 2.16/(Gate Del ay
Si gnal Del ay) + 3.3 s
The resol uti on bandwi dth must be wi de
enough so that the chargi ng ti me for the
resol uti on bandwi dth fi l ters i s l ess than
the pul se wi dth of the si gnal .
Vi deo
Bandwi dth
Set the vi deo bandwi dth:
(ESA) VBW > 1/gate l ength
The vi deo bandwi dth must be wi de
enough so that the ri se ti mes of the vi deo
bandwi dth does not attenuate the si gnal
(i n gated vi deo appl i cati ons). There are
no requi rements for PSA VBW setti ngs
usi ng gated LO.
148 Chapter 15
Concepts
Time Gating Concepts
C
o
n
c
e
p
t
s
Figure 15-20 Gate Positioning Parameters
Most contr ol setti ngs ar e deter mi ned by two key par ameter s of the
si gnal under test: the pul se repeti ti on i nterval (PRI ) and the pul se
wi dth (). I f you know these parameters, you can begi n by pi cki ng some
standar d setti ngs. Tabl e 15-2 and Tabl e 15-3 summar i ze the
parameters for a si gnal whose tr i gger event occurs at the same ti me as
the begi nni ng of the pul se (i n other words, SD i s 0). I f your si gnal has a
non-zero del ay, just add i t to the r ecommended gate del ay.
Table 15-2 Suggested Initial Settings for Known Pulse Width () and Zero
Signal Delay
Pulse width () Gate Delay
(SD +/2)
Resolution
Bandwidth
(2>SUT)
Gate Length
(/4)
Video Bandwidth
(1/gate length)
ESA gated video
only
4 s 3 s 1 MHz 1 s 1 MHz
10 s 5 s 1 MHz 3 s 1 MHz
50 s 25 s 100 kHz 13 s
100 kHz
63.5 s 32 s 100 kHz 16 s 100 kHz
100 s 50 s 100 kHz 25 s 100 kHz
500 s 250 s 10 kHz 125 s 10 kHz
1 ms 500 s 10 kHz 250 s 10 kHz
5 ms 2.5 ms 1 kHz 1.25 ms 1 kHz
10 ms 5 ms 1 kHz 2.5 ms 1 kHz
16.6 ms 8.3 ms 1 kHz 4 ms 1 kHz
33 ms 16.5 ms 1 kHz 8 ms 1 kHz
50 ms 25 ms 1 kHz 13 ms 1 kHz
100 ms 50 ms 1 kHz 25 ms 1 kHz
130 ms 65 ms 1 kHz 33 ms 1 kHz
Chapter 15 149
Concepts
Time Gating Concepts
C
o
n
c
e
p
t
s
NOTE Tabl e 15-3 bel ow appl i es onl y to ESA spectrum anal yzers. PSA gated
LO ti me gati ng i s not affected by anal yzer sweep ti mes (unl ess the
sweep ti me i s set too fast, Meas Uncal appears on the scr een and the
sweep ti me wi l l need to be i ncr eased).
Table 15-3 Suggested Sweep Times for an ESA at 401 Sweep Points and a
Known Pulse Repetition Interval or Pulse Repetition
Frequency
Pulse Repetition
Interval (PRI)
Pulse Repetition
Frequency (PRF)
Sweep Time (minimum)*
50 s 20 kHz 20.1 ms
100 s 10 kHz 40.1 ms
500 s 2 kHz 201 ms
1 ms 1 kHz 401 ms
5 ms 200 Hz 2.01 s
10 ms 100 Hz 4.01 s
16.7 ms 60 Hz 6.7 s
20 ms 50 Hz 8.02 s
33.3 ms 30 Hz 13.4 s
50 ms 20 Hz 20.1 s
100 ms 10 Hz 40.1 s
>170 ms Use the MAX HOLD tr ace functi on and take several measur ement sweeps.
* The number of sweep poi nts can be set to val ues between 101 and 8192. The mi ni mum
sweep ti me i s equal to the (number of sweep poi nts mi nus 1) ti mes (pul se repeti ti on
i nterval ).
Table 15-4 If You Have a Problem with the Time-Gated Measurement
Symptom Possible Causes Suggested Solution
(ESA onl y) Errati c anal yzer
trace wi th random verti cal
l i nes or dropouts extendi ng
bel ow the peak trace
ampl i tude.
1) Sweep rate too fast to
ensure at l east one gate
occurrence per trace poi nt.
2) Detector may be set to
somethi ng other than peak,
sampl e or average.
I ncrease sweep ti me unti l
dropouts di sappear. See
Tabl e 15-3 for sweep ti me
cal cul ati ons.
150 Chapter 15
Concepts
Time Gating Concepts
C
o
n
c
e
p
t
s
Errati c anal yzer trace wi th
dropouts that are not
removed by i ncreasi ng
anal yzer sweep ti me;
osci l l oscope vi ew of gate
output si gnal jumps
errati cal l y i n ti me domai n.
Gate Del ay may be greater
than tri gger repeti ti on
i nterval .
Reduce Gate Del ay unti l i t
i s l ess than tri gger i nterval .
For PSA check Gate View to
make sure the gate del ay i s
ti med properl y.
Gate does not tri gger. 1) Gate tri gger vol tage may
be too l ow.
2) Gate may not be
acti vated.
3) (PSA) Gate Source
sel ecti on may be wrong.
Ensure gate tri gger reaches
TTL l evel s. Check to see i f
other connecti ons to tri gger
si gnal may be reduci ng
vol tage. I f usi ng an
osci l l oscope, check that al l
i nputs are hi gh i mpedance,
not 50 .
Di spl ay spectrum does not
change when the gate i s
turned on.
I nsuffi ci ent setup ti me. I ncrease setup ti me for the
current resol uti on
bandwi dth, or i ncrease
resol uti on bandwi dth.
Di spl ayed spectrum too l ow
i n ampl i tude.
Resol uti on bandwi dth or
vi deo bandwi dth fi l ters not
chargi ng ful l y.
Wi den resol uti on
bandwi dth or vi deo
bandwi dth, or both.
Table 15-4 If You Have a Problem with the Time-Gated Measurement
Symptom Possible Causes Suggested Solution
Chapter 15 151
Concepts
Time Gating Concepts
C
o
n
c
e
p
t
s
Using the Edge Mode or Level Mode for Triggering
NOTE PSA spectrum anal yzers use edge mode tr i ggeri ng. ESA spectrum
anal yzer s can use edge or l evel tr i gger i ng modes.
Dependi ng on the tri gger si gnal that you are worki ng wi th, you can
tr i gger the gate i n one of two separ ate modes: edge or l evel . Thi s
gate-tri gger functi on i s separate from the normal external tri gger
capabi l i ty of the spectrum anal yzer, whi ch i ni ti ates a sweep of a
measurement tr ace based on an external TTL si gnal .
Edge Mode
Edge mode l ets you posi ti on the gate rel ati ve to ei ther the ri si ng or
fal l i ng edge of a TTL tr i gger si gnal . The l eft di agram of Fi gure 15-21
shows tri gger i ng on the posi ti ve edge of the tr i gger si gnal whi l e the
ri ght di agr am shows negati ve edge tri gger i ng.
Exampl e of key pr esses to i ni ti ate posi ti ve edge tr i ggeri ng:
(ESA) Pr ess Sweep, Gate, Edge Gate, Slope (Pos).
(PSA) Pr ess Sweep, Gate Setup, Polarity (Pos).
Figure 15-21 Using Positive or Negative Edge Triggering
Level Mode (ESA)
I n l evel gate-contr ol mode, an external tri gger si gnal opens and cl oses
the gate. Ei ther the TTL hi gh l evel or TTL l ow l evel opens the gate,
dependi ng on the setti ng of Level Gate. Gate del ay and gate l ength
control functi ons ar e not appl i cabl e when usi ng l evel mode tri gger i ng.
Level mode i s useful when your tr i gger si gnal occurs at exactl y the
same ti me as does the porti on of the si gnal you want to measur e.
152 Chapter 15
Concepts
Time Gating Concepts
C
o
n
c
e
p
t
s
Noise Measurements Using Time Gating
Ti me gati ng can be used to measure many types of si gnal s. However,
they must be repeti ti ve and for ESA, have a TTL ti mi ng tri gger si gnal
avai l abl e to synchroni ze the gate. Noi se i s not a repeti ti ve si gnal , so i f
you need to use gati ng when measuri ng noi se, you shoul d under stand
the i mpact on the measurement resul ts.
To measur e the power accuratel y of a noi sy si gnal , or noi se-l i ke si gnal
wi th ti me gati ng, a sampl e or average detector shoul d be used. Average
and sampl e detecti on i s avai l abl e for both ESA and PSA spectrum
anal yzer s when ti me gati ng i s on.
I f peak detecti on i s used dur i ng a gated measurement the power
readi ng wi l l be hi gher than i f average detecti on i s used. The resul ti ng
val ue i ncr eases as the ti me i nterval i ncreases, because the probabi l i ty
of fi ndi ng the stati sti cal l y rar er l ar ger peaks i ncr eases. For ver y
accurate noi se measurements usi ng the gated functi on, the i mpact of
these consi derati ons must be cal cul ated based on the curr ent spectrum
anal yzer setti ngs.
The equati on bel ow can be used to cal cul ate a corr ecti on val ue for the
measured noi se usi ng peak detecti on. Subtract the corr ecti on fr om the
measur ed val ue.
where:
BW
i
i s the i mpul se bandwi dth
ESA i s approxi matel y 1.62 resol uti on bandwi dth, for
resol uti on bandwi dths 1 kHz.
PSA i s approxi matel y 1.5 r esol uti on bandwi dth, for
resol uti on bandwi dths 3 MHz.
i s the ti me i nterval over whi ch the peak detecti on
occur s and i s equal to the sweep ti me/(number of sweep
poi nts 1).
Refer to Agi l ent Technol ogi es Appl i cati on Note 1303, page 18, for more
detai l s.
Correction 10 log
10
2BW
i
e + ( ) ln [ ] =
Chapter 15 153
Concepts
Trigger Concepts
C
o
n
c
e
p
t
s
Trigger Concepts
Selecting a Trigger
NOTE I f you ar e usi ng an ESA wi th fi r mwar e r evi si on A.07.xx or l ower, you
can use vi deo and external tr i ggeri ng as set up bel ow i n numbers 1 and
2. I f you have fi rmware A.08.xx or l ater and Opti on B7E wi th boar d
part number E4401-60224 or hi gher, RF burst tr i ggeri ng i s al so
avai l abl e (recommended for thi s exampl e). PSA can use vi deo, external
and RF burst tri gger i ng.
To determi ne the ESA fi r mware revi si on number and har dwar e boar d
part number:
Press System, More, Show System.
Press System, More, Show Hdwr.
1. Video Triggering
Vi deo tr i gger i ng contr ol s the sweep ti me based on the detected and
VBW fi l tered envel op si gnal to steady the bursted si gnal on the
di spl ay and to synchroni ze the measurement wi th the burst of
i nterest. Vi deo tri ggeri ng tri ggers the measurement at the poi nt at
whi ch the ri si ng si gnal cr osses the vi deo tri gger hori zontal green l i ne
on the di spl ay:
Press Trig, Video, 30, dBm.
2. External Triggering
I n the event that you have an external tr i gger avai l abl e that can be
used to synchroni ze wi th the burst of i nterest, connect the tri gger
si gnal to the rear of the ESA usi ng the GATE TRIG/EXT TRIG IN
(TTL) i nput connector. For the PSA use ei ther the tr i gger i nput
connector on the fr ont (EXT TRIGGER IN) or the r ear (TRIGGER IN) of
the i nstr ument. I t mi ght be necessar y to adjust the tri gger l evel (as
i ndi cated by the l ower hori zontal gr een l i ne) by rotati ng the front
panel knob or by enteri ng the numeri c val ue on the keypad.
(ESA) Pr ess Trig, External.
(PSA) Pr ess Trig, Ext Front or Ext Rear.
3. RF Burst Triggering
RF burst tri ggeri ng occurs i n the I F ci rcui try chai n, as opposed to
after the vi deo detecti on ci rcui tr y wi th vi deo tri ggeri ng. I n the event
vi deo tri ggeri ng i s used, the detecti on fi l ters are l i mi ted to the
maxi mum wi dth of the resol uti on bandwi dth fi l ters. Set the anal yzer
i n RF burst tr i gger mode (RF bur st i s a defaul t tr i gger for PSA):
Press Trig, RF Burst.
154 Chapter 15
Concepts
Trigger Concepts
C
o
n
c
e
p
t
s
TV Trigger
TV Trigger Setup Menu Functions
TV Source
When TV Source i s set to SA, the anal yzer demodul ates the TV
si gnal , by usi ng the anal yzer as a fi xed tuned recei ver. Thi s al l ows
stabl e, zer o span sweeps of the baseband vi deo waveform (band
l i mi ted by the RBW and VBW fi l ters).
When TV Source i s set to EXT VIDEO IN, an external baseband vi deo
si gnal may be used to produce the TV l i ne tri gger. I n thi s case, an
external TV tuner can be used to obtai n the baseband waveform of
the gi ven RF carri er for tr i ggeri ng the anal yzer sweep. Thi s wi l l
al l ow the anal yzer to be used i n swept mode for measurements of the
RF spectrum to synchroni ze to the vi deo modul ati on. The EXT VIDEO
IN connector i s l ocated on the rear panel of the anal yzer.
TV Standard
Sel ecti on of a TV standard establ i shes the number of TV l i nes and
the ki nd of col or encodi ng method that i s used. The number of TV
l i nes establ i shes the defaul ts for the TV l i ne counti ng ci r cui ts of the
anal yzer and the col or encodi ng method i s used to pr operl y set up
the TV pi cture di spl ay ci rcui ts. Opti on B7B supports both 525 l i ne
and 625 l i ne systems and can provi de a col or TV pi cture output for
NTSC and PAL col or encodi ng methods. A bl ack and whi te pi cture i s
pr ovi ded for the SECAM method.
The abi l i ty to di spl ay a col or pi cture i s l i mi ted by the bandwi dth
setti ngs of the anal yzer (resol uti on bandwi dth and vi deo
bandwi dth). However, baseband vi deo si gnal s i nput to the EXT
VI DEO I N connector on the rear panel of the anal yzer are mi ni mal l y
fi l ter ed, al l owi ng a ful l col or di spl ay of NTSC or PAL TV si gnal s.
Table 15-5
TV Standard Number of
Lines per
Frame
Approximate
Field Rate
Color
Encoding
Method
Color
Subcarrier
Frequency
NTSC-M 525 60 Hz NTSC 3.58 MHz
NTSC-Japan
(no pedestal )
525 60 Hz NTSC 3.58 MHz
PAL-M 525 60 Hz PAL 4.43 MHz
PAL-B,D,G,H,I 625 50 Hz PAL 4.43 MHz
PAL-N 625 50 Hz PAL 4.43 MHz
PAL-N
Combi nati on
625 50 Hz PAL 3.58 MHz
Chapter 15 155
Concepts
Trigger Concepts
C
o
n
c
e
p
t
s
Field
A tel evi si on i mage or frame i s composed of 525 (or 625 l i nes)
del i vered i n two successi ve fi el ds of 262.5 (or 312.5 l i nes) i nterl aced
together on a CRT when di spl ayed.
When Field i s set to Entire Frame, the l i ne count starts at l i ne one i n
fi el d one (often refer r ed to as the odd fi el d) and ends at 525 (or 625)
i n fi el d two (often refer r ed to as the even fi el d).
When Field i s set to Field One or Field Two, the l i ne count begi ns at 1
wi th the fi r st ful l l i ne i n the sel ected fi el d and ends at count 263 (or
313) for Fi el d One, and 262 (or 312) for Fi el d Two.
Sync
Anal og broadcast or cabl e tel evi si on si gnal s ar e usual l y ampl i tude
modul ated on an RF car r i er. For NTSC and PAL br oadcasts,
typi cal l y the RF carr i er ampl i tude i s maxi mi zed at the sync ti ps of
the baseband vi deo waveform and mi ni mi zed at the whi te l evel .
Thi s resul ts i n a demodul ated waveform on the anal yzer where the
sync pul ses are on top, or posi ti ve (Sync (Pos)).
Wi th SECAM broadcasts, typi cal l y the RF carri er ampl i tude i s
mi ni mi zed at the sync ti ps of the vi deo waveform and maxi mi zed at
the whi te l evel . Thi s resul ts i n a waveform on the anal yzer where
the sync pul ses ar e at the bottom, or negati ve (Sync (Neg)).
A normal baseband vi deo waveform for al l TV standards wi l l have
the sync ti ps on the bottom. When TV Source i s set to Ext Video In,
Sync shoul d be set to Neg.
TV Monitor
When TV Monitor i s pr essed, the pi ctur e r epr esented by the vi deo
waveform sel ected wi th TV Source i s presented on the LCD di spl ay of
the anal yzer. The pi cture can onl y be vi ewed, not pr i nted or saved.
Pressi ng a key that normal l y bri ngs up a menu restores the ori gi nal
graphi cal di spl ay wi th the sel ected menu enabl ed.
SECAM 625 50 Hz SECAM 4.406 MHz,
4.250 MHz
Table 15-5
TV Standard Number of
Lines per
Frame
Approximate
Field Rate
Color
Encoding
Method
Color
Subcarrier
Frequency
156 Chapter 15
Concepts
Trigger Concepts
C
o
n
c
e
p
t
s
Trigger Settings and Fast Time Domain Sweeps
Tri gger del ay can be used to move the sweep tri gger poi nt arbi tr ari l y
across a gi ven TV l i ne or l i nes to al l ow cl oser exami nati on of waveform
patter ns (Pr ess Trig, Trig Delay, and enter a del ay ti me).
I n fast sweeps (20 s to l ess than 5 ms), there may be up to one tr ace
poi nt of vari ati on i n the start ti me of the waveform di gi tal i zati on
pr ocess wi th respect to the actual TV tri gger pul se. Thi s randomness
l eads to the appearance of vi sual ji tter on the LCD di spl ay of the
anal yzer. I n thi s si tuati on, vi deo averagi ng may be used (N = 5, for
exampl e) to i mprove the vi sual stabi l i ty of the di spl ayed wavefor m.
Thi s type of ji tter does not occur when sweep ti mes are set greater than
or equal to 5 ms where di gi tal i zati on begi ns l ess than 100 ns after the
tr i gger pul se i n that mode (much l ess than 1 trace poi nt of ji tter ).
Chapter 15 157
Concepts
AM and FM Demodulation Concepts
C
o
n
c
e
p
t
s
AM and FM Demodulation Concepts
Demodulating an AM Signal Using the Analyzer as a
Fixed Tuned Receiver (Time-Domain)
The zero span mode can be used to recover ampl i tude modul ati on on a
car r i er si gnal .
The fol l owi ng functi ons establ i sh a cl ear di spl ay of the waveform:
Tri ggeri ng stabi l i zes the waveform tr ace by tri ggeri ng on the
modul ati on envel ope. I f the modul ati on of the si gnal i s stabl e, vi deo
tr i gger synchroni zes the sweep wi th the demodul ated waveform.
Li near di spl ay mode shoul d be used i n ampl i tude modul ati on (AM)
measurements to avoi d di storti on caused by the l ogari thmi c
ampl i fi er when demodul ati ng si gnal s.
Sweep ti me to vi ew the rate of the AM si gnal .
RBW and VBW are sel ected accordi ng to the si gnal bandwi dth.
Demodulating an FM Signal Using the Analyzer as a
Fixed Tuned Receiver (Time-Domain)
To recover the frequency modul ated si gnal , a spectrum anal yzer can be
used as a manual l y tuned recei ver (zero span). However, i n contrast to
AM, the si gnal i s not tuned i nto the passband center, but to one sl ope of
the fi l ter curve as Fi gure 15-22.
Figure 15-22 Determining FM Parameters using FM to AM Conversion
Here the fr equency vari ati ons of the FM si gnal are converted i nto
ampl i tude vari ati ons (FM to AM conversi on). The reason we want to
measure the AM component i s that the envel ope detector responds onl y
to AM vari ati ons. There are no changes i n ampl i tude i f the frequency
changes of the FM si gnal are l i mi ted to the fl at part of the RBW (I F
fi l ter ). The resul tant AM si gnal i s then detected wi th the envel ope
detector and di spl ayed i n the ti me domai n.
158 Chapter 15
Concepts
Stimulus Response Measurement Concepts
C
o
n
c
e
p
t
s
Stimulus Response Measurement Concepts
NOTE Sti mul us response measurements requi r e opti on 1DN or 1DQ wi th ESA
spectrum anal yzers.
Stimulus Response Overview
Sti mul us response measurements requi r e a source to sti mul ate a devi ce
under test (DUT), a recei ver to anal yze the fr equency response
character i sti cs of the DUT, and, for return l oss measur ements, a
di recti onal coupl er or bri dge. Characteri zati on of a DUT can be made i n
ter ms of i ts transmi ssi on or refl ecti on parameter s. Exampl es of
tr ansmi ssi on measurements i ncl ude fl atness and rejecti on. Return l oss
i s an exampl e of a refl ecti on measurement.
A spectr um anal yzer combi ned wi th a tracki ng generator forms a
sti mul us response measurement system. Wi th the tr acki ng generator
as the swept source and the anal yzer as the recei ver, operati on i s the
same as a si ngl e channel scal ar network anal yzer. The tr acki ng
gener ator output fr equency must be made to preci sel y track the
anal yzer i nput fr equency for good narr ow band operati on. A narrow
band system has a wi de dynami c measurement range. Thi s wi de
dynami c range wi l l be i l l ustr ated i n the fol l owi ng exampl e.
There are three basi c steps i n perfor mi ng a sti mul us response
measurement, whether i t i s a tr ansmi ssi on or a refl ecti on
measurement. The fi rst step i s to set up the anal yzer, the second i s to
normal i ze, and the l ast step i s to perform the measurement.
Tracking Generator Unleveled Condition
When usi ng the tracki ng generator, the message TG unleveled may
appear. The TG unleveled message i ndi cates that the tr acki ng
gener ator source power (Source, Amplitude) coul d not be mai ntai ned at
the sel ected l evel duri ng some porti on of the sweep. I f the unl evel ed
condi ti on exi sts at the begi nni ng of the sweep, the message wi l l be
di spl ayed i mmedi atel y. I f the unl evel ed condi ti on occurs after the sweep
begi ns, the message wi l l be di spl ayed after the sweep i s compl eted. A
momentary unl evel ed condi ti on may not be detected when the sweep
ti me i s short. The message wi l l be cl eared after a sweep i s compl eted
wi th no unl evel ed condi ti ons.
The unl evel ed condi ti on may be caused by any of the fol l owi ng:
Start fr equency i s too l ow or the stop fr equency i s too hi gh. The
unl evel ed condi ti on i s l i kel y to occur i f the tr ue frequency range
exceeds the tracki ng generator fr equency speci fi cati on (especi al l y
the l ow fr equency speci fi cati on).
Chapter 15 159
Concepts
Stimulus Response Measurement Concepts
C
o
n
c
e
p
t
s
Sour ce attenuati on may be set i ncorr ectl y (sel ect Attenuation (Auto)
for opti mum setti ng).
The source power may be set too hi gh or too l ow, use Amplitude (Off)
then Amplitude (On) to reset i t.
The source power sweep may be set too hi gh, resul ti ng i n an
unl evel ed condi ti on at the end of the sweep. Use Power Sweep (Off)
then Power Sweep (On) to decrease the ampl i tude.
Reverse RF power fr om the devi ce under test detected by the
tr acki ng generator ALC (automati c l evel control ) system.
Sweeping in Stimulus Response Auto Coupled Mode
Auto coupl ed sweep ti mes are usual l y much faster for sti mul us
response measurements than they are for spectrum anal yzer (SA)
measurements.
I n the sti mul us response mode, the Q of the DUT can determi ne the
fastest rate at whi ch the anal yzer can be swept. (Q i s the qual i ty factor,
whi ch i s the center fr equency of the DUT di vi ded by the bandwi dth of
the DUT.) To determi ne whether the anal yzer i s sweepi ng too fast, sl ow
the sweep and note whether there i s a fr equency or ampl i tude shi ft of
the tr ace. Conti nue to sl ow the sweep unti l ther e i s no l onger a
fr equency or ampl i tude shi ft.
Normalization Concepts
To make a transmi ssi on measurement accuratel y, the frequency
response of the test system must be known. Nor mal i zati on i s used to
el i mi nate thi s error from the measurement. To measure the fr equency
response of the test system, connect the cabl e (but not the DUT) fr om
the tr acki ng generator output to the anal yzer i nput.
Press View/Trace, More, Normalize, Store Ref (13), Normalize (On).
The frequency response of the test system i s automati cal l y stor ed i n
tr ace 3 and a normal i zati on i s perfor med. Thi s means that the acti ve
di spl ayed trace i s now the r ati o of the i nput data to the data stor ed i n
tr ace 3. (The reference trace i s Trace 3 wi th fi rmware revi si on A.04.00
and l ater)
When normal i zati on i s on, trace math i s bei ng perfor med on the acti ve
tr ace. The trace math performed i s (tr ace 1 tr ace 3 + the normal i zed
reference posi ti on), wi th the resul t pl aced i nto tr ace 1. Remember that
tr ace 1 contai ns the measurement tr ace, trace 3 contai ns the stored
reference tr ace of the system fr equency r esponse, and nor mal i zed
reference posi ti on i s i ndi cated by arrowheads at the edges of the
gr ati cul e.
NOTE Si nce the reference trace i s stor ed i n trace 3, changi ng trace 3 to
Clear Write wi l l i nval i date the normal i zati on.
160 Chapter 15
Concepts
Stimulus Response Measurement Concepts
C
o
n
c
e
p
t
s
Reconnect the DUT to the anal yzer. Note that the uni ts of the reference
l evel have changed to dB, i ndi cati ng that thi s i s now a rel ati ve
measurement. Change the normal i zed reference posi ti on:
Press View/Trace, More, Normalize, Norm Ref Posn.
Arrowheads at the l eft and ri ght edges of the grati cul e mark the
normal i zed reference posi ti on, or the posi ti on where 0 dB i nserti on l oss
(transmi ssi on measurements) or 0 dB return l oss (r efl ecti on
measurements) wi l l normal l y resi de. You can change the posi ti on of the
normal i zed trace, wi thi n the range of the grati cul e by enteri ng a
posi ti on number.
Measuring Device Bandwidth
I t i s often necessary to measure devi ce bandwi dth, such as when testi ng
a bandpass fi l ter. There i s a key i n the Peak Search menu that wi l l
perform thi s functi on. The devi ce si gnal bei ng measured must be
di spl ayed before acti vati ng the measurement. The span must i ncl ude
the ful l response.
Acti vate the measurement by toggl i ng the N dB Points key to On. The
anal yzer pl aces arrow marker s at the 3 dB poi nts on ei ther si de of the
response and r eads the bandwi dth. For other bandwi dth r esponses
enter the number of dB down desi r ed, from 1 dB to 80 dB.
No other si gnal can appear on the di spl ay wi thi n N dB of the hi ghest
si gnal . The measur ed si gnal cannot have more than one peak that i s
greater than or equal to N dB. A si gnal must have a peak greater than
the currentl y defi ned peak excursi on to be i denti fi ed. The defaul t val ue
for the peak excur si on i s 6 dB.
Measurements are made conti nuousl y, updati ng at the end of each
sweep. Thi s al l ows you to make adjustments and see changes as they
happen. The si ngl e sweep mode can al so be used, provi di ng ti me to
study or record the data.
The N dB bandwi dth measurement error i s typi cal l y 1% of the span.
Converting Return Loss to VSWR
Return l oss can be expressed as a vol tage standi ng wave rati o (VSWR)
val ue usi ng the fol l owi ng tabl e or formul a:
Table 15-6 Power to VSWR Conversion
Return
Loss
(dB)
VSWR Return
Loss
(dB)
VSWR Return
Loss
(dB)
VSWR Return
Loss
(dB)
VSWR Return
Loss
(dB)
VSWR
4.0 4.42 14.0 1.50 18.0 1.29 28.0 1.08 38.0 1.03
6.0 3.01 14.2 1.48 18.5 1.27 28.5 1.08 38.5 1.02
Chapter 15 161
Concepts
Stimulus Response Measurement Concepts
C
o
n
c
e
p
t
s
Wher e: RL i s the measur ed return l oss val ue.
VSWR i s someti mes stated as a rati o. For exampl e: 1.2:1 one poi nt two
to one VSWR. The fi rst number i s the VSWR val ue taken from the
tabl e or cal cul ated usi ng the formul a. The second number i s al ways 1.
8.0 2.32 14.4 1.47 19.0 1.25 29.0 1.07 39.0 1.02
10.0 1.92 14.6 1.46 19.5 1.24 29.5 1.07 39.5 1.02
10.5 1.85 14.8 1.44 20.0 1.22 30.0 1.07 40.0 1.02
11.0 1.78 15.0 1.43 20.5 1.21 30.5 1.06 40.5 1.02
11.2 1.76 15.2 1.42 21.0 1.20 31.0 1.06 41.0 1.02
11.4 1.74 15.4 1.41 21.5 1.18 31.5 1.05 41.5 1.02
11.6 1.71 15.6 1.40 22.0 1.17 32.0 1.05 42.0 1.02
11.8 1.69 15.8 1.39 22.5 1.16 32.5 1.05 42.5 1.02
12.0 1.67 16.0 1.38 23.0 1.15 33.0 1.05 43.0 1.01
12.2 1.65 16.2 1.37 23.5 1.14 33.5 1.04 43.5 1.01
12.4 1.63 16.4 1.36 24.0 1.13 34.0 1.04 44.0 1.01
12.6 1.61 16.6 1.35 24.5 1.13 34.5 1.04 44.5 1.01
12.8 1.59 16.8 1.34 25.0 1.12 35.0 1.04 45.0 1.01
13.0 1.58 17.0 1.33 25.5 1.11 35.5 1.03 45.5 1.01
13.2 1.56 17.2 1.32 26.0 1.11 36.0 1.03 46.0 1.01
13.4 1.54 17.4 1.31 26.5 1.10 36.5 1.03 46.5 1.01
13.6 1.53 17.6 1.30 27.0 1.09 37.0 1.03 47.0 1.01
13.8 1.51 17.8 1.30 27.5 1.09 37.5 1.03 47.5 1.01
Table 15-6 Power to VSWR Conversion
Return
Loss
(dB)
VSWR Return
Loss
(dB)
VSWR Return
Loss
(dB)
VSWR Return
Loss
(dB)
VSWR Return
Loss
(dB)
VSWR
VSWR
1 10
RL
20
----------
+
1 10
RL
20
----------

----------------------- =
162 Chapter 15
Concepts
Stimulus Response Measurement Concepts
C
o
n
c
e
p
t
s
163
E
S
A
/
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
16 ESA/PSA Programming
Examples
164 Chapter 16
ESA/PSA Programming Examples
Examples Included in this Chapter:
E
S
A
/
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Examples Included in this Chapter:
The fol l owi ng C and Vi sual Basi c exampl es work wi th both the ESA
Seri es and the PSA Seri es of spectrum anal yzer s. There i s al so a secti on
on programmi ng i n C usi ng the Agi l ent VTL (VI SA tr ansi ti on l i brary).
Programming using the Agilent VTL:
Programmi ng i n C Usi ng the VTL on page 167
Programming Examples for ESA and PSA spectrum analyzers:
Usi ng C to Make a Power Sui te ACPR Measurement on a cdmaOne
Si gnal on page 176
Usi ng C to Seri al Pol l the Anal yzer to Determi ne when an
Auto-al i gnment i s Compl ete on page 179
Usi ng C and Servi ce Request (SRQ) to Determi ne When a
Measurement i s Compl ete on page 182
Usi ng Vi sual Basi c6 to Capture a Screen I mage on page 188
Usi ng Vi sual Basi c6 to Transfer Bi nary Trace Data on page 192
Usi ng Agi l ent VEE to Transfer Trace Data on page 197
Vi sual Basi c i s a regi stered tr ademar k of Mi crosoft Corporati on.
Chapter 16 165
ESA/PSA Programming Examples
Finding Additional Examples and More Information
E
S
A
/
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Finding Additional Examples and More
Information
These exampl es are avai l abl e on the Agi l ent Technol ogi es PSA Seri es
documentati on CD-ROM or the ESA Seri es documentati on CD-ROM.
They can al so be found fr om the URLs:
http://www.agilent.com/find/esa
http://www.agilent.com/find/psa
VXI plug&play drivers: There are addi ti onal exampl es that use the VXI
pl ug&pl ay i nstrument dri ver s. These exampl es are i ncl uded i n the
on-l i ne documentati on i n the dri ver i tsel f. The dr i ver al l ows you to use
several di fferent pr ogrammi ng l anguages i ncl udi ng: VEE, LabVI EW, C,
C++, and BASI C. The software dr i vers can al so be found at the above
URLs.
I nterchangeable Virtual I nstruments COM (I VI -COM) drivers: Develop
system automation software easily and quickly. IVI-COM drivers take full
advantage of application development environments such as Visual Studio
using Visual Basic, C# or Visual C++ as well as Agilents Test and
Measurement Toolkit. You can now develop application programs that are
portable across computer platforms and I/O interfaces. With IVI-COM
drivers you do not need to have in depth test instrument knowledge to
develop sophisticated measurement software. IVI-COM drivers provide a
compatible interface to all. COM environments. The IVI-COM software
drivers can be found at the URL
http://www.agilent.com/find/ivi-com
I ntuiLink software: Ther e are addi ti onal exampl es that use the
I ntui Li nk software. I ntui Li nk al l ows you to captur e scr een and tr ace
data for di spl ay and mani pul ati on i n the Wi ndows COM envi ronment.
These exampl es are i ncl uded on the I ntui l i nk CD. The l atest versi on of
I ntui Li nk can al so be found at the URL
http://www.agilent.com/find/intuilink
166 Chapter 16
ESA/PSA Programming Examples
Programming Examples Information and Requirements
E
S
A
/
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Programming Examples Information and
Requirements
The programmi ng exampl es were wri tten for use on an I BM
compati bl e PC.
The programmi ng exampl es use C, Vi sual Basi c and VEE
pr ogrammi ng l anguages.
The programmi ng exampl es use GPI B and LAN i nterfaces.
Many of the exampl es use the SCPI programmi ng commands,
though there are some that use the pl ug&pl ay or I VI .com dr i vers.
Most of the exampl es are wri tten i n C usi ng the Agi l ent VI SA
tr ansi ti on l i brary.
The VI SA tr ansi ti on l i brary must be i nstal l ed and the GPI B card
confi gured. The Agi l ent I /O l i brari es contai n the l atest VI SA
tr ansi ti on l i brary and i s avai l abl e at: www.agilent.com/iolib
Chapter 16 167
ESA/PSA Programming Examples
Programming in C Using the VTL
E
S
A
/
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Programming in C Using the VTL
The C pr ogrammi ng exampl es that are pr ovi ded are wri tten usi ng the C
pr ogrammi ng l anguage and the Agi l ent VTL (VI SA transi ti on l i brary).
Thi s secti on i ncl udes some basi c i nformati on about programmi ng i n the
C l anguage. Note that some of thi s i nformati on may not be rel evant to
your parti cul ar appl i cati on. (For exampl e, i f you are not usi ng VXI
i nstruments, the VXI r eferences wi l l not be r el evant).
Refer to your C pr ogrammi ng l anguage documentati on for more detai l s.
(Thi s i nformati on i s taken fr om the manual VI SA Transi ti on Li brary,
part number E2090-90026.) The fol l owi ng topi cs are i ncl uded:
Typi cal Exampl e Program Contents on page 168
Li nki ng to VTL Li brari es on page 169
Compi l i ng and Li nki ng a VTL Program on page 169
Exampl e Program on page 171
I ncl udi ng the VI SA Decl arati ons Fi l e on page 171
Openi ng a Sessi on on page 172
Devi ce Sessi ons on page 172
Addr essi ng a Sessi on on page 174
Cl osi ng a Sessi on on page 175
168 Chapter 16
ESA/PSA Programming Examples
Programming in C Using the VTL
E
S
A
/
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Typical Example Program Contents
The fol l owi ng i s a summar y of the VTL functi on cal l s used i n the
exampl e pr ograms.
visa.h Thi s fi l e i s i ncl uded at the begi nni ng of the fi l e to
pr ovi de the functi on prototypes and constants defi ned
by VTL.
ViSession The ViSession i s a VTL data type. Each object that
wi l l establ i sh a communi cati on channel must be
defi ned as ViSession.
viOpenDefaultRM You must fi r st open a sessi on wi th the defaul t
resour ce manager wi th the viOpenDefaultRM
functi on. Thi s functi on wi l l i ni ti al i ze the defaul t
resour ce manager and return a poi nter to that r esour ce
manager sessi on.
viOpen Thi s functi on establ i shes a communi cati on channel
wi th the devi ce speci fi ed. A sessi on i denti fi er that can
be used wi th other VTL functi ons i s returned. Thi s cal l
must be made for each devi ce you wi l l be usi ng.
viPrintf
viScanf These are the VTL formatted I /O functi ons that are
patterned after those used i n the C programmi ng
l anguage. The viPrintf cal l sends the I EEE 488.2
*RST command to the i nstrument and puts i t i n a
known state. The viPrintf cal l i s used agai n to query
for the devi ce i denti fi cati on (*IDN?). The viScanf cal l
i s then used to read the resul ts.
viClose Thi s functi on must be used to cl ose each sessi on. When
you cl ose a devi ce sessi on, al l data str uctures that had
been al l ocated for the sessi on wi l l be de-al l ocated.
When you cl ose the defaul t manager sessi on, al l
sessi ons opened usi ng the defaul t manager sessi on wi l l
be cl osed.
Chapter 16 169
ESA/PSA Programming Examples
Programming in C Using the VTL
E
S
A
/
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Linking to VTL Libraries
Your appl i cati on must l i nk to one of the VTL i mport l i brari es:
32-bi t Versi on:
C:\VXIPNP\WIN95\LIB\MSC\VISA32.LIB for Mi cr osoft compi l er s
C:\VXIPNP\WIN95\LIB\BC\VISA32.LIB for Borl and compi l ers
16-bi t Versi on:
C:\VXIPNP\WIN\LIB\MSC\VISA.LIB for Mi crosoft compi l ers
C:\VXIPNP\WIN\LIB\BC\VISA.LIB for Borl and compi l ers
See the fol l owi ng secti on, Compi l i ng and Li nki ng a VTL Program for
i nformati on on how to use the VTL run-ti me l i brari es.
Compiling and Linking a VTL Program
32-bit Applications
The fol l owi ng i s a summar y of i mportant compi l er-speci fi c
consi derati ons for several C/C++ compi l er pr oducts when devel opi ng
WI N32 appl i cati ons.
For Mi crosoft Vi sual C++ versi on 2.0 compi l ers:
Sel ect Project | Update All Dependencies fr om the menu.
Sel ect Project | Settings fr om the menu. Cl i ck on the C/C++
button. Sel ect Code Generation fr om the Use Run-Time
Libraries l i st box. VTL requi res these defi ni ti ons for WI N32. Cl i ck
on OK to cl ose the di al og boxes.
Sel ect Project | Settings fr om the menu. Cl i ck on the Link
button and add visa32.lib to the Object / Library Modules
l i st box. Opti onal l y, you may add the l i brary di rectl y to your project
fi l e. Cl i ck on OK to cl ose the di al og boxes.
You may wi sh to add the i ncl ude fi l e and l i brary fi l e search paths.
They are set by doi ng the fol l owi ng:
1. Sel ect Tools | Options from the menu.
2. Cl i ck on the Directories button to set the i ncl ude fi l e path.
3. Sel ect Include Files from the Show Directories For l i st
box.
4. Cl i ck on the Add button and type i n the fol l owi ng:
C:\VXIPNP\WIN95\INCLUDE
5. Sel ect Library Files from the Show Directories For l i st
box.
170 Chapter 16
ESA/PSA Programming Examples
Programming in C Using the VTL
E
S
A
/
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
6. Cl i ck on the Add button and type i n the fol l owi ng:
C:\VXIPNP\WIN95\LIB\MSC
For Borl and C++ versi on 4.0 compi l ers:
You may wi sh to add the i ncl ude fi l e and l i brary fi l e search paths.
They are set under the Options | Project menu sel ecti on. Doubl e
cl i ck on Directories fr om the Topics l i st box and add the fol l owi ng:
C:\VXIPNP\WIN95\INCLUDE
C:\VXIPNP\WIN95\LIB\BC
16-bit Applications
The fol l owi ng i s a summar y of i mportant compi l er-speci fi c
consi derati ons for the Wi ndows compi l er.
For Mi crosoft Vi sual C++ versi on 1.5:
To set the memory model , do the fol l owi ng:
1. Sel ect Options | Project.
2. Cl i ck on the Compiler button, then sel ect Memory Model fr om
the Category l i st.
3. Cl i ck on the Model l i st arrow to di spl ay the model opti ons, and
sel ect Large.
4. Cl i ck on OK to cl ose the Compiler di al og box.
You may wi sh to add the i ncl ude fi l e and l i brary fi l e search paths.
They are set under the Options | Directories menu sel ecti on:
C:\VXIPNP\WIN\INCLUDE
C:\VXIPNP\WIN\LIB\MSC
Otherwi se, the l i brary and i ncl ude fi l es shoul d be expl i ci tl y speci fi ed
i n the pr oject fi l e.
Chapter 16 171
ESA/PSA Programming Examples
Programming in C Using the VTL
E
S
A
/
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Example Program
Thi s exampl e program queri es a GPI B devi ce for an i denti fi cati on
stri ng and pr i nts the r esul ts. Note that you must change the addr ess.
/*idn.c - program filename */
#include "visa.h"
#include <stdio.h>
void main ()
{
/*Open session to GPIB device at address 18 */
ViOpenDefaultRM (&defaultRM);
ViOpen (defaultRM, GPIB0::18::INSTR", VI_NULL,
VI_NULL, &vi);
/*Initialize device */
viPrintf (vi, "*RST\n");
/*Send an *IDN? string to the device */
printf (vi, "*IDN?\n");
/*Read results */
viScanf (vi, "%t", &buf);
/*Print results */
printf ("Instrument identification string: %s\n", buf);
/* Close sessions */
viClose (vi);
viClose (defaultRM);
}
Including the VISA Declarations File
For C and C++ pr ograms, you must i ncl ude the visa.h header fi l e at
the begi nni ng of every fi l e that contai ns VTL functi on cal l s:
#include "visa.h"
Thi s header fi l e contai ns the VI SA functi on pr ototypes and the
defi ni ti ons for al l VI SA constants and error codes. The visa.h header
fi l e i ncl udes the visatype.h header fi l e.
The visatype.h header fi l e defi nes most of the VI SA types. The VI SA
types are used thr oughout VTL to speci fy data types used i n the
functi ons. For exampl e, the viOpenDefaultRM functi on requi res a
poi nter to a par ameter of type ViSession. I f you fi nd ViSession i n the
visatype.h header fi l e, you wi l l fi nd that ViSession i s eventual l y
typed as an unsi gned l ong.
172 Chapter 16
ESA/PSA Programming Examples
Programming in C Using the VTL
E
S
A
/
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Opening a Session
A sessi on i s a channel of communi cati on. Sessi ons must fi rst be opened
on the defaul t r esour ce manager, and then for each devi ce you wi l l be
usi ng. The fol l owi ng i s a summary of sessi ons that can be opened:
A resource manager session i s used to i ni ti al i ze the VI SA system.
I t i s a parent sessi on that knows about al l the opened sessi ons. A
resour ce manager sessi on must be opened before any other sessi on
can be opened.
A device session i s used to communi cate wi th a devi ce on an
i nterface. A devi ce sessi on must be opened for each devi ce you wi l l be
usi ng. When you use a devi ce sessi on you can communi cate wi thout
worr yi ng about the type of i nterface to whi ch i t i s connected. Thi s
i nsul ati on makes appl i cati ons more robust and portabl e across
i nter faces. Typi cal l y a devi ce i s an i nstr ument, but coul d be a
computer, a pl otter, or a pri nter.
NOTE Al l devi ces that you wi l l be usi ng need to be connected and i n worki ng
condi ti on pri or to the fi rst VTL functi on cal l (viOpenDefaultRM). The
system i s confi gur ed onl y on the first viOpenDefaultRM per process.
Therefor e, i f viOpenDefaultRM i s cal l ed wi thout devi ces connected and
then cal l ed agai n when devi ces are connected, the devi ces wi l l not be
recogni zed. You must cl ose ALL resour ce manager sessi ons and r e-open
wi th al l devi ces connected and i n worki ng condi ti on.
Device Sessions
There are two parts to openi ng a communi cati ons sessi on wi th a
speci fi c devi ce. Fi r st you must open a sessi on to the defaul t resour ce
manager wi th the viOpenDefaultRM functi on. The fi rst cal l to thi s
functi on i ni ti al i zes the defaul t resource manager and returns a sessi on
to that r esource manager sessi on. You onl y need to open the defaul t
manager sessi on once. However, subsequent cal l s to viOpenDefaultRM
returns a sessi on to a uni que sessi on to the same defaul t resour ce
manager r esource.
Next, you open a sessi on wi th a speci fi c devi ce wi th the viOpen
functi on. Thi s functi on uses the sessi on returned from
viOpenDefaultRM and r etur ns i ts own sessi on to i denti fy the devi ce
sessi on. The fol l owi ng shows the functi on syntax:
vi OpenDefaul tRM (sesn);
vi Open (sesn, rsrcName, accessMode, timeout, vi);
Chapter 16 173
ESA/PSA Programming Examples
Programming in C Using the VTL
E
S
A
/
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
The sessi on r etur ned fr om viOpenDefaultRM must be used i n the sesn
par ameter of the viOpen functi on. The viOpen functi on then uses that
sessi on and the devi ce address speci fi ed i n the rsrcName par ameter to
open a devi ce sessi on. The vi par ameter i n viOpen returns a sessi on
i denti fi er that can be used wi th other VTL functi ons.
Your pr ogram may have several sessi ons open at the same ti me by
cr eati ng mul ti pl e sessi on i denti fi ers by cal l i ng the viOpen functi on
mul ti pl e ti mes.
The fol l owi ng summar i zes the parameters i n the previ ous functi on
cal l s:
sesn Thi s i s a sessi on returned fr om the viOpenDefaultRM
functi on that i denti fi es the resource manager sessi on.
rsrcName Thi s i s a uni que symbol i c name of the devi ce (devi ce
addr ess).
accessMode Thi s parameter i s not used for VTL. Use VI _NULL.
timeout Thi s parameter i s not used for VTL. Use VI _NULL.
vi Thi s i s a poi nter to the sessi on i denti fi er for thi s
parti cul ar devi ce sessi on. Thi s poi nter wi l l be used to
i denti fy thi s devi ce sessi on when usi ng other VTL
functi ons.
The fol l owi ng i s an exampl e of openi ng sessi ons wi th a GPI B
mul ti meter and a GPI B-VXI scanner:
ViSession defaultRM, dmm, scanner;
.
.
viOpenDefaultRM(&defaultRM);
viOpen (defaultRM, "GPIB0::22::INSTR", VI_NULL,
VI_NULL, &dmm);
viOpen (defaultRM, "GPIB-VXI0::24::INSTR", VI_NULL,
VI_NULL, &scanner);
.
.
viClose (scanner);
viClose (dmm);
viClose(defaultRM);
The above functi on fi r st opens a sessi on wi th the defaul t resour ce
manager. The sessi on returned from the resource manager and a devi ce
address i s then used to open a sessi on wi th the GPI B devi ce at address
22. That sessi on wi l l now be i denti fi ed as dmm when usi ng other VTL
functi ons. The sessi on returned fr om the resource manager i s then used
agai n wi th another devi ce addr ess to open a sessi on wi th the GPI B-VXI
devi ce at pri mary address 9 and VXI l ogi cal addr ess 24. That sessi on
wi l l now be i denti fi ed as scanner when usi ng other VTL functi ons. See
the fol l owi ng secti on for i nformati on on addressi ng parti cul ar devi ces.
174 Chapter 16
ESA/PSA Programming Examples
Programming in C Using the VTL
E
S
A
/
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Addressing a Session
As seen i n the pr evi ous secti on, the rsrcName parameter i n the viOpen
functi on i s used to i denti fy a speci fi c devi ce. Thi s parameter i s made up
of the VTL i nterface name and the devi ce addr ess. The i nterface name
i s determi ned when you run the VTL Confi gurati on Uti l i ty. Thi s name
i s usual l y the i nterface type fol l owed by a number. The fol l owi ng tabl e
i l l ustr ates the for mat of the rsrcName for the di ffer ent i nterface types:
The fol l owi ng descri bes the par ameter s used above:
board Thi s opti onal parameter i s used i f you have mor e than
one i nterface of the same type. The defaul t val ue for
board i s 0.
VSI logical
address Thi s i s the l ogi cal addr ess of the VXI i nstrument.
primary
address Thi s i s the pri mary address of the GPI B devi ce.
secondary
address Thi s opti onal parameter i s the secondary addr ess of the
GPI B devi ce. I f no secondary address i s speci fi ed, none
i s assumed.
I NSTR Thi s i s an opti onal parameter that i ndi cates that you
are communi cati ng wi th a resour ce that i s of type
INSTR, meani ng i nstrument.
NOTE I f you want to be compati bl e wi th future rel eases of VTL and VI SA, you
must i ncl ude the I NSTR par ameter i n the syntax.
The fol l owi ng are exampl es of val i d symbol i c names:
XI 0::24::I NSTR Devi ce at VXI l ogi cal addr ess 24 that i s of VI SA type
I NSTR.
VXI 2::128 Devi ce at VXI l ogi cal addr ess 128, i n the thi rd VXI
system (VXI 2).
GPI B-VXI 0::24 A VXI devi ce at l ogi cal address 24. Thi s VXI devi ce i s
connected vi a a GPI B-VXI command modul e.
GPI B0::7::0 A GPI B devi ce at pr i mary addr ess 7 and secondary
address 0 on the GPI B i nterface.
Interface Syntax
VXI VXI [board]::VXI logical address[::I NSTR]
GPI B-VXI GPI B-VXI [board]::VXI logical address[::I NSTR]
GPI B GPI B [board]::primary address[::secondary address][::I NSTR]
Chapter 16 175
ESA/PSA Programming Examples
Programming in C Using the VTL
E
S
A
/
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
The fol l owi ng i s an exampl e of openi ng a devi ce sessi on wi th the GPI B
devi ce at pri mary address23.
ViSession defaultRM, vi;
.
.
viOpenDefaultRM (&defaultRM);
viOpen (defaultRM, "GPIB0::23::INSTR", VI_NULL,VI_NULL,&vi);
.
.
viClose(vi);
viClose (defaultRM);
Closing a Session
The viClose functi on must be used to cl ose each sessi on. You can cl ose
the speci fi c devi ce sessi on, whi ch wi l l free al l data structures that had
been al l ocated for the sessi on. I f you cl ose the defaul t resource manager
sessi on, al l sessi ons opened usi ng that resource manager wi l l be cl osed.
Si nce system r esour ces are al so used when sear chi ng for r esour ces
(viFindRsrc) or wai ti ng for events (viWaitOnEvent), the viClose
functi on needs to be cal l ed to free up fi nd l i sts and event contexts.
176 Chapter 16
ESA/PSA Programming Examples
Using C to Make a Power Suite ACPR Measurement on a cdmaOne Signal
E
S
A
/
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Using C to Make a Power Suite ACPR
Measurement on a cdmaOne Signal
Thi s C progr ammi ng exampl e (ACPR.c) can be found on the
Documentati on CD.
Example:
/***************************************************************************
* ACPR.c
* Adjacent Channel Power Measurement using Power Suite
* Agilent Technologies 2001
*
* Instrument Requirements:
* PSA with firmware version >= A.02.00 or
* ESA with firmware version >= A.08.00
*
* Note: You can select which ACPR radio standard you would like by
* changing the standard for the RADIO:STANDARD command.
* This example sets the radio standard to IS95.
*
* Note: For PSA, ensure that you are SA mode before running this program.
*
*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "visa.h"
void main ()
{
/*program variable*/
ViSession defaultRM, viPSA;
ViStatus viStatus = 0;
ViChar _VI_FAR cResult[2000] = {0};
int iNum =0;
Chapter 16 177
ESA/PSA Programming Examples
Using C to Make a Power Suite ACPR Measurement on a cdmaOne Signal
E
S
A
/
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
int iSwpPnts = 401;
double freq,value;
static ViChar *cToken ;
long lCount=0L;
char sTraceInfo [1024]= {0};
FILE *fDataFile;
unsigned long lBytesRetrieved;
char *psaSetup = // PSA setup initialization
"*RST;*CLS;" // Reset the device and clear status
":INIT:CONT 0;"// Set analyzer to single sweep mode
":RADIO:STANDARD IS95";// Set the Radio Standard to IS95
/*open session to GPIB device at address 18 */
viStatus=viOpenDefaultRM (&defaultRM);
viStatus=viOpen (defaultRM, "GPIB0::18::INSTR", VI_NULL,VI_NULL, &viPSA);
/*check opening session sucess*/
if(viStatus)
{
printf("Could not open a session to GPIB device at address 18!\n");
exit(0);
}
/*Increase timeout to 20 sec*/
viSetAttribute(viPSA,VI_ATTR_TMO_VALUE,20000);
/*Send setup commands to instrument */
viPrintf(viPSA,"%s\n",psaSetup);
/*Get the center freq from user*/
printf("What is the center carrier frequency in MHz?\n");
scanf( "%lf",&freq);
/*Set the center freq*/
viPrintf(viPSA,"freq:center %lf MHZ\n",freq);
/*Perform an ACPR measurement*/
178 Chapter 16
ESA/PSA Programming Examples
Using C to Make a Power Suite ACPR Measurement on a cdmaOne Signal
E
S
A
/
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
viQueryf(viPSA,"%s\n", "%#t","READ:ACP?;*wai" , &iNum , cResult);
/*Remove the "," from the ASCII data for analyzing data*/
cToken = strtok(cResult,",");

/*Save data to an ASCII to a file, by removing the "," token*/
fDataFile=fopen("C:\\ACPR.txt","w");
fprintf(fDataFile,"ACPR.exe Output\nAgilent Technologies 2001\n\n");
fprintf(fDataFile,"Please read Programers Reference for an\n");
fprintf(fDataFile,"explanation of returned results.\n\n");
while (cToken != NULL)
{
lCount++;
value = atof(cToken);
fprintf(fDataFile,"\tReturn value[%d] = %lf\n",lCount,value);
cToken =strtok(NULL,",");
}
fprintf(fDataFile,"\nTotal number of return points of ACPR measurement :[%d]
\n\n",lCount);
fclose(fDataFile);
/*print message to the standard output*/
printf("The The ACPR Measurement Result was saved to C:\\ACPR.txt file\n\n");
/* Close session */
viClose (viPSA);
viClose (defaultRM);
}
Chapter 16 179
ESA/PSA Programming Examples
Using C to Serial Poll the Analyzer to Determine when an Auto-alignment is
Complete
E
S
A
/
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Using C to Serial Poll the Analyzer to
Determine when an Auto-alignment is
Complete
Thi s C programmi ng exampl e (SerAl i gn.c) can be found on the
Documentati on CD.
Example:
/*********************************************************************
* SerAlign.c
* Serial Poll Alignment Routine
* Agilent Technologies 2001
*
* Instrument Requirements:
* PSA Series Spectrum Analyzer or
* ESA Series Spectrum Analyers or
* VSA Series Transmitter Tester
*
* This program demonstrates how to
* 1) Perform an instrument alignment.
* 2) Poll the instrument to determine when the operation is complete.
* 3) Query to determine if the alignment was successfuly completed.
*
**********************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include "visa.h"
void main ()
{
/*program variables*/
ViSession defaultRM, viPSA;
ViStatus viStatus = 0;
ViUInt16 esr,stat;
180 Chapter 16
ESA/PSA Programming Examples
Using C to Serial Poll the Analyzer to Determine when an Auto-alignment is
Complete
E
S
A
/
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
long lResult = 0;
long lOpc = 0;
char cEnter = 0;
/*open session to GPIB device at address 18 */
viStatus=viOpenDefaultRM (&defaultRM);
viStatus=viOpen (defaultRM, "GPIB0::18::INSTR", VI_NULL,VI_NULL,&viPSA);
/*check opening session sucess*/
if(viStatus)
{
printf("Could not open a session to GPIB device at address 18!\n");
exit(0);
}
/*increase timeout to 60 sec*/
viSetAttribute(viPSA,VI_ATTR_TMO_VALUE,60000);
/*Clear the analyzer*/
viClear(viPSA);
/*Clear all event registers*/
viPrintf(viPSA, "*CLS\n");
/* Set the Status Event Enable Register */
viPrintf(viPSA, "*ESE 1\n");
/*Initiate self-alignment*/
viPrintf(viPSA, "CAL:ALL\n");
/* Send the Operation complete command so that the
stand event register will be set to 1 once
the pending alignment command is complete */
viPrintf(viPSA, "*OPC\n");
/* print message to standard output */
Chapter 16 181
ESA/PSA Programming Examples
Using C to Serial Poll the Analyzer to Determine when an Auto-alignment is
Complete
E
S
A
/
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
printf("Performing self-alignment.\n");
/* Serial pole the instrument for operation complete */
while(1)
{
viQueryf(viPSA,"*ESR?\n","%ld",&esr);
printf(".");
if (esr & 1) break;//look for operation complete bit
Sleep (1000);// wait 1000ms before polling again
}

/* Query the Status Questionable Condition Register */
viQueryf(viPSA,":STAT:QUES:CAL:COND?\n","%ld",&stat);
/*Determine if alignment was successful*/
if (stat)
printf("\nAlignment not successful\n\n");
else
printf("\nAlignment successful\n\n");
/*reset timeout to 5 sec*/
viSetAttribute(viPSA,VI_ATTR_TMO_VALUE,5000);
/*print message to the standard output*/
printf("Press Return to exit program \n\n");
scanf("%c",&cEnter);
/* Close session */
viClose (viPSA);
viClose (defaultRM);
}
182 Chapter 16
ESA/PSA Programming Examples
Using C and Service Request (SRQ) to Determine When a Measurement is
Complete
E
S
A
/
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Using C and Service Request (SRQ) to
Determine When a Measurement is Complete
Thi s C progr ammi ng exampl e (SRQ.c) can be found on the
Documentati on CD.
/*************************************************************************
* SRQ.C
* Determine when a measurement is done by waiting for SRQ
* and reading Status Register
*
* Instrument Requirements:
* PSA/ESA/EMC Series Spectrum Analyzers.
*
* This C programming demonstrates how:
* A. Set the service request mask to assert SRQ when
* either a measurement is uncalibrated or an error
* message has occurred.
* B. Initiate a sweep and wait for the SRQ interupt
* C. Poll all instruments and report the nature of the
* interrupt on the spectrum analyzer
*
* You have a royalty-free right to use, modify, reproduce and distribute
* the Sample Application Files (and/or any modified version) in any way
* you find useful, provided that you agree that Agilent Technologies has
* no warranty, obligations or liability for any Sample Application Files.
*
* Agilent Technologies provides programming examples for illustration only,
* This sample program assumes that you are familiar with the programming
* language being demonstrated and the tools used to create and debug
* procedures. Agilent Technologies support engineers can help explain the
* functionality of Agilent Technologies software components and associated
* commands, but they will not modify these samples to provide added
* functionality or construct procedures to meet your specific needs.
*
* Copyright 1999- 2004 Agilent Technologies Inc. All rights reserved.
Chapter 16 183
ESA/PSA Programming Examples
Using C and Service Request (SRQ) to Determine When a Measurement is
Complete
E
S
A
/
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
***************************************************************************/
#include <stdio.h>
#include <windows.h>
#include "visa.h"
ViSessiondefaultRM, viSA;
ViStatuserrStatus;
ViAddr iAddress;
int iSrqOccurred=0;
char cBuf[3]={0};
/*Wait until SRQ is generated and for the handler to be called. Print
something while waiting. When interrupt occurs it will be handled by
interrupt handler*/
void WaitForSRQ()
{
long lCount = 0L;
iSrqOccurred =0;
for (lCount =0;(lCount<10) && (iSrqOccurred ==0); lCount++)
{
long lCount2 =0;
printf(".");
while ((lCount2++ < 100) && (iSrqOccurred ==0))
{
Sleep(10);
}
}
}
/*Interrupt handler,trigger event handler */
ViStatus _VI_FUNCH mySrqHdlr(ViSession viSA, ViEventType eventType, ViEvent
ctx,ViAddr userHdlr)
{
ViUInt16 iStatusByte;
184 Chapter 16
ESA/PSA Programming Examples
Using C and Service Request (SRQ) to Determine When a Measurement is
Complete
E
S
A
/
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/* Make sure it is an SRQ event, ignore if stray event*/
if (eventType!=VI_EVENT_SERVICE_REQ)
{
printf ("\n Stray event type0x%1x\n",eventType);
/*Return successfully*/
return VI_SUCCESS;
}
/* When an interrupt occurs,determine which device generated the interrupt
(if an instrument other than the PSA/ESA generates the interrupt, simply report
"Instrument at GPIB Address xxx Has Generated an Interrupt").*/
printf ("\n\n SRQ event occurred!\n");
/*Get the GPIB address of the insrument, which has interrupted*/
viQueryf(viSA,"SYST:COMM:GPIB:SELF:ADDR?\n","%t", cBuf);
printf ("\n Instrument at GPIB address %s has generated an interrupt!\n",cBuf);
/*Get the status byte*/
/* If the PSA/ESA generated the interrupt, determine the nature of the
interrupt;
did the measurement complete or an error message occur?*/
viQueryf(viSA, "*ESR?\n", "%d", &iStatusByte);
if ( (0x01 & iStatusByte))
printf("\n SRQ message:\t Measurement complete\n");
else if ( (0x02 | 0x10 | 0x20 & iStatusByte ))
printf ("\n SRQ message:\t Error Message Occurred\n");
/*Return successfully*/
iSrqOccurred =1;
viReadSTB(viSA,&iStatusByte);
return VI_SUCCESS;
}
/* Main Program*/
void main()
{
Chapter 16 185
ESA/PSA Programming Examples
Using C and Service Request (SRQ) to Determine When a Measurement is
Complete
E
S
A
/
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/*Program Variables*/
ViStatus viStatus = 0;
long lOpc=0;
/* Open a GPIB session at address 18*/
viStatus=viOpenDefaultRM(&defaultRM);
viStatus=viOpen(defaultRM,"GPIB0::18",VI_NULL,VI_NULL,&viSA);
if(viStatus)
{
printf("Could not open a session to GPIB device at address 18!\n");
exit(0);
}
/* Set I/O timeout to twenty seconds */
viSetAttribute(viSA,VI_ATTR_TMO_VALUE,20000);
/*Clear the instrument*/
viClear(viSA);
/*Reset the instrument*/
viPrintf(viSA,"*RST\n");
/*Clear the status byte of the instrument*/
viPrintf(viSA,"*CLS\n");
/*Put the analyzer in a single sweep*/
viPrintf(viSA,"INIT:CONT 0 \n");
/* Change the instrument mode to Spectrum Analysis */
viPrintf(viSA,":INST:NSEL 1\n");
/*Set the analyzer resolution bandwidth to 300 Khz*/
viPrintf(viSA,"SENS:BAND:RES 300 KHz\n");
/*Set the analyzer to 10MHz span*/
viPrintf(viSA,"SENS:FREQ:SPAN 10MHz\n");
186 Chapter 16
ESA/PSA Programming Examples
Using C and Service Request (SRQ) to Determine When a Measurement is
Complete
E
S
A
/
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/*Initiate a sweep*/
viPrintf(viSA,"INIT:IMM\n");
/*Make sure the previous command has been completed*/
viQueryf(viSA, "*OPC?\n", "%d", &lOpc);
if (!lOpc)
{
printf("\nProgram Abort! error ocurred: last command was not
completed!\n");
exit(0);
}
/* Set the service request mask to assert SRQ when either a measurement
is completed or an error message has occurred.*/
viPrintf(viSA,"*SRE 96\n");
viPrintf(viSA,"*ESE 35\n");
/* Configure the computer to respond to an interrupt*/
/*install the handler and enable it */
viInstallHandler(viSA, VI_EVENT_SERVICE_REQ, mySrqHdlr,iAddress);
viEnableEvent(viSA, VI_EVENT_SERVICE_REQ,VI_HNDLR,VI_NULL);
/* Print Comment to user */
printf("Sending illegal command IDN and then waiting for SRQ\n");
/*Send an undefined command to the device*/
viPrintf(viSA,"IDN\n");
/*Wait for SRQ */
WaitForSRQ();
/*Set video averaging to 50 sweeps and turn averaging On*/
viPrintf(viSA,":SENS:AVER:TYPE LPOW;:SENS:AVER:COUN 50;:SENS:AVER:STAT ON\n");
/* Print Comment to user */
printf("\nInitiating measurement and waiting for SRQ when measurement
Chapter 16 187
ESA/PSA Programming Examples
Using C and Service Request (SRQ) to Determine When a Measurement is
Complete
E
S
A
/
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
done.\n");
/*Initiate the sweeps and set the *OPC bit after the sweeps are completed*/
viPrintf(viSA,":INIT:IMM;*OPC\n");
/*Wait for SRQ */
WaitForSRQ();
/*Disable and uninstall the interrupt handler*/
viDisableEvent (viSA, VI_EVENT_SERVICE_REQ,VI_HNDLR);
viUninstallHandler(viSA, VI_EVENT_SERVICE_REQ, mySrqHdlr,iAddress);
/*Clear the instrument status register*/
viPrintf(viSA,"*SRE 0 \n");
/*Clear the status byte of the instrument*/
viPrintf(viSA,"*CLS\n");
/*Close the session*/
viClose(viSA);
viClose(defaultRM);
}
188 Chapter 16
ESA/PSA Programming Examples
Using Visual Basic 6 to Capture a Screen Image
E
S
A
/
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Using Visual Basic

6 to Capture a Screen
Image
Thi s i s a Vi sual Basi c exampl e that stores the curr ent screen i mage on
your PC. The pr ogram works wi th the ESA or PSA Seri es spectrum
anal yzer s. The bas fi l e (screen.bas) and a compi l ed executabl e
(scr een.exe) can be found on the Documentati on CD.
Thi s exampl e:
1. Stores the curr ent screen i mage on the i nstruments fl ash as
C:PI CTURE.GI F.
2. Transfers the i mage over GPI B or LAN and stores i t on your PC i n
the cur rent di rector y as pi cture.gi f.
3. The fi l e C:PI CTURE.GI F i s then del eted fr om the i nstruments
fl ash.
NOTE Thi s exampl e uses GPI B addr ess 18 for the spectrum anal yzer.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Copyright (c) 1999- 2003 Agilent Technologies Inc. All rights reserved.

You have a royalty-free right to use, modify, reproduce and distribute


the Sample Application Files (and/or any modified version) in any way
you find useful, provided that you agree that Agilent Technologies has
no warranty, obligations or liability for any Sample Application Files.

Agilent Technologies provides programming examples for illustration only,


This sample program assumes that you are familiar with the programming
language being demonstrated and the tools used to create and debug
procedures. Agilent Technologies support engineers can help explain the
functionality of Agilent Technologies software components and associated
commands, but they will not modify these samples to provide added
functionality or construct procedures to meet your specific needs.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
To develop VISA applications in Microsoft Visual Basic, you first need
to add the Visual Basic (VB) declaration file in your VB project as a
Module. This file contains the VISA function definitions and constant
Chapter 16 189
ESA/PSA Programming Examples
Using Visual Basic 6 to Capture a Screen Image
E
S
A
/
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
declarations needed to make VISA calls from Visual Basic.
To add this module to your project in VB 6, from the menu, select
Project->Add Module, select the Existing tab, and browse to the
directory containing the VB Declaration file, select visa32.bas, and
press Open.

The name and location of the VB declaration file depends on which


operating system you are using. Assuming the standard VISA directory
of C:\Program Files\VISA or the standard VXIpnp directory of
C:\VXIpnp, the visa32.bas file can be located in one of the following:

\winnt\agvisa\include\visa32.bas - Windows NT/2000/XP


\winnt\include\visa32.bas - Windows NT/2000/XP
\win95\include\visa32.bas - Windows 95/98/Me

screen.bas
The following example program is written for the PSA and ESA Series
Spectrum Analyzers. It stores the current screen image on the
instruments flash as C:PICTURE.GIF. It then transfers the image over
GPIB or LAN and stores the image on your PC in the current directory
as picture.gif. The file C:PICTURE.GIF is then deleted on the
instruments flash.

Option Explicit
Private Sub Main()
Declare Variables used in the program
Dim status As Long VISA function status return code
Dim defrm As Long Session to Default Resource Manager
Dim vi As Long Session to instrument
Dim x As Integer Loop Variable
Dim ArrayPtr(1) As Long Array of Pointers
Dim ResultsArray(50000) As Byte results array, Big enough to hold a GIF
Dim length As Long Number of bytes returned from instrument
Dim fnum As Integer File Number to used to open file to store data
Dim isOpen As Boolean Boolean flag used to keep track of open file
190 Chapter 16
ESA/PSA Programming Examples
Using Visual Basic 6 to Capture a Screen Image
E
S
A
/
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Dim headerlength As Long length of header

Set the default number of bytes that will be contained in the
ResultsArray to 50,000 (50kB)
length = 50000

Set the array of pointers to the addresses of the variables
ArrayPtr(0) = VarPtr(length)
ArrayPtr(1) = VarPtr(ResultsArray(0))

Delete picture.gif file if it exists
On Error Resume Next
Kill "picture.gif"

On Error GoTo Error_Handler

Open the default resource manager session
status = viOpenDefaultRM(defrm)

Open the session. Note: For PSA, to use LAN, change the string to
"TCPIP0::xxx.xxx.xxx.xxx::inst0::INSTR" where xxxxx is the IP address
status = viOpen(defrm, "GPIB0::18::INSTR", 0, 0, vi)
If (status < 0) Then GoTo VisaErrorHandler

Set the I/O timeout to fifteen seconds
status = viSetAttribute(vi, VI_ATTR_TMO_VALUE, 15000)
If (status < 0) Then GoTo VisaErrorHandler

Store the current screen image on flash as C:PICTURE.GIF
status = viVPrintf(vi, ":MMEM:STOR:SCR C:PICTURE.GIF" + Chr$(10), 0)
If (status < 0) Then GoTo VisaErrorHandler

Grab the screen image file from the instrument
status = viVQueryf(vi, ":MMEM:DATA? C:PICTURE.GIF" + Chr$(10), _
"%#y", ArrayPtr(0))

Chapter 16 191
ESA/PSA Programming Examples
Using Visual Basic 6 to Capture a Screen Image
E
S
A
/
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Delete the tempory file on the flash named C:PICTURE.GIF
status = viVPrintf(vi, ":MMEM:DEL C:PICTURE.GIF" + Chr$(10), 0)
If (status < 0) Then GoTo VisaErrorHandler

Close the vi session and the resource manager session
Call viClose(vi)
Call viClose(defrm)

Store the results in a text file
fnum = FreeFile() Get the next free file number
Open "picture.gif" For Binary As #fnum
isOpen = True
headerlength = 2 + (Chr$(ResultsArray(1)))
For x = headerlength To length - 2
Put #fnum, , ResultsArray(x)
Next x

Intentionally flow into Error Handler to close file
Error_Handler:
Raise the error (if any), but first close the file
If isOpen Then Close #fnum
If Err Then Err.Raise Err.Number, , Err.Description
Exit Sub

VisaErrorHandler:
Dim strVisaErr As String * 200
Call viStatusDesc(defrm, status, strVisaErr)
MsgBox "*** Error : " & strVisaErr, vbExclamation, "VISA Error Message"
Exit Sub
End Sub
192 Chapter 16
ESA/PSA Programming Examples
Using Visual Basic 6 to Transfer Binary Trace Data
E
S
A
/
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Using Visual Basic

6 to Transfer Binary Trace


Data
Thi s i s a Vi sual Basi c exampl e that gets bi nary trace data fr om the
i nstrument. Bi nary data tr ansfer s ar e faster than the defaul t ASCI I
tr ansfer mode, because l ess data i s sent over the bus. Thi s exampl e
works wi th the ESA or PSA Seri es spectrum anal yzers. The bas fi l e
(bi ntrace.bas) and a compi l ed executabl e (bi ntrace.exe) can be found on
the Documentati on CD.
Thi s exampl e:
1. Queri es the I DN (i denti fi cati on) stri ng from the i nstrument.
2. Whi l e i n Spectrum Anal ysi s mode, i t reads the tr ace data i n bi nary
format (Real ,32 or Real ,64 or I nt,32).
3. Stores the data i s then to a fi l e "bi ntr ace.txt".
NOTE Thi s exampl e uses GPI B addr ess 18 for the spectrum anal yzer.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Copyright (c) 1999- 2003 Agilent Technologies Inc. All rights reserved.

You have a royalty-free right to use, modify, reproduce and distribute


the Sample Application Files (and/or any modified version) in any way
you find useful, provided that you agree that Agilent Technologies has
no warranty, obligations or liability for any Sample Application Files.

Agilent Technologies provides programming examples for illustration only,


This sample program assumes that you are familiar with the programming
language being demonstrated and the tools used to create and debug
procedures. Agilent Technologies support engineers can help explain the
functionality of Agilent Technologies software components and associated
commands, but they will not modify these samples to provide added
functionality or construct procedures to meet your specific needs.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
To develop VISA applications in Microsoft Visual Basic, you first need
to add the Visual Basic (VB) declaration file in your VB project as a
Module. This file contains the VISA function definitions and constant
Chapter 16 193
ESA/PSA Programming Examples
Using Visual Basic 6 to Transfer Binary Trace Data
E
S
A
/
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
declarations needed to make VISA calls from Visual Basic.
To add this module to your project in VB 6, from the menu, select
Project->Add Module, select the Existing tab, and browse to the
directory containing the VB Declaration file, select visa32.bas, and
press Open.

The name and location of the VB declaration file depends on which


operating system you are using. Assuming the standard VISA directory
of C:\Program Files\VISA or the standard VXIpnp directory of
C:\VXIpnp, the visa32.bas file can be located in one of the following:

\winnt\agvisa\include\visa32.bas - Windows NT/2000/XP


\winnt\include\visa32.bas - Windows NT/2000/XP
\win95\include\visa32.bas - Windows 95/98/Me

bintrace.bas
The following example program is written for the PSA and ESA Series
Spectrum Analyzers. It queries the IDN string from the instrument
and then reads the trace data in Spectrum Analysis mode in binary
format (Real,32 or Real,64 or Int,32). The data is then stored to a
file "bintrace.txt".
Binary transfers are faster than the default ASCII transfer mode,
because less data is sent over the bus.

Option Explicit
Private Sub Main()
Declare Variables used in the program
Dim status As Long VISA function status return code
Dim defrm As Long Session to Default Resource Manager
Dim vi As Long Session to instrument
Dim strRes As String * 100 Fixed length string to hold *IDN? Results
Dim x As Integer Loop Variable
Dim output As String output string variable
Dim ArrayPtr(1) As Long Array of Pointers
194 Chapter 16
ESA/PSA Programming Examples
Using Visual Basic 6 to Transfer Binary Trace Data
E
S
A
/
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Dim ResultsArray(8192) As Single trace element array of Real,32 values
For Real,64 data use Double. For Int,32 data use Long
Dim length As Long Number of trace elements return from instrument
Dim fnum As Integer File Number to used to open file to store data
Dim isOpen As Boolean Boolean flag used to keep track of open file

Set the default number of trace elements to the ResultsArray size
Note: PSA and ESA currently support up to 8192 trace points
length = 8192

Set the array of pointers to the addresses of the variables
ArrayPtr(0) = VarPtr(length)
ArrayPtr(1) = VarPtr(ResultsArray(0))

On Error GoTo Error_Handler

Open the default resource manager session
status = viOpenDefaultRM(defrm)

Open the session. Note: For PSA, to use LAN, change the string to
"TCPIP0::xxx.xxx.xxx.xxx::inst0::INTSR" where xxxxx is the IP address
status = viOpen(defrm, "GPIB0::18::INSTR", 0, 0, vi)
If (status < 0) Then GoTo VisaErrorHandler

Set the I/O timeout to five seconds
status = viSetAttribute(vi, VI_ATTR_TMO_VALUE, 5000)
If (status < 0) Then GoTo VisaErrorHandler

Ask for the devicess *IDN string.
status = viVPrintf(vi, "*IDN?" + Chr$(10), 0)
If (status < 0) Then GoTo VisaErrorHandler

Read back the IDN string from the instrument
status = viVScanf(vi, "%t", strRes)
If (status < 0) Then GoTo VisaErrorHandler

Chapter 16 195
ESA/PSA Programming Examples
Using Visual Basic 6 to Transfer Binary Trace Data
E
S
A
/
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Print the IDN string results in a message box
MsgBox (strRes)

Change the instrument mode to Spectrum Analysis
status = viVPrintf(vi, ":INST:NSEL 1" + Chr$(10), 0)
If (status < 0) Then GoTo VisaErrorHandler

Set instrument trace data format to 32-bit Real
Note: For higher precision use 64-bit data, ":FORM REAL,64"
For faster data transfer for ESA, use ":FORM INT,32"
status = viVPrintf(vi, ":FORM REAL,32" + Chr$(10), 0)
If (status < 0) Then GoTo VisaErrorHandler

Set Analyzer to single sweep mode
status = viVPrintf(vi, ":INIT:CONT 0" + Chr$(10), 0)
If (status < 0) Then GoTo VisaErrorHandler

Trigger a sweep and wait for sweep to complete
status = viVPrintf(vi, ":INIT:IMM;*WAI" + Chr$(10), 0)
If (status < 0) Then GoTo VisaErrorHandler

Query the trace data from the instrument
Note: Change the "%#zb" to "%#Zb" for Real,64 data
For Int,32 leave the modifier as "%#zb"
status = viVQueryf(vi, ":TRAC:DATA? TRACE1" + Chr$(10), _
"%#zb", ArrayPtr(0))
Close the vi session and the resource manager session
Call viClose(vi)
Call viClose(defrm)

Print number of elements returned
MsgBox ("Number of trace elements returned = " & length)

Create a string from the ResultsArray to output to a file
For x = 0 To length - 1
196 Chapter 16
ESA/PSA Programming Examples
Using Visual Basic 6 to Transfer Binary Trace Data
E
S
A
/
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
output = output & ResultsArray(x) & vbCrLf
Next x

Print Results to the Screen
MsgBox (output)

Store the results in a text file
fnum = FreeFile() Get the next free file number
Open "bintrace.txt" For Output As #fnum
isOpen = True
Print #fnum, output

Intentionally flow into Error Handler to close file
Error_Handler:
Raise the error (if any), but first close the file
If isOpen Then Close #fnum
If Err Then Err.Raise Err.Number, , Err.Description
Exit Sub

VisaErrorHandler:
Dim strVisaErr As String * 200
Call viStatusDesc(defrm, status, strVisaErr)
MsgBox "*** Error : " & strVisaErr, vbExclamation, "VISA Error Message"
Exit Sub
End Sub
Chapter 16 197
ESA/PSA Programming Examples
Using Agilent VEE to Transfer Trace Data
E
S
A
/
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Using Agilent VEE to Transfer Trace Data
This VEE programming example transfers trace data from a PSA or ESA
series spectrum analyzer. The program supports data transfer types to
integer 32, real 32, real 64 and ASCII data.
VEE Window Capture of tracetransfer.vee:
198 Chapter 16
ESA/PSA Programming Examples
Using Agilent VEE to Transfer Trace Data
E
S
A
/
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
199
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
17 ESA Programming Examples
200 Chapter 17
ESA Programming Examples
Examples Included in this Chapter:
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Examples Included in this Chapter:
This chapter includes C programming examples of how to program the ESA series
using SCPI commands. Twelve examples are written for ESA analyzers with GPIB
interface (Option A4H). Three examples are written for ESA analyzers with an
RS-232 interface (Option 1AX). These examples do not apply to analyzers that
have Option 290 (8590 Series Programming Code Compatibility).
Using C with Marker Peak Search and Peak Excursion Measurement
Routines on page 202
Using C for Marker Delta Mode and Marker Minimum Search Functions on
page 206
Using C to Perform Internal Self-Alignment on page 210
Using C to Read Trace Data in an ASCII Format (over GPIB) on page 214
Using C to Read Trace Data in a 32-Bit Real Format (over GPIB) on page
218
Using C to Read Trace Data in an ASCII Format (over RS-232) on page 223
Using C to Read Trace Data in a 32-bit Real Format (over RS-232) on page
228
Using C to Add Limit Lines on page 233
Using C to Measure Noise on page 239
Using C to Enter Amplitude Correction Data on page 243
Using C to Determine if an Error has Occurred on page 247
Using C to Measure Harmonic Distortion (over GPIB) on page 253
Using C to Measure Harmonic Distortion (over RS-232) on page 261
Using C to Make Faster Power Averaging Measurements on page 269
Chapter 17 201
ESA Programming Examples
Programming Examples System Requirements
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Programming Examples System Requirements
The ESA Series examples were written for use on an IBM compatible PC
configured as follows:
Pentium processor
Windows 95/98/2000/XP or Windows NT 4.0 operating system
C programming language
National Instruments GPIB interface card (for analyzers with Option A4H)
National Instruments VISA Transition Libraries (VTL)
COM1 serial port configured as follows (for analyzers with Option 1AX)
9600 baud
8 data bits
1 stop bit
no parity bits
hardware flow control
A HP/Agilent 82341C card may be substituted for the National Instruments GPIB,
and the HP VISA libraries may be substituted for the National Instruments VISA
Transition Libraries. If substitutions are made, the subdirectories for the include
and library files will be different than those listed in the following paragraphs.
Refer to the documentation for your interface card and the VISA libraries for
details.
202 Chapter 17
ESA Programming Examples
Using C with Marker Peak Search and Peak Excursion Measurement
Routines
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Using C with Marker Peak Search and Peak Excursion
Measurement Routines
This C programming example (mkpksrch.c) can be found on the Documentation
CD.
/************************************************************/
/* Using Marker Peak Search and Peak Excursion */
/* */
/* This example is for the E44xxB ESA Spectrum Analyzers */
/* and E740xA EMC Analyzers. */
/* */
/* This C programming example does the following. */
/* The SCPI instrument commands used are given as */
/* reference. */
/* */
/* - Opens a GPIB session at address 18 */
/* - Clears the Analyzer */
/* *CLS */
/* - Resets the Analyzer */
/* *RST */
/* - Sets the analyzer center frequency, span and units */
/* SENS:FREQ:CENT freq */
/* SENS:FREQ:SPAN freq */
/* UNIT:POW DBM */
/* - Set the input port to the 50 MHz amplitude reference */
/* CAL:SOUR:STAT ON */
/* - Set the analyzer to single sweep mode */
/* INIT:CONT 0 */
/* - Prompt the user for peak excursion and set them */
/* CALC:MARK:PEAK:EXC dB */
/* - Set the peak threshold to -90 dBm */
/* TRAC:MATH:PEAK:THR:STAT ON */
/* TRAC:MATH:PEAK:THR -90 */
/* - Trigger a sweep and wait for sweep to complete */
/* INIT:IMM;*WAI */
/* - Set the marker to the maximum peak */
/* CALC:MARK:MAX */
/* - Query and read the marker frequency and amplitude */
/* CALC:MARK:X? */
/* CALC:MARK:Y? */
/* - Close the session */
/************************************************************/

Chapter 17 203
ESA Programming Examples
Using C with Marker Peak Search and Peak Excursion Measurement
Routines
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <conio.h>
#include <ctype.h>
#include <string.h>
#include "visa.h"
#define hpESA_IDN_E4401B "Hewlett-Packard, E4401B"
#define hpESA_IDN_E4411B "Hewlett-Packard, E4411B"
#definehpEMC_IDN_E7401A "Hewlett-Packard, E7401A"
ViSession defaultRM, viESA;
ViStatus errStatus;
ViChar cIdBuff[256]= {0};
char cEnter = 0;
int iResult = 0;
/*Set the input port to 50MHz amplitude reference*/
void Route50MHzSignal()
{
viQueryf(viESA, "*IDN?\n", "%t", &cIdBuff);
iResult = (strncmp( cIdBuff, hpESA_IDN_E4401B, strlen(hpESA_IDN_E4401B)) &&
strncmp( cIdBuff, hpESA_IDN_E4411B, strlen(hpESA_IDN_E4411B)) && strncmp( cIdBuff,
hpEMC_IDN_E7401A, strlen(hpEMC_IDN_E7401A)));
if( iResult == 0 )
{
/*Set the input port to the 50MHz amplitude reference for the models*/
/*E4401B, E4411B and E7401A*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n");
}
else
{
/* For the analyzers having frequency limits >= 3GHz, prompt the user*/
/* to connect the amplitude reference output to the input*/
printf ("Connect AMPTD REF OUT to the INPUT \n");
printf ("......Press Return to continue \n");
scanf( "%c",&cEnter);
/*Externally route the 50MHz Signal*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n");
}
}
void main()
204 Chapter 17
ESA Programming Examples
Using C with Marker Peak Search and Peak Excursion Measurement
Routines
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
{
/*Program Variables*/
ViStatus viStatus = 0;
double dMarkerFreq = 0;
double dMarkerAmpl = 0;
float fPeakExcursion =0;
long lOpc = 0L;
/*Open a GPIB session at address 18.*/
viStatus=viOpenDefaultRM(&defaultRM);
viStatus=viOpen(defaultRM,"GPIB0::18",VI_NULL,VI_NULL,&viESA);
if(viStatus)
{
printf("Could not open a session to GPIB device at address 18!\n");
exit(0);
}
/*Clear the instrument*/
viClear(viESA);
/*Reset the instrument*/
viPrintf(viESA,"*RST\n");
/*Set Y-Axis units to dBm*/
viPrintf(viESA, "UNIT:POW DBM\n");
/*Set the analyzer center frequency to 50MHZ*/
viPrintf(viESA,"SENS:FREQ:CENT 50e6\n");
/*Set the analyzer span to 50MHZ*/
viPrintf(viESA,"SENS:FREQ:SPAN 50e6\n");
/*Display the program heading */
printf("\n\t\t Marker Program \n\n" );
/* Check for the instrument model number and route the 50MHz signal accordingly*/
Route50MHzSignal();
/*Set analyzer to single sweep mode*/
viPrintf(viESA,"INIT:CONT 0 \n");
/*User enters the peak excursion value*/
printf("\t Enter PEAK EXCURSION in dB: ");
scanf( "%f",&fPeakExcursion);

/*Set the peak excursion*/
viPrintf(viESA,"CALC:MARK:PEAK:EXC %1fDB \n",fPeakExcursion);
Chapter 17 205
ESA Programming Examples
Using C with Marker Peak Search and Peak Excursion Measurement
Routines
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/*Set the peak thresold */
viPrintf(viESA,"CALC:MARK:PEAK:THR -90 \n");
/*Trigger a sweep and wait for completion*/
viPrintf(viESA,"INIT:IMM;*WAI\n");
/*Set the marker to the maximum peak*/
viPrintf(viESA,"CALC:MARK:MAX \n");
/*Query and read the marker frequency*/
viQueryf(viESA,"CALC:MARK:X? \n","%lf",&dMarkerFreq);
printf("\n\t RESULT: Marker Frequency is: %lf MHZ \n\n",dMarkerFreq/10e5);
/*Query and read the marker amplitude*/
viQueryf(viESA,"CALC:MARK:Y?\n","%lf",&dMarkerAmpl);
printf("\t RESULT: Marker Amplitude is: %lf dBm \n\n",dMarkerAmpl);
/*Close the session*/
viClose(viESA);
viClose(defaultRM);
}
206 Chapter 17
ESA Programming Examples
Using C for Marker Delta Mode and Marker Minimum Search Functions
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Using C for Marker Delta Mode and Marker Minimum
Search Functions
This C programming example (mkrdelta.c) can be found on the Documentation
CD.
/************************************************************/
/* Using Marker Delta Mode and Marker Minimum Search */
/* */
/* This example is for the E44xxB ESA Spectrum Analyzers */
/* and E740xA EMC Analyzers. */
/* */
/* This C programming example does the following. */
/* The SCPI instrument commands used are given as */
/* reference. */
/* */
/* - Opens a GPIB session at address 18 */
/* - Clears the Analyzer */
/* - Resets the Analyzer */
/* *RST */
/* - Set the input port to the 50 MHz amplitude reference */
/* CAL:SOUR:STAT ON */
/* - Set the analyzer to single sweep mode */
/* INIT:CONT 0 */
/* - Prompts the user for the start and stop frequencies */
/* - Sets the start and stop frequencies */
/* SENS:FREQ:START freq */
/* SENS:FREQ:STOP freq */
/* - Trigger a sweep and wait for sweep completion */
/* INIT:IMM;*WAI */
/* - Set the marker to the maximum peak */
/* CALC:MARK:MAX */
/* - Set the analyzer to activate the delta marker */
/* CALC:MARK:MODE DELT */
/* - Trigger a sweep and wait for sweep completion */
/* INIT:IMM;*WAI */
/* - Set the marker to the minimum amplitude mode */
/* CALC:MARK:MIN */
/* - Query and read the marker amplitude */
/* CALC:MARK:Y? */
/* - Close the session */
/************************************************************/

#include <stdio.h>
Chapter 17 207
ESA Programming Examples
Using C for Marker Delta Mode and Marker Minimum Search Functions
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
#include <stdlib.h>
#include <math.h>
#include <conio.h>
#include <ctype.h>
#include <string.h>
#include "visa.h"
#define hpESA_IDN_E4401B "Hewlett-Packard, E4401B"
#define hpESA_IDN_E4411B "Hewlett-Packard, E4411B"
#define hpEMC_IDN_E7401A "Hewlett-Packard, E7401A"
ViSession defaultRM, viESA;
ViStatus errStatus;
ViChar cIdBuff[256] ={0};
char cEnter = 0;
int iResult =0;
/*Set the input port to the 50MHz amplitude reference*/
void Route50MHzSignal()
{
viQueryf(viESA, "*IDN?\n", "%t", &cIdBuff);
iResult = (strncmp( cIdBuff, hpESA_IDN_E4401B, strlen(hpESA_IDN_E4401B)) &&
strncmp( cIdBuff, hpESA_IDN_E4411B, strlen(hpESA_IDN_E4411B)) && strncmp( cIdBuff,
hpEMC_IDN_E7401A, strlen(hpEMC_IDN_E7401A)));
if( iResult == 0 )
{
/*Set the input port to the 50MHz amplitude reference for the models*/
/* E4401B, E4411B and E7401A*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n");
}
else
{
/* For the analyzers having frequency limits >= 3GHz, prompt the user*/
/* to connect the amplitude reference output to the input*/
printf ("Connect AMPTD REF OUT to the INPUT \n");
printf ("......Press Return to continue \n");
scanf( "%c",&cEnter);
/*Externally route the 50MHz Signal*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n");
}
}
void main()
{
/*Program Variable*/
208 Chapter 17
ESA Programming Examples
Using C for Marker Delta Mode and Marker Minimum Search Functions
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
ViStatus viStatus = 0;
double dStartFreq =0.0;
double dStopFreq =0.0;
double dMarkerAmplitude = 0.0;
long lOpc =0L;
/* Open an GPIB session at address 18*/
viStatus=viOpenDefaultRM(&defaultRM);
viStatus=viOpen(defaultRM,"GPIB0::18",VI_NULL,VI_NULL,&viESA);
if(viStatus)
{
printf("Could not open a session to GPIB device at address 18!\n");
exit(0);
}
/*Clear the instrument*/
viClear(viESA);
/*Reset the instrument*/
viPrintf(viESA,"*RST\n");
/*Display the program heading */
printf("\n\t\t Marker Delta Program \n\n" );
/*Check for the instrument model number and route the 50MHz signal accordingly*/
Route50MHzSignal();
/*Set the analyzer to single sweep mode*/
viPrintf(viESA,"INIT:CONT 0\n");
/*Prompt the user for the start frequency*/
printf("\t Enter the Start frequency in MHz ");
/*The user enters the start frequency*/
scanf("%lf",&dStartFreq);
/*Prompt the user for the stop frequency*/
printf("\t Enter the Stop frequency in MHz ");
/*The user enters the stop frequency*/
scanf("%lf",&dStopFreq);
/*Set the analyzer to the values given by the user*/
viPrintf(viESA,"SENS:FREQ:STAR %lf MHZ \n;:SENS:FREQ:STOP %lf
MHZ\n",dStartFreq,dStopFreq);
/*Trigger a sweep, wait for completion*/
Chapter 17 209
ESA Programming Examples
Using C for Marker Delta Mode and Marker Minimum Search Functions
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
viPrintf(viESA,"INIT:IMM;*WAI\n");
/*Set the marker to the maximum peak*/
viPrintf(viESA,"CALC:MARK:MAX\n");
/*Set the analyzer to activate delta marker mode*/
viPrintf(viESA,"CALC:MARK:MODE DELT\n");
/*Trigger a sweep, wait for completion*/
viPrintf(viESA,"INIT:IMM;*WAI\n");
/*Set the marker to minimum amplitude*/
viPrintf(viESA,"CALC:MARK:MIN\n");
/*Query and read the marker amplitude*/
viQueryf(viESA,"CALC:MARK:Y?\n","%lf",&dMarkerAmplitude);
/*print the marker amplitude*/
printf("\n\n\tRESULT: Marker Amplitude Delta = %lf dB\n\n",dMarkerAmplitude);
/*Close the session*/
viClose(viESA);
viClose(defaultRM);
}
210 Chapter 17
ESA Programming Examples
Using C to Perform Internal Self-Alignment
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Using C to Perform Internal Self-Alignment
This C programming example (intalign.c) can be found on the Documentation CD.
/************************************************************/
/* Performing Internal Self-alignment */
/* */
/* This example is for the E44xxB ESA Spectrum Analyzers */
/* and E740xA EMC Analyzers. */
/* */
/* This example shows two ways of executing an internal */
/* self-alignment. The first demonstrates using the *OPC? */
/* query to determine when the alignment has completed. The */
/* second demonstrates using the query form of the CAL:ALL */
/* command to not only determine when the alignment has */
/* been completed, but the pass/fail status of the align- */
/* ment process. */
/* */
/* This C programming example does the following. */
/* The SCPI instrument commands used are given as */
/* reference. */
/* */
/* - Opens a GPIB session at address 18 */
/* - Clears the Analyzer */
/* *CLS */
/* - Resets the Analyzer */
/* *RST */
/* - VISA function sets the time out to infinite */
/* - Initiate self-alignment */
/* CAL:ALL */
/* - Query for operation complete */
/* *OPC? */
/* - Query for results of self-alignment */
/* CAL:ALL? */
/* - Report the results of the self-alignment */
/* - Close the session */
/************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <string.h>
#include "visa.h"
Chapter 17 211
ESA Programming Examples
Using C to Perform Internal Self-Alignment
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
#define hpESA_IDN_E4401B "Hewlett-Packard, E4401B"
#define hpESA_IDN_E4411B "Hewlett-Packard, E4411B"
#definehpEMC_IDN_E7401A "Hewlett-Packard, E7401A"
ViSession defaultRM, viESA;
ViStatus errStatus;
ViChar cIdBuff[256]= {0};
char cEnter = 0;
int iResult = 0;
/*Set the input port to 50MHz amplitude reference*/
void Route50MHzSignal()
{
viQueryf(viESA, "*IDN?\n", "%t", &cIdBuff);
iResult = (strncmp( cIdBuff, hpESA_IDN_E4401B, strlen(hpESA_IDN_E4401B)) &&
strncmp( cIdBuff, hpESA_IDN_E4411B, strlen(hpESA_IDN_E4411B)) && strncmp( cIdBuff,
hpEMC_IDN_E7401A, strlen(hpEMC_IDN_E7401A)));
if( iResult == 0 )
{
/*Set the input port to the 50MHz amplitude reference for the models*/
/*E4401B, E4411B, and E7401A*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n");
}
else
{
/* For the analyzers having frequency limits >= 3GHz, prompt the user*/
/* to connect the amplitude reference output to the input*/
printf ("Connect AMPTD REF OUT to the INPUT \n");
printf ("......Press Return to continue \n");
scanf( "%c",&cEnter);
/*Externally route the 50MHz Signal*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n");
}
}
void main()
{
/*Program Variables*/
ViStatus viStatus = 0;
long lOpc =0L;
long lResult =0L;
/* Open a GPIB session at address 18*/
212 Chapter 17
ESA Programming Examples
Using C to Perform Internal Self-Alignment
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
viStatus=viOpenDefaultRM(&defaultRM);
viStatus=viOpen(defaultRM,"GPIB0::18",VI_NULL,VI_NULL,&viESA);
if(viStatus)
{
printf("Could not open a session to GPIB device at address 18!\n");
exit(0);
}
/*Clear the instrument*/
viClear(viESA);
/*Reset the instrument*/
viPrintf(viESA,"*RST\n");
/*Display the program heading */
printf("\n\t\t Internal Self-Alignment Program \n\n" );
/*Check for the instrument model number and route the 50MHz-signal accordingly*/
Route50MHzSignal();
/*VISA function sets the time out to infinite for this specified session*/
viSetAttribute(viESA, VI_ATTR_TMO_VALUE, VI_TMO_INFINITE);
printf("\t Performing first self alignment ..... " );
/*Initiate a self-alignment */
viPrintf(viESA,"CAL:ALL\n");
/*Query for operation complete*/
viQueryf(viESA, "*OPC?\n", "%d", &lOpc);
printf ("\n\n\t First Self Alignment is Done \n\n");
if (!lOpc)
{
printf("Program Abort! error ocurred: last command was not completed!\n");
exit(0);
}
printf ("\n\n\t Press Return to continue with next alignment \n\n");
scanf( "%c",&cEnter);
printf("\t Performing next self alignment ..... " );
/* Query for self-alignment results*/
viQueryf(viESA,"CAL:ALL?\n","%d",&lResult);
if (lResult)
printf ("\n\n\t Self-alignment Failed \n");
else
printf ("\n\n\t Self-alignment Passed \n");
/* Query for operation complete*/
Chapter 17 213
ESA Programming Examples
Using C to Perform Internal Self-Alignment
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
viQueryf(viESA, "*OPC?\n", "%d", &lOpc);
if (!lOpc)
{
printf("Program Abort! error ocurred: last command was not completed!\n");
exit(0);
}
/*Close the session*/
viClose(viESA);
viClose(defaultRM);
}
214 Chapter 17
ESA Programming Examples
Using C to Read Trace Data in an ASCII Format (over GPIB)
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Using C to Read Trace Data in an ASCII Format (over
GPIB)
This C programming example (ascigpib.c) can be found on the Documentation
CD.
/************************************************************/
/* Reading Trace Data using ASCII Format (GPIB) */
/* */
/* This example is for the E44xxB ESA Spectrum Analyzers */
/* and E740xA EMC Analyzers. */
/* */
/* The required SCPI instrument commands are given as */
/* reference. */
/* */
/* - Opens a GPIB session at address 18 */
/* - Clears the Analyzer */
/* - Resets the Analyzer */
/* *RST */
/* - Set the input port to the 50 MHz amplitude reference */
/* E4411B or E4401B */
/* CAL:SOUR:STAT ON */
/* E4402, E4403B, E4404BE, 4405B, E4407B or E4408B */
/* Prompt to connect AMPTD REF OUT to INPUT */
/* CAL:SOUR STAT ON */
/* - Query for the number of sweep points (only applies to */
/* firmware revisions A.04.00 and later); default is 401 */
/* SENS:SWE:POIN? */
/* - Sets the analyzer center frequency to 50 MHz */
/* SENS:FREQ:CENT 50 MHZ */
/* - Sets the analyzer span to 50 MHz */
/* SENS:FREQ:SPAN 50 MHZ */
/* - Set the analyzer to single sweep mode */
/* INIT:CONT 0 */
/* - Trigger a sweep and wait for sweep to complete */
/* INIT:IMM;*WAI */
/* - Specify units in dBm */
/* UNIT:POW DBM */
/* - Set the analyzer trace data to ASCII */
/* FORM:DATA: ASC */
/* - Trigger a sweep and wait for sweep to complete */
/* INIT:IMM;*WAI */
/* - Query the trace data */
/* TRAC:DATA? TRACE1 */
Chapter 17 215
ESA Programming Examples
Using C to Read Trace Data in an ASCII Format (over GPIB)
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/* - Remove the "," from the ACSII data */
/* - Save the trace data to an ASCII file */
/* - Close the session */
/************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <conio.h>
#include <ctype.h>
#include <string.h>
#include "visa.h"
#define hpESA_IDN_E4401B "Hewlett-Packard, E4401B"
#define hpESA_IDN_E4411B "Hewlett-Packard, E4411B"
#definehpEMC_IDN_E7401A "Hewlett-Packard, E7401A"
ViSession defaultRM, viESA;
ViStatus errStatus;
ViChar cIdBuff[256] ={0};
char cEnter =0;
int iResult =0;
/*Set the input port to 50MHz amplitude reference*/
void Route50MHzSignal()
{
viQueryf(viESA, "*IDN?\n", "%t", &cIdBuff);
iResult = (strncmp( cIdBuff, hpESA_IDN_E4401B, strlen(hpESA_IDN_E4401B)) &&
strncmp( cIdBuff, hpESA_IDN_E4411B, strlen(hpESA_IDN_E4411B)) && strncmp( cIdBuff,
hpEMC_IDN_E7401A, strlen(hpEMC_IDN_E7401A)));
if( iResult == 0 )
{
/*Set the input port to the 50MHz amplitude reference for the models*/
/*E4401B, E4411B and E7401A*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n");
}
else
{
/* For the analyzers having frequency limits >= 3GHz, prompt the user*/
/* to connect the amplitude reference output to the input*/
printf ("Connect AMPTD REF OUT to the INPUT \n");
printf ("......Press Return to continue \n");
scanf( "%c",&cEnter);
/*Externally route the 50MHz Signal*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n");
216 Chapter 17
ESA Programming Examples
Using C to Read Trace Data in an ASCII Format (over GPIB)
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
}
}
void main()
{
/*Program Variable*/
ViStatus viStatus = 0;
/*Dimension cResult to 13 bytes per sweep point, 8192 sweep points maximum*/
ViChar _VI_FAR cResult[106496] = {0};
FILE *fTraceFile;
static ViChar *cToken ;
int iNum =0;
int iSwpPnts = 401;
long lCount=0L;
long lOpc=0;
/*iNum set to 13 times number of sweep points, 8192 sweep points maximum*/
iNum =106496;
lCount =0;
/* Open a GPIB session at address 18*/
viStatus=viOpenDefaultRM(&defaultRM);
viStatus=viOpen(defaultRM,"GPIB0::18",VI_NULL,VI_NULL,&viESA);
if(viStatus)
{
printf("Could not open a session to GPIB device at address 18!\n");
exit(0);
}
/* Clear the instrument */
viClear(viESA);
/*Reset the instrument. This will set number of sweep points to default of 401*/
viPrintf(viESA,"*RST\n");
/*Display the program heading */
printf("\n\t\t Read in Trace Data using ASCII Format (GPIB) Program \n\n" );
/* Check for the instrument model number and route the 50MHz signal accordingly*/
Route50MHzSignal();
/*Query number of sweep points per trace (firmware revision A.04.00 and later)*/
/*For firmware revisions prior to A.04.00, the number of sweep points is 401*/
iSwpPnts = 401;
viQueryf(viESA,"SENSE:SWEEP:POINTS?\n","%d",&iSwpPnts);
/*Set the analyzer center frequency to 50MHz*/
Chapter 17 217
ESA Programming Examples
Using C to Read Trace Data in an ASCII Format (over GPIB)
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
viPrintf(viESA,"SENS:FREQ:CENT 50 MHz\n");
/*Set the analyzer to 50MHz Span*/
viPrintf(viESA,"SENS:FREQ:SPAN 50 MHz\n");
/*Set the analyzer to single sweep mode */
viPrintf(viESA,"INIT:CONT 0 \n");
/*Trigger a sweep and wait for sweep to complete */
viPrintf(viESA,"INIT:IMM;*WAI\n");
/* Specify units in dBm*/
viPrintf(viESA,"UNIT:POW DBM \n");
/*Set analyzer trace data format to ASCII Format*/
viPrintf(viESA,"FORM:DATA ASC \n");
/*Trigger a sweep and wait for sweep to complete */
viPrintf(viESA,"INIT:IMM;*WAI\n");
/*Query the Trace Data using ASCII Format */
viQueryf(viESA,"%s\n", "%#t","TRAC:DATA? TRACE1" , &iNum , cResult);
/*Remove the "," from the ASCII trace data for analyzing data*/
cToken = strtok(cResult,",");

/*Save trace data to an ASCII to a file, by removing the "," token*/
fTraceFile=fopen("C:\\temp\\ReadAscGpib.txt","w");
fprintf(fTraceFile,"ReadAscGpib.exe Output\nAgilent Technologies 2000\n\n");
fprintf(fTraceFile,"\tAmplitude of point[%d] = %s dBm\n",lCount+1,cToken);
while (cToken != NULL)
{
lCount++;
cToken =strtok(NULL,",");
if (lCount != iSwpPnts)
fprintf(fTraceFile,"\tAmplitude of point[%d] = %s
dBm\n",lCount+1,cToken);
}
fprintf(fTraceFile,"\nThe Total trace data points of the spectrum are :[%d]
\n\n",lCount);
fclose(fTraceFile);
/*Close the session*/
viClose(viESA);
viClose(defaultRM);
}
218 Chapter 17
ESA Programming Examples
Using C to Read Trace Data in a 32-Bit Real Format (over GPIB)
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Using C to Read Trace Data in a 32-Bit Real Format
(over GPIB)
This C programming example (32btgpib.c) can be found on the Documentation
CD.
/************************************************************/
/* Reading Trace Data using 32-bit Real Format (GPIB) */
/* */
/* This example is for the E44xxB ESA Spectrum Analyzers */
/* and E740xA EMC Analyzers. */
/* */
/* This C programming example does the following. */
/* The SCPI instrument commands used are given as */
/* reference. */
/* */
/* - Opens a GPIB session at address 18 */
/* - Clears the Analyzer */
/* - Resets the Analyzer */
/* *RST */
/* - Set the input port to the 50 MHz amplitude reference */
/* CAL:SOUR:STAT ON */
/* - Query for the number of sweep points (for firmware */
/* revisions A.04.00 and later). Default is 401. */
/* SENS:SWE:POIN? */
/* - Calculate the number of bytes in the header */
/* - Set the analyzer to single sweep mode */
/* INIT:CONT 0 */
/* - Sets the analyzer center frequency and span to 50 MHz */
/* SENS:FREQ:CENT 50 MHZ */
/* SENS:FREQ:SPAN 50 MHZ */
/* - Specify 10 dB per division for the amplitude scale in */
/* and dBm Units */
/* DISP:WIND:TRAC:Y:SCAL:PDIV 10 dB */
/* UNIT:POW DBM */
/* - Set the analyzer trace data to 32-bit Real */
/* FORM:DATA: REAL,32 */
/* - Set the binary order to swap */
/* FORM:BORD SWAP */
/* - Trigger a sweep and wait for sweep to complete */
/* INIT:IMM;*WAI */
/* - Calculate the number of bytes in the trace record */
/* - Query the trace data */
/* TRAC:DATA? TRACE1 */
Chapter 17 219
ESA Programming Examples
Using C to Read Trace Data in a 32-Bit Real Format (over GPIB)
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/* - Remove the "," from the ACSII data */
/* - Save the trace data to an ASCII file */
/* - Close the session */
/************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <conio.h>
#include <ctype.h>
#include <string.h>
#include "visa.h"
#define hpESA_IDN_E4401B "Hewlett-Packard, E4401B"
#define hpESA_IDN_E4411B "Hewlett-Packard, E4411B"
#define hpEMC_IDN_E7401A "Hewlett-Packard, E7401A"
ViSession defaultRM, viESA;
ViChar cIdBuff[256];
char cEnter =0;
int iResult =0;
void Route50MHzSignal()
{
viQueryf(viESA, "*IDN?\n", "%t", &cIdBuff);
iResult = (strncmp( cIdBuff, hpESA_IDN_E4401B, strlen(hpESA_IDN_E4401B)) &&
strncmp( cIdBuff, hpESA_IDN_E4411B, strlen(hpESA_IDN_E4411B)) && strncmp( cIdBuff,
hpEMC_IDN_E7401A, strlen(hpEMC_IDN_E7401A)));
if( iResult == 0 )
{
/*Set the input port to the 50MHz internal reference source for the models*/
/*E4401B, E4411B and E7401A*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n");
}
else
{
/* For the analyzers having frequency limits >= 3GHz, prompt the user to*/
/* connect the amplitude reference output to the input*/
printf ("Connect AMPTD REF OUT to the INPUT \n");
printf ("......Press Return to continue \n");
scanf( "%c",&cEnter);
/*Externally route the 50MHz Signal*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n");
}
}
220 Chapter 17
ESA Programming Examples
Using C to Read Trace Data in a 32-Bit Real Format (over GPIB)
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
void main()
{
/*Program Variables*/
ViStatus viStatus= 0;
ViChar _VI_FAR cResult[5000] = {0};
ViReal32 dTraceArray[401] = {0};
char cBufferInfo[6]= {0};
long lNumberBytes =0L;
long lOpc =0L;
unsigned long lRetCount = 0L;
int iSize = 0;
/*BytesPerPoint is 4 for Real32 or Int32 formats, 8 for Real64, and 2 for Uint16*/
int iBytesPerPnt = 4;
int iSwpPnts = 401;
int iDataBytes=1604;
int iHeaderBytes=6;
FILE *fTraceFile;
/* Open a GPIB session at address 18*/
viStatus=viOpenDefaultRM(&defaultRM);
viStatus=viOpen(defaultRM,"GPIB0::18",VI_NULL,VI_NULL,&viESA);
if(viStatus)
{
printf("Could not open a session to GPIB device at address 18!\n");
exit(0);
}
/*Clear the instrument */
viClear(viESA);
/*Reset the instrument. This will set number of sweep points to default of 401*/
viPrintf(viESA,"*RST\n");
/*Display the program heading */
printf("\n\t\t Read in Trace Data using 32-bit Real Format (using GPIB) \n\n" );

/* Set the input port to the 50MHz amplitude reference*/
Route50MHzSignal();
/*Query number of sweep points per trace (firmware revision A.04.00 and later)*/
/*For firmware revisions prior to A.04.00, the number of sweep points is 401*/
iSwpPnts=401;
viQueryf(viESA,"SENSE:SWEEP:POINTS?\n","%d",&iSwpPnts);
/*Calculate number of bytes in the header. The header consists of the "#" sign*/
/*followed by a digit representing the number of digits to follow. The digits */
Chapter 17 221
ESA Programming Examples
Using C to Read Trace Data in a 32-Bit Real Format (over GPIB)
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/*which follow represent the number of sweep points multiplied by the number */
/*of bytes per point. */
iHeaderBytes = 3; /*iDataBytes >3, plus increment for "#" and "n"*/
iDataBytes = (iSwpPnts*iBytesPerPnt);
lNumberBytes = iDataBytes;
while ((iDataBytes = (iDataBytes / 10 )) > 0 )
{
iHeaderBytes++;
}
/*Set analyzer to single sweep mode */
viPrintf(viESA,"INIT:CONT 0 \n");
/*Set the analyzer to 50MHz-center frequency */
viPrintf(viESA,"SENS:FREQ:CENT 50 MHZ\n");
/*Set the analyzer to 50MHz Span */
viPrintf(viESA,"SENS:FREQ:SPAN 50 MHZ\n");
/* Specify dB per division of each vertical division and Units */
viPrintf(viESA,"DISP:WIND:TRAC:Y:SCAL:PDIV 10dB\n");
viPrintf(viESA,"UNIT:POW DBM\n");
/*Set analyzer trace data format to 32-bit Real */
viPrintf(viESA,"FORM:DATA REAL,32 \n");
/*Set the binary byte order to SWAP */
viPrintf(viESA, "FORM:BORD SWAP\n");
/*Trigger a sweep and wait for sweep to complete*/
viPrintf(viESA,"INIT:IMM;*WAI\n");
/*Calculate size of trace record. This will be sum of HeaderBytes, NumberBytes*/
/*(the actual data bytes) and the "/n" terminator*/
iSize = lNumberBytes +iHeaderBytes+1;
/*Get trace header data and trace data */
viPrintf(viESA,"TRAC:DATA? TRACE1\n");
viRead (viESA,(ViBuf)cResult,iSize,&lRetCount);
/*Extract the trace data*/
memcpy(dTraceArray,cResult+iHeaderBytes,(size_t)lNumberBytes);
/*Save trace data to an ASCII file*/
fTraceFile=fopen("C:\\temp\\ReadTrace32Gpib.txt","w");
fprintf(fTraceFile,"ReadTrace32Gpib.exe Output\nAgilent Technologies 2000\n\n");
222 Chapter 17
ESA Programming Examples
Using C to Read Trace Data in a 32-Bit Real Format (over GPIB)
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
fprintf(fTraceFile,"The %d trace data points of the
spectrum:\n\n",(lNumberBytes/4));
for ( long i=0;i<lNumberBytes/4;i++)
fprintf(fTraceFile,"\tAmplitude of point[%d] = %.2lf
dBm\n",i+1,dTraceArray[i]);
fclose(fTraceFile);
/*Close the session*/
viClose(viESA);
viClose(defaultRM);
}
Chapter 17 223
ESA Programming Examples
Using C to Read Trace Data in an ASCII Format (over RS-232)
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Using C to Read Trace Data in an ASCII Format (over
RS-232)
This C programming example (ascrs232.c) can be found on the Documentation
CD.
/************************************************************/
/* Reading Trace Data using ASCII Format (RS-232) */
/* */
/* This example is for the E44xxB ESA Spectrum Analyzers */
/* and E740xA EMC Analyzers. */
/* */
/* This C programming example does the following. */
/* The SCPI instrument commands used are given as */
/* reference. */
/* */
/* - Opens an RS-232 session at COM1/COM2 */
/* - Clears the Analyzer */
/* - Resets the Analyzer */
/* *RST */
/* - Set the input port to the 50 MHz amplitude reference */
/* CAL:SOUR:STAT ON */
/* - Query for the number of sweep points (for firmware */
/* revisions A.04.00 and later). Default is 401. */
/* SENS:SWE:POIN? */
/* - Set the analyzer to single sweep mode */
/* INIT:CONT 0 */
/* - Sets the analyzer center frequency and span to 50 MHz */
/* SENS:FREQ:CENT 50 MHZ */
/* SENS:FREQ:SPAN 50 MHZ */
/* - Trigger a sweep */
/* INIT:IMM */
/* - Check for operation complete */
/* *OPC? */
/* - Specify dBm Unit */
/* UNIT:POW DBM */
/* - Set the analyzer trace data ASCII */
/* FORM:DATA: ASC */
/* - Trigger a sweep */
/* INIT:IMM */
/* - Check for operation complete */
/* *OPC? */
/* - Query the trace data */
/* TRAC:DATA? TRACE1 */
224 Chapter 17
ESA Programming Examples
Using C to Read Trace Data in an ASCII Format (over RS-232)
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/* - Remove the "," from the ACSII data */
/* - Save the trace data to an ASCII file */
/* - Close the session */
/************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <conio.h>
#include <ctype.h>
#include <string.h>
#include "visa.h"
#define hpESA_IDN_E4401B "Hewlett-Packard, E4401B"
#define hpESA_IDN_E4411B "Hewlett-Packard, E4411B"
#define hpEMC_IDN_E7401A "Hewlett-Packard, E7401A"
ViSession defaultRM, viESA;
ViStatus errStatus;
ViChar cIdBuff[256] ={0};
char cEnter ={0};
int iResult =0;
/*Set the input port to 50MHz amplitude reference*/
void Route50MHzSignal()
{
viQueryf(viESA, "*IDN?\n", "%t", &cIdBuff);
iResult = (strncmp( cIdBuff, hpESA_IDN_E4401B, strlen(hpESA_IDN_E4401B)) &&
strncmp( cIdBuff, hpESA_IDN_E4411B, strlen(hpESA_IDN_E4411B)) && strncmp( cIdBuff,
hpEMC_IDN_E7401A, strlen(hpEMC_IDN_E7401A)));
if( iResult == 0 )
{
/*Set the input port to the 50MHz amplitude reference for the models*/
/*E4411B and E4401B*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n");
}
else
{
/* For the analyzers having frequency limits >= 3GHz, prompt the user to/*
/* connect the amplitude reference output to the input*/
printf ("Connect AMPTD REF OUT to the INPUT \n");
printf ("......Press Return to continue \n");
scanf( "%c",&cEnter);
/*Externally route the 50MHz Signal*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n");
Chapter 17 225
ESA Programming Examples
Using C to Read Trace Data in an ASCII Format (over RS-232)
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
}
}
void main()
{
/*Program Variable*/
ViStatus viStatus = 0;
/*Dimension cResult to 13 bytes per sweep point, 8192 sweep points maximum*/
ViChar _VI_FAR cResult[106496] = {0};
FILE *fTraceFile;
static ViChar *cToken;
int iNum =0;
int iSwpPnts = 401;
long lCount=0L;
long lOpc=0L;
/*iNum set to 13 times number of sweep points, 8192 sweep points maximum*/
iNum =106496;
lCount =0;
/* Open a serial session at COM1 */
viStatus=viOpenDefaultRM(&defaultRM);
if (viStatus =viOpen(defaultRM,"ASRL1::INSTR",VI_NULL,VI_NULL,&viESA) !=
VI_SUCCESS)
{
printf("Could not open a session to ASRL device at COM1!\n");
exit(0);
}
/* Clear the instrument */
viClear(viESA);
/*Reset the instrument. This will set number of sweep points to default of 401*/
viPrintf(viESA,"*RST\n");
/*Display the program heading */
printf("\n\t\tRead in Trace Data using ASCII Format (RS232) Program \n\n" );
/* Check for the instrument model number and route the 50MHz signal accordingly*/
Route50MHzSignal();
/*Query number of sweep points per trace (firmware revision A.04.00 and later)*/
/*For firmware revisions prior to A.04.00, the number of sweep points is 401 */
iSwpPnts = 401;
viQueryf(viESA, "SENSE:SWEEP:POINTS?\n","%d",&iSwpPnts);
/*Set the analyzer center frequency to 50MHz */
226 Chapter 17
ESA Programming Examples
Using C to Read Trace Data in an ASCII Format (over RS-232)
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
viPrintf(viESA,"SENS:FREQ:CENT 50 MHz\n");
/*Set the analyzer to 50MHz Span*/
viPrintf(viESA,"SENS:FREQ:SPAN 50 MHz\n");
/*set the analyzer to single sweep mode*/
viPrintf(viESA,"INIT:CONT 0 \n");
/*Trigger a spectrum measurement*/
viPrintf(viESA,"INIT:IMM \n");
/*Read the operation complete query*/
viQueryf(viESA, "*OPC?\n", "%d", &lOpc);
if (!lOpc)
{
printf("Program Abort! error ocurred: last command was not completed!\n");
exit(0);
}
/*Specify units in dBm*/
viPrintf(viESA,"UNIT:POW DBM \n");
/*Set analyzer trace data format to ASCII Format*/
viPrintf(viESA,"FORM:DATA ASC \n");
/*Trigger a spectrum measurement*/
viPrintf(viESA,"INIT:IMM \n");
/*Read the operation complete query */
viQueryf(viESA, "*OPC?\n", "%d", &lOpc);
if (!lOpc)
{
printf("Program Abort! error ocurred: last command was not completed!\n");
exit(0);
}
/*Query the Trace Data using ASCII Format */
viQueryf(viESA,"%s\n", "%#t","TRAC:DATA? TRACE1" , &iNum , cResult);
/*Remove the "," from the ASCII trace data for analyzing data*/
cToken = strtok(cResult,",");

/*Save trace data to an ASCII to a file, by removing the "," token*/
fTraceFile=fopen("C:\\temp\\ReadAscRS232.txt","w");
fprintf(fTraceFile,"ReadAscRS232.exe Output\nHewlett-Packard 1999\n\n");
fprintf(fTraceFile,"\tAmplitude of point[%d] = %s dBm\n",lCount+1,cToken);
while (cToken != NULL)
{
Chapter 17 227
ESA Programming Examples
Using C to Read Trace Data in an ASCII Format (over RS-232)
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
lCount++;
cToken =strtok(NULL,",");
if (lCount != iSwpPnts)
fprintf(fTraceFile,"\tAmplitude of point[%d] = %s
dBm\n",lCount+1,cToken);
}
fprintf(fTraceFile,"\nThe Total trace data points of the spectrum are :[%d]
\n\n",lCount);
fclose(fTraceFile);
/*Close the session*/
viClose(viESA);
viClose(defaultRM);
}
228 Chapter 17
ESA Programming Examples
Using C to Read Trace Data in a 32-bit Real Format (over RS-232)
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Using C to Read Trace Data in a 32-bit Real Format
(over RS-232)
This C programming example (32brs232.c) can be found on the Documentation
CD.
/************************************************************/
/* Reading Trace Data using 32-bit Real Format (RS-232) */
/* */
/* This example is for the E44xxB ESA Spectrum Analyzers */
/* and E740xA EMC Analyzers. */
/* */
/* This C programming example does the following. */
/* The SCPI instrument commands used are given as */
/* reference. */
/* */
/* - Opens an RS-232 session at COM1/COM2 */
/* - Clears the Analyzer */
/* - Resets the Analyzer */
/* *RST */
/* - Set the input port to the 50 MHz amplitude reference */
/* CAL:SOUR:STAT ON */
/* - Query for the number of sweep points (for firmware */
/* revision A.04.00 and later). Default is 401. */
/* SENS:SWE:POIN? */
/* - Calculate the number of bytes in the header */
/* - Set the analyzer to single sweep mode */
/* INIT:CONT 0 */
/* - Sets the analyzer center frequency and span to 50 MHz */
/* SENS:FREQ:CENT 50 MHZ */
/* SENS:FREQ:SPAN 50 MHZ */
/* - Specify 10 dB per division for the amplitude scale in */
/* and dBm Units */
/* DISP:WIND:TRAC:Y:SCAL:PDIV 10 dB */
/* UNIT:POW DBM */
/* - Set the analyzer trace data to 32-bit Real */
/* FORM:DATA: REAL,32 */
/* - Set the binary order to swap */
/* FORM:BORD SWAP */
/* - Trigger a sweep */
/* INIT:IMM */
/* - Check for operation complete */
/* *OPC? */
/* - Calculate the number of bytes in the trace record */
Chapter 17 229
ESA Programming Examples
Using C to Read Trace Data in a 32-bit Real Format (over RS-232)
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/* - Set VISA timeout to 60 seconds, to allow for slower */
/* transfer times caused by higher number of sweep points */
/* at low baud rates. */
/* - Set VISA to terminate read after buffer is empty */
/* - Query the trace data */
/* TRAC:DATA? TRACE1 */
/* - Reset VISA timeout to 3 seconds */
/* - Remove the "," from the ACSII data */
/* - Save the trace data to an ASCII file */
/* - Close the session */
/************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <conio.h>
#include <ctype.h>
#include <string.h>
#include "visa.h"
#define hpESA_IDN_E4401B "Hewlett-Packard, E4401B"
#define hpESA_IDN_E4411B "Hewlett-Packard, E4411B"
#definehpEMC_IDN_E7401A "Hewlett-Packard, E7401A"
ViSession defaultRM, viESA;
ViStatus errStatus;
ViChar cIdBuff[256]= {0};
char cEnter = 0;
int iResult = 0;
/*Set the input port to 50MHz amplitude reference*/
void Route50MHzSignal()
{
viQueryf(viESA, "*IDN?\n", "%t", &cIdBuff);
iResult = (strncmp( cIdBuff, hpESA_IDN_E4401B, strlen(hpESA_IDN_E4401B)) &&
strncmp( cIdBuff, hpESA_IDN_E4411B, strlen(hpESA_IDN_E4411B)) && strncmp( cIdBuff,
hpEMC_IDN_E7401A, strlen(hpEMC_IDN_E7401A)));
if( iResult == 0 )
{
/*Set the input port to the 50MHz amplitude reference for the models*/
/*E4411B and E4401B*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n");
}
else
{
230 Chapter 17
ESA Programming Examples
Using C to Read Trace Data in a 32-bit Real Format (over RS-232)
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/* For the analyzers having frequency limits >= 3GHz, prompt the user to*/
/* connect the amplitude reference output to the input*/
printf ("Connect AMPTD REF OUT to the INPUT \n");
printf ("......Press Return to continue \n");
scanf( "%c",&cEnter);
/*Externally route the 50MHz Signal*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n");
}
}
void main()
{
/*Program Variables*/
ViStatus viStatus= 0;
ViChar _VI_FAR cResult[1024000] = {0};
ViReal32 dTraceArray[1024] = {0};
char cBufferInfo[7]= {0};
long lNumberBytes =0L;
long lOpc =0L;
unsigned long lRetCount = 0L;
int iSize = 0;
/*BytesPerPnt is 4 for Real32 or Int32 formats, 8 for Real64, and 2 for Uint16*/
int iBytesPerPnt = 4;
int iSwpPnts = 401; /*Number of points per sweep*/
int iDataBytes = 1604;/*Number of data points, assuming 4 bytes per point*/
int iHeaderBytes = 6; /*Number of bytes in the header, assuming 1604 data bytes*/
FILE *fTraceFile;
/* Open a serial session at COM1 */
viStatus=viOpenDefaultRM(&defaultRM);
if (viStatus =viOpen(defaultRM,"ASRL1::INSTR",VI_NULL,VI_NULL,&viESA) !=
VI_SUCCESS)
{
printf("Could not open a session to ASRL device at COM1!!\n");
exit(0);
}
/*Clear the instrument */
viClear(viESA);
/*Reset the instrument. This will set number of sweep points to default of 401*/
viPrintf(viESA,"*RST\n");
/*Display the program heading */
printf("\n\t\t Read in Trace Data using ASCII Format (using RS-232) Program \n\n"
);
Chapter 17 231
ESA Programming Examples
Using C to Read Trace Data in a 32-bit Real Format (over RS-232)
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s

/* Set the input port to the internal 50MHz reference source */
Route50MHzSignal();
/*Query number of sweep points per trace (firmware revision A.04.00 or later)*/
/*For firmware revisions prior to A.04.00, the number of sweep points is 401 */
iSwpPnts = 401;
viQueryf(viESA,"SENSE:SWEEP:POINTS?\n","%d",&iSwpPnts);
/*Calculate number of bytes in the header. The header consists of the "#" sign*/
/*followed by a digit representing the number of digits to follow. The digits */
/*which follow represent the number of sweep points multiplied by the number */
/*of bytes per point. */
iHeaderBytes = 3; /*iDataBytes >0, plus increment for "#" and "n" */
iDataBytes = (iSwpPnts*iBytesPerPnt);
lNumberBytes = iDataBytes;
while ((iDataBytes = (iDataBytes / 10 )) > 0 )
{
iHeaderBytes++;
}
/*Set analyzer to single sweep mode */
viPrintf(viESA,"INIT:CONT 0 \n");
/* Set the analyzer to 50MHz-center frequency */
viPrintf(viESA,"SENS:FREQ:CENT 50 MHZ\n");
/*Set the analyzer to 50MHz Span */
viPrintf(viESA,"SENS:FREQ:SPAN 50 MHZ\n");
/* Specify dB per division of each vertical division & Units */
viPrintf(viESA,"DISP:WIND:TRAC:Y:SCAL:PDIV 10dB\n");
viPrintf(viESA,"UNIT:POW DBM\n");
/*Set analyzer trace data format to 32-bit Real */
viPrintf(viESA,"FORM:DATA REAL,32\n");
/*Set the binary byte order to SWAP */
viPrintf(viESA, "FORM:BORD SWAP\n");
/*Trigger a sweep */
viPrintf(viESA,"INIT:IMM\n");
/*Read the operation complete query */
viQueryf(viESA, "*OPC?\n", "%d", &lOpc);
if (!lOpc)
232 Chapter 17
ESA Programming Examples
Using C to Read Trace Data in a 32-bit Real Format (over RS-232)
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
{
printf("Program Abort! error ocurred: last command was not completed!\n");
exit(0);
}
/*Calculate size of trace record. This will be the sum of HeaderBytes, Number*/
/*Bytes (the actual data bytes) and the "\n" terminator*/
iSize = lNumberBytes + iHeaderBytes + 1;
/*Increase timeout to 60 sec*/
viSetAttribute(viESA,VI_ATTR_TMO_VALUE,60000);
/*Set RS-232 interface to terminate when the buffer is empty*/
viSetAttribute(viESA,VI_ATTR_ASRL_END_IN,VI_ASRL_END_NONE);
/*Get trace header data and trace data*/
viPrintf(viESA,"TRAC:DATA? TRACE1\n");
viRead (viESA,(ViBuf)cResult,iSize,&lRetCount);
/*Reset timeout to 3 sec*/
viSetAttribute(viESA,VI_ATTR_TMO_VALUE,3000);
/*Extract the trace data*/
memcpy(dTraceArray,cResult+iHeaderBytes,(size_t)lNumberBytes);
/*Save trace data to an ASCII file*/
fTraceFile=fopen("C:\\temp\\ReadTrace32Rs232.txt","w");
fprintf(fTraceFile,"ReadTrace32Rs232.exe Output\nHewlett-Packard 1999\n\n");
fprintf(fTraceFile,"The %d trace data points of the
spectrum:\n\n",(lNumberBytes/4));
for ( long i=0;i<lNumberBytes/iBytesPerPnt;i++)
fprintf(fTraceFile,"\tAmplitude of point[%d] = %.2lf
dBm\n",i+1,dTraceArray[i]);
fclose(fTraceFile);
/*Close the session*/
viClose(viESA);
viClose(defaultRM);
}
Chapter 17 233
ESA Programming Examples
Using C to Add Limit Lines
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Using C to Add Limit Lines
This C programming example (limlines.c) can be found on the Documentation CD.
/************************************************************/
/* Using Limit Lines */
/* */
/* This example is for the E44xxB ESA Spectrum Analyzers */
/* and E740xA EMC Analyzers. */
/* */
/* This C programming example does the following. */
/* The SCPI instrument commands used are given as */
/* reference. */
/* */
/* */
/* - Open a GPIB session at address 18. */
/* - Clear the analyzer. */
/* *CLR */
/* - Reset the analyzer. */
/* *RST */
/* - Set Y-Axis Units to dBm */
/* UNIT:POW DBM */
/* - Define the upper limit line to have frequency/ */
/* amplitude pairs. */
/* CALC:LLINE1:CONT:DOM FREQ */
/* CALC:LLINE1:TYPE UPP */
/* CALC:LLINE1:DISP ON */
/* CALC:LLINE1:DATA freq1,amp1,1,freq2,amp2,1... */
/* - Define the lower limit line to have frequency/amplitude*/
/* pairs. */
/* CALC:LLINE2:CONT:DOM FREQ */
/* CALC:LLINE2:TYPE LOW */
/* CALC:LLINE2:DISP ON */
/* CALC:LLINE2:DATA freq1,amp1,1,freq2,amp2,1... */
/* - Turn the limit line test function on. */
/* CALC:LLINE2:STAT ON */
/* - Set the analyzer to a center frequency of 50 MHz, span */
/* to 20 MHz, and resolution bandwidth to 1 MHz. */
/* SENS:FREQ:SPAN 20 MHZ */
/* SENS:FREQ:CENT 50 MHZ */
/* SENS:BWID:RES 1 MHZ */
/* - Turn the limit line test function on. */
/* - Set the analyzer reference level to 0 dBm. */
/* DISP:WIND:TRAC:Y:SCAL:RLEV 0 */
234 Chapter 17
ESA Programming Examples
Using C to Add Limit Lines
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/* - Set the input port to the 50 MHz amplitude reference. */
/* CAL:SOUR:STAT ON */
/* - Check to see if limit line passes or fails. It should */
/* pass. */
/* CALC:LLINE:FAIL? */
/* - Pause for 5 seconds. */
/* - Deactivate the 50 MHz alignment signal. */
/* CAL:SOUR:STAT OFF */
/* - The limit line test should fail. */
/* - Close the session. */
/************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <conio.h>
#include <ctype.h>
#include <string.h>
#include <windows.h>
#include "visa.h"
#define YIELD Sleep(5000)
#define hpESA_IDN_E4401B "Hewlett-Packard, E4401B"
#define hpESA_IDN_E4411B "Hewlett-Packard, E4411B"
#define hpEMC_IDN_E7401A "Hewlett-Packard, E7401A"
ViSession defaultRM, viESA;
ViStatus errStatus;
ViChar cIdBuff[256]= {0};
char cEnter = 0;
int iResult = 0;
long lLimitTest =0L;
/*Set the input port to 50MHz amplitude reference*/
void Route50MHzSignal()
{
viQueryf(viESA, "*IDN?\n", "%t", &cIdBuff);
iResult = (strncmp( cIdBuff, hpESA_IDN_E4401B, strlen(hpESA_IDN_E4401B)) &&
strncmp( cIdBuff, hpESA_IDN_E4411B, strlen(hpESA_IDN_E4411B)) && strncmp( cIdBuff,
hpEMC_IDN_E7401A, strlen(hpEMC_IDN_E7401A)));
if( iResult == 0 )
{
/*Set the input port to the 50MHz amplitude reference for the models*/
/*E4401B, E4411B, and E7401A*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n");
}
Chapter 17 235
ESA Programming Examples
Using C to Add Limit Lines
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
else
{
/* For the analyzers having frequency limits >= 3GHz, prompt the user*/
/* to connect the amplitude reference output to the input*/
printf ("Connect AMPTD REF OUT to the INPUT \n");
printf ("......Press Return to continue \n");
scanf( "%c",&cEnter);
/*Externally route the 50MHz Signal*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n");
}
}

void printResult()
{
viQueryf(viESA, "CALC:CLIM:FAIL?\n", "%ld", &lLimitTest);
if (lLimitTest!=0)
{
printf ("\n\t..Limit Line Failed.....\n");
viQueryf(viESA, "CALC:LLINE1:FAIL?\n", "%ld", &lLimitTest);
if (lLimitTest==0)
printf ("\n\t......Limit Line1 Passed \n");
else printf ("\n\t......Limit Line1 Failed \n");
viQueryf(viESA, "CALC:LLINE2:FAIL?\n", "%ld", &lLimitTest);
if (lLimitTest==0)
printf ("\n\t......Limit Line2 Passed \n");
else printf ("\n\t......Limit Line2 Failed \n");
}
else
printf ("\n\t..Limit Test Pass\n");
}
void main()
{
/*Program Variable*/
ViStatus viStatus = 0;
long lOpc =0L;
/* Open a GPIB session at address 18*/
viStatus=viOpenDefaultRM(&defaultRM);
viStatus=viOpen(defaultRM,"GPIB0::18",VI_NULL,VI_NULL,&viESA);
if(viStatus)
{
printf("Could not open a session to GPIB device at address 18!\n");
236 Chapter 17
ESA Programming Examples
Using C to Add Limit Lines
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
exit(0);
}
/*Clear the instrument*/
viClear(viESA);
/*Reset the instrument*/
viPrintf(viESA,"*RST\n");
/* Check for the instrument model number and route the 50MHz signal accordingly*/
/*Route50MHzSignal();
/*Display the program heading */
printf("\n\t\t Limit Lines Program \n\n" );
/*Set the Y-Axis Units to dBm */
viPrintf(viESA, "UNIT:POW DBM\n");
/*Set to Frequency Domain Mode*/
viPrintf(viESA,"CALC:LLINE1:CONT:DOM FREQ\n");
/*Delete any current limit line and define the upper limit line
to have the following frequency/amplitude pairs*/
viPrintf(viESA,"CALC:LLINE1:TYPE UPP\n");
/* Turn on display*/
viPrintf(viESA,"CALC:LLINE1:DISP ON\n");
/*Send the upper limit line data*/
viPrintf(viESA,"CALC:LLINE1:DATA 40E06,-50,1, 45E06,-20,1, 50E06,-15,1,
55E06,-20,1, 60E06,-50,1\n");
/* Turn on display*/
viPrintf(viESA,"CALC:LLINE1:DISP ON\n");
/*Delete any current limit line and define the lower limit line
to have the following frequency/amplitude pairs*/
viPrintf(viESA,"CALC:LLINE2:TYPE LOW\n");
/*Send the lower limit line data*/
viPrintf(viESA,"CALC:LLINE2:DATA
40E06,-100,1,49.99E06,-100,1,50E06,-30,1,50.01E06,-100,1,60E06,-100,1\n");
/* Turn on display*/
viPrintf(viESA,"CALC:LLINE2:DISP ON\n");
/*Turn the limit line test function on.*/
Chapter 17 237
ESA Programming Examples
Using C to Add Limit Lines
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
viPrintf(viESA,"CALC:LLINE2:STAT ON\n");
/*Set the analyzer to a center frequency of 50 MHz, span to 20 MHz,
and resolution bandwidth to 1 MHz.*/
viPrintf(viESA,"SENS:FREQ:CENT 50e6\n");
viPrintf(viESA,"SENS:FREQ:SPAN 20e6\n");
viPrintf(viESA,"SENS:BWID:RES 1e6\n");
/*Set the analyzer reference level to 0 dBm*/
viPrintf(viESA,"DISP:WIND:TRAC:Y:SCAL:RLEV 0 \n");
/* Check for the instrument model number and route the 50MHz-signal accordingly*/
Route50MHzSignal();
/*Trigger a spectrum measurement*/
viPrintf(viESA,"INIT:IMM \n");
/*Check for operation complete */
viQueryf(viESA, "*OPC?\n", "%d", &lOpc);
if (!lOpc)
{
printf("Program Abort! error ocurred: last command was not completed!\n");
exit(0);
}
/*Check to see if limit line passes or fails. It should pass.*/
printf ("\n\t Limit Line status after activating the 50MHz signal \n");
/*Print the limits line result*/
printResult();
/*Pause for 5 seconds*/
YIELD;
/*Deactivate the 50 MHz alignment signal.*/
viPrintf(viESA,"CAL:SOUR:STAT OFF\n");
/*Trigger a spectrum measurement*/
viPrintf(viESA,"INIT:IMM \n");
/*Check for operation complete */
viQueryf(viESA, "*OPC?\n", "%d", &lOpc);
if (!lOpc)
{
printf("Program Abort! error ocurred: last command was not completed!\n");
exit(0);
}
238 Chapter 17
ESA Programming Examples
Using C to Add Limit Lines
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/* The limit line test should fail.*/
printf ("\n\t Limit Line status after de-activating the 50MHz signal \n");
/*Print the limits line result*/
printResult();
/*Close the session*/
viClose(viESA);
viClose(defaultRM);
}
Chapter 17 239
ESA Programming Examples
Using C to Measure Noise
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Using C to Measure Noise
This C programming example (noise.c) can be found on the Documentation CD.
/************************************************************/
/* Measuring Noise */
/* */
/* This example is for the E44xxB ESA Spectrum Analyzers */
/* and E740xA EMC Analyzers. */
/* */
/* This C programming example does the following. */
/* The SCPI instrument commands used are given as */
/* reference. */
/* */
/* - Opens a GPIB session at address 18 */
/* - Clears the Analyzer */
/* - Resets the Analyzer */
/* *RST */
/* - Sets the center frequency and span */
/* SENS:FREQ:CENT 50 MHZ */
/* SENS:FREQ:SPAN 10 MHZ */
/* - Set the input port to the 50 MHz amplitude reference */
/* CAL:SOUR:STAT ON */
/* - Set the analyzer to single sweep mode */
/* INIT:CONT 0 */
/* - Trigger a sweep and wait for sweep completion */
/* INIT:IMM;*WAI */
/* - Set the marker to the maximum peak */
/* CALC:MARK:MAX */
/* - Set the analyzer to active delta marker */
/* CALC:MARK:MODE DELT */
/* - Set the delta marker to 2 MHZ */
/* CALC:MARK:X 2E+6 */
/* - Activate the noise marker function */
/* CALC:MARK:FUNC NOIS */
/* - Trigger a sweep and wait for sweep completion */
/* INIT:IMM;*WAI */
/* - Query the marker delta amplitude from the analyzer */
/* CALC:MARK:Y? */
/* - Report the marker delta amplitude as the carrier to */
/* noise ratio in dBc/Hz */
/* - Close the session */
/************************************************************/

240 Chapter 17
ESA Programming Examples
Using C to Measure Noise
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <conio.h>
#include <ctype.h>
#include <string.h>
#include "visa.h"
#define hpESA_IDN_E4401B "Hewlett-Packard, E4401B"
#define hpESA_IDN_E4411B "Hewlett-Packard, E4411B"
#definehpEMC_IDN_E7401A "Hewlett-Packard, E7401A"
ViSession defaultRM, viESA;
ViStatus errStatus;
ViChar cIdBuff[256]= {0};
char cEnter = 0;
int iResult = 0;
long lOpc =0L;
/*Set the input port to 50MHz amplitude reference*/
void Route50MHzSignal()
{
viQueryf(viESA, "*IDN?\n", "%t", &cIdBuff);
iResult = (strncmp( cIdBuff, hpESA_IDN_E4401B, strlen(hpESA_IDN_E4401B)) &&
strncmp( cIdBuff, hpESA_IDN_E4411B, strlen(hpESA_IDN_E4411B)) && strncmp( cIdBuff,
hpEMC_IDN_E7401A, strlen(hpEMC_IDN_E7401A)));
if( iResult == 0 )
{
/*Set the input port to the 50MHz amplitude reference for the models*/
/*E4401B, E4411B amd E7401A*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n");
}
else
{
/* For the analyzers having frequency limits >= 3GHz, prompt the user*/
/* to connect the amplitude reference output to the input*/
printf ("Connect AMPTD REF OUT to the INPUT \n");
printf ("......Press Return to continue \n");
scanf( "%c",&cEnter);
/*Externally route the 50MHz Signal*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n");
}
}
Chapter 17 241
ESA Programming Examples
Using C to Measure Noise
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
void main()
{
/*Program Variables*/
ViStatus viStatus = 0;
double dMarkAmp =0.0;
long lOpc=0L;
/*Open a GPIB session at address 18*/
viStatus=viOpenDefaultRM(&defaultRM);
viStatus=viOpen(defaultRM,"GPIB0::18",VI_NULL,VI_NULL,&viESA);
if(viStatus)
{
printf("Could not open a session to GPIB device at address 18!\n");
exit(0);
}
/*Clear the Instrument*/
viClear(viESA);
/*Reset the Instrument*/
viPrintf(viESA,"*RST\n");
/*Display the program heading */
printf("\n\t\t Noise Program \n\n" );
/* Check for the instrument model number and route the 50MHz signal accordingly*/
Route50MHzSignal();
/*Set the analyzer center frequency to 50MHz*/
viPrintf(viESA,"SENS:FREQ:CENT 50e6\n");
/*Set the analyzer span to 10MHz*/
viPrintf(viESA,"SENS:FREQ:SPAN 10e6\n");
/*Set the analyzer in a single sweep mode*/
viPrintf(viESA,"INIT:CONT 0 \n");
/*Trigger a sweep and wait for sweep completion*/
viPrintf(viESA,"INIT:IMM;*WAI \n");
/*Set the marker to the maximum peak*/
viPrintf(viESA,"CALC:MARK:MAX \n");
/*Check for operation complete*/
viQueryf(viESA, "*OPC?\n", "%d", &lOpc);
if (!lOpc)
{
242 Chapter 17
ESA Programming Examples
Using C to Measure Noise
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
printf("Program Abort! error ocurred: last command was not completed!\n");
exit(0);
}
/*Set the analyzer in a single sweep mode*/
viPrintf(viESA,"INIT:CONT 0 \n");
/*Trigger a spectrum measurement*/
viPrintf(viESA,"INIT:IMM \n");
/*Set the analyzer in active delta marker mode*/
viPrintf(viESA,"CALC:MARK:MODE DELT \n");
/*Set the marker delta frequency to 2 MHz. This places the
active marker two divisions to the right of the input signal.*/
viPrintf(viESA,"CALC:MARK:X 2E+6 \n");
/*Activate the noise marker function.*/
viPrintf(viESA,"CALC:MARK:FUNC NOIS \n");
/*Trigger a sweep and wait for sweep completion*/
viPrintf(viESA,"INIT:IMM;*WAI \n");
/*Query and read the marker delta amplitude from the analyzer*/
viQueryf(viESA,"CALC:MARK:Y? \n","%lf",&dMarkAmp);
/*Report the marker delta amplitude as the carrier-to-noise ratio in dBc/Hz*/
printf("\t Marker Amplitude = %lf dBc/Hz\n",dMarkAmp);
/*Close the session*/
viClose(viESA);
viClose(defaultRM);
}
Chapter 17 243
ESA Programming Examples
Using C to Enter Amplitude Correction Data
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Using C to Enter Amplitude Correction Data
This C programming example (amplcorr.c) can be found on the Documentation
CD.
/************************************************************/
/* Entering Amplitude Correction Data */
/* */
/* This example is for the E44xxB ESA Spectrum Analyzers */
/* and E740xA EMC Analyzers. */
/* */
/* This C programming example does the following. */
/* The SCPI instrument commands used are given as */
/* reference. */
/* */
/* - Opens a GPIB session at address 18 */
/* - Clears the Analyzer */
/* - Resets the Analyzer */
/* *RST */
/* - Sets the stop frequency to 1.5 GHz */
/* SENS:FREQ:STOP 1.5 GHZ */
/* - Set the input port to the 50 MHz amplitude reference */
/* CAL:SOUR:STAT ON */
/* - Enter amplitude correction frequency/amplitude pairs: */
/* 0 Hz/ 0 dB, 100 MHz/5 dB, 1 GHz/-5 dB, 1.5 GHz/ 10 dB */
/* SENS:CORR:CSET1:DATA 0,0,100E6,5.0,1.0E9,-5.0,... */
/* - Activate amplitude correction */
/* SENS:CORR:CSET1:DATA */
/* SENS:CORR:CSET1:ALL:STAT ON */
/* - Query the analyzer for the amplitude corection factors */
/* SENS:CORR:CSET1:DATA? */
/* - Store them in an array */
/* - Display the array */
/* - Close the session */
/************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <conio.h>
#include <ctype.h>
#include <string.h>
#include "visa.h"
244 Chapter 17
ESA Programming Examples
Using C to Enter Amplitude Correction Data
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
#define hpESA_IDN_E4401B "Hewlett-Packard, E4401B"
#define hpESA_IDN_E4411B "Hewlett-Packard, E4411B"
#define hpEMC_IDN_E7401A "Hewlett-Packard, E7401A"
ViSession defaultRM, viESA;
ViStatus errStatus;
ViChar cIdBuff[256]= {0};
char cEnter = 0;
int iResult = 0;
/*Set the input port to 50MHz amplitude reference*/
void Route50MHzSignal()
{
viQueryf(viESA, "*IDN?\n", "%t", &cIdBuff);
iResult = (strncmp( cIdBuff, hpESA_IDN_E4401B, strlen(hpESA_IDN_E4401B)) &&
strncmp( cIdBuff, hpESA_IDN_E4411B, strlen(hpESA_IDN_E4411B)) && strncmp( cIdBuff,
hpEMC_IDN_E7401A, strlen(hpEMC_IDN_E7401A)));
if( iResult == 0 )
{
/*Set the input port to the 50MHz amplitude reference for the models*/
/*E4401B, E4411B, and E7401A*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n");
}
else
{
/* For the analyzers having frequency limits >= 3GHz, prompt the user*/
/* to connect the amplitude reference output to the input*/
printf ("Connect AMPTD REF OUT to the INPUT \n");
printf ("......Press Return to continue \n");
scanf( "%c",&cEnter);
/*Externally route the 50MHz Signal*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n");
}
}
void main()
{
/*Program Variables*/
ViChar _VI_FAR cResult[1024] ={0};
ViReal64 _VI_FAR aRealArray[2][100] ={0};
ViStatus viStatus = 0;
int iNum =0;
int iNoOfPoints =0;
long lCount = 0;
Chapter 17 245
ESA Programming Examples
Using C to Enter Amplitude Correction Data
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
long lFreq=0L;
long lAmpltd=1;
static ViChar *cToken;
/*No of amplitude corrections points */
iNoOfPoints = 4;
/* Open a GPIB session at address 18*/
viStatus=viOpenDefaultRM(&defaultRM);
viStatus=viOpen(defaultRM,"GPIB0::18",VI_NULL,VI_NULL,&viESA);
if(viStatus)
{
printf("Could not open a session to GPIB device at address 18!\n");
exit(0);
}
/*Clear the instrument*/
viClear(viESA);
/*Reset the instrument*/
viPrintf(viESA,"*RST\n");
/*Display the program heading */
printf("\n\t\t Amplitude Correction Program \n\n" );
/*Set the stop frequency to 1.5 GHz */
viPrintf(viESA,"SENS:FREQ:STOP 1.5 GHz\n");
/* Check for the instrument model number and route the 50MHz signal accordingly*/
Route50MHzSignal();
/* Purge any currently-loaded amplitude correction factors*/
viPrintf(viESA,"SENS:CORR:CSET1:DEL \n");
/* Enter amp cor frequency/amplitude pairs:
0 Hz, 0 dB, 100 MHz, 5 dB, 1 GHz, -5 dB, 1.5GHz,10*/
viPrintf(viESA,"SENS:CORR:CSET1:DATA ");
viPrintf(viESA,"0, 0.0,");
viPrintf(viESA,"100.E6, 5.0,");
viPrintf(viESA,"1.E9, -5.0,");
viPrintf(viESA,"1.5E9, 10 \n");

/* Activate amplitude correction. Notice that the noise floor slopes
up from 0 Hz to 100 MHz, then downward by 10 dB to 1 GHz, then upwards
again by 15 dB to 1.5 GHz.*/
viPrintf(viESA,"SENS:CORR:CSET1:STATE ON \n");
viPrintf(viESA,"SENS:CORR:CSET:ALL:STAT ON \n");
246 Chapter 17
ESA Programming Examples
Using C to Enter Amplitude Correction Data
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/*Query the analyzer for its amplitude correction factors */
viQueryf(viESA,"SENS:CORR:CSET1:DATA?" , "%s" , &cResult);

/*Remove the "," from the amplitude correction for analyzing data*/
cToken = strtok(cResult,",");

/*Store the array (frequency) value into a two-dimensional real array*/
aRealArray[lFreq=0][lCount=0] = atof( cToken);
/*Remove the "," from the amplitude correction for analyzing data*/
cToken =strtok(NULL,",");
/*Store the array(amplitude) value into a two-dimensional real array*/
aRealArray[lAmpltd=1][lCount] = atof(cToken);
while (cToken != NULL)
{
lCount++;
if (lCount == iNoOfPoints)
{
lCount --;
break;
}
/*Remove the "," from the amplitude correction for analyzing data*/
cToken =strtok(NULL,",");
/*Store the array (frequency) value into a two-dimensional real array*/
aRealArray[lFreq][lCount] = atof(cToken);
cToken =strtok(NULL,",");
/*Store the array (amplitude) value into a two-dimensional real array*/
aRealArray[lAmpltd][lCount] = atof(cToken);
}
/*Display the contents of the array.*/
for (long i=0;i<=lCount;i++)
{
printf("\tFrequency of point[%d] = %f MHz\n",i,aRealArray[lFreq][i]/1e6);
printf("\tAmplitude of point[%d] = %f dB\n",i,aRealArray[lAmpltd][i]);
}
/*Close the session*/
viClose(viESA);
viClose(defaultRM);
}
Chapter 17 247
ESA Programming Examples
Using C to Determine if an Error has Occurred
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Using C to Determine if an Error has Occurred
This C programming example (error.c) can be found on the Documentation CD.
/************************************************************/
/* Determine if an error has occurred */
/* */
/* This example is for the E44xxB ESA Spectrum Analyzers */
/* and E740xA EMC Analyzers. */
/* */
/* This C programming example does the following. */
/* The SCPI instrument commands used are given as */
/* reference. */
/* */
/* - Opens a GPIB session at address 18 */
/* - Clears the Analyzer */
/* *CLS */
/* - Resets the Analyzer */
/* *RST */
/* - Sets the service request mask to assert SRQ when */
/* either a measurement is uncalibrated or an error */
/* message has occurred. */
/* STAT:QUES:ENAB 512 */
/* STAT:QUES:INT:ENAB 8 */
/* *ESE 35 */
/* *SRE 104 */
/* - Set the center frequency to 500MHz and span to 100MHz */
/* SENS:FREQ:CENT 500 MHZ */
/* SENS:FREQ:SPAN 100 MHZ */
/* - Set the analyzer to an uncalibrated state */
/* - When an interrupt occurs, poll all instruments */
/* - Report the nature of the interrupt on the ESA analyzer */
/* - Pause 5 seconds to observe the analyzer */
/* - Sets the service request mask to assert SRQ when */
/* either a measurement is uncalibrated or an error */
/* message has occurred. */
/* *ESE 35 */
/* *SRE 96 */
/* - Send an illegal command to the ESA */
/* IDN (illegal command) */
/* - When an interrupt occurs, poll all instruments */
/* - Report the nature of the interrupt on the ESA analyzer */
/* - Clear the analyzer status registers */
/* *SRE 0 */
248 Chapter 17
ESA Programming Examples
Using C to Determine if an Error has Occurred
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/* *ESE 0 */
/* STAT:QUES:ENAB 0 */
/* STAT:QUES:INT:ENAB 0 */
/* *CLS */
/* - Continue monitoring for an interrupt */
/* - Close the session */
/************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <conio.h>
#include <ctype.h>
#include <string.h>
#include <windows.h>
#include "visa.h"
#define hpESA_IDN_E4401B "Hewlett-Packard, E4401B"
#define hpESA_IDN_E4411B "Hewlett-Packard, E4411B"
#define hpEMC_IDN_E7401A "Hewlett-Packard, E7401A"
#define YIELD Sleep(10)
ViSession defaultRM, viESA;
ViStatus errStatus;
ViChar cIdBuff[256] = {0};
char cEnter =0;
int iResult =0;
int iSrqOccurred = 0;
char cBuf[3]={0};
/*Wait until SRQ is generated and for the handler to be called. Print
something while waiting. When interrupt occurs it will be handled by
interrupt handler*/
void WaitForSRQ()
{
long lCount = 0L;
iSrqOccurred =0;
printf ("\t\nWaiting for an SRQ to be generated ...");
for (lCount =0;(lCount<10) && (iSrqOccurred ==0); lCount++)
{
long lCount2 =0;
printf(".");
while ((lCount2++ < 100) && (iSrqOccurred ==0))
{
Chapter 17 249
ESA Programming Examples
Using C to Determine if an Error has Occurred
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
YIELD;
}
}
printf("\n");
}
/*Set the input port to 50MHz amplitude reference*/
void Route50MHzSignal()
{
viQueryf(viESA, "*IDN?\n", "%t", &cIdBuff);
iResult = (strncmp( cIdBuff, hpESA_IDN_E4401B, strlen(hpESA_IDN_E4401B)) &&
strncmp( cIdBuff, hpESA_IDN_E4411B, strlen(hpESA_IDN_E4411B)) && strncmp( cIdBuff,
hpEMC_IDN_E7401A, strlen(hpEMC_IDN_E7401A)));
if( iResult == 0 )
{
/*Set the input port to the 50MHz amplitude reference for the models*/
/*E4401B, E4411B and E7401A*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n");
}
else
{
/* For the analyzers having frequency limits >= 3GHz, prompt the user*/
/* to connect the amplitude reference output to the input*/
printf ("Connect AMPTD REF OUT to the INPUT \n");
printf ("......Press Return to continue \n");
scanf( "%c",&cEnter);
/*Externally route the 50MHz Signal*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n");
}
}
/*Interrupt handler,trigger event handler */
ViStatus _VI_FUNCH sSrqHdlr(ViSession viESA, ViEventType eventType, ViEvent
ctx,ViAddr userHdlr)
{
ViUInt16 iStatusByte=0;
long lCond = 0L;
/* Make sure it is an SRQ event, ignore if stray event*/
if (eventType!=VI_EVENT_SERVICE_REQ)
{
printf ("\n Stray event type0x%1x\n",eventType);
/*Return successfully*/
250 Chapter 17
ESA Programming Examples
Using C to Determine if an Error has Occurred
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
return VI_SUCCESS;
}
/* When an interrupt occurs, determine which device generated the interrupt
(if an instrument other than the ESA generates the interrupt, simply report
"Instrument at GPIB Address xxx Has Generated an Interrupt").*/
printf ("\n SRQ Event Occurred!\n");
printf ("\n ... Original Device Session = %1d\n",viESA);
/*Get the GPIB address of the insrument, which has interrupted*/
viQueryf(viESA,"SYST:COMM:GPIB:SELF:ADDR?\n","%t", cBuf);
printf ("\n Instrument at GPIB Address %s Has Generated an Interrupt!\n",cBuf);
/*Get the status byte*/
/* If the ESA generated the interrupt, determine the nature of the interrupt
either a measurement is uncalibrated or an error message has occurred?*/
viQueryf(viESA, "STAT:QUES:INT:EVEN?\n", "%d", &iStatusByte);
if ( (0x08 & iStatusByte))
printf("\n SRQ message:\t Measurement uncalibrated\n");
/* If the ESA generated the interrupt, determine the nature of the interrupt;
did is the measurement complete or an error message occur?*/
viQueryf(viESA, "*ESR?\n", "%d", &iStatusByte);
if ( (iStatusByte !=0) && (0x01 & iStatusByte))
printf("\n SRQ message:\t Measurement complete\n");
else if ( (iStatusByte !=0) && (0x02 | 0x10 | 0x20 & iStatusByte ))
printf ("\n SRQ message:\t Error Message Occurred\n");
/*Return successfully*/
iSrqOccurred =1;
viReadSTB(viESA, &iStatusByte);
return VI_SUCCESS;
}
void main()
{
/*Program Variables*/
ViStatus viStatus = 0;
long lOpc= 0L;
int iIntNum= 0;
long lCount= 0L;
/* Open a GPIB session at address 18*/
viStatus=viOpenDefaultRM(&defaultRM);
viStatus=viOpen(defaultRM,"GPIB0::18",VI_NULL,VI_NULL,&viESA);
if(viStatus)
{
Chapter 17 251
ESA Programming Examples
Using C to Determine if an Error has Occurred
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
printf("Could not open a session to GPIB device at address 18!\n");
exit(0);
}
/*Clear the instrument*/
viClear(viESA);
/*Reset the instrument*/
viPrintf(viESA,"*RST\n");
/*Clear the status byte of the instrument*/
viPrintf(viESA,"*CLS\n");
/*Display the program heading */
printf("\n\t\t Status register - Determine if an Error has Occurred\n\n" );
/* Check for the instrument model number and route the 50MHz-signal accordingly*/
Route50MHzSignal();
/*Put the analyzer in single sweep*/
viPrintf(viESA,"INIT:CONT 0 \n");
/*Set the service request mask to assert SRQ when either a measurement
is uncalibrated (i.e. "Meas Uncal" displayed on screen) or an error
message has occurred.*/
viPrintf(viESA,"STAT:QUES:ENAB 512\n");
viPrintf(viESA,"STAT:QUES:INT:ENAB 8\n");
viPrintf(viESA,"*ESE 35\n");
viPrintf(viESA,"*SRE 104\n");
/*Configure the computer to respond to an interrupt,install the handler
and enable it */
viInstallHandler(viESA, VI_EVENT_SERVICE_REQ, sSrqHdlr,ViAddr(10));
viEnableEvent(viESA, VI_EVENT_SERVICE_REQ,VI_HNDLR,VI_NULL);
iSrqOccurred =0;
/*Set the analyzer to a 500 MHz center frequency*/
viPrintf(viESA,"SENS:FREQ:CENT 500 MHZ \n");
/*Set the analyzer to a 100 MHz span*/
viPrintf(viESA,"SENS:FREQ:SPAN 100 MHZ\n");
/*Set the analyzer to a auto resolution BW*/
viPrintf(viESA,"SENS:BAND:RES:AUTO 1\n");
/*Set the analyzer to a Auto Sweep Time*/
viPrintf(viESA,"SENS:SWE:TIME:AUTO 1\n");
252 Chapter 17
ESA Programming Examples
Using C to Determine if an Error has Occurred
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/*Allow analyzer to sweep several times.*/
viPrintf(viESA,"INIT:CONT 1 \n");
/*Manually couple sweeptime to 5ms. reduce resolution BW to 30 KHz.
"Meas Uncal" should be displayed on the screen, and an interrupt should
be generated.*/
viPrintf(viESA,"SENS:SWE:TIME 5 ms \n");
viPrintf(viESA,"SENS:BAND:RES 30 KHZ \n");
/*Wait for SRQ*/
WaitForSRQ();
/*Pause for 5 seconds to observe "Meas Uncal" message on ESA display*/
Sleep(5000);
/* Set the service request mask to assert SRQ when either a measurement
is completed or an error message has occurred.*/
viPrintf(viESA,"*SRE 96\n");
viPrintf(viESA,"*ESE 35\n");
/*Send an undefined command to the device*/
viPrintf(viESA,"IDN\n");
/*Wait for SRQ*/
WaitForSRQ();
/*Disable and uninstall the interrupt handler*/
viDisableEvent (viESA, VI_EVENT_SERVICE_REQ,VI_HNDLR);
viUninstallHandler(viESA, VI_EVENT_SERVICE_REQ, sSrqHdlr,ViAddr(10));
/*Clear the instrument status register*/
viPrintf(viESA,"*SRE 0 \n");
viPrintf(viESA,"*ESE 0 \n");
viPrintf(viESA,"STAT:QUES:ENAB 0\n");
viPrintf(viESA,"STAT:QUES:INT:ENAB 0\n");
/*Clear the status byte of the instrument*/
viPrintf(viESA,"*CLS\n");
/*Close the session*/
viClose(viESA);
viClose(defaultRM);
}
Chapter 17 253
ESA Programming Examples
Using C to Measure Harmonic Distortion (over GPIB)
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Using C to Measure Harmonic Distortion (over GPIB)
This C programming example (harmgpib.c) can be found on the Documentation
CD.
/************************************************************/
/* Measuring Harmonic Distortion (GPIB) */
/* */
/* This example is for the E44xxB ESA Spectrum Analyzers */
/* and E740xA EMC Analyzers. */
/* */
/* This C programming example does the following. */
/* The SCPI instrument commands used are given as */
/* reference. */
/* */
/* - Opens a GPIB session at address 18 */
/* - Clears the Analyzer */
/* *CLS */
/* - Resets the Analyzer */
/* *RST */
/* - Set the input port to the 50 MHz reference */
/* CAL:SOUR:STAT ON */
/* - Set the analyzer center frequency to the fundamental */
/* SENS:FREQ:CENT freq */
/* - Set the analyzer to 10 MHz span */
/* SENS:FREQ:SPAN 10 MHZ */
/* - Set the analyzer to single sweep mode */
/* INIT:CONT 0 */
/* - Take a sweep and wait for sweep completion */
/* INIT:IMM;*WAI */
/* - Perform the peak search */
/* CALC:MARK:MAX */
/* - Set the marker to reference level */
/* CALC:MARK:SET:RLEV */
/* - Take a sweep and wait for sweep completion */
/* INIT:IMM;*WAI */
/* - Perform the peak search */
/* CALC:MARK:MAX */
/* - Change VISA timeout to 60 seconds */
/* - Activate signal track */
/* CALC:MARK:TRCK:STAT ON */
/* - Perform narrow span and wait */
/* SENS:FREQ:SPAN 10e4 */
/* - Check for operation complete */
254 Chapter 17
ESA Programming Examples
Using C to Measure Harmonic Distortion (over GPIB)
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/* *OPC? */
/* - De-activate signal track */
/* CALC:MARK:TRCK:STAT OFF */
/* - Reset VISA timeout to 3 seconds */
/* - Set units to dBm */
/* UNIT:POW DBM */
/* - Take a sweep and wait for sweep completion */
/* INIT:IMM; */
/* *OPC? */
/* - Perform the peak search */
/* CALC:MARK:MAX */
/* - Read the marker amplitude,this is the fundamental Level*/
/* CALC:MARK:Y? */
/* - Change the amplitude units to volts */
/* UNIT:POW V */
/* - Take a sweep */
/* INIT:IMM */
/* - Check for operation complete */
/* *OPC? */
/* - Read the marker amplitude in volts, this is the */
/* fundamental amplitude in volts. */
/* CALC:MARK:Y? */
/* - Read the marker frequency */
/* CALC:MARK:X? */
/* - Measure each harmonic amplitude as follows: */
/* Set the span to 20 MHz */
/* SENS:FREQ:SPAN 20 MHZ */
/* Set the center frequency to the desired harmonic */
/* SENS:FREQ:CENT <freq> */
/* Take a sweep and wait for operation complete */
/* INIT:IMM */
/* *OPC? */
/* Perform peak search */
/* CALC:MARK:MAX */
/* Set VISA timeout to 60 seconds */
/* Activate signal track */
/* CALC:MARK:TRCK:STAT ON */
/* Zoom down to a 100 kHz span */
/* SENS:FREQ:SPAN 10E4 */
/* Take a sweep and wait for operation complete */
/* INIT:IMM */
/* *OPC? */
/* Signal track off */
/* CALC:MARK:TRCK:STAT OFF */
/* Reset VISA timeout to 3 seconds */
/* Perform Peak Search */
Chapter 17 255
ESA Programming Examples
Using C to Measure Harmonic Distortion (over GPIB)
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/* CALC:MARK:MAX */
/* Set marker amplitude in volts */
/* UNIT:POW V */
/* Query, read the marker amplitude in volts */
/* CALC:MARK:Y? */
/* Change the amplitude units to dBm and read the */
/* marker amplitude. */
/* UNIT:POW DBM */
/* - Calculate the relative amplitude of each harmonic */
/* reletive to the fundamental */
/* - Calculate the total harmonic distortion */
/* - Display the fundamental amplitude in dBm, fundamental */
/* frequency in MHz, relative amplitude of each harmonic */
/* in dBc and total harmonic distortion in percent */
/* - Close the session */
/************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <conio.h>
#include <ctype.h>
#include <string.h>
#include "visa.h"
#define hpESA_IDN_E4401B "Hewlett-Packard, E4401B"
#define hpESA_IDN_E4411B "Hewlett-Packard, E4411B"
#definehpEMC_IDN_E7401A "Hewlett-Packard, E7401A"
ViSession defaultRM, viESA;
ViStatus errStatus;
ViChar cIdBuff[256]= {0};
char cEnter = 0;
int iResult = 0;
long lOpc =0L;
/*Set the input port to 50MHz amplitude reference*/
void Route50MHzSignal()
{
viQueryf(viESA, "*IDN?\n", "%t", &cIdBuff);
iResult = (strncmp( cIdBuff, hpESA_IDN_E4401B, strlen(hpESA_IDN_E4401B)) &&
strncmp( cIdBuff, hpESA_IDN_E4411B, strlen(hpESA_IDN_E4411B)) && strncmp( cIdBuff,
hpEMC_IDN_E7401A, strlen(hpEMC_IDN_E7401A)));
if( iResult == 0 )
{
256 Chapter 17
ESA Programming Examples
Using C to Measure Harmonic Distortion (over GPIB)
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/*Set the input port to the 50MHz amplitude reference for the models*/
/*E4401B, E4411B, and E7401A*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n");
}
else
{
/* For the analyzers having frequency limits >= 3GHz, prompt the user*/
/* to connect the amplitude reference output to the input*/
printf ("Connect AMPTD REF OUT to the INPUT \n");
printf ("......Press Return to continue \n");
scanf( "%c",&cEnter);
/*Externally route the 50MHz Signal*/
viPrintf(viESA,"CAL:SOUR:STAT ON \n");
}
}
void TakeSweep()
{
/*Take a sweep and wait for the sweep completion*/
viPrintf(viESA,"INIT:IMM\n");
viQueryf(viESA, "*OPC?\n", "%d", &lOpc);
if (!lOpc)
{
printf("Program Abort! Error occurred: last command was not completed! \n");
exit(0);
}
}
void main()
{
/*Program Variables*/
ViStatus viStatus = 0;
double dFundamental = 0.0;
double dHarmFreq =0.0;
float fHarmV[10] ={0.0};
float fHarmDbm[10]={0.0};
float fRelAmptd[10]={0.0};
float fFundaAmptdDbm=0.0;
double dFundaAmptdV=0.0;
double dMarkerFreq = 0.0;
double dPrcntDistort =0.0;
double dSumSquare =0.0;
long lMaxHarmonic =0L;
long lNum=0L;
/*Setting default values*/
Chapter 17 257
ESA Programming Examples
Using C to Measure Harmonic Distortion (over GPIB)
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
lMaxHarmonic =5;
dFundamental =50.0;
/* Open a GPIB session at address 18*/
viStatus=viOpenDefaultRM(&defaultRM);
viStatus=viOpen(defaultRM,"GPIB0::18",VI_NULL,VI_NULL,&viESA);
if(viStatus)
{
printf("Could not open a session to GPIB device at address 18!\n");
exit(0);
}
/*Clear the instrument*/
viClear(viESA);
/*Reset the instrument*/
viPrintf(viESA,"*RST\n");
/*Display the program heading */
printf("\n\t\t Harmonic Distortion Program \n\n" );
/* Check for the instrument model number and route the 50MHz-signal accordingly*/
Route50MHzSignal();
/*Prompt user for fundamental frequency*/
printf("\t Enter the input signal fundamental frequency in MHz ");
/*The user enters fundamental frequency*/
scanf("%lf",&dFundamental);
/*Set the analyzer center frequency to the fundamental frequency. */
viPrintf(viESA,"SENS:FREQ:CENT %lf MHZ \n;",dFundamental);
/*Set the analyzer to 10MHz Span */
viPrintf(viESA,"SENS:FREQ:SPAN 10 MHZ\n");
/*Put the analyzer in a single sweep */
viPrintf(viESA,"INIT:CONT 0 \n");
/*Trigger a sweep, wait for sweep completion*/
viPrintf(viESA,"INIT:IMM;*WAI\n");
/*Perform a peak search */
viPrintf(viESA,"CALC:MARK:MAX \n");
/* Place the signal at the reference level using the
marker-to-reference level command and take sweep */
258 Chapter 17
ESA Programming Examples
Using C to Measure Harmonic Distortion (over GPIB)
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
viPrintf(viESA,"CALC:MARK:SET:RLEV \n");
/*Trigger a sweep, wait for sweep completion*/
viPrintf(viESA,"INIT:IMM;*WAI\n");
/*Perform a peak search */
viPrintf(viESA,"CALC:MARK:MAX \n");
/*increase timeout to 60 sec*/
viSetAttribute(viESA,VI_ATTR_TMO_VALUE,60000);
/*Perform activate signal track */
viPrintf(viESA,"CALC:MARK:TRCK:STAT ON \n");
/*Take a sweep and wait for the sweep completion*/
TakeSweep();
/*Perform narrow span and wait */
viPrintf(viESA,"SENS:FREQ:SPAN 10e4 \n");
/*Take a sweep and wait for the sweep completion*/
TakeSweep();
/*De activate the signal track */
viPrintf(viESA,"CALC:MARK:TRCK:STAT OFF \n");
/*Reset timeout to 3 sec*/
viSetAttribute(viESA,VI_ATTR_TMO_VALUE,3000);
/*Set units to DBM*/
viPrintf(viESA,"UNIT:POW DBM \n");
/*Perform a peak search */
viPrintf(viESA,"CALC:MARK:MAX \n");
/*Read the marker amplitude, this is the fundamental amplitude
in dBm */
viQueryf(viESA,"CALC:MARK:Y?\n","%1f", &fFundaAmptdDbm);
/*Change the amplitude units to Volts */
viPrintf(viESA,"UNIT:POW V \n");
/*Read the marker amplitude in volts, This is the fundamental amplitude
in Volts (necessary for the THD calculation).*/
viQueryf(viESA,"CALC:MARK:Y?\n","%lf",&dFundaAmptdV);
Chapter 17 259
ESA Programming Examples
Using C to Measure Harmonic Distortion (over GPIB)
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/*Read the marker frequency. */
viQueryf(viESA,"CALC:MARK:X? \n","%lf",&dMarkerFreq);
dFundamental = dMarkerFreq;
/*Measure each harmonic amplitude as follows: */
for ( lNum=2;lNum<=lMaxHarmonic;lNum++)
{
/*Measuring the Harmonic No#[%d] message */
printf("\n\t Measuring the Harmonic No [%d] \n",lNum );
/*Set the span to 20 MHz*/
viPrintf(viESA,"SENS:FREQ:SPAN 20 MHZ \n");
/*Set the center frequency to the nominal harmonic frequency*/
dHarmFreq = lNum*dFundamental;
viPrintf(viESA,"SENS:FREQ:CENT %lf HZ \n;",dHarmFreq);
/*Take a sweep and wait for the sweep completion*/
TakeSweep();
/*Perform a peak search and wait for completion */
viPrintf(viESA,"CALC:MARK:MAX\n");
/*increase timeout to 60 sec*/
viSetAttribute(viESA,VI_ATTR_TMO_VALUE,60000);
/*Activate signal track */
viPrintf(viESA,"CALC:MARK:TRCK:STAT ON\n");
/*Zoom down to a 100 kHz span */
viPrintf(viESA,"SENS:FREQ:SPAN 10e4\n");
/*Take a sweep and wait for the sweep completion*/
TakeSweep();
/* Signal track off */
viPrintf(viESA,"CALC:MARK:TRCK:STAT OFF\n");
/*Reset timeout to 3 sec*/
viSetAttribute(viESA,VI_ATTR_TMO_VALUE,3000);
/*Set Marker Amplitude in Volts*/
viPrintf(viESA,"UNIT:POW V\n");
/*Perform a peak search and wait for completion*/
viPrintf(viESA,"CALC:MARK:MAX\n");
260 Chapter 17
ESA Programming Examples
Using C to Measure Harmonic Distortion (over GPIB)
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/*Query and read the Marker Amplitude in Volts*/
/*Store the result in the array.*/
viQueryf(viESA,"CALC:MARK:Y?\n","%1f", &fHarmV[lNum]);
/*Change the amplitude units to DBM */
viPrintf(viESA,"UNIT:POW DBM\n");
/* Read the marker amplitude */
viQueryf(viESA,"CALC:MARK:Y?\n","%1f", &fHarmDbm[lNum]);
}
/*Sum the square of each element in the fHarmV array. Then
calculate the relative amplitude of each harmonic relative
to the fundamental */
for (lNum=2;lNum<=lMaxHarmonic;lNum++)
{
dSumSquare= dSumSquare + (pow (double(fHarmV[lNum]) ,2.0));
/* Relative Amplitude */
fRelAmptd[lNum] = fHarmDbm[lNum] - fFundaAmptdDbm ;
}
/*Calculate the total harmonic distortion by dividing the square root of
the sum of the squares (dSumSquare) by the fundamental amplitude in Volts
(dFundaAmptdV).Multiply this value by 100 to obtain a result in percent*/
dPrcntDistort = ((sqrt(double (dSumSquare))) /dFundaAmptdV) *100 ;
/*Fundamental amplitude in dBm */
printf("\n\t Fundamental Amplitude: %lf dB \n\n",fFundaAmptdDbm);
/*Fundamental Frequency in MHz*/
printf("\t Fundamental Frequency is: %lf MHz \n\n",dFundamental/10e5);
/*Relative amplitude of each harmonic in dBc*/
for (lNum=2;lNum<=lMaxHarmonic;lNum++)
printf("\t Relative amplitude of Harmonic[%d]: %lf dBc
\n\n",lNum,fRelAmptd[lNum]);
/*Total harmonic distortion in percent*/
printf("\t Total Harmonic Distortion: %lf percent \n\n",dPrcntDistort);
/*Close the session*/
viClose(viESA);
viClose(defaultRM);
}
Chapter 17 261
ESA Programming Examples
Using C to Measure Harmonic Distortion (over RS-232)
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Using C to Measure Harmonic Distortion (over RS-232)
This C programming example (harmrs23.c) can be found on the Documentation
CD.
/************************************************************/
/* Measuring Harmonic Distortion (RS-232) */
/* */
/* This example is for the E44xxB ESA Spectrum Analyzers */
/* and E740xA EMC Analyzers. */
/* */
/* This C programming example does the following. */
/* The SCPI instrument commands used are given as */
/* reference. */
/* */
/* - Opens an RS-232 session to the COM1 serial port */
/* - Clears the Analyzer */
/* *CLS */
/* - Resets the Analyzer */
/* *RST */
/* - Set the input port to the 50 MHz reference */
/* CAL:SOUR:STAT ON */
/* - Set the analyzer center frequency to the fundamental */
/* SENS:FREQ:CENT freq */
/* - Set the analyzer to 10 MHz span */
/* SENS:FREQ:SPAN 10 MHZ */
/* - Set the analyzer to single sweep mode */
/* INIT:CONT 0 */
/* - Trigger a sweep and wait for sweep completion */
/* INIT:IMM;*WAI */
/* - Perform the peak search */
/* CALC:MARK:MAX */
/* - Set the marker to reference level */
/* CALC:MARK:SET:RLEV */
/* - Trigger a sweep and wait for sweep completion */
/* INIT:IMM;*WAI */
/* - Perform the peak search */
/* CALC:MARK:MAX */
/* - Change VISA timeout to 60 seconds */
/* - Activate signal track */
/* CALC:MARK:TRCK:STAT ON */
/* - Perform narrow span and wait */
/* SENS:FREQ:SPAN 10e4 */
/* - Check for operation complete */
262 Chapter 17
ESA Programming Examples
Using C to Measure Harmonic Distortion (over RS-232)
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/* *OPC? */
/* - De-activate signal track */
/* CALC:MARK:TRCK:STAT OFF */
/* - Reset VISA timeout to 3 seconds */
/* - Set units to dBm */
/* UNIT:POW DBM */
/* - Take a sweep and wait for sweep completion */
/* INIT:IMM; */
/* *OPC? */
/* - Perform the peak search */
/* CALC:MARK:MAX */
/* - Read the marker amplitude,this is the fundamental Level*/
/* CALC:MARK:Y? */
/* - Change the amplitude units to volts */
/* UNIT:POW V */
/* - Take a sweep */
/* INIT:IMM */
/* - Check for operation complete */
/* *OPC? */
/* - Read the marker amplitude in volts, this is the */
/* fundamental amplitude in volts. */
/* CALC:MARK:Y? */
/* - Read the marker frequency */
/* CALC:MARK:X? */
/* - Measure each harmonic amplitude as follows: */
/* Set the span to 20 MHz */
/* SENS:FREQ:SPAN 20 MHZ */
/* Set the center frequency to the desired harmonic */
/* SENS:FREQ:CENT <freq> */
/* Take a sweep and wait for operation complete */
/* INIT:IMM */
/* *OPC? */
/* Perform peak search */
/* CALC:MARK:MAX */
/* Set VISA timeout to 60 seconds */
/* Activate signal track */
/* CALC:MARK:TRCK:STAT ON */
/* Zoom down to a 100 kHz span */
/* SENS:FREQ:SPAN 10E4 */
/* Take a sweep and wait for operation complete */
/* INIT:IMM */
/* *OPC? */
/* Signal track off */
/* CALC:MARK:TRCK:STAT OFF */
/* Reset VISA timeout to 3 seconds */
/* Perform Peak Search */
Chapter 17 263
ESA Programming Examples
Using C to Measure Harmonic Distortion (over RS-232)
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/* CALC:MARK:MAX */
/* Set marker amplitude in volts */
/* UNIT:POW V */
/* Query, read the marker amplitude in volts */
/* CALC:MARK:Y? */
/* Change the amplitude units to dBm and read the */
/* marker amplitude. */
/* UNIT:POW DBM */
/* - Calculate the relative amplitude of each harmonic */
/* reletive to the fundamental */
/* - Calculate the total harmonic distortion */
/* - Display the fundamental amplitude in dBm, fundamental */
/* frequency in MHz, relative amplitude of each harmonic */
/* in dBc and total harmonic distortion in percent */
/* - Close the session */
/************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <conio.h>
#include <ctype.h>
#include <string.h>
#include <visa.h>
#define hpESA_IDN_E4401B "Hewlett-Packard, E4401B"
#define hpESA_IDN_E4411B "Hewlett-Packard, E4411B"
#definehpEMC_IDN_E7401A "Hewlett-Packard, E7401A"
ViSession defaultRM, viESA;
ViStatus errStatus;
ViChar cIdBuff[256]= {0};
char cEnter = 0;
int iResult = 0;
long lOpc =0L ;
/*Set the input port to 50MHz amplitude reference*/
void Route50MHzSignal()
{
viQueryf(viESA, "*IDN?\n", "%t", &cIdBuff);
iResult = (strncmp( cIdBuff, hpESA_IDN_E4401B, strlen(hpESA_IDN_E4401B)) &&
strncmp( cIdBuff, hpESA_IDN_E4411B, strlen(hpESA_IDN_E4411B)) && strncmp( cIdBuff,
hpEMC_IDN_E7401A, strlen(hpEMC_IDN_E7401A)));
if( iResult == 0 )
{
264 Chapter 17
ESA Programming Examples
Using C to Measure Harmonic Distortion (over RS-232)
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/*Set the input port to the 50MHz amplitude reference for the models*/
/*E4411B, E4401B*/
viPrintf(viESA,"CAL:SOUR:STAT ON\n");
}
else
{
/* For the analyzers having frequency limits >= 3GHz, prompt the user*/
/* to connect the amplitude reference output to the input*/
printf ("Connect AMPTD REF OUT to the INPUT \n");
printf ("......Press Return to continue \n");
scanf( "%c",&cEnter);
/*Externally route the 50MHz Signal*/
viPrintf(viESA,"CAL:SOUR:STAT ON\n");
}
}
void TakeSweep()
{
/*Take a sweep and wait for the sweep completion*/
viPrintf(viESA,"INIT:IMM\n");
viQueryf(viESA, "*OPC?\n", "%d", &lOpc);
if (!lOpc)
{
printf("Program Abort! Error occurred: last command was not completed! \n");
exit(0);
}
}
void main()
{
/*Program Variables*/
ViStatus viStatus = 0;
double dFundamental = 0.0;
double dHarmFreq = 0.0;
float fHarmV[10] ={0.0};
float fHarmDbm[10]={0.0};
float fRelAmptd[10]={0.0};
float fFundaAmptdDbm=0.0;
double dFundaAmptdV=0.0;
double dMarkerFreq = 0.0;
double dPrcntDistort =0.0;
double dSumSquare =0.0;
long lMaxHarmonic =0L;
long lNum=0L;
Chapter 17 265
ESA Programming Examples
Using C to Measure Harmonic Distortion (over RS-232)
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/*Setting default values*/
lMaxHarmonic =5;
dFundamental =50.0;
/* Open a serial session at COM1 */
viStatus=viOpenDefaultRM(&defaultRM);
if (viStatus =viOpen(defaultRM,"ASRL1::INSTR",VI_NULL,VI_NULL,&viESA) !=
VI_SUCCESS)
{
printf("Could not open a session to ASRL device at COM1!\n");
exit(0);
}
/*Clear the instrument*/
viClear(viESA);
/*Reset the instrument*/
viPrintf(viESA,"*RST\n");
/*Display the program heading */
printf("\n\t\t Harmonic Distortion Program \n\n" );
/* Check for the instrument model number and route the 50MHz-signal accordingly*/
Route50MHzSignal();
/*Prompt user for fundamental frequency*/
printf("\t Enter the input signal fundamental frequency in MHz ");
/*The user enters fundamental frequency*/
scanf("%lf",&dFundamental);
/*Set the analyzer center frequency to the fundamental frequency. */
viPrintf(viESA,"SENS:FREQ:CENT %lf MHZ\n",dFundamental);
/*Set the analyzer to 10MHz Span */
viPrintf(viESA,"SENS:FREQ:SPAN 10 MHZ\n");
/*Put the analyzer in a single sweep mode */
viPrintf(viESA,"INIT:CONT 0\n");
/*Trigger a sweep, wait for sweep completion*/
viPrintf(viESA,"INIT:IMM;*WAI\n");
/*Perform a peak search */
viPrintf(viESA,"CALC:MARK:MAX\n");
266 Chapter 17
ESA Programming Examples
Using C to Measure Harmonic Distortion (over RS-232)
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/* Place the signal at the reference level using the
marker-to-reference level command and take sweep */
viPrintf(viESA,"CALC:MARK:SET:RLEV\n");
/*Trigger a sweep, wait for sweep completion*/
viPrintf(viESA,"INIT:IMM;*WAI\n");
/*Perform a peak search */
viPrintf(viESA,"CALC:MARK:MAX\n");
/*Increase timeout to 60 sec*/
viSetAttribute(viESA,VI_ATTR_TMO_VALUE,60000);
/*Perform activate signal track */
viPrintf(viESA,"CALC:MARK:TRCK:STAT ON\n");
/*Take a sweep and wait for the sweep completion*/
TakeSweep();
/*Perform narrow span and wait */
viPrintf(viESA,"SENS:FREQ:SPAN 10e4\n");
/*Take a sweep and wait for the sweep completion*/
TakeSweep();
/*De activate the signal track */
viPrintf(viESA,"CALC:MARK:TRCK:STAT OFF\n");
/*Reset timeout to 3 sec*/
viSetAttribute(viESA,VI_ATTR_TMO_VALUE,3000);
/*Set units to dBm*/
viPrintf(viESA,"UNIT:POW DBM\n");
/*Perform a peak search */
viPrintf(viESA,"CALC:MARK:MAX\n");
/*Read the marker amplitude, this is the fundamental amplitude
in dBm */
viQueryf(viESA,"CALC:MARK:Y?\n","%1f", &fFundaAmptdDbm);
/*Change the amplitude units to Volts */
viPrintf(viESA,"UNIT:POW V\n");
/*Read the marker amplitude in volts, This is the fundamental amplitude
in Volts (necessary for the THD calculation).*/
Chapter 17 267
ESA Programming Examples
Using C to Measure Harmonic Distortion (over RS-232)
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
viQueryf(viESA,"CALC:MARK:Y?\n","%lf",&dFundaAmptdV);
/*Read the marker frequency. */
viQueryf(viESA,"CALC:MARK:X? \n","%lf",&dMarkerFreq);
dFundamental = dMarkerFreq;
/*Measure each harmonic amplitude as follows: */
for ( lNum=2;lNum<=lMaxHarmonic;lNum++)
{
/*Measuring the Harmonic No#[%d] message */
printf("\n\t Measuring the Harmonic No [%d] \n",lNum );
/*Set the span to 20 MHz*/
viPrintf(viESA,"SENS:FREQ:SPAN 20 MHZ\n");
/*Set the center frequency to the nominal harmonic frquency*/
dHarmFreq = lNum * dFundamental;
viPrintf(viESA,"SENS:FREQ:CENT %lf HZ\n",dHarmFreq);
/*Take a sweep and wait for the sweep completion*/
TakeSweep();
/*Perform a peak search and wait for completion */
viPrintf(viESA,"CALC:MARK:MAX\n");
/*Increase timeout to 60 sec*/
viSetAttribute(viESA,VI_ATTR_TMO_VALUE,60000);
/*Activate signal track */
viPrintf(viESA,"CALC:MARK:TRCK:STAT ON\n");
/*Zoom down to a 100 KHz span */
viPrintf(viESA,"SENS:FREQ:SPAN 10e4\n");
/*Take a sweep and wait for the sweep completion*/
TakeSweep();
/* Signal track off */
viPrintf(viESA,"CALC:MARK:TRCK:STAT OFF\n");
/*Reset timeout to 3 sec*/
viSetAttribute(viESA,VI_ATTR_TMO_VALUE,3000);
/*Set marker amplitude in Volts*/
viPrintf(viESA,"UNIT:POW V\n");
268 Chapter 17
ESA Programming Examples
Using C to Measure Harmonic Distortion (over RS-232)
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/*Perform a peak search and wait for completion*/
viPrintf(viESA,"CALC:MARK:MAX\n");
/*Query and read the marker amplitude in Volts*/
/*Store the result in the fHarmV array.*/
viQueryf(viESA,"CALC:MARK:Y?\n","%1f", &fHarmV[lNum]);
/*Change the amplitude units to dBm */
viPrintf(viESA,"UNIT:POW DBM\n");
/* Read the marker amplitude */
viQueryf(viESA,"CALC:MARK:Y?\n","%1f", &fHarmDbm[lNum]);
}
/*Sum the square of each element in the fHarmV array and calculate
the relative amplitude of each harmonic relative to the fundamental*/
for (lNum=2;lNum<=lMaxHarmonic;lNum++)
{
dSumSquare= dSumSquare + (pow (double(fHarmV[lNum]) ,2.0));
/* Relative Amplitude */
fRelAmptd[lNum] = fHarmDbm[lNum] - fFundaAmptdDbm ;
}
/*Calculate the total harmonic distortion by dividing the square root of
the sum of the squares (dSumSquare) by the fundamental amplitude in Volts
(dFundaAmptdV).Multiply this value by 100 to obtain a result in percent*/
dPrcntDistort = ((sqrt(double (dSumSquare))) /dFundaAmptdV) *100 ;
/*Fundamental amplitude in dBm */
printf("\nFundamental Amplitude: %lf dB \n",fFundaAmptdDbm);
/*Fundamental frequency in MHz*/
printf("Fundamental Frequency is: %lf MHz \n",dFundamental/10e5);
/*Relative amplitude of each harmonic in dBc*/
for (lNum=2;lNum<=lMaxHarmonic;lNum++)
printf("Relative amplitude of Harmonic[%d]: %lf dBc
\n",lNum,fRelAmptd[lNum]);
/*Total harmonic distortion in percent*/
printf("Total Harmonic Distortion: %lf percent\n",dPrcntDistort);
/*Close the session*/
viClose(viESA);
viClose(defaultRM);
}
Chapter 17 269
ESA Programming Examples
Using C to Make Faster Power Averaging Measurements
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Using C to Make Faster Power Averaging Measurements
This C programming example (average.c) can be found on the Documentation CD.
/************************************************************/
/* Average.c Agilent Technologies 1999 */
/* */
/* This C programming example does the following: */
/* Performs Power Averaging of Multiple ESA Measurements */
/* and Writes the Result back to a Trace for display */
/* */
/* The required SCPI instrument commands are given as */
/* reference. */
/* */
/* - Opens a GPIB device at address 18 */
/* - Clears and Resets the Analyzer to a known state */
/* SYST:PRES:TYPE FACT */
/* *RST */
/* - Identify the Instrument model */
/* *IDN? */
/* - Sets the analyzer center frequency and span */
/* SENS:FREQ:CENT freq */
/* SENS:FREQ:SPAN freq */
/* - Sets the analyzer resolution bandwidth */
/* SENS:BAND rbw */
/* - Selects sampled as the detector mode */
/* SENS:DET SAMP */
/* - Disable optional Input/Output functions */
/* :SYST:PORT:IFVS:ENAB OFF */
/* - Turn off auto-alignment */
/* CAL:AUTO OFF */
/* - Select the desired number of sweep points */
/* SWE:POINTS points */
/* - Select the appropriate display reference level and */
/* amplitude reference routing */
/* E4402B/03B/04B/05B/07B/08B or E7402A/03A/04A/05A */
/* DISP:WIND:TRAC:Y:RLEV -20 DBM */
/* CAL:SOUR:STAT ON */
/* E4401B, E4411B, or E7401A */
/* DISP:WIND:TRAC:Y:RLEV -25 DBM */
/* CAL:SOUR:STAT ON; */
/* - Select single sweep mode */
/* INIT:CONT OFF */
/* - Disable local display */
270 Chapter 17
ESA Programming Examples
Using C to Make Faster Power Averaging Measurements
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/* DISP:ENAB OFF */
/* - Select internal machine binary data format (milli-dBm) */
/* FORM:DAT INT,32 */
/* - Select appropriate byte order (Intel) */
/* FORM:BORD SWAP */
/* - Repeat the following the requested number of times: */
/* - Trigger a measurement and wait for completion */
/* INIT:*OPC? */
/* - Read the resulting measurement trace */
/* TRAC:DATA? TRACE1 */
/* - Compute running averaged power at all trace points */
/* - Display measurement statistics */
/* - Write averaged data to second trace display */
/* TRAC:DATA TRACE2 <definite length block of data> */
/* - Enable viewing of second trace */
/* TRACE2:MODE VIEW */
/* - Enable local display for viewing */
/* DISP:ENAB ON */
/* - Select continuous sweep mode */
/* INIT:CONT ON */
/* - Close session and Return instrument to local control */
/************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <sys\timeb.h>
#include <visa.h>

#define hpESA_IDN_E4401B "Hewlett-Packard, E4401B"
#define hpESA_IDN_E4411B "Hewlett-Packard, E4411B"
#define hpEMC_IDN_E7401A "Hewlett-Packard, E7401A"
#define NUM_TRACES 100 /* number of traces to average
*/
#define NUM_POINTS 401 /* requested number of points/trace
*/
#define CENTER 50 /* center frequency in MHz, an integer
*/
#define SPAN 20 /* span frequency in MHz, an integer */
#define RBW 300 /* resolution BW in kHz, an integer */

#define DISPLAY 0 /* ESA display enable, disable for speed
*/

Chapter 17 271
ESA Programming Examples
Using C to Make Faster Power Averaging Measurements
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
#define DATA_LENGTH 4 /* number of data bytes in one trace point
*/
#define MAX_POINTS 8192 /* maximum number of points/trace in ESA
*/

int iNumTraces = NUM_TRACES,/* number of traces to average
*/
iRbw = RBW, /* resolution bandwidth */
iNumPoints = NUM_POINTS,/* actual number of trace points per sweep
*/
iSpan = SPAN, /* Analyzer Frequency Span in MHz */
iCenter = CENTER; /* Analyzer Center frequency in MHz
*/
int iResult =0;
unsigned long lRetCount; /* the number of bytes transferred in one trace record
*/

double dDelta, dTimePer, dPower;

struct timeb start_time, stop_time, elapsed_time;

char cCommand[100];
char cBuffer[100];
char cEnter;
double dPwrAvgArray[MAX_POINTS];

ViUInt32 iHeaderLength, /* header is "#nyyy..." n is number of chars in yyy,
*/
/* yyy is the total data length in bytes */
iArrayLength, /* iArrayLength is number of bytes of data
*/
iTermLength = 1, /* the response message includes a LF character
*/
iBlockSize, /* number of bytes expected in one trace definite block
*/
iTotalRetCount; /* total number of bytes actually transferred
*/

ViSession defaultRM, viESA;

/* reserve space for the header, data and terminator */
ViChar cInBuffer[sizeof("#nyyyyl") + (MAX_POINTS * DATA_LENGTH) ];
ViChar cOutBuffer[sizeof("TRAC:DATA TRACE2,#nyyyyl") + (MAX_POINTS * DATA_LENGTH
) ];

/****************** Calculate length byte in block header
272 Chapter 17
ESA Programming Examples
Using C to Make Faster Power Averaging Measurements
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
***********************/
int HeaderLength(int iArrayLength) {
int iHeaderLength;

iHeaderLength = 3; /* iArrayLength >0 plus increment for "#" and "n"
*/
while ( (iArrayLength = (iArrayLength / 10)) > 0 ) {
iHeaderLength++;
}

return(iHeaderLength);
}

/******************* prepare ESA for measurement
************************/
void setup() {

viPrintf(viESA, ":SENS:FREQ:CENT %i MHz\n", iCenter);
viPrintf(viESA,":SENS:FREQ:SPAN %i MHZ\n", iSpan);
viPrintf(viESA, ":SENS:BAND %i KHZ\n", iRbw);

/* use the sampling detector for power-average calculations */
viPrintf(viESA, ":DET SAMP\n");

/* Turn off analog output of option board to maximize measurement rate */
viPrintf(viESA, ":SYST:PORT:IFVS:ENAB OFF\n");

/* Turn auto align off to maximize measurement rate */
viPrintf(viESA, ":CAL:AUTO OFF\n");

/* set requested number of points */
viPrintf(viESA, ":SWE:POINTS %i\n", NUM_POINTS);

printf("This program will measure and calculate\n");
printf ("the power average of %i %i-point
traces.\n",iNumTraces,iNumPoints);

/* Turn on 50 MHz amplitude reference signal */
viPrintf(viESA, ":CAL:SOUR:STAT ON\n");

/* Identify the instrument and get the model number */
viQueryf(viESA, "*IDN?\n", "%t", &cBuffer);

iResult = (strncmp( cBuffer, hpESA_IDN_E4401B, strlen(hpESA_IDN_E4401B)) &&
strncmp( cBuffer, hpESA_IDN_E4411B, strlen(hpESA_IDN_E4411B)) && strncmp( cBuffer,
hpEMC_IDN_E7401A, strlen(hpEMC_IDN_E7401A)));
if( iResult == 0 )
Chapter 17 273
ESA Programming Examples
Using C to Make Faster Power Averaging Measurements
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
{
/*Set the input port to the 50MHz amplitude reference for the models*/
/*E4401B, E4411B and E7401A*/
viPrintf(viESA,":DISP:WIND:TRAC:Y:RLEV -25 DBM\n");
viPrintf(viESA,"CAL:SOUR:STAT ON \n");
}
else
{
/* For the analyzers having frequency limits >= 3GHz, prompt the user*/
/* to connect the amplitude reference output to the input*/
printf ("Connect AMPTD REF OUT to the INPUT \n");
printf ("......Press Return to continue \n");
scanf( "%c",&cEnter);
/*Externally route the 50MHz Signal*/
viPrintf(viESA, ":DISP:WIND:TRAC:Y:RLEV -20 DBM\n");
viPrintf(viESA,"CAL:SOUR:STAT ON \n");
}

/* Single sweep mode */
viPrintf(viESA, ":INIT:CONT OFF\n");

/* Turn off the local display to maximize measurement rate */
if(!DISPLAY) {
viPrintf(viESA, ":DISP:ENAB OFF\n");
}

/* transfer data in definite length,32 bit integer blocks. Select */
/* machine units (milli-dBm) to maximize measurement rate */
viPrintf(viESA, ":FORM:DATA INT,32\n" );

/* select the byte order; low-byte first for Intel platforms */
/* To further increase measurement rate,:FORM:BORD NORM could */
/* be used instead. The byte ordering would then need to be */
/* done within this program. */
viPrintf(viESA, ":FORM:BORD SWAP\n");

/* pre-calculate amount of data to be transferred per measurement */
iTermLength = 1;
iArrayLength = iNumPoints * DATA_LENGTH;
iHeaderLength = HeaderLength(iArrayLength);
iBlockSize = iHeaderLength + iArrayLength + iTermLength;

}

274 Chapter 17
ESA Programming Examples
Using C to Make Faster Power Averaging Measurements
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/**************** Write binary trace data to ESA *******************/
void write_binary_trace(char *cScpiCommand, int *ipTraceData) {

/* trace data must point to an integer array of size NUM_POINTS */
memcpy(&cOutBuffer[strlen(cScpiCommand)], ipTraceData, iArrayLength);
memcpy(&cOutBuffer, cScpiCommand, strlen(cScpiCommand));

/* Add a <newline> to the end of the data, This isnt necessary */
/* if the GPIB card has been configured to assert EOI when the last */
/* character is sent, but it ensures a valid iTermLength is provided. */
cOutBuffer[iArrayLength + strlen(cScpiCommand)] = 0x0A;
iBlockSize = (strlen(cScpiCommand) + iArrayLength + 1);
viWrite(viESA,(ViBuf) cOutBuffer, iBlockSize, &lRetCount );
}

/******* Measure and calculate power-average of multiple measurements
*********/
void average() {
int i=0, iLoop=0;
int iArray[NUM_POINTS];

long lOpc =0L;
double dLogTen = log(10.0);

setup();

iTotalRetCount = lRetCount = 0;

/* start the timer */
ftime( &start_time );

/* Now run through the event loop iNumTraces times */
for(i=0; i<iNumTraces; i++) {

/* trigger a new measurement and wait for complete */
viPrintf(viESA, ":INIT:IMM;*WAI\n");

/* Read the trace data into a buffer */
viPrintf(viESA, ":TRAC:DATA? TRACE1\n");
viRead(viESA,(ViBuf) cInBuffer, (ViUInt32) iBlockSize, &lRetCount );
iTotalRetCount += lRetCount;

/* copy trace data to an array, */
/* byte order swapping could be done here rather than in ESA */
memcpy(iArray, &cInBuffer[iHeaderLength], iArrayLength);

Chapter 17 275
ESA Programming Examples
Using C to Make Faster Power Averaging Measurements
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/* calculate a running dPower-average */
for(iLoop = 0; iLoop < NUM_POINTS; iLoop++) {
/* running average of dPower, in milliwatts */
dPower = exp( dLogTen * (iArray[iLoop]/10000.0));
if(i > 0) {
dPwrAvgArray[iLoop] += ((dPower - dPwrAvgArray[iLoop])/(i+1));
}
else {
dPwrAvgArray[iLoop] = dPower;
}
}
} /* end of event loop */

/* stop the timer */
ftime( &stop_time );

/* Calculate elapsed time */
if (start_time.millitm > stop_time.millitm) {
stop_time.millitm += 1000;
stop_time.time--;
}
elapsed_time.millitm = stop_time.millitm - start_time.millitm;
elapsed_time.time = stop_time.time - start_time.time;

/* This is measurement time in milliseconds */
dDelta = (1000.0 * elapsed_time.time) + (elapsed_time.millitm);

/* show measurement statistics */
dTimePer=dDelta/((float)iNumTraces);
printf("\tPower average of %i %i-point traces performed in %3.1f
seconds\n",iNumTraces,iNumPoints,dDelta/1000);
printf("\t%6.1f milliseconds per averaged measurement\n",dTimePer);
printf("\t%6.1f averaged measurements per second\n",1000.0/dTimePer);
printf("\t%i bytes transferred per trace, %i bytes total\n\n",lRetCount,
iTotalRetCount);
return;
}

/******************************** Main ******************************/
void main(void) {
int iLoop;
int iAvgArray[NUM_POINTS];
ViStatus viStatus;

/* Open a GPIB session at address 18 */
viStatus = viOpenDefaultRM(&defaultRM);
276 Chapter 17
ESA Programming Examples
Using C to Make Faster Power Averaging Measurements
E
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
viStatus = viOpen(defaultRM,"GPIB0::18",VI_NULL,VI_NULL,&viESA);
if(viStatus)
{
printf("Could not open a session to GPIB device at address 18!\n");
exit(0);
}

/*Clear the Instrument */
viClear(viESA);

/* go to known instrument state with cleared status byte */
viPrintf(viESA, ":SYST:PRES:TYPE FACT;*RST\n");

/* measure, transfer and calculate power average of multiple traces */
average();

/* convert average power array back to integer array */
for (iLoop = 0; iLoop < iNumPoints; iLoop++) {
dPower = 10.0 * log10( dPwrAvgArray[iLoop]);
iAvgArray[iLoop] = (int) (1000.0 * dPower);
}

/* build TRAC:DATA TRACE2,#nyyy header and write the result to Trace 2 */
sprintf(cCommand,":TRAC:DATA TRACE2,#%i%i", HeaderLength(iArrayLength)-2,
iArrayLength);
write_binary_trace(cCommand, iAvgArray);

/* enable the trace, local display and return to continuous sweep */
viPrintf(viESA,":TRACE2:MODE VIEW;:DISP:ENAB ON;:INIT:CONT ON\n");

/* Close session */
viClose(viESA);
viClose(defaultRM);

} /***************************** End of Main *******************************/
277
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
18 PSA Programming Examples
278 Chapter 18
PSA Programming Examples
Examples Included in this Chapter:
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Examples Included in this Chapter:
Usi ng C wi th Marker Peak Search and Peak Excursi on
Measurement Routi nes on page 280
Usi ng C for Savi ng and Recal l i ng I nstrument State Data on page
283
Usi ng C to Save Bi nary Trace Data on page 287
Usi ng C to Make a Power Cal i brati on Measurement for a GSM
Mobi l e Handset on page 291
Usi ng C wi th the CALCul ate:DATA:COMPress? RMS Command
on page 297
Usi ng C Over Socket LAN (UNI X) on page 303
Usi ng C Over Socket LAN (Wi ndows NT) on page 323
Usi ng Java Programmi ng Over Socket LAN on page 326
Usi ng the VXI Pl ug-N-Pl ay Dri ver i n LabVI EW on page 335
Usi ng LabVI EW6 to Make an EDGE GSM Measurement on
page 336
Usi ng Vi sual Basi c.NET wi th the I VI -Com Dri ver on page 338
Usi ng Agi l ent VEE to Capture the Equi val ent SCPI Learn Stri ng
on page 342
LabVI EW i s a regi stered trademark of Nati onal I nstruments
Corporati on.
Vi sual Basi c i s a regi stered tr ademar k of Mi crosoft Corporati on.
Chapter 18 279
PSA Programming Examples
Programming Examples Information and Requirements
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Programming Examples Information and
Requirements
The programmi ng exampl es were wri tten for use on an I BM
compati bl e PC.
The programmi ng exampl es use C, Vi sual Basi c and LabVI EW
pr ogrammi ng l anguages.
There are exampl es usi ng GPI B and LAN i nterfaces.
Many of the exampl es use the SCPI programmi ng commands,
though there are some that use the pl ug&pl ay or I VI .com dr i vers.
Most of the exampl es are wri tten i n C usi ng the Agi l ent VI SA
tr ansi ti on l i brary.
The VI SA tr ansi ti on l i brary must be i nstal l ed and the GPI B card
confi gured. The Agi l ent I /O l i brari es contai n the l atest VI SA
tr ansi ti on l i brary and i s avai l abl e at: www.agilent.com/iolib
280 Chapter 18
PSA Programming Examples
Using C with Marker Peak Search and Peak Excursion Measurement
Routines
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Using C with Marker Peak Search and Peak
Excursion Measurement Routines
Thi s C programmi ng exampl e (peaksrch.c) can be found on the
Documentati on CD.
/************************************************************/
/* peaksrch.c */
/* Agilent Technologies 2001 */
/* */
/* Using Marker Peak Search and Peak Excursion */
/* */
/* This example is for the E444xA PSA Spectrum Analyzers */
/* */
/* This C programming example does the following. */
/* */
/* - Open a GPIB session at address 18 */
/* - Select Spectrum Analysis Mode */
/* - Reset & Clear the Analyzer */
/* - Set the analyzer center frequency and span */
/* - Set the input port to the 50 MHz amplitude reference */
/* - Set the analyzer to single sweep mode */
/* - Prompt the user for peak excursion level in dBm */
/* - Set the peak threshold to user defined level */
/* - Trigger a sweep and wait for sweep to complete */
/* - Set the marker to the maximum peak */
/* - Query and read the marker frequency and amplitude */
/* - Close the session */
/************************************************************/

#include <windows.h>
#include <stdio.h>
#include "visa.h"
ViSession defaultRM, viPSA;
ViStatus errStatus;
Chapter 18 281
PSA Programming Examples
Using C with Marker Peak Search and Peak Excursion Measurement
Routines
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
void main()
{
/*Program Variables*/
ViStatus viStatus = 0;
char cEnter = 0;
int iResult = 0;
double dMarkerFreq = 0;
double dMarkerAmpl = 0;
float fPeakExcursion =0;
long lOpc = 0L;
char *psaSetup = // PSA setup initialization
":INST SA;" // Change to Spectrum Analysis mode
"*RST;*CLS;" // Reset the device and clear status
":SENS:FREQ:CENT 50 MHz;"// Set center freq to 50 MHz
":SENS:FREQ:SPAN 50 MHz;"// Set freq span to 50 MHz
":SENS:FEED AREF;"// Set input port to internal 50 MHz ref
":INIT:CONT 0;"// Set analyzer to single sweep mode
":CALC:MARK:PEAK:THR -90";// Set the peak thresold to -90 dBm
/*Open a GPIB session at address 18.*/
viStatus=viOpenDefaultRM(&defaultRM);
viStatus=viOpen(defaultRM,"GPIB0::18",VI_NULL,VI_NULL,&viPSA);
if(viStatus)
{
printf("Could not open a session to GPIB device at address 18!\n");
exit(0);
}
/*Display the program heading */
printf("\n\t\t Marker Program \n\n" );
/* Send setup commands to instrument */
viPrintf(viPSA,"%s\n",psaSetup);
282 Chapter 18
PSA Programming Examples
Using C with Marker Peak Search and Peak Excursion Measurement
Routines
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/*User enters the peak excursion value */
printf("\t Enter PEAK EXCURSION level in dBm: ");
scanf( "%f",&fPeakExcursion);

/*Set the peak excursion*/
viPrintf(viPSA,"CALC:MARK:PEAK:EXC %1fDB \n",fPeakExcursion);
/*Trigger a sweep and wait for completion*/
viPrintf(viPSA,"INIT:IMM;*WAI\n");
/*Set the marker to the maximum peak*/
viPrintf(viPSA,"CALC:MARK:MAX \n");
/*Query and read the marker frequency*/
viQueryf(viPSA,"CALC:MARK:X? \n","%lf",&dMarkerFreq);
printf("\n\t RESULT: Marker Frequency is: %lf MHz \n\n",dMarkerFreq/10e5);
/*Query and read the marker amplitude*/
viQueryf(viPSA,"CALC:MARK:Y?\n","%lf",&dMarkerAmpl);
printf("\t RESULT: Marker Amplitude is: %lf dBm \n\n",dMarkerAmpl);
/*Close the session*/
viClose(viPSA);
viClose(defaultRM);
}
Chapter 18 283
PSA Programming Examples
Using C for Saving and Recalling Instrument State Data
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Using C for Saving and Recalling Instrument
State Data
Thi s C programmi ng exampl e (State.c) can be found on the
Documentati on CD.
/***************************************************************************
* State.c
* Agilent Technologies 2001
*
* PSA Series Transmitter Tester using VISA for I/O
* This program shows how to save and recall a state of the instrument
*
*******************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include "visa.h"
void main ()
{
/*program variables*/
ViSession defaultRM, viVSA;
ViStatus viStatus= 0;

/*open session to GPIB device at address 18 */
viStatus=viOpenDefaultRM (&defaultRM);
viStatus=viOpen (defaultRM, "GPIB0::18::INSTR", VI_NULL,VI_NULL, &viVSA);
/*check opening session sucess*/
if(viStatus)
{
printf("Could not open a session to GPIB device at address 18!\n");
exit(0);
}
284 Chapter 18
PSA Programming Examples
Using C for Saving and Recalling Instrument State Data
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/*set the instrument to SA mode*/
viPrintf(viVSA, "INST SA\n");
/*reset the instrument */
viPrintf(viVSA, "*RST\n");
/*set the input port to the internal 50Mhz reference source*/
viPrintf(viVSA, "SENS:FEED AREF\n");
/*tune the analyzer to 50MHZ*/
viPrintf(viVSA, "SENS:FREQ:CENT 50E6\n");
/*change the span*/
viPrintf(viVSA, "SENS:FREQ:SPAN 10 MHZ\n");
/*turn the display line on*/
viPrintf(viVSA, "DISP:WIND:TRACE:Y:DLINE:STATE ON\n");
/*change the resolution bandwidth*/
viPrintf(viVSA, "SENS:SPEC:BAND:RES 100E3\n");
/*change the Y Axis Scale/Div*/
viPrintf(viVSA, "DISP:WIND:TRAC:Y:SCAL:PDIV 5\n");
/*Change the display refernece level*/
viPrintf(viVSA, "DISP:WIND:TRAC:Y:SCAL:RLEV -15\n");
/*trigger the instrument*/
viPrintf(viVSA, "INIT:IMM;*WAI\n");
/*save this state in register 10.
!!!Carefull this will overwrite register 10*/
viPrintf(viVSA, "*SAV 10\n");
/*display message*/
Chapter 18 285
PSA Programming Examples
Using C for Saving and Recalling Instrument State Data
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
printf("PSA Programming example showing *SAV,*RCL SCPI commands\n");
printf("used to save instrument state\n\t\t------------------------");
printf("\n\nThe instrument state has been saved to an internal register\n");
printf("Please observe the display and notice the signal shape\n");
printf("Then press any key to reset the
instrument\n\t\t------------------------");
/*wait for any key to be pressed*/
getch();
/*reset the instrument */
viPrintf(viVSA, "*RST\n");
/*set again the input port to the internal 50Mhz reference source*/
viPrintf(viVSA, "SENS:FEED AREF\n");
/*display message*/
printf("\n\nThe instrument was reset to the factory default setting\n");
printf("Notice the abscence of the signal on the display\n");
printf("Press any key to recall the saved
state\n\t\t------------------------");
/*wait for any key to be pressed*/
getch();
/*recall the state saved in register 10*/
viPrintf(viVSA, "*RCL 10\n");
/*display message*/
printf("\n\nNotice the previous saved instrument settings were restored\n");
printf("Press any key to terminate the
program\n\t\t------------------------\n\n");
/*wait for any key to be pressed*/
getch();
/*reset the instrument */
286 Chapter 18
PSA Programming Examples
Using C for Saving and Recalling Instrument State Data
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
viPrintf(viVSA, "*RST;*wai\n");
/*Set the instrument to continuous sweep */
viPrintf(viVSA, "INIT:CONT 1\n");
/* close session */
viClose (viVSA);
viClose (defaultRM);
}
Chapter 18 287
PSA Programming Examples
Using C to Save Binary Trace Data
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Using C to Save Binary Trace Data
Thi s C progr ammi ng exampl e (Tr ace.c) can be found on the
Documentati on CD.
Thi s exampl e uses Opti on B7J.
/***************************************************************************
* Trace.c
* Agilent Technologies 2001
*
* Instrument Requirements:
* E444xA with option B7J and firmware version >= A.02.00 or
* E4406A with firmware version >= A.05.00
*
* This Program shows how to get and save binary trace data in Basic mode
* The results are saved to C:\trace.txt
*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include "visa.h"
void main ()
{
/*program variable*/
ViSession defaultRM, viPSA;
ViStatus viStatus= 0;
char sBuffer[80]= {0};
char dummyvar;
FILE *fTraceFile;
long lNumberPoints= 0;
long lNumberBytes= 0;
long lLength= 0;
long i = 0;
long lOpc = 0L;
unsigned long lBytesRetrieved;
288 Chapter 18
PSA Programming Examples
Using C to Save Binary Trace Data
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
ViReal64 adTraceArray[10240];
char *psaSetup =/* setup commands for VSA/PSA */
":INST BASIC;"/* Set the instrument mode to Basic */
"*RST;*CLS;"/* Reset the device and clear status */
":INIT:CONT 0;"/* Set analyzer to single measurement mode */
":FEED AREF;"/* set the input port to the internal
50MHz reference source */
":DISP:FORM:ZOOM1;"/* zoom the spectrum display */
":FREQ:CENT 50E6;"/* tune the analyzer to 50MHz */
":FORM REAL,64;"/* Set the ouput format to a binary format */
":FORM:BORD SWAP;"/* set the binary byte order to SWAP (for PC) */
":INIT:IMM;";/* trigger a spectrum measurement */
/*open session to GPIB device at address 18 */
viStatus=viOpenDefaultRM (&defaultRM);
viStatus=viOpen (defaultRM, "GPIB0::18::INSTR", VI_NULL,VI_NULL, &viPSA);
/*check opening session sucess*/
if(viStatus)
{
printf("Could not open a session to GPIB device at address 18!\n");
exit(0);
}
/* Set I/O timeout to ten seconds */
viSetAttribute(viPSA,VI_ATTR_TMO_VALUE,10000);
/* Send setup commands to instrument */
viPrintf(viPSA,"%s\n",vsaSetup);
/* Query the instrument for Operation complete */
viQueryf(viPSA,"*OPC?\n", "%d", &lOpc);
/* fetch the spectrum trace data*/
viPrintf(viPSA,"FETC:SPEC7?\n");
Chapter 18 289
PSA Programming Examples
Using C to Save Binary Trace Data
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/*print message to the standard output*/
printf("Getting the spectrum trace in binary format...\nPlease wait...\n\n");
/* get number of bytes in length of postceeding trace data
and put this in sBuffer*/
viRead (viPSA,(ViBuf)sBuffer,2,&lBytesRetrieved);
/* Put the trace data into sBuffer */
viRead (viPSA,(ViBuf)sBuffer,sBuffer[1] - 0,&lBytesRetrieved);
/* append a null to sBuffer */
sBuffer[lBytesRetrieved] = 0;
/* convert sBuffer from ASCII to integer */
lNumberBytes = atoi(sBuffer);
/* calculate the number of points given the number of byte in the trace
REAL 64 binary format means each number is represented by 8 bytes*/
lNumberPoints = lNumberBytes/sizeof(ViReal64);
/*get and save trace in data array */
viRead (viPSA,(ViBuf)adTraceArray,lNumberBytes,&lBytesRetrieved);
/* read the terminator character and discard */
viRead (viPSA,(ViBuf)sBuffer,1, &lLength);
/*print message to the standard output*/
printf("Querying instrument to see if any errors in Queue.\n");
/* loop until all errors read */
do
{
viPrintf (viPSA,"SYST:ERR?\n");/* check for errors */
viRead (viPSA,(ViBuf)sBuffer,80,&lLength);/* read back last error message
*/
290 Chapter 18
PSA Programming Examples
Using C to Save Binary Trace Data
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
sBuffer[lLength] = 0; /* append a null to byte count */
printf("%s\n",sBuffer); /* print error buffer to display */
} while (sBuffer[1] != 0);
/* set the analyzer to continuous mode for manual use */
viPrintf(viPSA, "INIT:CONT 1\n");
/*save trace data to an ASCII file*/
fTraceFile=fopen("C:\\Trace.txt","w");
fprintf(fTraceFile,"Trace.exe Output\nAgilent Technologies 2001\n\n");
fprintf(fTraceFile,"List of %d points of the averaged spectrum
trace:\n\n",lNumberPoints);
for (i=0;i<lNumberPoints;i++)
fprintf(fTraceFile,"\tAmplitude of point[%d] = %.2lf
dBm\n",i+1,adTraceArray[i]);
fclose(fTraceFile);
/*print message to the standard output*/
printf("The %d trace points were saved to C:\\Trace.txt
file\n\n",lNumberPoints);

/* Send message to standard output */
printf("\nPress Enter to set analyzers input port back to RF.\n");
scanf("%c",&dummyvar);
/* set the input port to RF */
viPrintf(viPSA, "feed rf\n");
/* Close session */
viClose (viPSA);
viClose (defaultRM);
}
Chapter 18 291
PSA Programming Examples
Using C to Make a Power Calibration Measurement for a GSM Mobile
Handset
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Using C to Make a Power Calibration
Measurement for a GSM Mobile Handset
Thi s C programmi ng exampl e (powercal .c) can be found on the
Documentati on CD.
Thi s pr ogram uses Basi c mode whi ch i s opti onal -B7J- i n the PSA
Seri es spectrum anal yzers and i s standard i n the E4406A Vector Si gnal
Anal yzer. I t uses the Waveform measurement wi th the
CALC:DATA2:COMP? DME command to return the power of 75
consecuti ve GSM/EDGE bursts. The DME (dB Mean) parameter
returns the average of the dB trace val ues. The DME parameter i s onl y
avai l abl e i n l ater versi on of i nstrument fi rmware A.05.00 for PSA and
A.07.00 for VSA. Earl i er i nstruments see the Usi ng C wi th the
CALCul ate:DATA:COMPress? RMS Command exampl e.
Thi s pr ogram al so demonstrates how to seri al pol l the "Wai ti ng for
Tri gger" status bi t to determi ne when to i ni ti ate the GSM phone. The
data r esul ts ar e pl aced i n an ASCI I fi l e (power cal .txt).
The pr ogram can al so be adapted to perform W-CDMA Downl i nk Power
Control measurements i n the code domai n power Symbol Power vi ew.
I n essence, you can average any stepped power measurement trace
usi ng thi s method.
/********************************************************************************
* powercal.c
* Agilent Technologies 2003
*
* This program demonstrates the process of using the Waveform
* measurement and the CALC:DATA2:COMP? DME command to return the power
* of 75 consecutive GSM/EDGE bursts.
* The DME (db Mean) parameter returns the average of the dB trace values.
*
* This program also demonstrates how to serial poll the "Waiting
* for Trigger" Status bit to determine when to initiate the GSM phone
* The data results are placed in an ASCII file, powercal.txt
*
* This program can also be adapted to perform W-CDMA Downlink PowerControl
* measurements in the Code Domain Power Symbol Power View. In essence,
* you can average any stepped power measurement trace using this method.
*
292 Chapter 18
PSA Programming Examples
Using C to Make a Power Calibration Measurement for a GSM Mobile
Handset
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
* Instrument Requirements:
* E444xA with option B7J and firmware version >= A.05.00 or
* E4406A with firmware version >= A.07.00 or
*
* Signal Source Setup:
* Set up GSM/EDGE frame for either 1, 2, 4, or eight slots per frame.
* When configuring two slots per frame, turn on slots 1 and 5
* When configuring four slots per frame, turn on slots 1,3,5, and 7.
* Set frame repeat to Single.
* Set the signal amplitude to -5 dBm.
* Set the signal source frequency to 935.2 MHz
*
* CALC:DATA2:COMP? DME parameters:
* soffset = 25us (This avoids averaging data points when the burst
* is transitioning on.)
* length = 526us (Period over which the power of the burst is averaged)
* roffset = 4.6153846 ms / slots per frame (Repitition interval of burst)
**********************************************************************************
****/
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <math.h>
#include "c:\program files\visa\winnt\include\visa.h"
void main ()
{
/*program variable*/
ViSession defaultRM, viVSA;
ViStatus viStatus= 0;
ViUInt16 stb;
FILE *fDataFile;
long lthrowaway,lbursts;
long lNumberPoints= 0;
long lNumberBytes= 0;
long lLength = 0;
Chapter 18 293
PSA Programming Examples
Using C to Make a Power Calibration Measurement for a GSM Mobile
Handset
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
long i = 0;
long lOpc = 0L;
double sweeptime = 0;
double burstinterval= 0;
unsigned long lBytesRetrieved;
ViReal64 adDataArray[100];
char sBuffer[80]= {0};
char *basicSetup = // measurement setup commands for VSA/PSA
":INST:SEL BASIC;"// Put the instrument in Basic Mode
"*RST;"// Preset the instrument
"*CLS; "//Clear the status byte
":STAT:OPER:ENAB 32;" //Enable Status Operation
":DISP:ENAB 0;"// Turn the Display off (improves Speed)
":FORM REAL,64;"// Set the ouput format to binary
":FORM:BORD SWAP;"// set the binary byte order to SWAP (for PC)
":CONF:WAV;"// Changes measurement to Waveform
":INIT:CONT 0;"// Puts instrument in single measurement mode
":CAL:AUTO OFF;"//Turn auto align off
":FREQ:CENTER 935.2MHz;"//Set Center Freq to 935.2MHz
":WAV:ACQ:PACK MED;"//Set DataPacking to Medium
":WAV:BAND:TYPE FLAT;"//Select Flattop RBW Filter
":WAV:DEC:FACT 4;"//Set Decimation Factor to 4
":WAV:DEC:STAT ON;"//Turn Decimation On
":DISP:WAV:WIND1:TRAC:Y:RLEV 5;" //Set referance level to 5 dBm
":WAV:BWID:RES 300kHz;"//Set Res bandwith filter to 300kHz
":POW:RF:ATT 5;"//Set 5dB of internal attenuation
":WAV:ADC:RANG P0;"//Set ADC Range to P0, This is
//necessary to prevent autoranging
":WAV:TRIG:SOUR IF;"//Set Trigger source to IF burst
":TRIG:SEQ:IF:LEV -20;";//Set IF Trig level to -20dB
/*open session to GPIB device at address 18 */
viStatus=viOpenDefaultRM (&defaultRM);
viStatus=viOpen (defaultRM, "GPIB0::18", VI_NULL,VI_NULL,&viVSA);
294 Chapter 18
PSA Programming Examples
Using C to Make a Power Calibration Measurement for a GSM Mobile
Handset
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/*check opening session sucess*/
if(viStatus)
{
printf("Could not open a session to GPIB device at address 18!\n");
exit(0);
}
/* Set I/O timeout to ten seconds */
viSetAttribute(viVSA,VI_ATTR_TMO_VALUE,10000);
viClear(viVSA);//send device clear to instrument
/*print message to the standard output*/
printf("Enter number of bursts per frame (1,2,4 or 8): ");
scanf( "%ld",&lbursts);
/* Send setup commands to instrument */
viPrintf(viVSA,"%s\n",basicSetup);
/* Calculate sweep time and set it*/
burstinterval = 4.6153846 / 1000.00 / lbursts;
sweeptime= burstinterval * 75.0;
viPrintf(viVSA,":WAV:SWE:TIME %fs\n",sweeptime);
/* Clear status event register */
viQueryf(viVSA,"STAT:OPER:EVENT?\n","%ld",&lthrowaway);
/* Initiate the waveform measurement and get the instrument ready
to calculate the mean RMS I/Q voltage in each burst
(We will convert these discreate values into Mean dBm Power values) */
viPrintf(viVSA,"INIT:IMM\n");
/* Serial poll the instrument to determine when it is waiting for
trigger and the GSM phone can be told to send its 75 bursts. */
Chapter 18 295
PSA Programming Examples
Using C to Make a Power Calibration Measurement for a GSM Mobile
Handset
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
while(1)
{
viReadSTB(viVSA,&stb); //read status byte
if (stb & 128) break; //look for "waiting for trigger" bit
printf("Waiting on Analyzer...\n");
Sleep (50); // wait 50 ms between each serial poll
}
/*print message to the standard output*/
printf("Analyzer is Ready!\n\nWaiting for phone to trigger...\n\n");
/*Querry for Operation Complete */
viQueryf(viVSA,"*OPC?\n", "%d", &lOpc);
/*Use the CALC:DATA0:COMP command to return the average power in each burst*/
viPrintf(viVSA,":CALC:DATA2:COMP? DME,25E-6,526E-6,%f\n",burstinterval);
/* get number of bytes in length of postceeding data and put this in sBuffer*/
viRead (viVSA,(ViBuf)sBuffer,2,&lBytesRetrieved);
printf("Getting the burst data in binary format...\n\n");
/* Put the returned data into sBuffer */
viRead (viVSA,(ViBuf)sBuffer,sBuffer[1] - 0,&lBytesRetrieved);
/* append a null to sBuffer */
sBuffer[lBytesRetrieved] = 0;
/* convert sBuffer from ASCII to integer */
lNumberBytes = atoi(sBuffer);
/*calculate the number of returned values given the number of bytes.
REAL 64 binary data means each number is represented by 8 bytes */
lNumberPoints = lNumberBytes/sizeof(ViReal64);
/*get and save returned data into an array */
viRead (viVSA,(ViBuf)adDataArray,lNumberBytes,&lBytesRetrieved);
296 Chapter 18
PSA Programming Examples
Using C to Make a Power Calibration Measurement for a GSM Mobile
Handset
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/* read the terminator character and discard */
viRead (viVSA,(ViBuf)sBuffer,1, &lthrowaway);
/*print message to the standard output*/
printf("Querying instrument to see if any errors in Queue.\n");
/* loop until all errors read */
do
{
viPrintf (viVSA,"SYST:ERR?\n"); /* check for errors */
viRead (viVSA,(ViBuf)sBuffer,80,&lLength);/* read back last error message */
sBuffer[lLength] = 0; /* append a null to byte count */
printf("%s\n",sBuffer); /* print error buffer to display */
} while (sBuffer[1] != 0);
/* Turn the Display of the instrument back on */
viPrintf(viVSA,"DISP:ENAB 1\n");
/*save result data to an ASCII file*/
fDataFile=fopen("powercal.txt","w");
fprintf(fDataFile,"powercal.exe Output\nAgilent Technologies 2003\n\n");
fprintf(fDataFile,"Power of %d GSM/EDGE bursts:\n",lNumberPoints);
fprintf(fDataFile,"(%d burst(s) per frame):\n\n",lbursts);
for (i=0;i<lNumberPoints;i++)
{
fprintf(fDataFile,"\tPower of burst[%d] = %.2lf dBm\n",i+1,adDataArray[i]);
}
fclose(fDataFile);
/*print message to the standard output*/
printf("The %d burst powers were saved to powercal.txt
file.\n\n",lNumberPoints);
viClose (viVSA);
viClose (defaultRM);
}
Chapter 18 297
PSA Programming Examples
Using C with the CALCulate:DATA:COMPress? RMS Command
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Using C with the CALCulate:DATA:COMPress?
RMS Command
Thi s C programmi ng exampl e (cal comp.c) can be found on the
Documentati on CD.
Thi s pr ogram uses the CALCulate:DATA:COMPress? RMS command to
average the vol tage trace data to cal cul ate power of consecuti ve GSM
bursts. Ol der i nstrument fi rmwar e does not support the newer DME
parameter descri bed i n the previ ous exampl e. You wi l l have to use the
techni que i n thi s exampl e to cal cul ate the dB mean. Thi s exampl e uses
the Waveform measurement i n the Basi c mode. Basi c mode i s opti onal
-B7J- i n the PSA Seri es spectrum anal yzers and i s standard i n the
E4406A Vector Si gnal Anal yzer.
The CALC:DATA2:COMP? RMS command i s used to return the power of 1
to 150 consecuti ve GSM/EDGE bursts. The RMS parameter returns the
average of the vol tage trace val ues. These measured val ues are then
conver ted to dBm val ues.
Thi s pr ogram al so demonstrates how to seri al pol l Seri al pol l the
i nstrument to determi ne when the Message Avai l abl e status bi t i s set.
/**************************************************************************
calcomp.c
* Agilent Technologies 2001
*
* This program demonstrates the process of using the Waveform
* measurement and the CALC:DATA0:COMP? RMS command to return the power
* of 1 to 450 consecutive GSM/EDGE bursts (one burst per frame).
* The data results are placed in an ASCII file, C:\calccomp.txt
*
* Instrument Requirements:
* E444xA with option B7J and firmware version >= A.02.00 or
* E4406A with firmware version >= A.05.00 or
*
* Signal Source Setup:
* Turn on 1 slot per GSM/EDGE frame.
* Set frame repeat to Continous.
* Set the signal amplitude to -5 dBm.
* Set the signal source frequency to 935.2 MHz
*
298 Chapter 18
PSA Programming Examples
Using C with the CALCulate:DATA:COMPress? RMS Command
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
* CALC:DATA0:COMP? RMS parameters:
* soffset = 25us (This avoids averaging data points when the burst
* is transitioning on.)
* length = 526us (Period over which the power of the burst is averaged)
* roffset = 4.165 ms (Repition interval of burst. For this example
* it is equal to one GSM frame: 4.165 ms.)
*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <math.h>
#include "visa.h"
void main ()
{
/*program variable*/
ViSession defaultRM, viPSA;
ViStatus viStatus= 0;
ViUInt16 stb;
FILE *fDataFile;
long lthrowaway,lbursts;
long lNumberPoints= 0;
long lNumberBytes= 0;
long lLength = 0;
long i = 0;
long lOpc = 0L;
double sweeptime = 0;
unsigned long lBytesRetrieved;
ViReal64 adDataArray[500];
ViReal64 adPowerArray[500];
char sBuffer[80]= {0};
char *basicSetup = // measurement setup commands for VSA/PSA
":INST:SEL BASIC;"// Put the instrument in Basic Mode
"*RST;"// Preset the instrument
"*CLS;" //Clear the status byte
Chapter 18 299
PSA Programming Examples
Using C with the CALCulate:DATA:COMPress? RMS Command
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
":DISP:ENAB 0;"// Turn the Display off (improves Speed)
":FORM REAL,64;"// Set the ouput format to binary
":FORM:BORD SWAP;"// set the binary byte order to SWAP (for PC)
":CONF:WAV;"// Changes measurement to Waveform
":INIT:CONT 0;"// Puts instrument in single measurement mode
":CAL:AUTO OFF;"//Turn auto align off
":FREQ:CENTER 935.2MHz;"//Set Center Freq to 935.2MHz
":WAV:ACQ:PACK MED;"//Set DataPacking to Medium
":WAV:BAND:TYPE FLAT;"//Select Flattop RBW Filter
":WAV:DEC:FACT 4;"//Set Decimation Factor to 4
":WAV:DEC:STAT ON;"//Turn Decimation On
":DISP:WAV:WIND1:TRAC:Y:RLEV 5;" //Set referance level to 5 dBm
":WAV:BWID:RES 300kHz;"//Set Res bandwith filter to 300kHz
":POW:RF:ATT 5;"//Set 5dB of internal attenuation
":WAV:TRIG:SOUR IF;"//Set Trigger source to IF burst
":TRIG:SEQ:IF:LEV -20;";//Set IF Trig level to -20dB
/*open session to GPIB device at address 18 */
viStatus=viOpenDefaultRM (&defaultRM);
viStatus=viOpen (defaultRM, "GPIB0::18", VI_NULL,VI_NULL,&viPSA);
/*check opening session sucess*/
if(viStatus)
{
printf("Could not open a session to GPIB device at address 18!\n");
exit(0);
}
/* Set I/O timeout to ten seconds */
viSetAttribute(viPSA,VI_ATTR_TMO_VALUE,10000);
viClear(viPSA);//send device clear to instrument
/*print message to the standard output*/
printf("Enter number of bursts (1 to 450) to calculate mean power for: ");
scanf( "%ld",&lbursts);
300 Chapter 18
PSA Programming Examples
Using C with the CALCulate:DATA:COMPress? RMS Command
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/* Send setup commands to instrument */
viPrintf(viPSA,"%s\n",basicSetup);
/* Calculate sweep time and set it*/
sweeptime=4.6153846*lbursts;
viPrintf(viPSA,":WAV:SWE:TIME %fms\n",sweeptime);
/* Clear status event register */
viQueryf(viPSA,"STAT:OPER:EVENT?\n","%ld",&lthrowaway);
/* Initiate the waveform measurement */
viPrintf(viPSA,"INIT:IMM\n");
/* Query the instrument for Operation complete */
viQueryf(viPSA,"*OPC?\n", "%d", &lOpc);
/* Have the instrument calculate the mean RMS I/Q voltage in each burst
(We will convert these discreate values into Mean dBm Power values) */
viPrintf (viPSA, ":CALC:DATA0:COMP? rms,25E-6,526E-6,4.61538461538E-3\n");
/* Serial poll the instrument to determine when Message Available
Status Bit is set. The instruments output buffer will then
contain the measurement results*/
i=0;
while(1)
{
i++;
viReadSTB(viPSA,&stb); //read status byte
if (stb & 16) break; //look for message available bit
Sleep (20); // wait 100ms before polling again
}
/*print message to the standard output*/
printf("\nMessage Available statuts bit set after %ld serial poles.\n\n",i);
printf("Getting the burst data in binary format...\nPlease wait...\n\n");
Chapter 18 301
PSA Programming Examples
Using C with the CALCulate:DATA:COMPress? RMS Command
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/* get number of bytes in length of postceeding data
and put this in sBuffer*/
viRead (viPSA,(ViBuf)sBuffer,2,&lBytesRetrieved);
/* Put the returned data into sBuffer */
viRead (viPSA,(ViBuf)sBuffer,sBuffer[1] - 0,&lBytesRetrieved);
/* append a null to sBuffer */
sBuffer[lBytesRetrieved] = 0;
/* convert sBuffer from ASCII to integer */
lNumberBytes = atoi(sBuffer);
/*calculate the number of returned values given the number of bytes.
REAL 64 binary data means each number is represented by 8 bytes */
lNumberPoints = lNumberBytes/sizeof(ViReal64);
/*get and save returned data into an array */
viRead (viPSA,(ViBuf)adDataArray,lNumberBytes,&lBytesRetrieved);
/* read the terminator character and discard */
viRead (viPSA,(ViBuf)sBuffer,1, &lthrowaway);
/*print message to the standard output*/
printf("Querying instrument to see if any errors in Queue.\n");
/* loop until all errors read */
do
{
viPrintf (viPSA,"SYST:ERR?\n"); /* check for errors */
viRead (viPSA,(ViBuf)sBuffer,80,&lLength);/* read back last error message */
sBuffer[lLength] = 0; /* append a null to byte count */
printf("%s\n",sBuffer); /* print error buffer to display */
} while (sBuffer[1] != 0);
302 Chapter 18
PSA Programming Examples
Using C with the CALCulate:DATA:COMPress? RMS Command
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/* Turn the Display of the instrument back on */
viPrintf(viPSA,"DISP:ENAB 1\n");
/*save result data to an ASCII file*/
fDataFile=fopen("C:\\calccomp.txt","w");
fprintf(fDataFile,"Calccomp.exe Output\nAgilent Technologies 2001\n\n");
fprintf(fDataFile,"Power of %d GSM/EDGE bursts:\n\n",lNumberPoints);
for (i=0;i<lNumberPoints;i++)
{
/* Convert RMS voltage for each burst to Mean Power in dBm */
adPowerArray[i]=10*log10(10*adDataArray[i]*adDataArray[i]);
fprintf(fDataFile,"\tPower of burst[%d] = %.2lf
dBm\n",i+1,adPowerArray[i]);
}
fclose(fDataFile);
/*print message to the standard output*/
printf("The %d burst powers were saved to C:\\calccomp.txt
file.\n\n",lNumberPoints);
viClose (viPSA);
viClose (defaultRM);
}
Chapter 18 303
PSA Programming Examples
Using C Over Socket LAN (UNIX)
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Using C Over Socket LAN (UNIX)
Thi s C progr ammi ng exampl e (socketi o.c) compi l es i n the HP-UX UNI X
envi ronment. I t i s por tabl e to other UNI X envi r onments wi th onl y
mi nor changes.
I n UNI X, LAN communi cati on vi a sockets i s very si mi l ar to readi ng or
wri ti ng a fi l e. The onl y di fference i s the openSocket() routi ne, whi ch
uses a few networ k l i brary routi nes to create the TCP/I P network
connecti on. Once thi s connecti on i s created, the standard fr ead() and
fwri te() routi nes are used for networ k communi cati on.
I n Wi ndows, the routi nes send() and recv() must be used, si nce
fr ead() and fwri te() may not wor k on sockets.
The program reads the anal yzers host name fr om the command l i ne,
fol l owed by the SCPI command. I t then opens a socket to the anal yzer,
usi ng port 5025, and sends the command. I f the command appear s to be
a query, the program quer i es the anal yzer for a response, and pri nts the
response.
Thi s exampl e program can al so be used as a uti l i ty to tal k to your
anal yzer from the command prompt on your UNI X workstati on or
Wi ndows 95 PC, or fr om wi thi n a scri pt.
Thi s pr ogram i s al so avai l abl e on your documentati on CD ROM.
/***************************************************************************
* $Header: socketio.c,v 1.5 96/10/04 20:29:32 roger Exp $
* $Revision: 1.5 $
* $Date: 96/10/04 20:29:32 $
*
* $Contributor: LSID, MID $
*
* $Description: Functions to talk to an Agilent E4440A spectrum
* analyzer via TCP/IP. Uses command-line arguments.
*
* A TCP/IP connection to port 5025 is established and
* the resultant file descriptor is used to "talk" to the
* instrument using regular socket I/O mechanisms. $
*
*
*
* E4440A Examples:
304 Chapter 18
PSA Programming Examples
Using C Over Socket LAN (UNIX)
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
*
* Query the center frequency:
* lanio 15.4.43.5 sens:freq:cent?
*
* Query X and Y values of marker 1 and marker 2 (assumes they are on):
* lanio myinst calc:spec:mark1:x?;y?; :calc:spec:mark2:x?;y?
*
* Check for errors (gets one error):
* lanio myinst syst:err?
*
* Send a list of commands from a file, and number them:
* cat scpi_cmds | lanio -n myinst
*
****************************************************************************
*
* This program compiles and runs under
* - HP-UX 10.20 (UNIX), using HP cc or gcc:
* + cc -Aa -O -o lanio lanio.c
* + gcc -Wall -O -o lanio lanio.c
*
* - Windows 95, using Microsoft Visual C++ 4.0 Standard Edition
* - Windows NT 3.51, using Microsoft Visual C++ 4.0
* + Be sure to add WSOCK32.LIB to your list of libraries!
* + Compile both lanio.c and getopt.c
* + Consider re-naming the files to lanio.cpp and getopt.cpp
*
* Considerations:
* - On UNIX systems, file I/O can be used on network sockets.
* This makes programming very convenient, since routines like
* getc(), fgets(), fscanf() and fprintf() can be used. These
* routines typically use the lower level read() and write() calls.
*
* - In the Windows environment, file operations such as read(), write(),
* and close() cannot be assumed to work correctly when applied to
* sockets. Instead, the functions send() and recv() MUST be used.
*/
Chapter 18 305
PSA Programming Examples
Using C Over Socket LAN (UNIX)
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/* Support both Win32 and HP-UX UNIX environment */
#ifdef _WIN32 /* Visual C++ 4.0 will define this */
# define WINSOCK
#endif
#ifndef WINSOCK
# ifndef _HPUX_SOURCE
# define _HPUX_SOURCE
# endif
#endif
#include <stdio.h> /* for fprintf and NULL */
#include <string.h> /* for memcpy and memset */
#include <stdlib.h> /* for malloc(), atol() */
#include <errno.h> /* for strerror */
#ifdef WINSOCK
#include <windows.h>
# ifndef _WINSOCKAPI_
# include <winsock.h> // BSD-style socket functions
# endif
#else /* UNIX with BSD sockets */
# include <sys/socket.h> /* for connect and socket*/
# include <netinet/in.h> /* for sockaddr_in */
# include <netdb.h> /* for gethostbyname */
# define SOCKET_ERROR (-1)
# define INVALID_SOCKET (-1)
typedef int SOCKET;
306 Chapter 18
PSA Programming Examples
Using C Over Socket LAN (UNIX)
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
#endif /* WINSOCK */
#ifdef WINSOCK
/* Declared in getopt.c. See example programs disk. */
extern char *optarg;
extern int optind;
extern int getopt(int argc, char * const argv[], const char* optstring);
#else
# include <unistd.h> /* for getopt(3C) */
#endif
#define COMMAND_ERROR (1)
#define NO_CMD_ERROR (0)
#define SCPI_PORT 5025
#define INPUT_BUF_SIZE (64*1024)
/**************************************************************************
* Display usage
**************************************************************************/
static void usage(char *basename)
{
fprintf(stderr,"Usage: %s [-nqu] <hostname> [<command>]\n", basename);
fprintf(stderr," %s [-nqu] <hostname> < stdin\n", basename);
fprintf(stderr," -n, number output lines\n");
fprintf(stderr," -q, quiet; do NOT echo lines\n");
fprintf(stderr," -e, show messages in error queue when done\n");
}
#ifdef WINSOCK
int init_winsock(void)
{
WORD wVersionRequested;
Chapter 18 307
PSA Programming Examples
Using C Over Socket LAN (UNIX)
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
WSADATA wsaData;
int err;
wVersionRequested = MAKEWORD(1, 1);
wVersionRequested = MAKEWORD(2, 0);

err = WSAStartup(wVersionRequested, &wsaData);

if (err != 0) {
/* Tell the user that we couldnt find a useable */
/* winsock.dll. */
fprintf(stderr, "Cannot initialize Winsock 1.1.\n");
return -1;
}
return 0;
}
int close_winsock(void)
{
WSACleanup();
return 0;
}
#endif /* WINSOCK */
/***************************************************************************
*
> $Function: openSocket$
*
* $Description: open a TCP/IP socket connection to the instrument $
*
* $Parameters: $
* (const char *) hostname . . . . Network name of instrument.
* This can be in dotted decimal notation.
* (int) portNumber . . . . . . . The TCP/IP port to talk to.
* Use 5025 for the SCPI port.
308 Chapter 18
PSA Programming Examples
Using C Over Socket LAN (UNIX)
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
*
* $Return: (int) . . . . . . . . A file descriptor similar to open(1).$
*
* $Errors: returns -1 if anything goes wrong $
*
***************************************************************************/
SOCKET openSocket(const char *hostname, int portNumber)
{
struct hostent *hostPtr;
struct sockaddr_in peeraddr_in;
SOCKET s;
memset(&peeraddr_in, 0, sizeof(struct sockaddr_in));
/***********************************************/
/* map the desired host name to internal form. */
/***********************************************/
hostPtr = gethostbyname(hostname);
if (hostPtr == NULL)
{
fprintf(stderr,"unable to resolve hostname %s\n", hostname);
return INVALID_SOCKET;
}
/*******************/
/* create a socket */
/*******************/
s = socket(AF_INET, SOCK_STREAM, 0);
if (s == INVALID_SOCKET)
{
fprintf(stderr,"unable to create socket to %s: %s\n",
hostname, strerror(errno));
return INVALID_SOCKET;
}
Chapter 18 309
PSA Programming Examples
Using C Over Socket LAN (UNIX)
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
memcpy(&peeraddr_in.sin_addr.s_addr, hostPtr->h_addr, hostPtr->h_length);
peeraddr_in.sin_family = AF_INET;
peeraddr_in.sin_port = htons((unsigned short)portNumber);
if (connect(s, (const struct sockaddr*)&peeraddr_in,
sizeof(struct sockaddr_in)) == SOCKET_ERROR)
{
fprintf(stderr,"unable to create socket to %s: %s\n",
hostname, strerror(errno));
return INVALID_SOCKET;
}

return s;
}
/***************************************************************************
*
> $Function: commandInstrument$
*
* $Description: send a SCPI command to the instrument.$
*
* $Parameters: $
* (FILE *) . . . . . . . . . file pointer associated with TCP/IP socket.
* (const char *command) . . SCPI command string.
* $Return: (char *) . . . . . . a pointer to the result string.
*
* $Errors: returns 0 if send fails $
*
***************************************************************************/
int commandInstrument(SOCKET sock,
const char *command)
{
int count;

310 Chapter 18
PSA Programming Examples
Using C Over Socket LAN (UNIX)
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/* fprintf(stderr, "Sending \"%s\".\n", command); */
if (strchr(command, \n) == NULL) {
fprintf(stderr, "Warning: missing newline on command %s.\n", command);
}

count = send(sock, command, strlen(command), 0);
if (count == SOCKET_ERROR) {
return COMMAND_ERROR;
}
return NO_CMD_ERROR;
}
/**************************************************************************
* recv_line(): similar to fgets(), but uses recv()
**************************************************************************/
char * recv_line(SOCKET sock, char * result, int maxLength)
{
#ifdef WINSOCK
int cur_length = 0;
int count;
char * ptr = result;
int err = 1;
while (cur_length < maxLength) {
/* Get a byte into ptr */
count = recv(sock, ptr, 1, 0);
/* If no chars to read, stop. */
if (count < 1) {
break;
}
cur_length += count;
/* If we hit a newline, stop. */
Chapter 18 311
PSA Programming Examples
Using C Over Socket LAN (UNIX)
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
if (*ptr == \n) {
ptr++;
err = 0;
break;
}
ptr++;
}

*ptr = \0;

if (err) {
return NULL;
} else {
return result;
}
#else
/***********************************************************************
* Simpler UNIX version, using file I/O. recv() version works too.
* This demonstrates how to use file I/O on sockets, in UNIX.
***********************************************************************/
FILE * instFile;
instFile = fdopen(sock, "r+");
if (instFile == NULL)
{
fprintf(stderr, "Unable to create FILE * structure : %s\n",
strerror(errno));
exit(2);
}
return fgets(result, maxLength, instFile);
#endif
}
/***************************************************************************
312 Chapter 18
PSA Programming Examples
Using C Over Socket LAN (UNIX)
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
*
> $Function: queryInstrument$
*
* $Description: send a SCPI command to the instrument, return a response.$
*
* $Parameters: $
* (FILE *) . . . . . . . . . file pointer associated with TCP/IP socket.
* (const char *command) . . SCPI command string.
* (char *result) . . . . . . where to put the result.
* (size_t) maxLength . . . . maximum size of result array in bytes.
*
* $Return: (long) . . . . . . . The number of bytes in result buffer.
*
* $Errors: returns 0 if anything goes wrong. $
*
***************************************************************************/
long queryInstrument(SOCKET sock,
const char *command, char *result, size_t maxLength)
{
long ch;
char tmp_buf[8];
long resultBytes = 0;
int command_err;
int count;
/*********************************************************
* Send command to analyzer
*********************************************************/
command_err = commandInstrument(sock, command);
if (command_err) return COMMAND_ERROR;
/*********************************************************
* Read response from analyzer
********************************************************/
count = recv(sock, tmp_buf, 1, 0); /* read 1 char */
Chapter 18 313
PSA Programming Examples
Using C Over Socket LAN (UNIX)
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
ch = tmp_buf[0];
if ((count < 1) || (ch == EOF) || (ch == \n))
{
*result = \0; /* null terminate result for ascii */
return 0;
}

/* use a do-while so we can break out */
do
{
if (ch == #)
{
/* binary data encountered - figure out what it is */
long numDigits;
long numBytes = 0;
/* char length[10]; */

count = recv(sock, tmp_buf, 1, 0); /* read 1 char */
ch = tmp_buf[0];
if ((count < 1) || (ch == EOF)) break; /* End of file */
if (ch < 0 || ch > 9) break; /* unexpected char */
numDigits = ch - 0;
if (numDigits)
{
/* read numDigits bytes into result string. */
count = recv(sock, result, (int)numDigits, 0);
result[count] = 0; /* null terminate */
numBytes = atol(result);
}

if (numBytes)
{
resultBytes = 0;
314 Chapter 18
PSA Programming Examples
Using C Over Socket LAN (UNIX)
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
/* Loop until we get all the bytes we requested. */
/* Each call seems to return up to 1457 bytes, on HP-UX 9.05 */
do {
int rcount;
rcount = recv(sock, result, (int)numBytes, 0);
resultBytes += rcount;
result += rcount; /* Advance pointer */
} while ( resultBytes < numBytes );

/************************************************************
* For LAN dumps, there is always an extra trailing newline
* Since there is no EOI line. For ASCII dumps this is
* great but for binary dumps, it is not needed.
***********************************************************/
if (resultBytes == numBytes)
{
char junk;
count = recv(sock, &junk, 1, 0);
}
}
else
{
/* indefinite block ... dump til we read only a line feed */
do
{
if (recv_line(sock, result, maxLength) == NULL) break;
if (strlen(result)==1 && *result == \n) break;
resultBytes += strlen(result);
result += strlen(result);
} while (1);
}
}
else
{
/* ASCII response (not a binary block) */
*result = (char)ch;
Chapter 18 315
PSA Programming Examples
Using C Over Socket LAN (UNIX)
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
if (recv_line(sock, result+1, maxLength-1) == NULL) return 0;
/* REMOVE trailing newline, if present. And terminate string. */
resultBytes = strlen(result);
if (result[resultBytes-1] == \n) resultBytes -= 1;
result[resultBytes] = \0;
}
} while (0);

return resultBytes;
}
/*************************************************************************
*
> $Function: showErrors$
*
* $Description: Query the SCPI error queue, until empty. Print results. $
*
* $Return: (void)
*
*************************************************************************/
void showErrors(SOCKET sock)
{
const char * command = "SYST:ERR?\n";
char result_str[256];
do {
queryInstrument(sock, command, result_str, sizeof(result_str)-1);

/******************************************************************
* Typical result_str:
* -221,"Settings conflict; Frequency span reduced."
* +0,"No error"
316 Chapter 18
PSA Programming Examples
Using C Over Socket LAN (UNIX)
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
* Dont bother decoding.
******************************************************************/
if (strncmp(result_str, "+0,", 3) == 0) {
/* Matched +0,"No error" */
break;
}
puts(result_str);
} while (1);
}
/***************************************************************************
*
> $Function: isQuery$
*
* $Description: Test current SCPI command to see if it a query. $
*
* $Return: (unsigned char) . . . non-zero if command is a query. 0 if not.
*
***************************************************************************/
unsigned char isQuery( char* cmd )
{
unsigned char q = 0 ;
char *query ;

/*********************************************************/
/* if the command has a ? in it, use queryInstrument. */
/* otherwise, simply send the command. */
/* Actually, we must a little more specific so that */
/* marker value queries are treated as commands. */
/* Example: SENS:FREQ:CENT (CALC1:MARK1:X?) */
/*********************************************************/
if ( (query = strchr(cmd,?)) != NULL)
{
/* Make sure we dont have a marker value query, or
Chapter 18 317
PSA Programming Examples
Using C Over Socket LAN (UNIX)
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
* any command with a ? followed by a ) character.
* This kind of command is not a query from our point of view.
* The analyzer does the query internally, and uses the result.
*/
query++ ; /* bump past ? */
while (*query)
{
if (*query == ) /* attempt to ignore white spc */
query++ ;
else break ;
}

if ( *query != ) )
{
q = 1 ;
}
}
return q ;
}
/***************************************************************************
*
> $Function: main$
*
* $Description: Read command line arguments, and talk to analyzer.
Send query results to stdout. $
*
* $Return: (int) . . . non-zero if an error occurs
*
***************************************************************************/
int main(int argc, char *argv[])
{
SOCKET instSock;
318 Chapter 18
PSA Programming Examples
Using C Over Socket LAN (UNIX)
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
char *charBuf = (char *) malloc(INPUT_BUF_SIZE);
char *basename;
int chr;
char command[1024];
char *destination;
unsigned char quiet = 0;
unsigned char show_errs = 0;
int number = 0;
basename = strrchr(argv[0], /);
if (basename != NULL)
basename++ ;
else
basename = argv[0];

while ( ( chr = getopt(argc,argv,"qune")) != EOF )
switch (chr)
{
case q: quiet = 1; break;
case n: number = 1; break ;
case e: show_errs = 1; break ;
case u:
case ?: usage(basename); exit(1) ;
}

/* now look for hostname and optional <command> */
if (optind < argc)
{
destination = argv[optind++] ;
strcpy(command, "");
if (optind < argc)
{
while (optind < argc) {
/* <hostname> <command> provided; only one command string */
strcat(command, argv[optind++]);
if (optind < argc) {
Chapter 18 319
PSA Programming Examples
Using C Over Socket LAN (UNIX)
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
strcat(command, " ");
} else {
strcat(command, "\n");
}
}
}
else
{
/* Only <hostname> provided; input on <stdin> */
strcpy(command, "");

if (optind > argc)
{
usage(basename);
exit(1);
}
}
}
else
{
/* no hostname! */
usage(basename);
exit(1);
}

/**********************************************/
/* open a socket connection to the instrument */
/**********************************************/
#ifdef WINSOCK
if (init_winsock() != 0) {
exit(1);
}
#endif /* WINSOCK */
instSock = openSocket(destination, SCPI_PORT);
if (instSock == INVALID_SOCKET) {
320 Chapter 18
PSA Programming Examples
Using C Over Socket LAN (UNIX)
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
fprintf(stderr, "Unable to open socket.\n");
return 1;
}
/* fprintf(stderr, "Socket opened.\n"); */
if (strlen(command) > 0)
{
/********************************************************/
/* if the command has a ? in it, use queryInstrument. */
/* otherwise, simply send the command. */
/********************************************************/
if ( isQuery(command) )
{
long bufBytes;
bufBytes = queryInstrument(instSock, command,
charBuf, INPUT_BUF_SIZE);
if (!quiet)
{
fwrite(charBuf, bufBytes, 1, stdout);
fwrite("\n", 1, 1, stdout) ;
fflush(stdout);
}
}
else
{
commandInstrument(instSock, command);
}
}
else
{
/* read a line from <stdin> */
while ( gets(charBuf) != NULL )
{
if ( !strlen(charBuf) )
continue ;

Chapter 18 321
PSA Programming Examples
Using C Over Socket LAN (UNIX)
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
if ( *charBuf == # || *charBuf == ! )
continue ;

strcat(charBuf, "\n");
if (!quiet)
{
if (number)
{
char num[10];
sprintf(num,"%d: ",number);
fwrite(num, strlen(num), 1, stdout);
}
fwrite(charBuf, strlen(charBuf), 1, stdout) ;
fflush(stdout);
}

if ( isQuery(charBuf) )
{
long bufBytes;

/* Put the query response into the same buffer as the
* command string appended after the null terminator.
*/
bufBytes = queryInstrument(instSock, charBuf,
charBuf + strlen(charBuf) + 1,
INPUT_BUF_SIZE -strlen(charBuf) );
if (!quiet)
{
fwrite(" ", 2, 1, stdout) ;
fwrite(charBuf + strlen(charBuf)+1, bufBytes, 1, stdout);
fwrite("\n", 1, 1, stdout) ;
fflush(stdout);
}
}
else
322 Chapter 18
PSA Programming Examples
Using C Over Socket LAN (UNIX)
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
{
commandInstrument(instSock, charBuf);
}
if (number) number++;
}
}

if (show_errs) {
showErrors(instSock);
}
#ifdef WINSOCK
closesocket(instSock);
close_winsock();
#else
close(instSock);
#endif /* WINSOCK */
return 0;
}
/* End of lanio.c */
Chapter 18 323
PSA Programming Examples
Using C Over Socket LAN (Windows NT)
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Using C Over Socket LAN (Windows NT)
Thi s C programmi ng exampl e (getopt.c) compi l es i n the Wi ndows NT
envi ronment. I n Wi ndows, the routi nes send() and r ecv() must be
used, si nce fr ead() and fwri te() may not work on sockets.
The program reads the anal yzers host name fr om the command l i ne,
fol l owed by the SCPI command. I t then opens a socket to the anal yzer,
usi ng port 5025, and sends the command. I f the command appear s to be
a query, the program quer i es the anal yzer for a response, and pri nts the
response.
Thi s exampl e program can al so be used as a uti l i ty to tal k to your
anal yzer from the command prompt on your Wi ndows NT PC, or from
wi thi n a scri pt.
/***************************************************************************
getopt(3C) getopt(3C)
NAME
getopt - get option letter from argument vector
SYNOPSIS
int getopt(int argc, char * const argv[], const char *optstring);
extern char *optarg;
extern int optind, opterr, optopt;
DESCRIPTION
getopt returns the next option letter in argv (starting from argv[1])
that matches a letter in optstring. optstring is a string of
recognized option letters; if a letter is followed by a colon, the
option is expected to have an argument that may or may not be
separated from it by white space. optarg is set to point to the start
of the option argument on return from getopt.
getopt places in optind the argv index of the next argument to be
processed. The external variable optind is initialized to 1 before
324 Chapter 18
PSA Programming Examples
Using C Over Socket LAN (Windows NT)
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
the first call to the function getopt.
When all options have been processed (i.e., up to the first non-option
argument), getopt returns EOF. The special option -- can be used to
delimit the end of the options; EOF is returned, and -- is skipped.
***************************************************************************/
#include <stdio.h> /* For NULL, EOF */
#include <string.h> /* For strchr() */
char *optarg; /* Global argument pointer. */
int optind = 0; /* Global argv index. */
static char *scan = NULL; /* Private scan pointer. */
int getopt( int argc, char * const argv[], const char* optstring)
{
char c;
char *posn;

optarg = NULL;

if (scan == NULL || *scan == \0) {
if (optind == 0)
optind++;

if (optind >= argc || argv[optind][0] != - || argv[optind][1] == \0)
return(EOF);
if (strcmp(argv[optind], "--")==0) {
optind++;
return(EOF);
}

scan = argv[optind]+1;
Chapter 18 325
PSA Programming Examples
Using C Over Socket LAN (Windows NT)
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
optind++;
}

c = *scan++;
posn = strchr(optstring, c); /* DDP */

if (posn == NULL || c == :) {
fprintf(stderr, "%s: unknown option -%c\n", argv[0], c);
return(?);
}

posn++;
if (*posn == :) {
if (*scan != \0) {
optarg = scan;
scan = NULL;
} else {
optarg = argv[optind];
optind++;
}
}

return(c);
}
326 Chapter 18
PSA Programming Examples
Using Java Programming Over Socket LAN
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Using J ava Programming Over Socket LAN
Thi s Java programmi ng exampl e (Scpi Demo.java) demonstrates si mpl e
socket pr ogrammi ng wi th Java and can be found on the Documentati on
CD. I t i s wri tten i n Java pr ogrammi ng l anguage, and wi l l compi l e wi th
Java compi l ers versi ons 1.0 and above.
import java.awt.*;
import java.io.*;
import java.net.*;
import java.applet.*;
// This is a SCPI Demo to demonstrate how one can communicate with the
// E4440A PSA with a JAVA capable browser. This is the
// Main class for the SCPI Demo. This applet will need Socks.class to
// support the I/O commands and a ScpiDemo.html for a browser to load
// the applet.
// To use this applet, either compile this applet with a Java compiler
// or use the existing compiled classes. copy ScpiDemo.class,
// Socks.class and ScpiDemo.html to a floppy. Insert the floppy into
// your instrument. Load up a browser on your computer and do the
// following:
// 1. Load this URL in your browser:
// ftp://<Your instruments IP address or name>/int/ScpiDemo.html
// 2. There should be two text windows show up in the browser:
// The top one is the SCPI response text area for any response
// coming back from the instrument. The bottom one is for you
// to enter a SCPI command. Type in a SCPI command and hit enter.
// If the command expects a response, it will show up in the top
// window.
public class ScpiDemo extends java.applet.Applet implements Runnable {
Thread responseThread;
Socks sck;
URL appletBase;
TextField scpiCommand = new TextField();
TextArea scpiResponse = new TextArea(10, 60);
Panel southPanel = new Panel();
Chapter 18 327
PSA Programming Examples
Using Java Programming Over Socket LAN
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Panel p;
// Initialize the applets
public void init() {

SetupSockets();
SetupPanels();
// Set up font type for both panels
Font font = new Font("TimesRoman", Font.BOLD,14);
scpiResponse.setFont(font);
scpiCommand.setFont(font);
scpiResponse.appendText("SCPI Demo Program: Response messages\n");
scpiResponse.appendText("--------------------------------------------\n");
}
// This routine is called whenever the applet is actived
public void start() {
// Open the sockets if not already opened
sck.OpenSockets();
// Start a response thread
StartResponseThread(true);
}
// This routine is called whenever the applet is out of scope
// i.e. minize browser
public void stop() {
// Close all local sockets
sck.CloseSockets();
// Kill the response thread
StartResponseThread(false);
}
// Action for sending out scpi commands
// This routine is called whenever a command is received from the
// SCPI command panel.
328 Chapter 18
PSA Programming Examples
Using Java Programming Over Socket LAN
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
public boolean action(Event evt, Object what) {
// If this is the correct target
if (evt.target == scpiCommand) {
// Get the scpi command
String str = scpiCommand.getText();
// Send it out to the Scpi socket
sck.ScpiWriteLine(str);
String tempStr = str.toLowerCase();
// If command str is "syst:err?", dont need to send another one.
if ( (tempStr.indexOf("syst") == -1) ||
(tempStr.indexOf("err") == -1) ) {
// Query for any error
sck.ScpiWriteLine("syst:err?");
}
return true;
}
return false;
}
// Start/Stop a Response thread to display the response strings
private void StartResponseThread(boolean start) {
if (start) {
// Start a response thread
responseThread = new Thread(this);
responseThread.start();
}
else {
// Kill the response thread
responseThread = null;
}
}
// Response thread running
public void run() {
String str = ""; // Initialize str to null

Chapter 18 329
PSA Programming Examples
Using Java Programming Over Socket LAN
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
// Clear the error queue before starting the thread
// in case if theres any error messages from the previous actions
while ( str.indexOf("No error") == -1 ) {
sck.ScpiWriteLine("syst:err?");
str = sck.ScpiReadLine();
}

// Start receiving response or error messages
while(true) {
str = sck.ScpiReadLine();
if ( str != null ) {
// If response messages is "No error", do no display it,
// replace it with "OK" instead.
if ( str.equals("+0,\"No error\"") ) {
str = "OK";
}
// Display any response messages in the Response panel
scpiResponse.appendText(str+"\n");
}
}
}
// Set up and open the SCPI sockets
private void SetupSockets() {
// Get server url
appletBase = (URL)getCodeBase();
// Open the sockets
sck = new Socks(appletBase);
}
// Set up the SCPI command and response panels
private void SetupPanels() {
// Set up SCPI command panel
southPanel.setLayout(new GridLayout(1, 1));
p = new Panel();
p.setLayout(new BorderLayout());
330 Chapter 18
PSA Programming Examples
Using Java Programming Over Socket LAN
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
p.add("West", new Label("SCPI command:"));
p.add("Center", scpiCommand);
southPanel.add(p);
// Set up the Response panel
setLayout(new BorderLayout(2,2));
add("Center", scpiResponse);
add("South", southPanel);
}

}
// Socks class is responsible for open/close/read/write operations
// from the predefined socket ports. For this example program,
// the only port used is 5025 for the SCPI port.
class Socks extends java.applet.Applet {
// Socket Info
// To add a new socket, add a constant here, change MAX_NUM_OF_SOCKETS
// then, edit the constructor for the new socket.
public final int SCPI=0;
private final int MAX_NUM_OF_SOCKETS=1;
// Port number
// 5025 is the dedicated port number for E4440A Scpi Port
private final int SCPI_PORT = 5025;
// Socket info
private URL appletBase;
private Socket[] sock = new Socket[MAX_NUM_OF_SOCKETS];
private DataInputStream[] sockIn = new DataInputStream[MAX_NUM_OF_SOCKETS];
private PrintStream[] sockOut = new PrintStream[MAX_NUM_OF_SOCKETS];
private int[] port = new int[MAX_NUM_OF_SOCKETS];
private boolean[] sockOpen = new boolean[MAX_NUM_OF_SOCKETS];
// Constructor
Chapter 18 331
PSA Programming Examples
Using Java Programming Over Socket LAN
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Socks(URL appletB)
{
appletBase = appletB;
// Set up for port array.
port[SCPI] = SCPI_PORT;
// Initialize the sock array
for ( int i = 0; i < MAX_NUM_OF_SOCKETS; i++ ) {
sock[i] = null;
sockIn[i] = null;
sockOut[i] = null;
sockOpen[i] = false;
}
}
//***** Sockects open/close routines
// Open the socket(s) if not already opened
public void OpenSockets()
{
try {
// Open each socket if possible
for ( int i = 0; i < MAX_NUM_OF_SOCKETS; i++ ) {
if ( !sockOpen[i] ) {
sock[i] = new Socket(appletBase.getHost(),port[i]);
sockIn[i] = new DataInputStream(sock[i].getInputStream());
sockOut[i] = new PrintStream(sock[i].getOutputStream());
if ( (sock[i] != null) && (sockIn[i] != null) &&
(sockOut[i] != null) ) {
sockOpen[i] = true;
}
}
}
}
catch (IOException e) {
System.out.println("Sock, Open Error "+e.getMessage());
332 Chapter 18
PSA Programming Examples
Using Java Programming Over Socket LAN
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
}
}
// Close the socket(s) if opened
public void CloseSocket(int s)
{
try {
if ( sockOpen[s] == true ) {
// write blank line to exit servers elegantly
sockOut[s].println();
sockOut[s].flush();
sockIn[s].close();
sockOut[s].close();
sock[s].close();
sockOpen[s] = false;
}
}
catch (IOException e) {
System.out.println("Sock, Close Error "+e.getMessage());
}
}
// Close all sockets
public void CloseSockets()
{
for ( int i=0; i < MAX_NUM_OF_SOCKETS; i++ ) {
CloseSocket(i);
}
}
// Return the status of the socket, open or close.
public boolean SockOpen(int s)
{
return sockOpen[s];
}
Chapter 18 333
PSA Programming Examples
Using Java Programming Over Socket LAN
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
//************* Socket I/O routines.
//*** I/O routines for SCPI socket
// Write an ASCII string with carriage return to SCPI socket
public void ScpiWriteLine(String command)
{
if ( SockOpen(SCPI) ) {
sockOut[SCPI].println(command);
sockOut[SCPI].flush();
}
}
// Read an ASCII string, terminated with carriage return from SCPI socket
public String ScpiReadLine()
{
try {
if ( SockOpen(SCPI) ) {
return sockIn[SCPI].readLine();
}
}
catch (IOException e) {
System.out.println("Scpi Read Line Error "+e.getMessage());
}
return null;
}
// Read a byte from SCPI socket
public byte ScpiReadByte()
{
try {
if ( SockOpen(SCPI) ) {
return sockIn[SCPI].readByte();
}
}
334 Chapter 18
PSA Programming Examples
Using Java Programming Over Socket LAN
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
catch (IOException e) {
System.out.println("Scpi Read Byte Error "+e.getMessage());
}
return 0;
}
}
Chapter 18 335
PSA Programming Examples
Using the VXI Plug-N-Play Driver in LabVIEW
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Using the VXI Plug-N-Play Driver in
LabVIEW

Thi s exampl e shows how to use the VXI pl ug and pl ay dri ver over LAN
i n LabVI EW 6. The vi fi l e (l an_pnp.vi ) can be found on the
Documentati on CD.
You must have Versi on K of the Agi l ent I O l i brari es i nstal l ed on your
PC, ei ther al one or i nstal l ed si de-by-si de wi th the Nati onal I nstr uments
I O l i br ar i es. Al so, you must fi r st i mpor t the VXI pl ug and pl ay dr i ver
i nto LabVI EW before runni ng thi s exampl e. The i nstrument dri ver s are
avai l abl e at:
http://www.agilent.com/find/iolib (Cl i ck on i nstrument dr i vers.)
Thi s exampl e:
1. Opens a VXI 11.3 Lan connecti on to the i nstrument
2. Sets the Center Fr equency to 1 GHz
3. Queri es the i nstruments center frequency
4. Cl oses the Lan connecti on to the i nstrument
NOTE Substi tute your i nstr uments I .P. address for the one used i n the
exampl e.
336 Chapter 18
PSA Programming Examples
Using LabVIEW 6 to Make an EDGE GSM Measurement
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Using LabVIEW

6 to Make an EDGE GSM


Measurement
Thi s i s a LabVI EW 6 exampl e that uses SCPI commands i nstead of the
i nstrument dri ver. I t demonstr ates readi ng ASCI I trace poi nts of enti re
EDGE waveform data i n the Power Vs. Ti me measurement over LAN.
Thi s program uses the opti onal GSM/EDGE personal i ty i n the PSA
Seri es Spectrum Anal yzers and i n the E4406A Vector Si gnal Anal yzer.
The vi fi l e (epvt.vi ) can be found on the Documentati on CD.
Thi s exampl e:
1. Opens a VXI 11.3 Lan connecti on to the i nstrument
2. Changes the data format to ASCI I .
3. I ni ti ates a power vs. ti me measurement and reads the resul ts.
4. The comma separ ated ASCI I r esul ts str i ng i s conver ted to an ar r ay
of val ues.
Chapter 18 337
PSA Programming Examples
Using LabVIEW 6 to Make an EDGE GSM Measurement
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
338 Chapter 18
PSA Programming Examples
Using Visual Basic .NET with the IVI-Com Driver
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Using Visual Basic

.NET with the IVI-Com


Driver
Thi s exampl e uses Vi sual Basi c .NET wi th the I VI -Com dri ver. I t makes
a ti me domai n (Waveform) measurement usi ng the Basi c mode. Basi c
mode i s standard i n the E4406A Vector Si gnal Anal yzer and i s opti onal
(B7J) i n the PSA Seri es Spectr um Anal yzers. The vb fi l e
(vbi vi comsa_basi cwaveform.vb) and the compi l ed executabl e fi l e
(vbi vi comsa.exe) can be found on the Documentati on CD.
*************************************************************************
VBIviComSA_BasicWaveform.vb, August 5, 2003
This example demonstrates the use of the IVI-COM driver in VB.NET
through an interop assembly. The Raw I/Q trace data from the Waveform
measurement in Basic Mode is queried and printed to the screen.

Requirements:
1) E4406A or PSA Series Spectrum Analyzer with Option B7J
2) Latest AgilentSa IVI-COM driver
You may download it here: http://www.agilent.com/find/inst_drivers
This example was tested with version 2.1.0.0 of the driver
3) Create a new project and add the References to this module
and to the the IVI-COM driver dlls:
For .NET, right click on Reference, choose Add Reference
and then click on Browse and directly link the DLLs in the directory:
C:\Program Files\IVI\Bin\Primary Interop Assemblies
Agilent.AgilentSa.Interop.dll
Agilent.AgilentSaAppBasic.Interop.dll
Agilent.Itl.Interop
IviDriverLib.dll
IviSpecAnLib.dll

THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.

Chapter 18 339
PSA Programming Examples
Using Visual Basic .NET with the IVI-Com Driver
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Copyright (c) 2003. Agilent Technologies, Inc.
*************************************************************************
Option Strict On
Imports Agilent.TMFramework
Imports Agilent.AgilentSa.Interop
Imports Ivi.Driver.Interop
Imports System.Runtime.InteropServices
Module ConsoleApp
Sub Main()
Prompt the user for the address of the instrument
Dim address As String
Console.WriteLine("Enter address of the instrument " & vbCrLf & _
"(ex: GPIB0::18::INSTR or TCPIP0::192.168.100.2::inst0::INSTR):")
address = Console.ReadLine()
Try
Create an instance of the driver, connection to the instrument
is not established here, it is done by calling Initialize
Dim instr As New AgilentSaClass()
Establish the connection to the instrument
Last parameter (DriverSetup) is optional, VB could omit it (but not C#)
Important: Close must be called to release resources used by the driver
instr.Initialize(address, False, False, "")
Try
INHERENT CAPABILITIES
Note that it is not necessary to program against the IIviDriver
interface, the same can be achieved by using the class directly
Using the IIviDriver interface gives us interchangeable code
Dim inherent As IIviDriver = instr
340 Chapter 18
PSA Programming Examples
Using Visual Basic .NET with the IVI-Com Driver
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Dim manufacturer As String
Dim model As String
Dim firmware As String
manufacturer = inherent.Identity.InstrumentManufacturer
model = inherent.Identity.InstrumentModel
firmware = inherent.Identity.InstrumentFirmwareRevision
Output instrument information to the console
Console.WriteLine("Manufacturer: " + manufacturer)
Console.WriteLine("Model: " + model)
Console.WriteLine("Firmware: " + firmware)
Reset the instrument
inherent.Utility.Reset()
INSTRUMENT SPECIFIC
Using the IAgilentSa interface is not necessary or beneficial
at the moment, but in the future if other instruments implement
the IAgilentSa interface, the code that is written to work with
that interface can be reused without changes, as opposed to code
that is written against the class object directly
Dim sa As IAgilentSa = instr
Obtain trace data from the instrument
Dim traceData As Array
sa.Application.Select("Basic")
sa.Application.Basic.Waveform.Configure()
sa.Application.Basic.Spectrum.Traces.Initiate()
traceData = sa.Application.Basic.Waveform.Traces.Item("RawIQ").Read(10000)
Output the trace data to the console
Console.WriteLine("Press ENTER to display trace data.")
Console.ReadLine()
Dim traceValue As Double
For Each traceValue In traceData
Console.WriteLine(traceValue)
Chapter 18 341
PSA Programming Examples
Using Visual Basic .NET with the IVI-Com Driver
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Next
Catch ex As Exception
Console.WriteLine(ex.Message)
Finally
Close the connection
instr.Close()
End Try
Catch ex As COMException
Console.WriteLine(ex.Message)
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
Wait for user input
Console.WriteLine("Press ENTER to end program.")
Console.ReadLine()
End Sub
End Module
342 Chapter 18
PSA Programming Examples
Using Agilent VEE to Capture the Equivalent SCPI Learn String
P
S
A

P
r
o
g
r
a
m
m
i
n
g

E
x
a
m
p
l
e
s
Using Agilent VEE to Capture the Equivalent
SCPI Learn String
Thi s exampl e shows how to use VEE to emul ate the *LRN SCPI
command. The VEE fi l e (l rnstri ng.vee) can be found on the
Documentati on CD.
This VEE programming example transfers the saved state register (17 in
this example) to the program. The program then copies this register back
into the instrument and recalls the state. This, in many cases, is equivalent
to the *LRN SCPI command.
Index
343
I
n
d
e
x
A
ACPR
C programmi ng exampl e 176
acti ve functi on posi ti on, movi ng
14
addi ng l i mi t l i nes programmi ng
exampl e usi ng C 233
adjacent channel power
measurement 74
Agi l ent VEE pr ogr am exampl e
197, 342
al i gnments
programmi ng exampl e 179
AM demodul ati on
ti me-domai n demodul ati on,
manual l y cal cul ati ng 157
AM si gnal demodul ati on 92
anal yzer di storti on products 40
attenuati on
i nput, reduci ng 26
setti ng automati cal l y 27
setti ng manual l y 27
aver agi ng
descr i pti on 30
types 30
aver agi ng faster programmi ng
exampl e usi ng C 269
B
Bl uetooth power measurement 68
burst power measur ement 68
C
C l anguage
addressi ng sessi ons 174
cl osi ng sessi ons 175
compi l i ng and l i nki ng 169
cr eati ng 167
exampl e 171
openi ng sessi on 172
sessi ons 172
usi ng VI SA l i br ar y 167
usi ng VI SA transi ti on l i br ary
169, 171
C programmi ng, socket LAN,
UNI X 303
C programmi ng, socket LAN,
WI N NT 323
cal cul ate aver age power of GSM
bursts
programmi ng exampl e 297
cal i brati on
programmi ng exampl e 179
CCDF stati sti cal power
measurement 71
channel power measurement
noi se-l i ke si gnal s 54
compari ng si gnal s
two si gnal s 12, 14
two si gnal s not on the same
screen 15
compressi ng measurement data,
pr ogr ammi ng exampl e 297
Concepts
AM demodul ati on 157
FM demodul ati on 157
concepts
gated FFT (PSA) 137
gated LO (PSA) 136
gated vi deo (ESA) 136
harmoni c di storti on, cal cul ati on
132
I F fi l ter, defi ned 130
resol vi ng si gnal s of equal
ampl i tude 130
resol vi ng smal l si gnal s hi dden
by l arge si gnal s 131
sti mul us response 158
ti me gati ng 133
TV tri gger 154
counter resol uti on, r eadout 32
D
del ta marker 12, 14
Demod key 96
demodul ati ng
AM 92
AM overvi ew 92
FM 98
FM overvi ew 98
TV si gnal s 121
depth of modul ati on
measurement 126
detectors, average 29
devi ce bandwi dth measur ement
114, 160
di spl ay
acti ve functi on posi ti on, movi ng
14
di storti on measurements
harmoni c 45
i denti fyi ng TOI di stor ti on 42
i ndenti fyi ng di storti on products
40
over vi ew 40
di storti on products 40
dri fti ng si gnal s 38
E
enteri ng ampl i tude correcti on
data programmi ng exampl e
usi ng C 243
equi pment 10
er ror status programmi ng
exampl e usi ng C 247
exampl es
AM demodul ati on
ESA bui l t-i n AM
demodul ati on 96
manual demodul ati on 92
average detector, usi ng 29
averagi ng, tr ace 30
di storti on
harmoni cs 45
i denti fy di storti on products 40
TOI 42
exter nal mi xi ng
fr equency tracki ng cal i brati on
86
presel ected mi xers, usi ng 86
unpresel ected mi xer s, usi ng
82
FM demodul ati on
ESA bui l t-i n FM demodul ati on
98
frequency dri ft 36
i nput attenuati on, r educi ng 26
mar ker counter 32
measur i ng
l ow-l evel si gnal s 29
noi se
band power marker 52
channel power, usi ng 54
noi se marker 50
overvi ew 48
si gnal to noi se 48
power sui te
ACP 74
burst power 68
CCDF 71
mul ti -carr i er power 77
resol uti on bandwi dth, reduci ng
28
segmented sweep
moni tor CDMA band 108
usi ng wi th l i mi t l i nes 106
vi ew harmoni cs 104
si gnal s
l ow-l evel , overvi ew 26
off-screen, compari ng 15
on-screen, compari ng 12, 14
resol vi ng, equal ampl i tude 17
resol vi ng, smal l si gnal s hi dden
by l arge si gnal s 20
sti mul us response
devi ce bandwi dth 114, 160
fi l ter r esponse 116
refl ecti on cal i brati on 118
transmi ssi on 112
ti me gati ng
344
Index
I
n
d
e
x
ESA-E ti me gate 64
PSA gated FFT 66
PSA gated sweep 62
tr ace averagi ng 30
tr acki ng a si gnal 38
TV si gnal s
demodul ate and vi ew 122
depth of modul ati on 126
external mi xi ng
enteri ng conver si on l oss data 85
presel ected mi xer s, usi ng 86
setti ng mi xer bi as 84
unpresel ected mi xers, usi ng 82
F
fi ndi ng hi dden si gnal s 131
FM demodul ati on
ti me-domai n demodul ati on,
manual l y cal cul ati ng 157
FM si gnal demodul ati on 98
frequency r eadout resol uti on
i ncreased 32
G
gate del ay
setti ng the gate del ay, ti me
gati ng 144
gate l ength
setti ng the gate l ength, ti me
gati ng 144
gated FFT (PSA), concepts 137
gated LO (PSA), concepts 136
gated vi deo (ESA), concepts 136
GSM mobi l e power cal i bati on PSA
pr ogr ammi ng exampl e usi ng
C 291
GSM/EDGE pr ogram exampl e,
usi ng LabVI EW 336
H
harmoni c di storti on
measuri ng har moni cs 132
measuri ng l ow-l evel si gnal s 15
hol d, maxi mum 36
I
i denti fyi ng di storti on products 40
i ni ti al setti ng for ti me gati ng 148
i nput attenuati on, reduci ng 26
i ntermodul ati on di storti on, thi rd
order 42, 132
i nternal sel f al i gnment
pr ogr ammi ng exampl e usi ng
C 210
I VI -Com dri ver program exampl e
usi ng Vi sual Basi c .NET 338
J
Java programmi ng, socket LAN
326
L
LabVI EW program exampl e 335,
336
l i mi t l i nes
enteri ng data 107
l ow-l evel si gnal s
harmoni cs, measuri ng 15
i nput attenuati on, r educi ng 26
resol uti on bandwi dth, reduci ng
28
sweep ti me, reduci ng 29
tr ace aver agi ng 30
M
marker counter exampl e
mar ker frequency resol uti on 32
marker del ta mode programmi ng
exampl e usi ng C 206
marker peak search programmi ng
exampl e usi ng C 202, 280
markers
band power 52
del ta 12, 14
noi se marker 49, 50
span pai r 52
Max Hol d key 36
maxi mum hol d 36
MCP 77
measure harmoni c di storti on over
GPI B programmi ng exampl e
usi ng C 253
measure harmoni c di storti on over
RS-232 pr ogr ammi ng
exampl e usi ng C 261
measure noi se programmi ng
exampl e usi ng C 239
measurements
devi ce bandwi dth 114, 160
di storti on 40
harmoni cs 45
TOI 42
frequency dri ft 36, 38
noi se
band power marker 52
channel power 54
noi se mar ker 50
overvi ew 48
si gnal to noi se 48
sti mul us response 112
fi l ter r esponse 116
ti me gati ng 57
ESA-E ti me gate 64
PSA gated FFT 66
PSA gated sweep 62
TV
depth of modul ati on 126
fast ti me-domai n sweeps 156
measuri ng return l oss 120
measurments
di storti on
i denti fyi ng 40
movi ng si gnal s 38
mul ti -car ri er power measurement
77
N
N dB Poi nts key 114, 160
noi se measurements
band power marker, usi ng 52
channel power, usi ng 54
noi se marker, usi ng 50
over vi ew 48
si gnal to noi se 48
sweep ti me, reduci ng 29
normal i zati ng reference posi ti on
113, 159
Nor mal i ze On Off key 113, 159
O
openSocket 303, 323, 326
overvi ew
sti mul us response 112
overvi ews
di storti on 40
l ow-l evel si gnal 26
noi se 48
resol vi ng si gnal s 130
ti me gati ng 133
P
Pl ug-N-Pl ay dri ver pr ogr am
exampl e 335
posi ti oni ng the gate, ti me gati ng
143
power sui te
channel power 54
measur ements
ACP or adjacent channel
power 74
burst power 68
CCDF 71
MCP or mul ti -car ri er power 77
power sui te measurements 67
program exampl e
Agi l ent VEE 197, 342
C 176, 179, 182, 303, 323
Index
345
I
n
d
e
x
C, usi ng ESA 202, 206, 210,
214, 218, 223, 228, 233,
239, 243, 247, 253, 261, 269
C, usi ng PSA 280, 283, 287,
291, 297
I VI -Com dri ver 338
Java 326
LabVI EW 335, 336
socket LAN, UNI X usi ng C 303
socket LAN, usi ng Java 326
socket LAN, WI N NT usi ng C
323
Vi sual Basi c 188, 192
Vi sual Basi c .NET 338
VXI Pl ug-N-Pl ay dri ver 335
programmi ng
exampl e usi ng C l anguage 171
usi ng C l anguage 167
programmi ng exampl e
ACPR measurement 176
addi ng l i mi t l i nes, usi ng C 233
al i gnments 179
cal cul ate average power of GSM
bursts 297
determi ne i f an error occur red,
usi ng C 247
EDGE/GSM usi ng LabVI EW
336
enteri ng ampl i tude correcti on
data, usi ng C 243
GSM mobi l e power cal i brati on
wi th a PSA, usi ng C 291
i nternal sel f-al i gnment, usi ng C
210
I VI -Com dri ver, usi ng Vi sual
Basi c .NET 338
l i st of ESA exampl es 200
maki ng faster power averagi ng
measurements, usi ng C 269
marker del ta mode, usi ng C 206
mar ker peak search, usi ng C
202, 280
measure harmoni c di storti on
over GPI B, usi ng C 253
measure harmoni c di storti on
over RS-232, usi ng C 261
measure noi se, usi ng C 239
read ESA 32-bi t trace data over
GPI B, usi ng C 218
read ESA 32-bi t trace data over
RS- 232, usi ng C 228
read ESA ASCI I trace data over
GPI B, usi ng C 214
read ESA ASCI I trace data over
RS- 232, usi ng C 223
savi ng and recal l i ng PSA states,
usi ng C 283
savi ng PSA bi nary tr ace data,
usi ng C 287
SCPI l ear n stri ng, usi ng VEE
342
screen i mage capture 188
SRQ, usi ng 182
system requi r ements, ESA
exampl es 201
system requi r ements, PSA
exampl es 279
tr ansfer bi nary trace data 192
tr ansfer trace data, usi ng VEE
197
usi ng C over socket LAN vi a
UNI X 303
usi ng C over socket LAN vi a
WI N NT 323
usi ng Java over socket LAN 326
VXI Pl ug-N-Pl ay dri ver, usi ng
LabVI EW 335
R
RBW sel ecti ons 28
read ESA 32-bi t trace data over
GPI B programmi ng exampl e
usi ng C 218
read ESA 32-bi t trace data over
RS-232 pr ogr ammi ng
exampl e usi ng C 228
read ESA ASCI I tr ace data over
GPI B programmi ng exampl e
usi ng C 214
read ESA ASCI I tr ace data over
RS-232 pr ogr ammi ng
exampl e usi ng C 223
refl ecti on cal i br ati on and
measurement 118
resl ovi ng, equal ampl i tude 130
resol uti on bandwi dth
adjusti ng 28
resol vi ng si gnal s 131
resol vi ng si gnal s
smal l si gnal s hi dden by l ar ge
si gnal s 131
resol vi ng two si gnal s
equal ampl i tude 17, 130
retur n l oss
conver ti ng to VSWR 160
retur n l oss measurement 120
rul es for ti me gati ng 147
S
savi ng and recal l i ng PSA states
pr ogr ammi ng exampl e usi ng
C 283
savi ng PSA bi nary trace data
progr ammi ng exampl e usi ng
C 287
SCPI l earn stri ng usi ng VEE
progr am exampl e 342
screen i mage capture
programmi ng exampl e 188
segmented sweep
CDMA exampl e 108
measur i ng harmoni cs 104
usi ng wi th l i mi t l i nes 106
si gnal parameter s for a
ti me-gated measurement 141
si gnal tr acki ng
exampl e 38
marker tracki ng 22
usi ng to r esol ve si gnal s 22
si gnal s
l ow-l evel , overvi ew 26
off-scr een, compari ng 15
on-scr een, compari ng 12, 14
resol vi ng, over vi ew 130
separati ng, over vi ew 130
socket LAN
Java progr am exampl e 326
socket LAN, UNI X
C program exampl e 303
socket LAN, WI N NT
C program exampl e 323
Span Zoom key 36
SRQ
programmi ng exampl e 182
sti mul us r esponse
measur e response of a LP fi l ter
116
sti mul us response measurements
112
sti mul us r esponse, concepts 158
sweep coupl i ng
sti mul us response
measurements 113, 115,
117, 159
sweep ti me and sensi ti vi ty tr ade
off 28
sweep ti me for a ti me-gated
measurement 64, 142
sweep ti me, changi ng 29
T
test equi pment 10
thi r d order i ntermodul ati on
di stor ti on exampl e 42, 45
ti me gati ng
descri pti on 133
ESA-E ti me gate, usi ng 64
exampl e 57
gated FFT (PSA), concepts 137
346
Index
I
n
d
e
x
gated LO (PSA), concepts 136
gated vi deo (ESA), concepts 136
how ti me gati ng works 135
i ni ti al setti ngs 148
keys 143
posi ti oni ng the gate 63, 143
PSA gated FFT, usi ng 66
PSA gated sweep, usi ng 62
rul es 147
setti ng sweep ti me 148
setti ng the gate l ength 144
setti ng the resol uti on
bandwi dth 144, 145
setti ng the span 143, 146
setti ng the vi deo bandwi dth
144, 146
si gnal parameters 141
steps for measur i ng unknown
si gnal s 141
sweep ti me 64, 142
tr i ggeri ng
edge mode 151
l evel mode 151
negati ve edge 151
posi ti ve edge 151
tr oubl eshooti ng 149
ti me gati ng measurement 57
tracki ng generator
nor mal i zati on 113, 160
refl ecti on cal i brati on
measurement 118
source power control 112
sti mul us response 158
sti mul us r esponse measurement
112
sweep coupl i ng 113, 115, 117,
159
unl evel ed condi ti on 158
tracki ng unstabl e si gnal s 38
transfer bi nar y trace data
programmi ng exampl e 192
transfer trace data usi ng VEE
pr ogr am exampl e 197
troubl eshooti ng
ti me-gated measurements 149
TV pi ctur e vi ewi ng 121
TV standar d setup 154
TV tri gger setup 154
U
unstabl e si gnal s 38
V
VI SA l i br ary 169, 171
Vi sual Basi c .NET pr ogr am
exampl e 338
Vi sual Basi c program exampl e
screen i mage capture 188
tr ansfer bi nary trace data 192
VSWR and retur n l oss 160
VTL, compi l i ng and l i nki ng C
l anguage 169
VXI Pl ug-N-Pl ay dri ver pr ogr am
exampl e 335
W
W-CDMA ACP measurement 74
W-CDMA CCDF power
measurement 71
W-CDMA mul ti -carr i er power
measurement 77