8 HP E1340A Arbitrary Function Generator User’s Man ual Contents
Certification
Hewlett-Pac kard Compa ny certif ies that this product m et its published sp ecifi cation s at the time of shipment from the factory. H ewlettPackard further certifies that its calibration measurements are traceable to the United Stat es Nation al Instit ute of Stand ard s and Technology (for m erl y Nat ional Bur ea u of Standar ds ), to the ex tent allo wed by that orga ni zati on’ s cal ib rat ion f ac ili t y, and t o th e calibration
facilities of ot her International Standards Organization members.
Warranty
This Hewlet t-Pa ck ar d product is warr ante d agai nst de fect s in mate rials and w orkmansh ip for a period of three years from date of shipment. Duration and conditions of warranty for this product may be superseded when the product i s i nt egrated into (be com es a part of)
other HP product s. Du ring the warrant y period, Hewlett-Packard Company will, at its opt ion, either repair or repl ace pr oducts which
prove to be defective.
For warranty se r vice or repair, this product mu st be r et ur ned to a service facility designated by Hewl et t -P ackard (HP). Buyer sha l l pr epay shipping cha rges to HP and HP shall pay shipping charges to re tu rn the product to Buyer. However, Buyer shall pay all shipping
charges, duties, and taxe s for products returned to HP from anot her count r y.
HP warrants that its softwar e and firmwar e designa ted b y HP for use with a product will execute its programmin g instru cti ons wh en
properly installe d on that product. HP does not warrant that the operat ion of the product, or software , or firmware will be uninterrupted
or er ro r f r ee.
Limitation Of Warrant y
The foreg oin g warra nt y sh al l not apply t o defects resulting from impr oper or inadequate m ai nt enance by Buyer, Buyer-supplied products or interfacing, unauthori ze d m odificati on or misus e, operation outside of the environmenta l specificat i ons for the product, or improper site prep arat i on or maint ena nce.
The design and imp le mentation of an y circuit on thi s pr oduct is the sole responsibility of the Buyer. HP does not warrant th e Buyer’s
circuitr y or malfunctions of HP products that result from the Bu yer’s circuitry. In addition, HP d oes not warrant a n y damage that occurs as a result of the B uyer’s circuit or any defects that re sult from Buyer-supplied product s.
NO OTHER WARRANTY IS EXPRESSED OR IMPLIED. HP SPECIFICALLY DISCLAIMS THE IMPLIED WARR ANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
Exclusive Remedie s
THE REMED IES PROVIDED HEREIN ARE BUYER’S SOLE AND EXCLUSIVE REMEDIES. HP SHALL NOT BE LIABLE
FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER BASED ON CONTRACT, TORT, OR ANY OTHER LEGAL THEORY.
Notice
The information contained in this document is subject to change without notice. HEWLETT-PACKARD (HP) MAKES NO WARRANTY OF ANY KIND W ITH REGARD TO THIS MATERIAL, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. HP shall not be liable for errors contained
herein or for incidental or consequential damages in connection with the furnishing, performance or use of this material. This document c ontains proprietary information whi ch is protected by copyright. All rights are reserved. No part of this document may be photocopied, reproduced, or translate d to another lan guage wit h out the prior written consent of Hewlett -Packar d C ompany. HP assumes no
responsibility for the use or reliability of its software on equipment that is not furnished by HP.
Restricted Rights Legen d
Use, dupli ca tion or discl osu re by the U. S. Go vernme nt is subje ct to rest rict i ons as set fort h in subparagraph (c)(1)(i i) of the Right s in
Technical Data and Comp uter Softwa re clause in D F ARS 252.227-701 3.
Hewlett-Packar d Company
3000 Hanover Street
Palo Alto, Cal if ornia 943 04 U.S. A.
Rights for non-DOD U.S. Government Departments and Agen ci es are as set f orth in F AR 52.227 -19 (c) (1,2).
HP E1340A Arbitrar y Function Gene rat or Modu le Use r’s Manu al
HP E1340A Arbitrary Function Generator Module User’s Manual 9
Documentatio n History
All Editions and Updates of this manual and their creation date are listed below. The first Edition of the manual is Edition 1. The Edition number increment s by 1 whenever the manua l is revised . Updates , which are issued betw een Edi ti ons, c ontain repla ce ment pa ges
to correct or add additional information to the current Edition of the manual. Whenever a new Edition is created, it wil l contain all of
the Update inf ormat ion for the pre viou s Editi on. Each new Ed iti on or Update also incl ude s a revis ed c op y of this documentation history page.
Instruction manual symbol affixed to product. Indicat es that the user must refer to t he
manual for specific WARNING or CAUTION information to avoid personal injury
or damage to the product.
Indicates the field wiring terminal that must
be connected to earth ground before operating the equipment—protects against electrical shock in case of fault.
Frame or chassis ground termi nal — t ypi-
or
cally connects to the equipment’s metal
frame.
WARNING
CAUTION
Alternating current (AC).
Direct curren t (DC).
Indicate s ha za rdous voltages.
Calls at te nt i on t o a pr ocedure, practi ce, or
condition that could cause bodily injury or
death.
Calls at te nt i on t o a pr ocedure, practi ce, or condition that could possibly cause damage to
equipme nt or perma nen t los s of data.
WARNINGS
The following ge ner al safet y prec aut ions mus t be observed du ring al l phas es of oper ation , ser vice , and repai r of this pr oduct.
Failure to comply with these precautions or with specific warnings elsewhere in this manual violates safety standards of design,
manufacture, and inten ded use of the product. Hewlett-Packard Company assumes no liability for the cust o mer’s failu re to
comply with these requirements.
Ground the equipment: For Safety Cl as s 1 equipmen t (equ ipment ha vin g a protective ea rth ter mi nal) , an unint erru ptib le sa fety earth
ground must be provide d from the ma in s power sour ce to the produ ct input wi rin g termi nals or suppli ed power cable .
DO NOT operate the produc t in an explosive at mospher e or in the presen ce of flammable gases or fume s.
For continued protect ion a gainst fire, repl ace the line fuse (s) only with fuse(s) of the same voltage and current rating a nd type .
DO NOT use repaired fuses or short-circui ted fuse holders.
Keep away from live circuits: Operatin g personnel must not remove equipment covers or shields. Procedures involving the removal
of covers or shields are for use by service-trained personnel onl y. Under certain conditions , dangerous voltages may exist even with the
equipment switched off. To avoid dangerous ele ctrical shock , DO NOT perf orm procedures involving cover or shield removal unless
you are qualified to do so.
DO NOT operate damaged equipment: Whene ver it i s p ossibl e tha t the sa fe ty protection features buil t int o t his pr oduct have been impaired, eithe r t hr ough physical dam a ge, exces si ve moisture, or any ot her re as on, REMOVE POWER and do not use the product until
safe operation can be verified by service-trained personnel. If necessary, return the product to a Hewlet t-P ackar d Sales and Se rvice O ffice for service and repair to ensure that safety features are maintaine d.
DO NOT service or adjust alon e: Do not attempt internal service or adjustment unless another person, capable of rendering first aid
and resuscitation, is present.
DO NOT substitute parts or modify equipment: Because of the danger of introducing additional hazar ds, do not install substitut e
parts or perform any unauthorized modifica tion to the product. Retur n the product to a Hewlet t-P ackar d Sales and Ser vice O ffice for
service and repair to ensure that safety features a re ma i nt ai ned.
10 HP E1340A Arbitrary Function Generator Module User’s Manual
Declaration of Conformity
according to ISO/IEC Guide 22 and EN 45014
Manufacturer’s Name:Hewlett-Pa ckar d C ompany
Loveland Manufacturing Center
Manufact urer’s Addre s s:815 14th Street S.W.
Loveland, Colorado 80537
declares, that the product:
Product Name:Arbitrary Function Generator
Model Number :E1340A
Produc t Opt ion s:All
conforms to the following Pr od uct Spe cifi cati ons :
IEC 801-2:1991/ E N5008 2-1 (1 992) : 4kVCD, 8k VA D
IEC 801-3:1984/ E N5008 2-1 (1 992) : 3 V/m
IEC 801-4:1988/ E N5008 2-1 (1 992) : 1kV P ower Lin e
.5kV Signal Lines
Supplementary Information: The product her ewi th c ompl ies wit h th e requirements of the Low Voltage Directive
73/23/EEC and the EMC Directive 89/336/ EEC and carri es the CE-mark ing acc ordingly.
Tested in a typical configuration in an HP B-Size VXI mainframe.
April, 1995Jim White, QAManagerApril, 1995Jim White, QA Manager
European conta ct: Your loca l He wlett-Pa cka rd Sales a nd Servi ce O ffic e or Hewlett- Packa rd GmbH, Departm ent
HQ-TRE, Herr en ber ger Straße 130, D- 71034 Böblingen, Germ a ny (FAX + 49-7031-14-3143 ).
HP E1340A Arbitrary Function Generator Module User’s Manual 11
Notes
12 HP E1340A Arbitrary Function Generator Module User’s Manual
Please fold and tape for mailing
Reader Comment Sheet
HP E1340A Arbitrary Function Generator Modul e User’s Manual
Editio n 3
You can help us improve our manual s b y sharing your commen ts and sug gesti ons. In apprec iat ion of your time, we will
enter yo u in a quarterly drawing for a Hewlett -Pac kar d Palmt op Personal Computer (U.S. government employees
cannot participate in the drawing).
Your Name
C ompany N ame
Job Title
Address
City, State/Province
Country
Zip/Postal C ode
Telephone Number with Area Code
Please list the syste m contr ol ler , oper ati ng syste m, pr ogr a m ming la ng uage, and pl ug-in mo dules you are using.
fold here
BUSINESS REPLY MAIL
FIRST CLASSPERMIT NO. 37LOVELAND,CO
HEWLETT-PACKARD COMPANY
cut along this line
Measurement Systems Division
Learning Products Department
P.O. Box 301
Loveland, CO 80539-9984
NO POSTAGE
NECESSARY
IF MAILED
IN THE
UNITED STATES
fold here
Please penci l-in one circl e for each statement below:Disagree Agree
• The documentation is well organized.OOOOO
•Instructions are easy to understand.OOOOO
•The documentation is clearly written.OOOOO
•Examples are clea r a nd useful.OOOOO
•Illustrati ons are clear and help ful.OOOOO
•The documentation meets my overall expectations.OOOOO
Please write any c omments or suggestions be l ow--be specific.
14 HP E1340A Arbitrary Function Generat or Module User’s Manual
Getting Started with the HP E1340A
Chapter Contents
Chapter 1
This chapter shows you ho w to configure, install, and b egi n using the
HP E1340A Arbitrary Function Generator (AFG). The main sections of this
chapter include:
This section shows how to prepare the AFG for use. Included are
instructions to install the AFG, to download the AFG Device Driver, and to
addre ss t he AFG.
Installing the AFGThe AFG can be installed in any mainfra me slot, except slot 0. For
installation instructions in a B-Size VXIbus System, refer to the B-size
Installation an d Getting Start ed Guide. For install ation instructio ns inC-Size VXIbus Systems, refer to the C-size Installat ion an d Getting Start ed
Guide.
Downloading the
AFG Devic e D ri v e r
The HP E1340A AFG driver allows the AFG to operate in an
HP E1300/E1301 Ma inframe or HP E1405/E1 406 Co mma nd Mo dule using
the Standard Commands for Programmable Instruments (i.e., SCPI)
instrument command language. The driver is supplied on the AFG’s
example program disks (see “Instrument and Programming Languages” on
page 19 f or more i nf ormat ion on the disks).
15 Gettin g Started with the HP E1340AChapter 1
The procedure for downloading the driver is contained in the HP
Installation N ote Do wnloadin g Device Drivers. The E1300/E1301
Mainframe Manual, H P E1405 Command Module Manu al, and E1406
Command Module Manual also contain the installation procedure.
Mainframe/Command
Module Requirements
Recommended
Systems to Download
the Drivers
To download a driver, the ROM version number of the HP E1300/E1301
Mainframe or HP E1405 Command M odu le must be A.06.00 or above. To
determine the version number, send t he IEEE 488.2 common command
*IDN?. A typical returned value (for the HP E1300A Mainframe) is:
HEWLETT-PACKARD,E1300A,0,A.06.01
where "A.06.01" is the version nu mber.
The AFG instrument driver can be downloaded with the following systems.
HP BASIC with an External HP- IB Controller
This system downloads the driver o ver th e Hewlett-P ac kard Interface Bus
(HP-IB*) with an HP BASIC controller, like the HP Series 200/300
computer. Be sure to connect the computer to the Mainframe’s / Command
Module’s HP-IB port. The program to download the driver is named
“VXIDLD_GET”, and is in GET/ S AVE f ormat. The pr o gra m is located on
the HP IBASIC example program disk (HP part number E1340-10035).
This disk is f orm at ted in the LIF format.
HP IBASIC in an HP E1300/E1301 Mainframe or
HP E1405/E1406 Command Module
This system downloads the drivers using the HP IBASIC (i.e., HP
Instrument BASIC) pr ogra m la nguage. The language comes with options to
the HP E1300/E1301 M ainframe and the HP E1405/ E1406 Command
Modules. IBASIC reads dis ks formatted in either the LIF or M S-DOS®
format and can use either example program disk (depend ent on your disk
drive). To download the driver from the LIF disk or t he DOS disk, use
“AUTOST”.
Externally Connected MS-DOS® Computer
This system downloads the driver us ing an MS-DOS computer over the
RS-232 serial int erface. Connect the computer to th e Mai nframe’s /
Command Module’s RS-232 port. The program to download the driver is
named “VXIDLD.EXE” and is located on the DOS example program disk
(HP part number E1340-10036). Th is disk is formatted for MS-DOS.
* HP-IB is Hewlett-Packard’s implement at ion of IEEE Std 488. 1-1 978
Chapter 1Getting Started with the HP E1340A 16
AFG Logical
Address
The AFG is shipped from the factory with a logical addre ss setting of 80,
as shown in Figure 1-1.
The E1340A AFG logical address is us ed:
• to place the AFG in the servant area of a commander
(e.g. HP E1405/E1406 C omm and M o dule).
• to address the AFG (see “Addressing the AFG” later in this chapter).
Figure 1-1. Setting the Logical Address
17 Gettin g Started with the HP E1340AChapter 1
Assigning the AFG to a
Commander
In VXIbus systems, each device must be in the servant area of a
commander. Note th e following wh en assigning the E1340 A AFG:
• In a B-size system, the system instrument is the commander. Any
AFG logical address (1 - 255) places the AFG in the commander
servant ar ea. The AFG logical addre ss should remain at 80, or if
necessary, set to some other multiple of 8 (s ee “Addressing the
AFG”).
• The E1340A AFG is a register-based device. If the AFG’s driver is
downloaded in t he HP E1405/E1406 Command Module, then the
AFG must be in th e serva n t a r ea o f the Command Module to
prog ram with SCP I commands.
Addr essing t he AF GThe following information explains how the AFG is addressed using
dif feren t com p u ter ( contr o ller) configur ations.
IB ASICTo program the AFG in a B-size or C-size system using IBASIC, the AFG
must have a unique address. The addr ess is a combinat i on of the IBASIC
interface select code, the Mainframe’s/Command Module’s primary HP-IB
address, and the AFG’s s ec ondary HP-IB address. An addr ess in this form
in an HP IBASIC sta tement appears as:
External Controller
and PC
OUTPUT 80910;"SOUR: RO SC:SOUR INT"
Interface Select Code (8): The IBASIC interface select code is 8. This
select code is used to access all devices installed in B-size and C-size
systems under IBASIC control.
Primary HP-IB Address (09): This is the address of the HP-IB port on the
Mainframe or C ommand Modu le . Valid add r esses are 0 to 30. The
mainframe/command module has a factory set address of 9.
Secondary HP-IB Address (10): This address is derived from the logical
address of the de vice (AFG) by dividing t he logical address by 8. F or t he
E1340A AFG factory set logical address of 80, the secondary address is 10.
When programming the AFG from an external computer such as a HP
Series 300 or PC, the addressing convention used is the same as IBASIC
exc ept for th e interface select code. An exam p le is sho wn b elow:
OUTPUT 70910;"SOUR: RO SC:SOUR INT"
Interface Select Code (7): Determined by the address of the HP-IB
interface card in the computer. In most Hewlett-Packard computers, this
card has a factory set address of 7, including the HP 82335 HP-IB Interface
Card (this card was used with an HP Vectra personal computer to create the
C and QuickBASIC example programs).
The Pri mary HP-IB Address and Secondary HP-IB Address are the
same as described previously for IBASIC programming.
Chapter 1Getting Started with the HP E1340A 18
Instrument and Programming Languages
The purpose of this manual is to teach you how to use the E1340A AFG. To
do this, the manual uses block diagrams, flowcharts, and example programs.
The programs s hown in the manual are SCPI pr ogr a ms wr itten in HP
IBASIC. These programs, and Quic kBASIC and C language v ersions of the
programs are on the following disks whic h ship with the manual:
• HP E1340A Instrument Driver and HP IBASIC Example Progra ms -
3.5" 720 kbyte disk (E1340-10035)
• HP E1340A Instrument Driver and QuickBASIC and C Language
Example programs - 3.5" 1.44 M byte disk (E1340-10036)
SCPI ProgrammingSCPI (Standar d Comm a nds for Programm ab le Instru ments) is an
ASCII-based instrument command language des igned for test and
measurement instruments. The HP E1300/E1301 Main frame or
HP E1405/E1406 Comm a nd Mo dule with the AFG drive r installed
interprets the ASCII command strings and sets the AFG accordingly. The
Mainframe/Command Module does this by writing to the AFG registers.
SCPI Command
Structure
The AFG SCPI command set is found in Chapter 7. SCPI commands are
based on a hierarchical structure, also known as a tree system. In this
system, ass ociated commands are grouped together under a common node
or root, t hus, for ming subtree s o r subsystem s. An example i s the AF G’s
’ARM’ subsystem shown below.
ARM
[:STARt|SEQuence[1]]
[:LAYer[1]]
:COUNt <
:LAYer2
:COUNt <
:SLOPe <
:SOURce <
is the root keyword of the command, :STARt|SEQuence1 is the
ARM
second level keyword,
so on. A colon (:) always s eparates a command keyword from a lower level
keyword as shown below:
ARM:LAY2:SOUR EXT
number>
number>
edge >
source>
:LAYer1 and :LAYer2 are th ird leve l ke ywords, a n d
19 Gettin g Started with the HP E1340AChapter 1
A semicolon (;) is us ed to s epara te two commands within the same
subsystem, and can also save typing. For e xa mple, sending th is c omma nd
messa ge:
ARM:LAY2:SOUR EXT ;SLO P POS; COUN 10
Is the same as sending these three commands:
ARM:LAY2:SOUR EXT
ARM:LAY2:SLO P POS
ARM:LAY2:COUN 10
Manual FormatThe typical format of commands listed in the command reference and
throughout t his manual is:
[SOURce:]FREQuency:MODE <mode>
Command headers enclosed in brackets are optional. UPPER CASE letters
in the header are required, lower case letters can be omitted. To aid in
learni ng the AFG command set, all headers are incl uded in the example
programs; however, the headers are abbreviated. In an example
program, the previous statement with a mode parameter of
appear as:
FIX would
SOUR:FREQ:MODE FIX
Command CouplingMany of the AFG SCPI commands are value coupled. This means that the
value set by one command may affect the valid limits for the values of other
commands. This can resu lt in "Settings Conf lict" errors when t h e program
executes. To prevent these errors, the AFG commands must be executed in
a "Coupling Group".
The AFG uses one coupling group. Commands not in the coupling group
must precede or follow commands in the coupling group. Executing
uncoupled commands in the coupling group breaks the coupling and can
cause a "Settings Conflict" error.
The coupling group and associated commands can be found in Appendix B,
Table B-2.
Chapter 1Getting Started with the HP E1340A 20
How to Execute
Coupled Commands
Command coupling determines the AFG programming sequence. Coupled
comma nd s must be contiguou s and execut ed in the same program statement .
This is done by placing the co mmands in the same program line, or by
suppressing the end-of-line terminator until the last (coupled) command has
been sent (HP IBASIC progra ms on ly).
To send multiple commands in a single line or in a single statement, the
commands ar e linked with a semi colon (;) and a colo n (:). This is illustrated
in the foll owing l ines :
SOUR:ROSC:SO UR INT;:SOUR:F UNC: SHAP SIN
or
SOUR:ROSC:SOUR INT;
:SOUR:FUNC:SHAP SIN
Both techniques are used in the programs found throughout this manual.
Note that the semicolon (;) and colon (:) link commands with in different
subsystems. Only a semicolon (;) is required t o link commands within the
same s ubs ystem (s ee “SCPI C o m mand Structure” earlier in this chapt er).
NoteSee “HP IBASIC Language Programs” later in this chapter for information
on suppressing the end-of-l ine te rmin ato r.
21 Gettin g Started with the HP E1340AChapter 1
HP IBASIC
Language Programs
The following information identifies the system on which the
HP IBASIC programs were written and shows how the programs are
structured.
System ConfigurationExcept where noted, the example programs in HP IBASIC were developed
(and tested) on the following system:
Mainframe:HP E1301A Mainframe
(IBASIC Opt io n)
HP E1340A Logical Address: 80
Instrument Language:SCPI
Program StructureThe structure of an example program in HP IBASIC is s hown below:
1!RE-SAVE“ARB_GEN”
2!This program generates a 4096 point, 0 to 5V ramp waveform.
3!The data is transferred to the AFG as voltages.
4!
10!Assign I/O path between IBASIC and the E1340A.
20ASSIGN @Afg TO 80910
30COM @Afg, Waveform(1:4096)
40!
50!Set up error checking
60ON INTR 8 CALL Errmsg
70ENABLE INTR 8;2
80OUTPUT @Afg;“*CLS”
90OUTPUT @Afg; “*SRE 32”
100OUTPUT @Afg; “*ESE 60”
110!
120!Call the subprogram which resets the AFG.
130CALL Rst
140!Set AFG parameters
150OUTPUT @A fg;“SOUR:ROSC:SO UR INT;”; !re fe re nc e osci llato r
160OUTPUT @A fg; “:SOUR:F REQ:FIX 1E3;”;!frequency
170OUTPUT @Afg; “:SOUR:FUNC:S HAP USER; ”; !func ti on
180OUTPUT @Afg; “:SOUR:VO LT :LEV:IMM:AMPL 5.1V ”!scale
amplitude
190!
200!Call subprogram which defi ne s waveform segment .
210CALL Ramp_wave
220!
230!Select output sequence and initiate waveform
240OUTPUT @Afg;“SOUR:FUNC:USER A”
250OUTPUT @A fg;“INIT:IMM” !wait-for-arm stat e
Contin ued on next page
Chapter 1Getting Started with the H P E1340A 22
260!
270WAI T .1!allow interrupt to be serviced
280OFF INTR 8
290END
300!
310SUB Ramp_wave
320 Ramp_wave: !Subprogram which defines a ramp waveform
330COM @Afg,Waveform(*)
340FOR I=1 TO 4096
350Waveform(I)=I*.00122
360NEXT I
370!
380OUT PUT @A fg; “SOUR:LIST:SEGM:SEL A”!Selec t segme nt name
390OUT PUT @Afg;“ SOUR:LIST : SEG M:VOLT”;Wavef orm(*)!loa d
400SUBEND
410!
420SUB Rst
430 Rst: !Subprogram which resets the E1340.
440COM @Afg,Waveform(*)
450OUTPUT @A fg;“*RST;*OPC?” !reset the AFG
460ENTER @Afg;Complete
470SUBEND
480!
490SUB Errmsg
500 Errmsg: !Subprogram which displays E1340 program ming error s
510COM @Afg,Waveform(*)
520DIM Message$[256]
530!Read AFG status byte register and clear service request bit
540B=SPOLL(@Afg)
550!End of statem ent if error occur s among coupl ed com mands
560OUTPUT @A fg;“”
570OUT PUT @Afg;“ABORT”!abort output waveform
580REPEAT
590OUTPUT @Afg;“SYST:ERR?” !read AFG error queue
600ENTER @Afg;Code,Message$
610PRINT Code,Message$
waveform point s
620UNTIL Code=0
630STOP
640SUBEND
23 Gettin g Started with the HP E1340AChapter 1
Turning Off (Suppressing) the End-Of-Line Terminator
As mentioned, coupled commands must be contiguous and executed in the
same program statement. By su ppre ssing the end-of-line (EOL) terminator
(Line Feed) on a command line, c oupled commands can be sent on separate
lines, yet as a single program statement.
In HP IBASIC programs, the EOL terminator is suppressed by placing a
semico lon ( ; ) following the q u otation mark ( “ ) which closes the
command string. In the program above, the commands in lines 150 - 180 are
in the coupling group. The semicolons following the command strings in
lines 150 throu gh 170 suppre ss t h e EOL terminator; t heref ore lines 15 0 180 are sent as a single statement.
Getting Programs
The HP IBASIC programs are stored on the disk as ASCII files. The
program name is shown in the program titl e and in line 1 of the pr ogram
1 !RE-SAVE"ARB_GEN"). To get a program, type:
(e.g.,
GET “file name” (e.g., GET “ARB_GEN”)
Declaring IBASIC Variables in COM (common) Memory
When writing or modifying IBASIC programs , array variables can b e
declared in COM (common) memory. Variables not in COM memory resid e
in the IBASIC stack. The ’stack’ is a 32 kB yte (d efault) s egmen t of memo ry
which contai ns components su ch as pointers and lo cal variab les f or
subprograms and de clarations. When too many variables (or too large a n
array) are in the stack, Error 2 - Memory Overflow will occur. If a memory
overflow occurs, the stack size can be changed with the command
PROGram:MALLocate < nbytes> (see the Instr ument BASIC User’s Man ual
for more information).
Chapter 1Getting Started with the HP E1340A 24
C La nguage
Programs
All of the C Language example programs in this manual are written for the
HP 82335 HP-IB Inter fa ce Car d using the HP-IB Command Library for C.
Unless otherwise noted, the library functions used in the programs are
com patible with the ANSI C standard.
The following identifies the system on which the programs are written,
shows how to compile the programs, and gives a typical example program.
System ConfigurationThe C programs were developed on the following syst em:
Controller:HP Vectra 386/25 personal computer
(386 processor operated at 25 MHz)
HP-IB Interface Card:HP 82335 HP-IB Interface with
/AL” and “-ml” parameters to t he appropriate types when
C Program ExampleFollowing is an example program written in C using the HP 82335 HP- IB
Interface Card. The program:
• sends commands to the AFG to generate an arb itrary wa veform
• receives data from t he AFG
• shows how to send coupled commands
• performs error checking of the AFG
Chapter 1Getting Started with the HP E1340A 26
/* ARB_GEN.C - This program generates a 4096 points ramp. The data to */
/* generate the ramp is transferred to the AFG as voltages */
/* Include the following header files */
#include <stdio.h>
#include <string.h>
#include <malloc.h>/* Use “alloc.h” for Turbo C(c) or C++(c) */
#include <cfunc.h>/* This file is f r om the HP-IB Command Library Disk */
Assign an I/O path between the computer and the AFG */
/*********************************************************************************/
void main(void)/* Run the program */
{
rst_clr( );/* Reset the AFG */
gen_seg();/* Generate segment list and output sequence */
run_query();/* Query wav eform segment memory */
}
/*********************************************************************************/
void gen_seg(void)
{
char static *set_com m ands[] =/* Use “set_commands” to setup the AFG */
{
“SOUR:ROSC:SOUR INT; ”/* Select the Ref. Oscillator */
“:SOUR:FREQ:FIX 1e3;”/* Set waveform frequency */
“:SOUR:FUNC:SHAP USER;”/*
“:SOUR:VOLT:LEV: IMM: AMP L 5.1V”,/* Set the amplit ude */
“SOUR:LIST:SEGM :SE L a”/* Select the segm ent nam e */
},
Command to select the user function */
Contin ued on next page
27 Gettin g Started with the HP E1340AChapter 1
*seg_commands =/* Use “seg_commands” to store segm ents */
“SOUR:LIST:SEGM:VOLT ”,/* Command to send volts data */
*out_commands[] = / *
{
“SOUR:FUNC:USER a”,/* Select the user name */
“INIT:IMM”/* Start waveform generation */
};
float*Wave_seg;
intloop,
seg_size = 4096;/* Set the segment size to 4096 point s */
/*
Allocate sufficient memory for storing the segments into computer memory */
if (atoi(into) != 0)/* Determine if error is present */
/* If errors present, print and exit */
{
while (atoi(into) != 0)
{
printf(“Error %s in function %s\n\n”, into, func_ti on);
IOOUTPUTS(ADDR, “SYST:ERR?”, 9);
IOENTERS(ADDR, into, &length);
}
exit(1);
}
}
Chapter 1Getting Started with the HP E1340A 30
QuickBASIC
Language Programs
All of the Quic kBASIC Language exam ple programs in this manual are
written for the HP 82335 HP-IB Interface Card using the HP-IB Command
Library for BASIC.
The following identifies the system on which the programs are written,
shows how to compile the programs, and gives a typical example program.
System ConfigurationThe QuickBASIC pr o grams were developed on the following system:
Controller:HP Vectra 386/25 personal computer
(386 processor operated at 25 MHz)
HP-IB Interface Card:HP 82335 HP-IB Interface with
Running a ProgramTo run a program, first comp ile and link the program to make an executable
file. You can e ither compile and link the pr o gram in the QuickBASIC
environment, or compile and link separately on the command li ne as
follows.
Using the QuickBASIC Environment
To compile and link a pro gr a m, select the Q uickBASIC env ironment as
follows:
qb <path \progra m nam e> /l
This loads both the program and HP-IB library into the QuickBASIC
environment. Note that t his only selects the QuickBASIC version 4.0 and
above environment. For ot he r ver s ions of QuickB ASIC, r efer to the “HP
82335 Using the HP-IB Interface and Command Library” manual.
Using the Command Line
To compile and link using the c omma nd line is a two step method as
follows:
\path \qbhpib
First, compile the program by executing:
bc <path \program name >
31 Gettin g Star ted with the HP E1340AChapter 1
This gen erates an object lis t ing that has t he same name as the pr ogra m name
with an OBJ extension. This object file must be linked to the HP-IB library.
Second, link the HP-IB library:
link <path \program name>
Af ter prom pted for a run file, press the Enter k ey. The execu t able file wi th
an EXE extension is then generated.
QuickBASIC Program
Example
The following is an example program written in Qu ic kBASIC using the HP
82335 HP-IB Interface Card. The program:
• sends commands to the AFG to generat e an arbitrary waveform
• receives data from t he AFG
• shows how to send coupled commands
• performs error checking of the AFG
’ ARB_GEN.BAS - This program generates a 4096 points ramp. The data to
’ generate the ramp is transferred to the AFG as voltages
DECLARE SUB GenSeg ()
DECLARE SUB CmdExe (Commands$(), Length%)
DECLARE SUB SendData (Commands$, WaveSeg!(), NumSize%)
DECLARE SUB RstClr ()
DECLARE SUB CheckError (FuncType$)
DECLARE SUB RunQuery ()
COMMON SHARED ADDR&, ISC&
REM $INCLUDE: ’QBSETUP’
ISC& = 7 ’Assigns the HP-IB select code
ADDR& = 70910 ’Assign an I/O path between the computer and the AFG
CALL RstClr ’ Reset the AFG
CALL GenSeg ’ Generate segment list and output sequence
CALL RunQuery ’ Query segment name
’ Re-enable EOL and EOI for normal HP-IB operation; then send the data
CALL IOEOI(ISC&, 1)
CALL IOEOL(ISC&, Endline$, LEN(Endl ine$))
CALL IOOUTPUTA(ADDR&, SEG WaveSeg!(1), NumSize%)
END SUB
35 Gettin g Started with the HP E1340AChapter 1
Introductory Programs
The introductory programs in this section include:
• AFG Self-Test
• Resetting the AFG and clearing its status registers
• Querying the AFG power-on/reset settings
• Checking for Errors
• Generating a sine wave
AFG Self-TestThe AFG self-test is executed with the command:
*TST?
Table 1-1. HP E1340A Self-Test Codes.
Self-Test CodeDescr ip tion
HP IBASIC (SLFTST)
0Test passed
1Test fai led. An error m ess a g e describ es the failure.
The self-test checks communication bet ween the E1340A and the E1300/01
mainframe or C omman d M odule. Upon completion of the test, one of the
self-test codes listed in Table 1-1 is returned.
1!RE-SAVE “SLFTST”
10!Send the self-test command, enter and display the r esult.
20DIM Message$[256]
30OUTPUT 80910;"*T ST?"
40ENTER 80910;Rslt
50IF Rslt <>0 THEN
60 REPEAT
70OUTPUT 80910;"SYST:ERR?"
80ENTER 80910;Code,Message$
90PRINT Code,Me ssage$
100UNTIL Code=0
110END IF
120PRINT Rslt
130END
Chapter 1Getting Started with the HP E1340A 36
C and QuickBASIC
Programs
The C and QuickBASIC v ersions of SLFTST are on the C language
exampl e programs disk (HP P/N E1340-10036).
Resetting and
Clearing the AFG
HP IBASIC (RSTCLS)
The commands used to reset and clear the AFG are:
*RST
*CLS
Resett i n g t he AFG s ets it to its powe r-o n configur ation and cl ea r i n g t h e
AFG clears its statu s registers. Status register programming is covered in
Chapter 8.
1 !RE-SAVE"RSTCLS"
10!Assign an I/O path between IBASIC and the AFG .
20ASSIGN @Afg TO 80910
30COM @Afg
40!Call the subprogram
50CALL Rst_cls
60END
70!
80SUB Rst_cls
90 Rst_cls: !subprogram which r esets and clears the AFG.
100 COM @Afg
110 OUTPUT @Afg;"*RST;*CLS;*OPC?" !reset and clear t he AFG
120 ENTER @Afg;Complete
130 SUBEND
C and QuickBASIC
Programs
Querying the
Power-On /Rese t
Configurat ion
The C and QuickB ASIC versions of RSTCLS are on the C language
exampl e programs disk (HP P/N E1340-10036).
After resetting the AFG or cycling power, the AFG parameters are set to
the ir p ower -on v alues. These va lues are l i st ed in A ppen dix B, Table B-5.
The command which queries each AFG parameter setting is:
*LRN?
37 Gettin g Started with the HP E1340AChapter 1
HP IBASIC (LRN)
1!RE-SAVE “LRN”
10!Assign an I/O path between IBASIC and the AFG .
20ASSIGN @Afg TO 80910
30!Call the subprogram
40CALL Lrn_conf(@Afg)
50END
60!
70SUB Lrn_conf(@Afg)
80 Lrn_conf: !subprogram which queries the AFG reset configur ation
90 DIM Lrn$[1000],Temp$[40]
100 OUTPUT @Afg;"*LRN?"
110 ENTER @AFG;Lrn$
120 Temp$=""
130 FOR I=1 TO LEN(Lrn$)
140 IF Lrn$[I,I]=";" THEN
150 PRINT Temp$ !print Temp$ when ; is received
160 Temp$=""
170ELSE
180 Temp$=Tem p$&Lrn$[ I,I] !build Temp$ from *LRN data
190END IF
200 NEXT I
210 SUBEND
C and QuickBASIC
Programs
The C and Quic kBASIC versions of LRN ar e on th e C langua g e e xa mple
programs disk (HP P/N E1340-1 0036 ).
Checking for ErrorsThe followi ng HP I BAS IC pr ogr a m shows the lines and subprogram added
to th e HP IBASIC programs to check for error s. Line 140 c lea r s the AFG
standard event st atus r eg ist er. Li nes 150 and 160 u nmask the appropr iate
bits in the A FGs status byte register and standard event status register.
When an error occurs, the subprogram “Errmsg” reads the AFG error queue
and displays the code and message. Note that line 310 is used to force an
"end of stateme nt " c ondition should a syntax error occur in a group of
commands. Otherwise, the
considered as part of the group and be ignored by the AFG SCPI interpreter.
NoteAn alternative HP IBASIC err or checking program is in the C-Size VXIbus
Systems Installation an d Getting Start ed Guide. Error checking routines for
C language and QuickBASIC programs are found in programs
ARB_GEN.C and ARB_GEN.BAS, l isted previously in this chapter.
ABORT command in line 320 could be
Chapter 1Getting Started with the HP E1340A 38
HP IBASIC (ERRORCHK)
1!RE-SAVE"ERRORCHK"
2!This program represents the method used to check for programmin g
3!errors in HP IBASIC programs.
10!Assign I/O path between IBASIC and the E1340A.
20ASSIGN @Afg TO 80910
30COM @Afg
40!Define branch to be taken when an E1340A error occurs.
50!Enable IBASIC interface to generate interrupt when error occu rs.
60ON INTR 8 CALL Errmsg
70ENABLE INTR 8;2
80!Clear all bits in the standard event status register, unmask the
90!standard event status group summary bit in the E1340A status byte
100!register (decimal weight 32), unma sk the query error, device
110!dependent error, execution error, and command error bit s
120!(decimal sum 60) in the E1340A standard event status register.
130OUTPUT @Afg;"*CLS"
140OUTPUT @A fg; "*SRE 32 "
150OUTPUT @Afg;"*ESE 60"
160 !
170!Subprogram calls would be here
180 !
190WAIT .1 !allow error branch to occur before turning intr off
200OFF INTR 8
210 END
220 !
230 SUB Errmsg
240 Errmsg: !Subprogram which displays E1340 program ming error s
250 COM @Afg
260 DIM Message$[256]
270 !Read AFG status byte regist er and cle ar service request bit
280 B=SPOLL(@Afg)
290 !End of statement if error occurs among coupled commands
300 OUTPUT @Afg;""
310 OUTPUT @Afg;"ABORT " !abort output waveform
320 REPEAT
330 OUTPUT @Afg;"SYST:ERR?" !read AFG error queue
340 ENTER @Afg;Code,Message$
350 PRINT Code,Message$
360 UNTIL Code=0
370 STOP
380 SUBEND
39 Gettin g Started with the HP E1340AChapter 1
Generating a Sine
Wave
HP IBASIC (RSTSINE)
To output a s ine wa ve , only an amplitude needs to be specified and the AFG
placed in the wait-for-trigger state (INIT). Using the minimum amount of
AFG commands , th is programs g enerat es a 10 kHz, 10 Vp-p sine wav e.
1 !RE-SAVE"RSTSINE"
2!This program outputs a sine wave based on a specified amplitude
3!and the reset settings of the AFG.
4 !
10!Assign an I/O path between IBASIC and the AFG .
20ASSIGN @Afg TO 80910
30COM @Afg
40!
50!Reset the AFG
60CALL Rst
70OUTPUT @AFG; "SOUR:V OLT :LEV: IM M:AMP L 5" !set amplitude
80OUTPUT @Afg;"INIT:IMM" !output sine wave using reset condition s
90END
100 !
110SUB Rst
120 Rst: !subprogram which r esets the AFG.
130 COM @Afg
140 OUTPUT @Afg;"*RST ;*O PC?" !reset the AFG
150 ENTER @Afg;Complete
160 SUBEND
C and QuickBASIC
Programs
The C and QuickB ASIC versions of RSTSINE are on th e C language
exampl e programs disk (HP P/N E1340-10036).
HP E1340A Example Programs
For easy reference, names and de scriptions of the example programs in this
man ual are summa rized in Appendix B, Table B-1.
Chapter 1Getting Started with the HP E1340A 40
Generating Standard Waveforms with the
Chapter Contents
Chapter 2
HP E1340A
This chapter shows how to generate standard wav eforms (SINusoid,
SQUare, TRIangle, and RAMPS) using the HP E1340A 12-Bit Arbitrary
Function Generator (hereafter called the “AFG”).
The following sections show ho w to generat e standard wave forms, how to
setup the AFG for different output loads, how to select the output amplitude
units (i.e., V, Vpeak, etc.), and h ow to set the waveform amplitude and
offset. The sections are as follows:
• Selecting the Amplitude Levels and Output Units . . . . . . . . Page 50
• Pro g ram Commen t s. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Pag e 52
Standard Waveforms Flowchart
The flowchart on page 42 shows the sequence used to generate standard
waveforms. The reset (power-on) values of each command are also noted on
the flowchart. The programs in this chapter begin with a reset (the IEEE
*RST command) which places the AFG into its power-on state. Thus,
488.2
the programs do not execute all of the commands on the flowchart.
41 Generating Standard Waveforms with the HP E1340AChapter 2
Chapter 2Generati ng St anda rd Waveforms with the HP E1340A 42
Generating DC Voltages
This progra m outputs a +5 V DC volta ge. The c ommands ar e:
1. Reset the AFG -
The *RST command aborts an y waveform output and selects the
sinusoid function.
This command specifies the amplitude. Refer to the section called
“Selecting the Amplitude L evels and Ou tput Units” on page 50 for
more inform ation.
HP IBASIC Program Example (DCVOLTS)
1!RE-SAVE“DCVOLTS”
2!This program outputs 5V dc.
3!
10!Assign I/O path between IBASIC and the E1340A.
20ASSIGN @Afg TO 80910
30COM @Afg
40!
50!Set up error checking
60ON INTR 8 CALL Errmsg
70ENABLE INTR 8;2
80OUTPUT @Afg;“*CLS”
90OUTPUT @Afg; “*SRE 32”
100OUTPUT @Afg; “*ESE 60”
110!
120!Call the subprogram which resets the AFG.
130CALL Rst
140!
150!Set AFG parameters
160OUTPUT @Afg;“SOUR:FUNC:SHAP DC” !func tion
170OUTPUT @A fg; “SOUR:VOLT:LEV:IMM:AM PL 5V ” !amplitude
180!
190WAI T .1!allow interrupt to be serviced
*RST
Contin ued on next page
43 Generating Standard Waveforms with the HP E1340AChapter 2
200OFF INTR 8
210END
220!
230SUB Rst
•
•
300SUB Errmsg
•
•
C and QuickBASIC
Program Versions
The C example program, DCVOLTS.C, is in directory “CPROG” and the
QuickBASIC example program, DCVOLTS.BAS, is in directory
“QBPROG” on the C and QuickBASIC example disk (part number
E1340-10036).
Chapter 2Generati ng St anda rd Waveforms with the HP E1340A 44
Generating Sine, Triangle, and Square Waves
This pro gram outputs a Sine Wave at 1 kHz and 5 V output le vel. The
commands are:
1. Reset the AFG -
The *RST command aborts an y waveform output and selects the
sinusoid function.
2. Set the Waveform Frequency -
[SOURce:]FREQuency[:FIXed] <frequency>
Thi s command specifies the waveform frequency. R efer to Appendix
B for the frequency limits.
3. Select the Function -
[SOURce:]FUNCt ion[: SHAP e] SINusoid
This command selects the SINusoid function. (Although *RST
automatically selects this function, it is selected here for good
programming practice.) For the Triangle and Square Wave functions,
use the
TRIangle and SQUare parameters, respectively, instead of
*RST
This command specifies the amplitude. Refer to the section called
“Selecting the Amplitude L evels and Ou tput Units” on page 50 for
more inform ation.
5. Initiate t he Waveform -
INITiate[ :I MMediate]
This command gen erates an immediate output with the arm source
IMMediate. Refer to Chapter 5 for triggering information.
set to
45 Generating Standard Waveforms with the HP E1340AChapter 2
HP IBASIC Program Example (SINEWAVE)
1!RE-SAVE“SINEW AVE ”
2!This program generates a 5V, 1 kHz sine wave.
3!
10!Assign I/O path between IBASIC and the E1340A.
20ASSIGN @Afg TO 80910
30COM @Afg
40!
50!Set up error checking
60ON INTR 8 CALL Errmsg
70ENABLE INTR 8;2
80OUTPUT @Afg;“*CLS”
90OUTPUT @Afg; “*SRE 32”
100OUTPUT @Afg; “*ESE 60”
110!
120!Call the subprogram which resets the AFG.
130CALL Rst
140!
150!Set AFG parameters
160OUTPUT @Afg;“SOUR:FREQ: FI X 1E3;”;!frequ ency
170OUTPUT @A fg; “:SOUR:FUNC:SHAP SIN;”;!functi on
180OUTPUT @A fg; “:SOUR:VOLT:LEV:IMM:A MPL 5V”!amplit ude
190OUTPUT @A fg;“INIT:IMM”!wait-for-arm state
200!
210WAI T .1!allow interrupt to be serviced
220OFF INTR 8
230END
240!
250SUB Rst
•
•
320SUB Errmsg
•
•
C and QuickBASIC
Program Versions
The C example program, SINEWAVE.C, is in directory “CPROG” and the
QuickBASIC example program, SINEWAVE.BAS, is in directory
“QBPROG” on the C and QuickBASIC example disk (part number
E1340-10036).
Chapter 2Generati ng St anda rd Waveforms with the HP E1340A 46
Generating Ramp Waves
This progra m outputs a ne gat ive goi ng Ramp at 10 kHz, 4 V output leve l,
and +1 V offset. The commands are:
1. Reset the AFG -
The *RST command aborts any waveform output, selects the sinusoid
function, sel ects the 42.9 MHz referenc e oscillator source, 10 kHz
frequency, arm sta rt immediate, 0 V offs et, and
0 V output.
2. Set the Frequency -
[SOURce:]FREQuency[:FIXed] <frequency>
This command specifies the frequency. Refer to Appendix B for the
frequency limits.
3. Select the Function -
[SOURce:]FUNCt ion[: SHAP e] RAMP
This command selects the RAMP function.
4. Select the Ramp P olarit y -
[SOURce:]RAMP :POLari ty INVerte d
This command selects the polarity of the RAMP wave. Use NORMal
for the initial voltage to go positive; use INVerted f or t he initial
voltage to go negative.
This command specifies the amplitude. Refer to the section called
“Selecting the Amplitude L evels and Ou tput Units” on page 50 for
more inform ation.
47 Generating Standard Waveforms with the HP E1340AChapter 2
6. Set the Offset -
[SOURce:]VO LTage[ :LE Vel ][ :IMM edi ate] :OF F Set <offs et >
This command specifies the offset. Refer to the section called
“Selecting the Amplitude L evels and Ou tput Units” on page 50 for
more inform ation.
7. Initiate t he Waveform -
INITiate[ :I MMediate]
This command gen erates an immediate output with the arm source
IMMediate. Refer to Chapter 5 for triggering information.
set to
HP IBASIC Program Example (RAMPWAVE)
1!RE-SAVE"RAMPWAVE"
2!This program generates a 4V, 10 kHz negative-going ramp wav e.
3!
10!Assign I/O path between IBASIC and the E1340A.
20ASSIGN @Afg TO 80910
30COM @Afg
40!
50!Set up error checking
60ON INTR 8 CALL Errmsg
70ENABLE INTR 8;2
80OUTPUT @Afg; "*CLS"
90OUTPUT @Afg;"*SRE 32"
100OUTPUT @Afg;"*ESE 60"
110!
120!Call the subprogram which resets the AFG.
130CALL Rst
140!
150!Set AFG parameters
160OUTPUT @Afg; "SOUR:ROSC:SOUR INT;";!reference oscillator
170OUTPUT @Afg;":SOUR:FREQ:FIX 10E3;";!frequency
180OUTPUT @Afg;":SOUR:FUNC:SHAP RAMP;";!function
190OUTPUT @Afg;":SOUR: RAM P:POL INV;";!ramp polarity
200OUTPUT @A fg; ":SOUR:VOLT :LEV :I MM:AMPL 4V;";!a mplitude
210OUTPUT @A fg; ":SOUR:VOLT :LEV :I MM:OFFS 1V"!of fset
220OUTPUT @A fg;"INIT:IMM" !wait-for-arm state
230!
240WAI T .1!allow interrupt to be serviced
250OFF INTR 8
260END
270!
280SUB Rst
Contin ued on next page
Chapter 2Generati ng St anda rd Wavefo rms with the HP E1340A 48
•
•
350SUB Errmsg
•
•
C and QuickBASIC
Program Versions
The C example program, RAMPWAVE.C, is in directory “CPROG” and
the QuickBASIC example program, RAMPWAVE.BAS, is in directory
“QBPROG” on the C and QuickBASIC example disk (part number
E1340-10036).
49 Generating Standard Waveforms with the HP E1340AChapter 2
Selecting the Amplitude Levels and Output Units
This pro gra m s hows h ow t o s et the out put a mp litude using the VPP (volts
peak-to-peak) output unit. The commands are:
1. Reset the AFG -
The *RST command aborts any waveform output, selects the sinusoid
function, sel ects the 42.9 MHz r eference oscillator sourc e, arm start
immediat e, 0 V offset, and 0 V output.
[SOURce:]VO LTage[ :LE Vel ][ :IMM edi ate] :OF F Set <
These commands specify the amplitude and offset. Refer to
Appendix B for the amplitude limits. The maximum value of the
combined amplitude and offset voltages must remai n within the
7 V limit.
4. Initiate t he Waveform -
INITiate[ :I MMediate]
This command gen erates an immediate output with the arm source
IMMediate. Refer to Chapter 5 for triggering information.
set to
offset>
Chapter 2Generati ng St anda rd Waveforms with the HP E1340A 50
HP IBASIC Program Example (OUTPUNIT)
1!RE-SAVE“OUTPUNIT”
2!This program sets the AFG’s output uni t s to volts peak-to-peak.
3!
10!Assign I/O path between IBASIC and the E1340A.
20ASSIGN @Afg TO 80910
30COM @Afg
40!
50!Set up error checking
60ON INTR 8 CALL Errmsg
70ENABLE INTR 8;2
80OUTPUT @Afg;“*CLS”
90OUTPUT @Afg; “*SRE 32”
100OUTPUT @Afg; “*ESE 60”
110!
120!Call the subprogram which resets the AFG.
130CALL Rst
140!
150!Set AFG parameters
160OUTPUT @A fg; “SOUR:VOLT:LEV:IMM:AM PL:UNIT:VOLT VPP”
•
•
!output units
C and QuickBASIC
Program Versions
200OUTPUT @A fg; “SOUR:VO LT:LEV:IMM:AMPL 8;”;!amplitude
210OUTPUT @A fg; “:SOUR:VO LT:LEV:IMM:O F F S 1”!offse t
220OUTPUT @Afg;“INIT:IMM ” !wait-for-arm state
230!
240WAI T .1!allow interrupt to be serviced
250OFF INTR 8
260END
270!
280SUB Rst
•
•
350SUB Errmsg
•
•
The C example program, OUTPUNIT.C, is in directory “CPROG” and the
QuickBASIC example program, OUTPUNIT.BAS, is in directory
“QBPROG” on the C and QuickBASIC example disk (part number
E1340-10036).
51 Generating Standard Waveforms with the HP E1340AChapter 2
Program Comments
The following comments gi ve additio nal details on the pro gram exa mples in
this chapter.
Reference
Oscillator Sources
Outp ut Load
Comments
Output Units
Comments
• The SINusoid, SQUare, TRIangle, and RAMP functions can use any
of the Ref erenc e Osci llator Sour ces. The sources, selected by
[SOURce:]ROSCi llator: SO URce, are:
INTernal - 42.949 6729 6 MHz (power -on value)
EXTernal - User provided value (the front panel “Aux In” BNC)
• If using the EXTernal refer ence oscillator sou rce, ent e r the sou rce
frequency to the AFG using
[SOURce:]ROS Ci ll ator: F REQuency:EXTernal <f requency>.
• For correct output a mp litu de values, the load applied to the AFG
“Signal Output” terminals must b e the same va lue as the selected
AFG output impedance value.
• To o utpu t to an open circ uit, ex ecute OUTPut:LOAD INFini t y or
9.9E+37. The HP E1340A then outputs the corre ct am plitude and
offset for an open circuit. The amplitude and offset range are
doubled while resolution worsens by a factor of 2.
• The selected unit type can be overridden by sending a unit suffix
with the amplitude command. For example, if the selected unit is
VPP, sendi n g:
changes the unit type to volts (i.e., V) for that command. However,
the default unit type remains in eff ect for subseq u ent ampl itude
commands that are sent without the unit suffix.
• The V (volts) suffix and VPK (volts peak) suffix generate the same
amplitude values for all time varying waveforms like
SQUare, TRIangle, and RAMPS.
SINusoid,
• The default unit type only applies for amplitudes an d not for offsets.
The unit for offsets must always be specified in “
example, executing:
[SOURce:]VOLTage:OFFSet .1VPP
causes an error . To prev ent t h e error, ex ecute either:
[SOURce:]VOLTage:OFFSet 0.1
V” for volts. For
or
[SOURce]:VOLTage:OFFSet 0.1V
Chapter 2Generati ng St anda rd Waveforms with the HP E1340A 52
• The W, DBM, and DBMW unit types references the amplitude levels
to the 50
values are meaningless and not available when selecting an open
circuit load.
Ω output load valu e. Thus, t he W, DBM, a nd DBMW
Using MINimum
and MAXimum
Parameters
You can exec ute many commands (like [SO URce :]FR EQue ncy[ :CW|:F IXed ])
using the
However,
values when received using the values of other commands in effect at that
time. The values of oth er commands af fecting the
computation are subseq uently changed, but the already computed MIN and
MAX valu es do not change.
Thus, if a group of coupled commands are sent where the
MAXimum parameters conflict with the current AFG setting, the AFG
generates an error. This happens even though the commands that f ollow
may set th e AFG to a state that d oes not conflict with the
MAXimum parameters.
For best results, use values in th e commands and do not use the
and MAXimum parameters.
MINimum or MAXimum parameters instead of a number value.
MIN and MAX are internally converted immediately to numeric
MIN and MAX
MINimum and
MINimum and
MINimum
53 Generating Standard Waveforms with the HP E1340AChapter 2
Chapter 2Generati ng St anda rd Waveforms with the HP E1340A 54
Generating Arbitrary Waveforms with the
Chapter Contents
Chapter 3
HP E1340A
This chapter shows how to generate arbitrary waveforms using the
HP E1340A 12-Bit Arbitrary Function Generator (called the “AFG”).
The following sections show how to generate arbitrary waveforms. Also
included are example programs that generat e various arbitrary wave for ms.
The sections are as follows:
The flowchart on page 58 shows the commands and the command execution
order to generate standard wa ve forms. The reset (power-on) values of each
command are also noted on the flowchart. Note that the IEEE 488.2
command places the AFG into its po wer- on st at e. Th us, it may be
unnecessary to execute all of the commands on the flowchart.
*RST
55 Generating Arbitrary Waveforms with the HP E1340AChapter 3
How the AFG Generates Arbitrary Waveforms
Refer to Figure 3-1. A n arbitrary waveform consists of two parts, a
waveform segment (or all points on a waveform) and a segment sequenc e.
The segments contain the actual voltage points of the waveform. The
segment sequ ence determines which waveform segments are to be output.
The AFG has four waveform segments available: A, B, C, and D. The size
of each waveform segment is 4096 points. Thus, to store data into a
wavefo rm segment, the numb er of data items (or waveform p oints) must be
4096.
To output a w aveform, set the user function to out put one or more of the
waveform segments. To output a waveform with a single waveform
segment, use one of the A through D waveform seg ments. To ou tput
wav efo rms with mu ltip le wav e f orm segment s, us e a comb i n a tio n o f AB o r
ABCD waveform segments. The AB combination outputs the 8192 point
waveform defined by the A and B waveform segments. Thus, the A
segment is output first and then the B segment . The ABC D combination
outputs the 16384 point waveform defined by the A , B, C, an d D waveform
segments. Thus, the A segment is output first and the D segment is output
last.
Similarly, t h e AB combinat ion output s a waveform with 8192 points and
the ABCD combination outputs a waveform with 16384 points.
The segment values can be either sent as voltage values
[SOURce:]LIST[:SEGMent]:VOLT <voltage_list>) or DAC
(use
(digital-to-ana log converter) codes
[SOURce:]LIST[:SEGMent]:VOLT:DAC <voltage_list>).
(use
If sent as voltage values, the AFG converts them to DAC codes before
storing them in memory.
To output a w aveform, th e AFG set s t he DAC to the voltage value of the
selected waveform segment. The wav eform frequency determines the
waveform repetition rate.
Chapter 3Generating Ar bitr ary Waveforms with the HP E1340A 56
Figure 3-1. Generating Arbitrary Waveform s
57 Generating Arbitrary Waveforms with the HP E1340AChapter 3
Chapter 3Generating Ar bitr ary Waveforms with the HP E1340A 58
Generating a Simple Arbitrary Waveform
This program shows h ow to generate an a rb itrar y waveform with a single
waveform segment. The examp l e generates a 4096 point ramp. The AFG
stores the waveform segment into segment memory as voltage data points.
The commands are:
1. Reset the AFG -
The *RST command aborts an y waveform output and sets the AFG to
a defined state.
2. Select the Reference Oscillator -
[SOURce:]ROS Cill ator:SO URce <sourc e>
This command selects the Reference Oscillator Source (see
“Program Comments” later in this chapter).
3. Set the Waveform Frequency -
[SOURce:]FREQuency[:CW|FIXed] <frequency>
This command sets the repetition rate of the waveform. See
Appendix B for the frequency limits.
4. Select the Arbitrary Waveform Function -
[SOURce:]FUNCt ion[: SHAP e] USER
This command selects the arbitrary waveform function.
This command specifies the maximum output amplitude. The
amplitude must be equal or grea ter than the maximum volt age value
of the waveform segment. Refer to App endix B for th e amplitude
limits.
59 Generating Arbitrary Waveforms with the HP E1340AChapter 3
6. Select the Waveform Segment -
[SOURce:]LIST[:SEGMent]:SELect <name>
Use either A, B, C, or D in <name> for the waveform segment.
7. Store the Waveform Segment as Voltages -
[SOURce:]LIST [:SE GMent] :VOLT age <voltage_l ist>
This command stores the points of the waveform segment into the
AFG’s segmen t mem ory. These points are sent to the AFG as volts
which are the output voltage points that constitutes the waveform
segment.
8. Select the User Name -
[SOURce:]FUNCtion:USER <name>
This command s elects the wavef orm segment to be output. Make the
name in this command the same name as the waveform segment to be
output.
9. Initiate t he Waveform -
INITiate[ :I MMediate]
This command gen erates an immediate output with the arm source
IMMediate. Refer to Chapter 5 for triggering information.
set to
10. Query the Waveform Segment (Optional) -
[SOURce:]LIST [ :SE Gm ent] :SELect ?
This command retur ns the currently selected waveform segment.
Chapter 3Generating Ar bitr ary Waveforms with the HP E1340A 60
HP IBASIC Program Example (ARB_GEN)
1!RE-SAVE“ARB_GEN”
2!This program generates a 4096 point, 0 to 5V ramp waveform.
3!The data is transferred to the AFG as voltages.
4!
10!Assign I/O path between IBASIC and the E1340A.
20ASSIGN @Afg TO 80910
30COM @Afg, Waveform(1:4096)
40!
50!Set up error checking
60ON INTR 8 CALL Errmsg
70ENABLE INTR 8;2
80OUTPUT @Afg;“*CLS”
90OUTPUT @Afg; “*SRE 32”
100OUTPUT @Afg; “*ESE 60”
110!
120!Call the subprogram which resets the AFG.
130CALL Rst
140!Set AFG parameters
150OUTPUT @A fg;“SOUR:ROSC:SO UR INT;”;!reference oscillator
160OUTPUT @A fg; “:SOUR:F REQ:FIX 1E3;”;!fre quency
170OUTPUT @Afg; “:SOUR:FUNC:S HAP USER; ”;!function
180OUTPUT @Afg; “:SOUR:VO LT :LEV:IMM:AMPL 5.1V ”!scale
190!
200!Call subprogram which defi ne s waveform segment .
210CALL Ramp_wave
220!
230!Select output sequence and initiate waveform
240OUTPUT @Afg;“SOUR:FUNC:USER A”
250OUTPUT @A fg;“INIT:IMM” !wait-for-arm state
260!
270WAI T .1!allow interrupt to be serviced
280OFF INTR 8
290END
300!
310SUB Ramp_wave
320 Ramp_wave: !Subprogram which defines a ramp wavefo rm
330COM @Afg,Waveform(*)
340FOR I=1 TO 4096
350Waveform(I)=I*.00122
360NEXT I
370!
380OUTPUT @Afg;“SOUR:LIST : SEGM:SEL A”!Select segme nt name
amplitude
Contin ued on next page
61 Generating Arbitrary Waveforms with the HP E1340AChapter 3
The C example program, ARB_GEN.C , is i n directory “CPROG” and the
QuickBASIC example program, ARB_GEN.BAS, is in directory
“QBPROG” on the C and QuickBASIC example disk (part number
E1340-10036).
Transferring Data in C To transfer data to the AFG requires that the data sent with the
[SOURce:]LIST[:SEGMent]:VOLTage c om man d mu s t be contigu ous. T o do
this, send no carria ge return (CR) and line feed (LF) before transf err i ng all
the data. The
function below):
1. Disable EOI and EOL using
2. Next, sent to the AFG the SCPI
send_data function does this as follows (refer to the C
IOEOI (IS C, 0 ) and IOEOL (ISC, “ ”, 0),
respectively.
ISC conta ins the HP-IB sel ect c ode, and the 0 and “ ”
(NULL) valu es d isab les the carriage retur n (C R) a nd line feed (LF)
to allow the AFG to receive a command string without a terminator.
[SOURce:]LIST[:SEGment]:VOLTage command str ing using
IOOUTPUTS (ADDR, commands, strlen(commands)). ADDR
contains the AFG HP-IB address, commands contains the SCPI
command string, and
commands. This enab les the AFG to receive voltage data. S ince CR
strlen(com mands) contains the string length of
or LF is disabled, the AFG holds execution until all the data is sent.
3. Enable EOI and EOL using
respectively. The va riable
IOEOI (ISC, 1) and IOEOL (ISC, state, 2),
state contains the decimal codes for CR
and LF. Although EOL and EOI are enabled, no CR and LF is sent
until all voltage dat a tra nsfer is compl eted (next step).
Chapter 3Generating Ar bitr ary Waveforms with the HP E1340A 62
4. The volta ge data values are sent next usin g the array Wave_seg in
IOOUTPUTA (ADDR, Wave_seg, num_size). The valu es in
Wave_seg are in a floating point format. IOOUTPUTS automatically
separates each value in the arrays by a comma ( , ).
5. After all the data is sent, the data transfer terminates with a CR and
LF. This lets the AFG know that it can rec eive a new co mmand.
/* First disable EOI and EOL; then send the last command */
IOEOI (ISC, 0); IOEO L (ISC, “ ”, 0);
IOOUTPUTS (ADDR, commands, strlen(commands));
/* Re-enable EOL and EOI for normal HP-I B operation; then
send the last data */
IOEOI (ISC, 1);IO EOL (ISC, state, 2);
IOOUTPUTA (ADDR, Wav e _ seg, num_s i ze);
}
Transferring Data in
QuickBASIC
To transfer data to the AFG requires that the data sent with the
[SOURce:]LIST[:SEGMent]:VOLTage c om man d mu s t be contigu ous. T o do
this, send no carria ge return (CR) and line feed (LF) before transf err i ng all
the data. The
SendData routine in the QuickBASIC program do this as
follows (refer to the QuickBASIC routine below):
1. Disable EOI and EOL using
respectively.
ISC& contains the HP-IB select code, the 0 and “ ”
IOEOI (IS C &, 0 ) a nd I OEOL (ISC&, “ ”, 0),
(NULL) valu es d isab les the carriage retur n (C R) a nd line feed (LF)
to allow the AFG to receive a command string without a terminator.
2. Next, sent to the AFG the SCPI
[SOURce:]LIST[:SEGment]:VOLTage command str ing using
IOOUTPUTS(ADDR& , Commands$, LEN(Commands$). ADDR&
contains the AFG HP-IB address, Commands$ contains the SCPI
command string, and
Commands$. This enables the AFG to receive voltage data. Since
LEN(Comm ands$) contains the string length of
CR or LF is disabled, the AFG holds execution until all the data is
sent.
3. Enable EOI and EOL using
Endline$, LEN(Endline$))
IOEOI(ISC&, 1) and IOEOL(ISC&,
, resp ectively. The va riable Endline $
contains the decimal codes for CR and LF. Although EOL and EOI
are enabled, no CR and LF is sent until all voltage data transfer is
completed (next step).
63 Generating Arbitrary Waveforms with the HP E1340AChapter 3
4. The volta ge data values are sent next usin g the array WaveSeg! () in
IOOUTPUTA(ADDR& , SEG WaveSeg!(1), NumSize%). The values
WaveSeg! are in a floating point format. IOOUTPUTS
in
automatically separates each value in the arrays by a comma ( , ).
5. After all the data is sent, the data transfer terminates with a CR and
LF. This lets the AFG know that it can rec eive a new co mmand.
SUB SendData (Commands$, WaveSeg!(), NumSize%)
Endline$ = CHR$(13) + CHR$(10)
’ First disable EOI and EOL; then send the last command
CALL IOEOI(ISC&, 0)
CALL IOEOL(ISC&, “ ”, 0)
CALL IOOUTPUTS(ADDR&, Commands$, LEN(Commands$))
’ Re-enable EOL and EOI for normal HP-IB operation; then send the data
CALL IOEOI(ISC&, 1)
CALL IOEOL(ISC&, Endline$, LEN(Endl ine$))
CALL IOOUTPUTA(ADDR&, SEG WaveSeg!(1), NumSize%)
END SUB
Chapter 3Generating Ar bitr ary Waveforms with the HP E1340A 64
Executing Several Waveform Segments
This program shows h ow to generate an a rb itrar y waveform that combines
two different waveform segments. One waveform se g ment generates a 1 kHz,
5 V sine wave. The other one generates a 1 kHz, 5 Vpeak triangle.
The commands are:
1. Reset the AFG -
The *RST command aborts wav eform output and sets the AFG to a
defined state.
2. Set the Waveform Frequency -
[SOURce:]FREQuency[:CW|FIXed] <frequency>
This command sets the repetition rate of the waveform. See
Appendix B for the frequency limits.
3. Select the Arbitrary Waveform Function -
[SOURce:]FUNCt ion[: SHAP e] USER
This command sel ects the arbitrary wavefo rm function. Couple the
command to th e previous frequen cy command.
This command specifies the maximum output amplitude. The
amplitude must be equal or grea ter than the maximum volt age value
of the waveform segment. Refer to App endix B for th e amplitude
limits
*RST
5. Select the First Wavefor m Seg m en t -
[SOURce:]LIST[:SEGMent]:SELect A
Use A to select the first waveform segment.
65 Generating Arbitrary Waveforms with the HP E1340AChapter 3
6. Store the First Waveform Segment as Voltages -
[SOURce:]LIST [:SE GMent] :VOLT age <voltage_l ist>
This command stores the points of t he “A” waveform segment into
the AFG’s s egm e nt me mory. These points are sent to the AFG as
volts which are t he output voltage points that constitutes the
waveform segment.
7. Select the Second Waveform Segment -
[SOURce:]LIST[:SEGMent]:SELect B
Use B to select the second waveform segment.
8. Store the Second Waveform Segment as Voltages -
[SOURce:]LIST [:SE GMent] :VOLT age <voltage_l ist>
This command stores the points of the B waveform segment into the
AFG’s segmen t mem ory. These points are sent to the AFG as volts
which are the output voltage points that constitutes the waveform
segment.
9. Select the User Name -
[SOURce:]FUNCtion:USER AB
This command selects the waveform segments to b e ou tput
AB).
(i.e.,
10. Initiate t he Waveform -
INITiat e[:IMMediat e]
This command gen erates an immediate output with the arm source
IMMediate. Refer to Chapter 5 for triggering information.
set to
Chapter 3Generating Ar bitr ary Waveforms with the HP E1340A 66
HP IBASIC Program Example (MULSEG)
1!RE-SAVE“MULSEG”
2!This program generates an arbitrary waveform compri sed of t wo
3!wavef orm segments. One segm ent is a sine wave and the other
4!segment is a triangle wave.
5!
10!Assign I/O path between IBASIC and the E1340A.
20ASSIGN @Afg TO 80910
30COM @Afg,Waveform1(1:4096),Waveform2(1:4096)
40!
50!Set up error checking
60ON INTR 8 CALL Errmsg
70ENABLE INTR 8;2
80OUTPUT @Afg;“*CLS”
90OUTPUT @Afg; “*SRE 32”
100OUTPUT @Afg; “*ESE 60”
110!
120!Call the subprogram which resets the AFG.
130CALL Rst
140!
150!Set AFG parameters
160OUTPUT @Afg;“SOUR:FREQ: FI X 10E3;”;!frequency
170OUTPUT @Afg; “:SOUR:FUNC:S HAP USER; ”; !func tion
180OUTPUT @Afg; “:SOUR:VO LT :LEV:IMM:AMPL 5.1V ” !scale
190!
200!Call subprogram which defi ne s waveform segment s A and B.
210CALL Sine_tri_wave
220!
230!Select output sequence and initiate waveform
240OUTPUT @Afg;“SOUR:FUNC:USER AB”
250OUTPUT @A fg;“INIT:IMM” !wait-for-arm state
260!
270WAI T .1!allow interrupt to be serviced
280OFF INTR 8
290END
300!
310SUB Sine_tri_ wave
320 Sine_tri_wave: !Subprogram which defines waveforms
330COM @Afg,Waveform1(*),Waveform2(*)
340FOR I=1 TO 4096
350Waveform1(I )= 5*(SI N(2*PI *(I/ 4096)))
360NEXT I
370!
amplitude
Contin ued on next page
67 Generating Arbitrary Waveforms with the HP E1340AChapter 3
380OUTPUT @Afg;“SOUR:LIST : SEGM:SEL A”
!select segme nt name
390OUTPUT @Afg;“ SOUR:LIST : SEG M: VOLT”;Waveform1(*)
!load wavef orm poi nts
400!
420Waveform2(I)=I*.0024414
430NEXT I
440FOR I=2048 TO 4096
450Waveform2(I)=(4096-I )*.0024414
460NEXT I
470!
480OUTPUT @Afg;“SOUR:LIST : SEG M: SEL B” !selec t segme nt nam e
490OUTPUT @Afg;“ SOUR:LIST : SEG M: VOLT”;Waveform2(*)
!load wavef orm poi nts
500SUBEND
510!
520SUB Rst
•
•
590SUB Errmsg
•
•
C and QuickBASIC
Program Versions
The C exampl e program, M ULSEG.C, is in directory “CPROG” and the
QuickBASIC example program, MULSEG.BAS, is in directory
“QBPROG” on the C and QuickBASIC example disk (part number
E1340-10036).
Chapter 3Generating Ar bitr ary Waveforms with the HP E1340A 68
Arbitrary Waveform Hopping
This program performs waveform hopping of waveform segments A and B.
Use a very stable 1 kHz, 0 to 5 V square wave applied to the AFG’s “Aux
In” connector to switch between the waveform segments. The positive level
of the square wave out puts waveform segment A t o gener at e a 5 cy cle sine
wave. The zero level of the square wa ve outputs waveform segment B to
generate a 5 cycle triangle wave. (You may need to adjust the 1 kHz square
wave to output a s ta b le arbitrary wavef orm.) There will be ab out a 20 msec
delay between a transition on the “Aux In” connector and the output
switching.
1. Reset the AFG -
The *RST command aborts wav eform output and sets the AFG to a
defined state.
2. Setup the AFG f or an Arbitrary Wa ve fo rm Output -
[SOURce:]FREQuency[:CW|FIXed] <frequency>
[SOURce:]FUNCt ion[: SHAP e] USER
[SOURce:]VOLTage[:LEVel][:IMMediate][:AMPLitude] <
These co mman ds setup the AFG t o output ar b itrary wa v eforms.
3. Select the First Wavefor m Seg m en t -
[SOURce:]LIST[:SEGMent]:SELect A
Use A to select the first waveform segment.
4. Store the First Waveform Segment as Voltages -
[SOURce:]LIST [:SE GMent] :VOLT age <voltage_l ist>
This command stores the points of t he “A” waveform segment into
the AFG’s s egm e nt me mory. These points are sent to the AFG as
volts which are t he output voltage points that constitutes the
waveform segment.
*RST
amplitude>
69 Generating Arbitrary Waveforms with the HP E1340AChapter 3
5. Select the Second Waveform Segment -
[SOURce:]LIST[:SEGMent]:SELect B
Use B to select the second waveform segment.
6. Store the Second Waveform Segment as Voltages -
[SOURce:]LIST [:SE GMent] :VOLT age <voltage_l ist>
This command stores the points of the “B” waveform segment into
the AFG’s s egm e nt me mory. These points are sent to the AFG as
volts which are t he output voltage points that constitutes the
waveform segment.
7. Select the User Name -
[SOURce:]FUNCtion:USER HOP_AB
This command setup the AFG to hop between waveform segments A
and B.
8. Initiate t he Waveform -
This command gen erates an immediate output with the arm source
IMMediate. Refer to Chapter 5 for triggering information.
set to
HP IBASIC Program Example (ARB_HOP)
1!RE-SAVE“ARB_HOP”
2!This program hops (selects) between tw o w aveform s egments based
3!on the level of a 1 kHz, 0 to 5V square wave applied t o the AFG’ s
4!“Aux In” connector. A low level selects segment A (sine wave), a
5!high level selects segment B (triangle wave).
6!
10!Assign I/O path between IBASIC and the E1340A.
20ASSIGN @Afg TO 80910
30COM @Afg,Waveform1(1:4096),Waveform2(1:4096)
40!
50!Set up error checking
60ON INTR 8 CALL Errmsg
70ENABLE INTR 8;2
80OUTPUT @Afg;“*CLS”
90OUTPUT @Afg; “*SRE 32”
100OUTPUT @Afg; “*ESE 60”
110!
120!Call the subprogram which resets the AFG.
130CALL Rst
140!Set AFG parameters
150OUTPUT @Afg;“SOUR:FREQ: FI X 10E3;”;!frequency
160OUTPUT @Afg; “:SOUR:FUNC:S HAP USER; ”; !func tion
INITiat e[:IMMediat e]
Contin ued on next page
Chapter 3Generating Ar bitr ary Waveforms with the HP E1340A 70
180!
190!Call subprogram which defi ne s waveform segment s A and B.
200CALL Sine_tri_wave
210!
220!Select output sequence and initiate waveform
230OUTPUT @Afg;“SOUR:FUNC:USER HO P_AB”
240OUTPUT @A fg;“INIT:IMM”!wait-for-arm state
250!
260WAI T .1!allow interrupt to be serviced
270OFF INTR 8
280END
290!
300SUB Sine_tri_ wave
310 Sine_tri_wave:!Subprogram which defines
waveforms
320COM @Afg,Waveform1(*),Waveform2(*)
350FOR I=1 TO 4096
360Waveform1(I )= 5*(SI N(2*PI *(I/ 4096)))
370NEXT I
380!
390OUTPUT @Afg;“SOUR:LIST : SEGM:SEL A”!Select segme nt name
400OUTPUT @Afg;“ SOUR:LIST : SEG M: VOLT”;Waveform1(*)
!load wavef orm poi nts
410!
420FOR I=1 TO 2047
430Waveform2(I)=I*.0024414
440NEXT I
450FOR I=2048 TO 4096
460Waveform2(I)=(4096-I )*.0024414
470NEXT I
480!
490OUTPUT @Afg;“SOUR:LIST : SEGM:SEL B”!Select segme nt name
500OUTPUT @Afg;“ SOUR:LIST : SEG M: VOLT”;Waveform2(*)
!load wavef orm poi nts
510SUBEND
520!
530SUB Rst
•
•
600SUB Errmsg
•
•
71 Generating Arbitrary Waveforms with the HP E1340AChapter 3
C and QuickBASIC
Program Versions
The C exampl e program , AR B_HOP . C, is in di rectory “CPROG” and the
QuickBASIC exam p le progr a m, ARB_HOP.BAS, is in direct ory
“QBPROG” on the C and QuickBASIC example disk (part number
E1340-10036).
Chapter 3Generating Ar bitr ary Waveforms with the HP E1340A 72
Generating Built-In Arbitrary Waveforms
The AFG has 16 built-in arbitrary wavefor ms availab le for us e. All of these
waveforms have 4096 points and are stored in an EPR OM (see “Program
Comments” for the waveform listing). To execute the waveforms,
download the data points into wa veform segment A, B, C, or D. The
following program downloads and generates the 16th waveform.
1. Reset the AFG -
The *RST command aborts wav eform output and sets the AFG to a
defined state.
2. Setup the AFG f or an Arbitrary Wa ve fo rm Output -
[SOURce:]FREQuency[:CW|FIXed] <frequency>
[SOURce:]FUNCt ion[: SHAP e] USER
[SOURce:]VOLTage[:LEVel][:IMMediate][:AMPLitude] <
These co mman ds setup the AFG t o output an arb itra ry wavef orm.
3. Download the Waveform Data from the EEProm into M emory -
[SOURce:]ARBi trary: DO WNl oad <source>, <dest>, <length>
This command downloads the segment data from the EPROM where
<source> selects the waveform block in the EPROM, <dest> is the
waveform segment name (i.e., A, B, C, or D), and
waveform segment length (i.e., 4096).
4. Select the User Name -
[SOURce:]FUNCtion:USER <name>
*RST
amplitude>
<length> is the
This command s elects the wavef orm segment to be output. Make the
name in this command the same name as the waveform segment to be
output.
73 Generating Arbitrary Waveforms with the HP E1340AChapter 3
5. Initiate t he Waveform -
INITiate[ :I MMediate]
This command gen erates an immediate output with the arm source
IMMediate. Refer to Chapter 5 for triggering information.
set to
HP IBASIC Program Example (ROM_DOWN)
1!RE-SAVE“ROM_DOWN”
2!This program downloads a 4096 point waveform to waveform segment
3!memory from block 16 (EEPR16) of the AFG’s waveform EEPROM.
4!
10!Assign I/O path between IBASIC and the E1340A.
20ASSIGN @Afg TO 80910
30COM @Afg
40!
50!Set up error checking
60ON INTR 8 CALL Errmsg
70ENABLE INTR 8;2
80OUTPUT @Afg;“*CLS”
90OUTPUT @Afg; “*SRE 32”
100OUTPUT @Afg; “*ESE 60”
110!
120!Call the subprogram which resets the AFG.
130CALL Rst
140!
150!Set AFG parameters
160OUTPUT @Afg;“SOUR:FREQ: FI X 1E3;”;!frequ ency
170OUTPUT @Afg; “:SOUR:FUNC:S HAP USER; ”;!function
180OUTPUT @A fg; “:SOUR:VOLT:LEV:IMM:A MPL 5V”!amplit ude
190OUTPUT @Afg;“SOUR:ARB:DOWN EEPR16, A, 4096”!download
200OUTPUT @Afg;“SOUR:FUNC:USER A” !select sequence
210OUTPUT @A fg;“INIT:IMM”!wait-for-arm state
220!
230WAI T .1!allow interrupt to be serviced
240OFF INTR 8
250END
260!
270SUB Rst
•
•
waveform
340SUB Errmsg
•
•
Chapter 3Generating Ar bitr ary Waveforms with the HP E1340A 74
C and QuickBASIC
Program Versions
The C example program, ROM_DOWN.C , is i n directory “CPROG” and
the QuickBASIC example program, ROM_DOWN.BAS, is in directory
“QBPROG” on the C and QuickBASIC example disk (part number
E1340-10036).
75 Generating Arbitrary Waveforms with the HP E1340AChapter 3
Sample Programs
The following programs generate various arbitrary waveforms. All
programs output waveforms at a 1 kHz waveform frequency and 5 V
amplitude.
Due to the similarity of all the programs, only the first program is
completely presented here. Only the differences are shown by the other
programs.
Generating a
Damped Sine Wave
This program generates a Damped Sine Wave using 4096 segments or
points.
HP IBASIC Program Example (SIN_D)
1!RE-SAVE“SIN_D”
2!This program generates a damped sine wave.
3!
10!Assign I/O path between IBASIC and the E1340A.
20ASSIGN @Afg TO 80910
30COM @Afg, Waveform(1:4096)
40!
50!Set up error checking
60ON INTR 8 CALL Errmsg
70ENABLE INTR 8;2
80OUTPUT @Afg;“*CLS”
90OUTPUT @Afg; “*SRE 32”
100OUTPUT @Afg; “*ESE 60”
110!
Contin ued on next page
Chapter 3Generating Ar bitr ary Waveforms with the HP E1340A 76
120!Call the subprogram which resets the AFG.
130CALL Rst
140!
150!Set AFG parameters
160OUTPUT @Afg;“SOUR:FREQ: FI X 1E3;”;!frequ ency
170OUTPUT @Afg; “:SOUR:FUNC:S HAP USER; ”;!function
180OUTPUT @Afg; “:SOUR:VO LT :LEV:IMM:AMPL 1.1V ” !scale
amplitude
190!
200!Call subprogram which defi ne s waveform segment .
210CALL Damped_sine
220!
230!Select output sequence and initiate waveform
240OUTPUT @Afg;“SOUR:FUNC:USER A”
250OUTPUT @A fg;“INIT:IMM”!wait-for-arm state
260!
270WAI T .1!allow interrupt to be serviced
280OFF INTR 8
290END
300!
310SUB Damped_sine
320 Damped_sine: ! Subprogram which define s a damped sine wave
330COM @Afg,Waveform(*)
340A =4/4096
350W=(2*PI)/50
360FOR T=1 TO 4096
370 Waveform(T)=EXP(-A*T)*SIN(W*T)
380NEXT T
390!
400OUTPUT @Afg;“SOUR:LIST : SEGM:SEL A”!select segme nt name
410OUTPUT @Afg; “SOUR:LIST:SEG M: VOLT”;Waveform ( *)!load
420SUBEND
430!
440SUB Rst
waveform point s
•
•
510SUB Errmsg
•
•
C and QuickBASIC
Program Versions
The C example program, SIN_D.C, is in directory “ CPROG” and the
QuickBASIC exam p le progr a m, SIN_D.BAS, is in direct ory “QBPROG”
on the C and QuickBASIC example disk (part number E134 0-10036).
77 Generating Arbitrary Waveforms with the HP E1340AChapter 3
Generating an
Exponential
This program generates an Exponential Charge/Discharge Waveform with
4096 segments or points.
Charge/Discharge
Waveform
HP IBASIC Program Example (CHARGE)
This pro gram is similar to the “SIN_D” BASIC program on page 76, with
the foll owing diff eren ces:
1!RE-SAVE“CHARGE”
2!This program generates an exponential charge/discharge waveform.
•
•
210CALL Charge
•
•
310SUB Charge
320 Charge:!Subprogram which defines an exponential charge/discharge
330 !waveform.
340COM @Afg,Waveform(*)
350Rc=400
360FOR T=1 TO 4096
370IF T>=0 AND T<2047 THEN
380 Waveform(T)=1*(1-EXP(-T/Rc))
390END IF
400IF T>=2047 THEN
410Waveform(T)=1*(1-EXP(-2048/Rc))-1*(1-EXP(-(T-2047)/Rc))
420END IF
430NEXT T
440!
450OUTPUT @Afg;“SOUR:LIST : SEGM:SEL A”!select segme nt name
460OUTPUT @Afg; “ SOUR:LIST :SEGM:VO LT”;Waveform(*)!load
waveform point s
470SUBEND
Chapter 3Generating Ar bitr ary Waveforms with the HP E1340A 78
C and QuickBASIC
Program Versions
The C exampl e program , C HARGE.C, is in directory “CPROG” and the
QuickBASIC example program, CHARGE.BAS, is in directory
“QBPROG” on the C and QuickBASIC example disk (part number
E1340-10036).
Generating a Sine
Wave with Spikes
This program generat es a Sine Wave with Spikes using 4096 s egments or
points.
HP IBASIC Program Example (SPIKES)
This pro gram is similar to the “SIN_D” BASIC program on page 76, with
the foll owing diff eren ces:
1!RE-SAVE“SPIKES”
2!This program generates a sine wave with a spike.
190!
200!Call subprogram which defi ne s waveform segment .
210CALL Sine_spike
•
•
310SUB Sine_spike
320 Sine_spike: !Subprogram which defin es a sine wave with a spike
330COM @Afg,Waveform(*)
340FOR I=1 TO 4096
350Waveform(I )=.5*SI N(2*PI *(I /4096))
360NEXT I
370Width=50
Contin ued on next page
79 Generating Arbitrary Waveforms with the HP E1340AChapter 3
380FOR J=1 TO W idth/ 2
390Waveform(J+1024)=W aveform( J+1024)+ J*.04
400NEXT J
410FOR J=1 TO W idth/ 2
420Waveform(J+1024+ Width/ 2)= Waveform (J+1024+ Width/ 2)
+1-(J*.04 )
430NEXT J
440!
450OUTPUT @Afg;“SOUR:LIST : SEGM:SEL A”!select segme nt name
460OUTPUT @Afg; “ SOUR:LIST :SEGM:VO LT”;Waveform(*)!load
waveform point s
470SUBEND
C and QuickBASIC
Program Versions
Generating a
Half-Rectified Sine
Wave
The C exampl e program, SPIKES.C, is in directory “CPROG” and the
QuickBASIC example program, SPIKES.BAS, is in directory “QBPROG”
on the C and QuickBASIC example disk (part number E134 0-10034).
This program generates a Half-Rectified Sine Wave using 4096 segme nts or
poi nts.
Chapter 3Generating Ar bitr ary Waveforms with the HP E1340A 80
HP IBASIC Program Example (SIN_R)
This pro gram is similar to the “SIN_D” BASIC program on page 76, with
the foll owing diff eren ces:
1!RE-SAVE“SIN_R”
2!This program generates a 1/2 wave rect ified si ne wav e.
•
•
210CALL Rec_sine
•
•
310SUB Rec_sine
320 Rec_sine:!Subprogram whi ch defines a recti f ie d sine wave
330COM @Afg,Waveform(*)
340FOR I=1 TO 4096
350Waveform(I)=SIN( 2*PI*( I/4096))
360NEXT I
370FOR I=2049 TO 4096
380Waveform(I)= 0
390NEXT I
400!
410OUTPUT @Afg;“SOUR:LIST : SEGM:SEL A”!select segme nt name
420OUTPUT @Afg; “SOUR:LIST:SEG M: VOLT”;Waveform ( *)!load
430SUBEND
waveform point s
C and QuickBASIC
Program Versions
The C example program, SIN_R.C, is in directory “CPROG” and the
QuickBASIC example program, SIN_R.BAS, is in directory “QBPROG”
on the C and QuickBASIC example disk (part number E134 0-10036).
81 Generating Arbitrary Waveforms with the HP E1340AChapter 3
Program Comments
The following comments gi ve additio nal details on the pro gram exa mples in
this chapter.
Amplitude Effects
on Voltage List
Reference
Oscillator Sources
Waveforms in the
EPRom
If the segment data is sent as voltage values, the AFG changes the data into
digital-to-ana log con verter (D AC) co des. Th is requires t hat the voltage
value of the segment data MUST NOT exceed the AFG’s current amplitude
level (set by
does, the AFG generat es an error.
[SOURce:]VOLTage[ :LE Vel][:I MMedi ate] [:AM PLitude] ). If it
• The SINusoid, SQUare, TRIangle, and RAMP functions can use any
of the Ref erenc e Osci llator Sour ces. The sources, selected by
[SOURce:]ROSCi llator: SO URce, are:
INTernal - 42.949 6729 6 MHz (power -on value)
EXTernal - User provided value (the front panel “Aux In” BNC)
• If using the EXTernal refer ence oscillator sou rce, ent e r the sou rce
frequency to the AFG using
[SOURce:]ROS Ci ll ator: F REQuency:EXTernal <f requency>.
The following are the waveforms located in the EPRom:
EEPRom1Sine Wave
EEPRom2Triangle Wave
EEPRom3Sin(x)/x for 8.25 radians
EEPRom4Haversine
EEPRom5Square Wave
EEPRom6First ten terms of a Squa re Wave
EEPRom7First four terms of a Square Wave
EEPRom8Falling Ram p
EEPRom9First 20 ter ms of a Falling Ramp
EEPRom10Rising Ramp
EEPRom11First 20 terms of a Rising Ramp
EEPRom12White Noise
EEPRom13Modulated White Noise
EEPRom14A 3rd, 4th, 5th Harmonic Chord
EEPRom158 cycles of a linear ris ing S ine Wave
EEPRom16Positive half-cycle Sin e Wave
Chapter 3Generating Ar bitr ary Waveforms with the HP E1340A 82
HP E1340A Sweep ing and Frequency- Shift
Chapter Contents
This chapter c overs the sweeping and frequ ency-shift keying (FSK) f eatures
of the HP E1340A Arbitrary Function Generator (AFG). The chapter is
organized as follows:
Detailed information on the commands introduced in this chapter can be
found in Chapter 7 under “ Command Reference”. The commands in this
chapter are shown in their entirety (optional headers included) to help you
locate them in t h e reference.
Programming Flowchart
The flowchart on page 84 shows the commands and the command execution
order to generate standard wa ve forms. The reset (power-on) values of each
command are also noted on the flowchart. Note that the IEEE 488.2
command places the AFG into its po wer- on st at e. Th us, it may be
unnecessary to execute all of the commands on the flowchart.
*RST
83 HP E1340A Sweeping and Frequency-Shift KeyingChapter 4
Chapter 4HP E1340A Sweeping and Frequency-Shift Keying 84
Sweeping
The AFG offers linear frequency sweeping of standard wavefor ms
(i.e. sine, square, triangle, ramp) and arbitrary waveforms from 0.0 Hz to
15 M Hz for s in e wav es, and 0.0 Hz to 1 MHz for s qu are , trian gle , a n d r a m p
waves.
The comman d subsystems covered in this s ection include:
• [SOURce:]ROSCillator
• [SOURce:]FREQuency
• [SOURce:]SWEep
Sweeping
Considerations
Sweeping Using
Start and Stop
Frequenc ies
The AFG only allows for continuous repetitive sweeping. The INITiate
[:IMMediat e]
number of points in the sweep and the sweep time. For more information on
sweeping, see Chapt er 7 u nder the
The following program specifies a start frequency and a stop frequency and
continuously sweeps between 0 and 1 MHz. The program also queries the
start frequency, stop frequency, c enter frequ ency, an d frequency span to
show the relationship between them.
Using the flowchart as a guide, the steps of this program are:
1. Select the Reference Oscillator -
2. Select the Frequency Sweep Mode -
3. Set the Start Frequency -
4. Set the Stop Frequency -
command starts the sweepi ng at a fixed rate determined b y th e
The C program SMPLSWP1. C is in d irectory “CPROG”, and the
QuickBASIC pr ogra m SMPLSWP1. BAS is in directory “QBPROG” on
the exampl e program d isk HP P/N E134 0-10036.
87 HP E1340A Sweeping and Frequency-Shift KeyingChapter 4
Sweeping Using
Start and Span
Frequencies
The following program sp ec ifies a start frequency and a frequency span t o
continuously sweep from 1 kHz to 21 kHz. The program also queries the
start frequency, stop frequency, c enter frequ ency, an d frequency span to
show the relationship between them. Using the flowchart as a guide, the
steps of this program are:
1!RE-SAVE“SMPLSWP2”
2!This program sweeps a sine wave from 1 kHz to 21 kHz by
3!specifying a start frequency and a frequency span.
4!
10!Assign I/O path between IBASIC and the E1340A.
20ASSIGN @Afg TO 80910
30COM @Afg
40!
50!Set up error checking
60ON INTR 8 CALL Errmsg
70ENABLE INTR 8;2
80OUTPUT @Afg;“*CLS”
90OUTPUT @Afg; “*SRE 32”
100OUTPUT @Afg; “*ESE 60”
110!
120!Call the subprogram which resets the AFG.
130CALL Rst
140!
150!Set AFG parameters
160OUTPUT @Afg; “SOUR:FRE Q:MO DE SWE; ”;!frequ en cy mode
170OUTPUT @A fg; “:SOUR:FREQ:STAR 1E3;”;!start freq ue nc y
180OUTPUT @Afg; “:SOUR:FREQ :S PAN 20E3;”;!frequency span
190OUTPUT @A fg; “:SOUR:FUNC:SHAP SIN;”; !function
Contin ued on next page
Chapter 4HP E1340A Sweeping and Frequency-Shift Keying 88
200OUTPUT @A fg; “:SOUR:VOLT:LEV:IMM:A MPL 5V” !ampli tude
210OUTPUT @A fg;“INIT:IMM” !wait-for-arm state
220!
230!Call subprogram which queri e s sweep parameters
240CALL Query
250!
260WAI T .1!allow interrupt to be serviced
270OFF INTR 8
280END
290!
300SUB Query
310 Query: !Subprogram which queries sweep parameters
320COM @Afg
330OUTPUT @Afg;“SOUR:FREQ:STAR?”
340ENTER @Afg;Sweep1$
350OUTPUT @Afg;“SOUR:FREQ:ST O P?”
360ENTER @Afg;Sweep2$
370OUTPUT @Afg;“SOUR:FREQ:CENT?”
380ENTER @Afg;Sweep3$
390OUTPUT @Afg;“SOUR:FREQ: SPA N ?”
400ENTER @Afg;Sweep4$
410PRINT “START = ”;Sweep1$,“STOP = ”;Sweep2$
420PRINT
430PRINT “CENTER = ”;Sweep3$,“SPAN = ”;Sweep4$
440SUBEND
450!
460SUB Rst
•
•
530SUB Errmsg
•
•
The start, stop, center, and span values returned a r e:
START = +1.000000000E+003STOP = +2.100000000E+004
CENTER = +1.100000000E+004SPAN = +2.000000000E+004
C and QuickBASIC
Programs
The C program SMPLSWP2. C is in d irectory “CPROG”, and the
QuickBASIC pr ogra m SMPLSWP2. BAS is in directory “QBPROG” on
the exampl e program d isk HP P/N E134 0-10036.
89 HP E1340A Sweeping and Frequency-Shift KeyingChapter 4
Sweep Points Vs.
Sweep Time
To demonstrate the relationship between the number of points (frequencies)
in a frequency sweep and the time of the sweep, the following program uses
100 frequency points to continuously sweep from 5 kHz to 15 kHz in 0.5
seconds. (See “Program Comments” to determine the sweep time.)
Using the flowchart as a guide, the steps of this program are:
1. Select the Frequency Sweep Mode -
[SOURce:]FREQuency:MODE SWEep
2. Set the Start Frequency -
[SOURce:]FREQuenc y:STA Rt <start_f req >
3. Set the Stop Frequency -
[SOURce:]FREQuenc y:STOP <stop_f req>
4. Set the Number of Points (frequencies) in the Frequency Sweep -
1!RE-SAVE“SWP_P VST ”
2!This program sweeps a sine wave from 5 kHz to 15 kHz
3!in 0.5 seconds to demonstrate how to set the sweep time.
4!
10!Assign I/O path between IBASIC and the E1340A.
20ASSIGN @Afg TO 80910
30COM @Afg
40!
50!Set up error checking
60ON INTR 8 CALL Errmsg
70ENABLE INTR 8;2
80OUTPUT @Afg;“*CLS”
90OUTPUT @Afg; “*SRE 32”
100OUTPUT @Afg; “*ESE 60”
110!
120!Call the subprogram which resets the AFG.
130CALL Rst
Contin ued on next page
Chapter 4HP E1340A Sweeping and Frequency-Shift Keying 90
140!
150!Set AFG parameters
160OUTPUT @Afg; “SOUR:FRE Q:MO DE SWE; ”;!frequ en cy mode
170OUTPUT @A fg; “:SOUR:FREQ:STAR 5E3;”;!start freq ue nc y
180OUTPUT @Afg; “:SOUR:FREQ :S TO P 15E3; ”;!stop fre que nc y
190OUT P UT @Afg;“:SOUR:SWE:PO IN 100;”; !sweep points
200OUT P U T @Afg; “:SOUR:SW E:TIM E .495;”; !sweep time
210OUTPUT @A fg; “:SOUR:FUNC:SHAP SIN;”; !function
220OUTPUT @A fg; “:SOUR:VOLT:LEV:IMM:A MPL 5V” !ampli tude
230OUTPUT @A fg;“INIT:IMM” !wait-for-arm state
240!
250WAI T .1!allow interrupt to be serviced
260OFF INTR 8
270END
280!
290SUB Rst
•
•
360SUB Errmsg
•
•
C and QuickBASIC
Programs
The C program SWP_PVST.C is in directory “CPROG”, and the
QuickBASIC pro gra m SWP_P VST.BAS is in direc tory “QBPRO G ” on the
exampl e program d isk HP P/N E1340-10036.
91 HP E1340A Sweeping and Frequency-Shift KeyingChapter 4
Frequency-Shift Keying
Frequency-shift keying (FSK) changes the frequency of the output
waveform or sample rate based on the signal level of the frequen cy-shift
keying co ntrol source. FSK frequ enc ies can ra nge from 0.0 Hz to
20 MHz. The frequency-shift keying control source is applied to the front
panel “Aux In” BNC Connector.
The comman d subsystems associated with frequency-shift keying in clude:
• [SOURce:]ROSCillator
• [SOURce:]FREQuency
- FSK mode and related c omma nds
Program Exa mpleThe following program shows the basic steps involved in setting up and
using the frequency-shift keying function of the AFG. A 5V, 1 kHz square
wave control signal is applied to the AFG’s front panel “FSK” port. Output
frequenci es of 20 kHz and 10 k H z occur as the level of the 1 kHz signal
changes.
Using the flowchart as a guide, the steps of this program are:
Chapter 4HP E1340A Sweeping and Frequency-Shift Keying 92
HP IBASIC (FSK1)
1!RE-SAVE“FSK1”
2!This program sets up frequency-shift keying using the AFG’s "Aux In"
3!port as the control source. A high signal on the port selec ts the
4!first frequency. A low signal on the port selects the second frequency.
5!
10!Assign I/O path between IBASIC and the E1340A.
20ASSIGN @Afg TO 80910
30COM @Afg
40!
50!Set up error checking
60ON INTR 8 CALL Errmsg
70ENABLE INTR 8;2
80OUTPUT @Afg;“*CLS”
90OUTPUT @Afg; “*SRE 32”
100OUTPUT @Afg; “*ESE 60”
110!
120!Call the subprogram which resets the AFG.
130CALL Rst
140!
150!Set AFG parameters
160OUTPUT @A fg;“SOUR:ROSC:SO UR INT;”;!reference oscillator
170OUTPUT @A fg; “:SOUR:F REQ:MODE FSK ;”;!frequency mode
180OUTPUT @Afg; “:SOUR:FREQ :F SK 10E3, 20E3; ”;!FSK frequ en cie s
190OUTPUT @A fg; “:SOUR:FUNC:SHAP SIN;”;!functi on
200OUTPUT @A fg; “:SOUR:VOLT:LEV:IMM:A MPL 5V” !ampli tude
210OUTPUT @A fg;“INIT:IMM”!wait-for-arm state
220!
230WAI T .1!allow interrupt to be serviced
240OFF INTR 8
250END
260!
270SUB Rst
The C program F SK1.C is in direct ory “CPROG ”, and the QuickBASIC
program FSK1.BAS is in directory “QBPROG” on the example program
disk HP P/N E1340-10 036.
93 HP E1340A Sweeping and Frequency-Shift KeyingChapter 4
Program Comments
The following information is associated with sweeping and frequency-shift
keying. Include d are de tails on t he operation of these functions, and on the
various modes, ranges, etc., used in the programs in this c hapt er.
Reference
Oscillator Sources
AFG Frequenc y
Modes
There are two reference oscillator sources f or t he AFG which are selected
[SOURce:]ROSCillator:SOURce command:
by the
EXTernal: The AFG’s front panel “Aux In” BNC .
INTernal: The internal 42.94967296 MHz oscillator.
INTernal ref eren ce os c il lat or gives a fre quency resolut ion of .01 Hz.
The
INTernal is the default reference oscillator source. Thus, in m a n y programs,
the source is not specified.
There are three frequency “modes” available in the AFG. The modes
selected by the
CW|FIXed: Single frequency mode.
FSKey: Frequency shift keying mode.
SWEep: Frequency sweep mode.
[SOURce:]FREQuency:MODE command are:
Frequenc y Poi ntsThe number of frequencies g enerated (points) in a frequ ency sweep can be
from 2 to 1,073,741,824. Th e defau lt nu mber is 1001. Th e number of points
is set with the
only.
SOURce:SWEep:PO INts command and applies to sweeps
Specifying a
Sweep Time
The sweep time (set by SOURce:SWEep:TI ME) is t h e period from the
generation of the first frequency in the sweep or list to the generation of
the last fr equency (see below).
The duration (t) of each frequency is :
specified s weep time /(frequency p oints - 1)
For multiple sweeps or repetitions through the list, the duration of the last
frequency (f
repetitions, the duration of f
Sweep time
) is also t. To maintain a constant ra te between sweeps or
n
must be accounted for as follows:
n
specified
= Sweep repetition time
* ((points - 1)/points)
desired
Chapter 4HP E1340A Sweeping and Frequency-Shift Keying 94
HP E1340A Arming and Marker Outputs
Chapter Contents
Chapter 5
This chapter shows you how to arm and gate the HP E1340A AFG in order
to start and advance standard and a rbitra ry waveforms. This chapter also
shows how generate the different marker outputs at the "Aux Out" BNC
connector. The sections of this chapter include:
• The ARM Configurat i on . . . . . . . . . . . . . . . . . . . . . . . . . . . . Page 95
• Pro g ram Commen t s. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Pag e 107
The ARM Configuration
The HP E1340A AFG uses an ARM triggering configuration to output t he
standard and arbitrary waveforms. When initiated, an arm signal enables the
AFG to output the waveforms each time an arm signal is received.
The ARM StatesThe AFG operates within three states: Idle, Wait-for-arm, and Instrument
Action.
When power is applied, or following a reset or an abort, the AFG is in the
Idle state. The AFG is set to the Wait-for-arm state with the
INITiate[:IMMediate] command.
The AFG starts instrument action when it receives an arm from the
specified arm source.
After the instrument action (waveform is output) occurs, the AFG returns to
the Wait-for-arm state until the next arm occurs. When the specified arm
count has been reached, the AFG returns to the Idle state.
95 HP E1340A Arming and Marker OutputsChapter 5
Initiating Waveforms
After the AFG has been configured to output the desired waveform, the
AFG is set to the Wait-for-arm state with the command :
INITiate[:IMMediate]
Arming the AFG
INITia te
executed before a waveform is output :
If INITi ate[ :IMM edi ate] is executed when the AFG is not in the Idle state,
error 213, "Init ignored " is generat ed.
In order for the AFG to output a waveform, it must be armed. The
information in this section covers the commands a n d programm ing
sequence us ed to arm the AFG f or fixed frequency waveform generation.
is an uncoupled command and is gene r a lly the last command
100SUB Sine_wave
110 Sine_wave: !Subprogram which outputs a sine wave
120COM @Afg
130OUTPUT @Afg;“SOUR:FREQ:FIX 1E3;”;!frequency
140OUTPUT @Afg;“:SOUR:FUNC:S HAP SIN; ”; !function
150OUTPUT @Afg;“:SOUR:VO LT :LEV:IMM:AMPL 5 V ”!ampli tude
160OUTPUT @Afg;“INIT:IMM” !wait-for-arm state
170SUBEND
Arming CommandsThe commands which arm the AFG a llow you to specify the following:
• the arm source
• the slope of an external arm signal
• the number of arms per INITi ate[: IMMedi ate] command
• the number of waveform cycles per arm
The arming commands i nclude:
ARM
[:STARt|SEQuence[1]]
[:LAYer[1]]
:COUNt <
:LAYer2
:COUNt <
:SLOPe <
:SOURce <
The arming commands for continuous waveforms are coupled commands.
number>
number>
edge >
source>
Chapter 5HP E1340A Arming and Marker Outputs 96
NoteDetailed informat ion on the commands introduced in this chapter can be
found in Chapt er 7 - “Command Ref eren ce”. The commands in this chapter
are shown in their entirety (optional headers included) to help you locate
them in the reference.
Setting th e
Arm Source
The following program sh ows how to sel ect the source which arms the
AFG. The progra m selects the AFG’s "Aux In" BNC connector as the
arming source. When the AFG receiv es as arming signal, it outputs a
10 kHz, 1 Vpp squar e wa v e.
1!RE-SAVE“EXT_ARM”
2!This program arms the AFG with an external signal appl i ed to th e
3!AFG’s "Aux In" port. W hen arm ed, the AF G out puts 100 cycles
4!of a 10 kHz, 1 Vpp square wave.
5!
10!Assign I/O path between IBASIC and the E1340A.
20ASSIGN @Afg TO 80910
30COM @Afg
40!
50!Set up error checking
60ON INTR 8 CALL Errmsg
70ENABLE INTR 8;2
80OUTPUT @Afg;“*CLS”
90OUTPUT @Afg; “*SRE 32”
100OUTPUT @Afg; “*ESE 60”
110!
120!Call the subprogram which resets the AFG.
130CALL Rst
140!
150!Set AFG parameters
160OUTPUT @A fg; “SOUR:FRE Q:MO DE F I X;”;!frequenc y mod e
170OUTPUT @A fg; “:SOUR:F REQ:FIX 1E3;”;!fre quency
180OUTPUT @Afg; “:SOUR:FUNC:S HAP SQ U;”; !func tion
190OUTPUT @Afg; “:SOUR:VO LT :LEV:IMM:AMPL 1VPP ;”; !amplit ude
200OUTPUT @Afg; “:ARM:STAR: LAY2:SOUR EXT;”; !arm source
210OUTPUT @A fg; “:ARM:STAR:LAY2:COUN INF; ”; !arm count
220OUTPUT @Afg;“:ARM:STAR: LAY1: COUN 1E3” !cycle count
230OUTPUT @A fg;“INIT:IMM” !wait-for-arm state
240!
250WAI T .1!allow interrupt to be serviced
260OFF INTR 8
270END
280!
290SUB Rst
•
•
360SUB Errmsg
•
•
C and QuickBASIC
Programs
The C program EXT_ARM.C is in directory “CPROG”, and the
QuickBASIC pro gra m EXT_ ARM. BAS is in dire c t ory “QBPROG” on the
exampl e program d isk HP P/N E1340-10036.
Chapter 5HP E1340A Arming and Marker Outputs 98
Setting the Arm
and Wavef o rm
Cycle Count
The following program sh ows you h ow to set the nu mb er of arms the AFG
is to receive before returning to the Idle state, and how to set the number of
waveform cycles (repetitions) per arm.
The program sets a five cycle burst that occurs each time the AFG receives
an external arm. The r e will be about a 50 msec delay b et ween a trans istion
on the "Aux In" connector and the output switchin g.
7. Set th e Numb er of Wave form Cycles (Burst Count) -
ARM[:STARt][:LAYer[1]]:COUNt <number>
8. Place the AFG in the Wait-for-arm State -
INITiate[:IMMediate]
99 HP E1340A Arming and Marker OutputsChapter 5
HP IBASIC (BURST)
1!RE-SAVE“BURST”
2!This program sets the arm count to infini ty and the waveform
3!repetition count to 5. The arm source is set to external and a
4!1 kHz square wave is applied to "Aux In" connector. The AFG outputs
5!a 5 cycle burst on each positive edge of the external arm signal.
6!
10!Assign I/O path between IBASIC and the E1340A.
20ASSIGN @Afg TO 80910
30COM @Afg
40!
50!Set up error checking
60ON INTR 8 CALL Errmsg
70ENABLE INTR 8;2
80OUTPUT @Afg;“*CLS”
90OUTPUT @Afg; “*SRE 32”
100OUTPUT @Afg; “*ESE 60”
110!
120!Call the subprogram which resets the AFG.
130CALL Rst
140!
150!Set AFG parameters
160OUTPUT @Afg;“SOUR:FREQ: FI X 10E3;”;!frequency
170OUTPUT @A fg; “:SOUR:FUNC:SHAP SIN;”; !function
180OUTPUT @Afg; “:SOUR:VO LT :LEV:IMM:AMPL 2.5V PP; ”; !ampli tude
190OUTPUT @Afg; “:ARM:STAR: LAY2:SOUR EXT;”; !arm source
200OUTPUT @A fg; “:ARM:STAR:LAY2:SLOP POS ;”; !arm slope
210OUTPUT @A fg; “:ARM:STAR:LAY2:COUN INF; ”; !arm count
220OUTPUT @A fg; “:ARM:STAR:LAY1:COUN 5” !cyc le co unt
230OUTPUT @A fg;“INIT:IMM” !wait-for-arm state
240!
250WAI T .1!allow interrupt to be serviced
260OFF INTR 8
270END
280SUB Rst
•
•
360SUB Errmsg
•
•
C and QuickBASIC
Programs
The C program BURST.C is in directory “CPROG”, and the QuickBASIC
program BURST.BAS is in directory “QBPROG” on the example program
disk HP P/N E1340-10 036.
Chapter 5HP E1340A Arming and Marker Outputs 100
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.