Programming Guide (With Remote Operation and File Downloads) Agilent Technologies Signal Generators This guide applies to the following signal generator models: N5181A/82A MXG RF Signal Generators N5183A MXG Microwave Analog Signal Generator E4428C/38C ESG RF Signal Generators E8663B RF Analog Signal Generator E8257D/67D PSG Microwave Signal Generators Due to our continuing efforts to improve our products through firmware and hardware revisions, signal generator design and operation may vary from descr
Notice The material contained in this document is provided “as is”, and is subject to being changed, without notice, in future editions. Further, to the maximum extent permitted by applicable law, Agilent disclaims all warranties, either express or implied with regard to this manual and to any of the Agilent products to which it pertains, including but not limited to the implied warranties of merchantability and fitness for a particular purpose.
Contents 1 Getting Started with Remote Operation Programming and Software/Hardware Layers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2 Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3 IO Libraries and Programming Languages . Agilent IO Libraries Suite . . . . . . . . Windows NT and Agilent IO Libraries Selecting IO Libraries for GPIB . . . . . Selecting IO Libraries for LAN . . . . .
Contents Selecting IO Libraries for RS- 232 Setting Up the RS- 232 Interface . Verifying RS- 232 Functionality . . Character Format Parameters . . . If You Have Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Contents Generating a Swept Signal Using VISA and Visual C++ . . . . . . . . Saving and Recalling States Using VISA and C. . . . . . . . . . . . . . Reading the Data Questionable Status Register Using VISA and C . Reading the Service Request Interrupt (SRQ) Using VISA and C . . Using 8757D Pass- Thru Commands (PSG with Option 007 Only) . . LAN Programming Interface Examples . . . . . . VXI- 11 Programming . . . . . . . . . . . . . . . VXI- 11 Programming Using SICL and C++ .
Contents Data Questionable Modulation Status Group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 Data Questionable Calibration Status Group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 Data Questionable BERT Status Group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 5 Creating and Downloading Waveform Files Overview of Downloading and Extracting Waveform Files . . . . . . . . . . . . . . . . . . . . . . . . 184 Waveform Data Requirements . . .
Contents Verifying the Waveform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226 Building and Playing Waveform Sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226 Using the Download Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227 Downloading E443xB Signal Generator Files E443xB Data Format. . . . . . . . . . . . . . Storage Locations for E443xB ARB files . SCPI Commands. . . . . . . . . . .
Contents SCPI Command for a Block Data Download . . . . . . . . . . . . . . . . . . Selecting a Downloaded PRAM File as the Data Source. . . . . . . . . . . Modulating and Activating the Carrier . . . . . . . . . . . . . . . . . . . . . . Storing a PRAM File to Non- Volatile Memory and Restoring to Volatile Extracting a PRAM File. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Modifying PRAM Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Documentation Overview Installation Guide • • • • • • • Safety Information Receiving the Instrument Environmental & Electrical Requirements Basic Setup Accessories Operation Verification Regulatory Information User’s Guide • • • • Instrument Overview Front Panel Operation Security Basic Troubleshooting Programming Guide • Remote Operation • Status Registers • Creating & Downloading Files SCPI Reference • SCPI Basics • Command Descriptions • Programming Command Compatibility Service Guide • • • •
x Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
1 Getting Started with Remote Operation • “Programming and Software/Hardware Layers” on page 2 • “Interfaces” on page 3 • “IO Libraries and Programming Languages” on page 5 • “Using the Web Browser” on page 10 • “Preferences” on page 16 • “Error Messages” on page 19 Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide 1
Getting Started with Remote Operation Programming and Software/Hardware Layers Programming and Software/Hardware Layers Agilent MXG, ESG, PSG, and E8663B signal generators support the following interfaces: Instrument Interfaces Supported Agilent MXG GPIB, LAN, and USB 2.0 Agilent E8663Ba GPIB, LAN, and ANSI/EIA232 (RS- 232) serial connection Agilent ESG GPIB, LAN, and ANSI/EIA232 (RS- 232) serial connection Agilent PSGa GPIB, LAN, and ANSI/EIA232 (RS- 232) serial connection a.
Getting Started with Remote Operation Interfaces Figure 1-1 Software/Hardware Layers Interfaces GPIB GPIB is used extensively when a dedicated computer is available for remote control of each instrument or system. Data transfer is fast because GPIB handles information in bytes with data transfer rates of up to 8 MBps.
Getting Started with Remote Operation Interfaces LAN Data transfer using the LAN is fast as the LAN handles packets of data. The single cable distance between a computer and the signal generator is limited to 100 meters (100Base- T and 10Base- T). The Agilent MXG is capable of 100Base- T LAN communication. The ESG, PSG and E8663B are designed to connect with a 10Base- T LAN. Where auto- negotiation is present, the ESG, PSG, and E8663B can connect to a 100Base- T LAN, but communicate at 10Base- T speeds.
Getting Started with Remote Operation IO Libraries and Programming Languages IO Libraries and Programming Languages The IO libraries is a collection of functions used by a programming language to send instrument commands and receive instrument data. Before you can communicate and control the signal generator, you must have an IO library installed on your computer.
Getting Started with Remote Operation IO Libraries and Programming Languages NOTE Before setting the LAN interface, the signal generator must be configured for VXI- 11 SCPI. Refer to “Configuring the VXI- 11 for LAN (Agilent MXG)” on page 29 or “Configuring the VXI- 11 for LAN (ESG/PSG/E8663B)” on page 30. Refer to the Agilent IO Libraries Suite Help documentation for details about this software.
Getting Started with Remote Operation IO Libraries and Programming Languages available with the Agilent IO Libraries versions M and earlier, to send commands to the signal generator. If the interface you want to use does not appear in the VISA Assistant then you must manually configure the interface. See the Manual VISA Configuration section below. Refer to the VISA Assistant Help menu and the Agilent VISA User’s Manual (available on Agilent’s website) for more information.
Getting Started with Remote Operation IO Libraries and Programming Languages VISA VISA is an IO library used to develop IO applications and instrument drivers that comply with industry standards. It is recommended that the VISA library be used for programming the signal generator. The NI- VISA and Agilent VISA libraries are similar implementations of VISA and have the same commands, syntax, and functions. The differences are in the lower level IO libraries; NI- 488.2 and SICL respectively.
Getting Started with Remote Operation IO Libraries and Programming Languages Programming Languages Along with Standard Commands for Programming Instructions (SCPI) and IO library functions, you use a programming language to remotely control the signal generator. Common programming languages include: • • • • • • • • • C/C++ C# MATLAB® (MATLAB is a registered trademark of The MathWorks.) HP Basic LabView Java (Java is a U.S. trademark of Sun Microsystems, Inc.
Getting Started with Remote Operation Using the Web Browser Using the Web Browser The instrument can be accessed through a standard web browser, when it is connected to the LAN. To access through the web browser, enter the instrument IP address as the URL in your browser.
Getting Started with Remote Operation Using the Web Browser Enabling the Signal Generator Web Server NOTE Javascript or Active Scripts must be enabled to use the web front panel controls. 1. Turn on the Web server as shown below. Agilent MXG Web Server On If necessary toggle Web Server to On. For details on each key, use the key help. Refer to “Getting Help (Agilent MXG)” on page 18 and the User’s Guide. For additional SCPI command information, refer to the SCPI Command Reference.
Getting Started with Remote Operation Using the Web Browser 2. Launch the PC or workstation web browser. 3. In the web browser address field, enter the signal generator’s IP address. For example, http://101.101.101.101 (where 101.101.101.101 is the signal generator’s IP address). The IP (internet protocol) address can change depending on the LAN configuration (see “Using LAN” on page 28). 4. On the computer’s keyboard, press Enter. The web browser displays the signal generator’s homepage. 5.
Getting Started with Remote Operation Using the Web Browser FTP enables the transfer of files between the instrument and a computer. The FTP access button provides drag- and- drop file capability. The FTP access softkey opens to show the folders containing the signal generator’s memory catalog files. Use the FTP window to drag and drop files from the FTP page to your computer.
Getting Started with Remote Operation Using the Web Browser LAN Configuration System Defaults (Agilent MXG) NOTE The instrument’s LAN configuration system information can be found on the signal generator’s homepage and on the signal generator. Refer to “Enabling the Signal Generator Web Server” on page 11 and to “Displaying the LAN Configuration Summary (Agilent MXG)” on page 15.
Getting Started with Remote Operation Using the Web Browser Table 1-1 LAN Configuration Summary Values Parameter Default TCP Keep Alive: On Domain Name:a TCP Keep Alive Timeout: 1800.0 sec Signal Generator Web Server Interface Description: Agilent () SICL Interface Nameb: gpib0 Web Password: agilent a.The Domain Name defaults to a null field. b.
Getting Started with Remote Operation Preferences Preferences The following commonly- used manual command sections are included here: “Configuring the Display for Remote Command Setups (Agilent MXG)” on page 17 “Configuring the Display for Remote Command Setups (ESG/PSG/E8663B)” on page 17 “Getting Help (Agilent MXG)” on page 18 “Setting the Help Mode (ESG/PSG/E8663B)” on page 18 “Setting the Help Mode (ESG/PSG/E8663B)” on page 18 16 Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programmin
Getting Started with Remote Operation Preferences Configuring the Display for Remote Command Setups (Agilent MXG) Select Update in Remote until On is highlighted. SCPI commands: :DISPlay:REMote ON|OFF|1|0 :DISPlay:REMote? For details on each key, use the key help (described in User’s Guide). Configuring the Display for Remote Command Setups (ESG/PSG/E8663B) SCPI commands: :DISPlay:REMote ON|OFF|1|0 :DISPlay:REMote? Select Update in Remote until On is highlighted.
Getting Started with Remote Operation Preferences Getting Help (Agilent MXG) When you press Help: Help displays for the next key you press. Use the cursor keys, Page Up, Page Down, and the RPG knob to scroll the help text. Then press Cancel to close the help window or press any other key to close the help window and execute that key. For details on each key, use the key help (described in User’s Guide).
Getting Started with Remote Operation Error Messages Error Messages If an error condition occurs in the signal generator, it is reported to both the SCPI (remote interface) error queue and the front panel display error queue. These two queues are viewed and managed separately; for information on the front panel display error queue, refer to the User’s Guide.
Getting Started with Remote Operation Error Messages Error Message Types Events generate only one type of error. For example, an event that generates a query error will not generate a device- specific, execution, or command error. Query Errors (–499 to –400) indicate that the instrument’s output queue control has detected a problem with the message exchange protocol described in IEEE 488.2, Chapter 6. Errors in this class set the query error bit (bit 2) in the event status register (IEEE 488.2, section 11.
2 Using IO Interfaces Using the programming examples with GPIB, LAN, RS- 232, and USB interfaces: • “Using GPIB” on page 22 • “Using LAN” on page 28 • “Using RS- 232 (ESG, PSG, and E8663B Only)” on page 45 • “Using USB (Agilent MXG)” on page 53 Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide 21
Using IO Interfaces Using GPIB Using GPIB GPIB enables instruments to be connected together and controlled by a computer. GPIB and its associated interface operations are defined in the ANSI/IEEE Standard 488.1- 1987 and ANSI/IEEE Standard 488.2- 1992. See the IEEE website, http://www.ieee.org, for details on these standards. The following sections contain information for installing a GPIB interface card or NI- GPIB interface card for your PC or UNIX- based system.
Using IO Interfaces Using GPIB Interface Type Operating System IO Library Languages Backplane/ BUS Max IO (kB/sec) Buffering Agilent USB/GPIB Interface Converter for PC- Based Systems Agilent 82350B for PCI bus computers Windows 98(SE)/ME/2000 /XP VISA / SICL C/C++, Visual Basic, Agilent VEE, HP Basic for Windows PCI 32 bit > 900 Built- in NI- GPIB Interface Card for PC- Based Systems National Instruments PCI- GPIB Windows 95/98/2000/ ME/NT VISA NI- 488.
Using IO Interfaces Using GPIB Set Up the GPIB Interface For the Agilent MXG refer to Figure 2- 1 and for the ESG, PSG, and E8663B, Figure 2- 2 on page 24. Figure 2-1 Setting the GPIB Address on the Agilent MXG SCPI commands: :SYSTem:COMMunicate:GPIB:ADDRess :SYSTem:COMMunicate:GPIB:ADDRess? Default address: 19 Range: 0–30 For details on each key, use the key help. Refer to “Getting Help (Agilent MXG)” on page 18 and the User’s Guide.
Using IO Interfaces Using GPIB Connect a GPIB interface cable between the signal generator and the computer. (The following table lists cable part numbers.) Model Length 10833A 10833B 1 meter 2 meters 10833C 10833D 10833F 10833G 4 meters .5 meter 6 meters 8 meters Verify GPIB Functionality To verify GPIB functionality, use the VISA Assistant, available with the Agilent IO Library or the Getting Started Wizard available with the National Instrument IO Library.
Using IO Interfaces GPIB Programming Interface Examples GPIB Programming Interface Examples NOTE The portions of the programming examples discussed in this section are taken from the full text of these programs that can be found in Chapter 3, “Programming Examples.” • “Interface Check using HP Basic and GPIB” on page 26 • “Interface Check Using NI- 488.
Using IO Interfaces GPIB Programming Interface Examples #include "stdafx.h" #include #include "windows.h" #include "Decl-32.
Using IO Interfaces Using LAN Using LAN The Agilent MXG is capable of 100Base- T LAN communication. The ESG, PSG, and E8663B are designed to connect with a 10Base- T LAN. Where auto- negotiation is present, the ESG, PSG, and E8663B can connect to a 100Base- T LAN, but communicate at 10Base- T speeds. For more information refer to http://www.ieee.org.
Using IO Interfaces Using LAN Setting Up the LAN Interface For LAN operation, the signal generator must be connected to the LAN, and an IP address must be assigned to the signal generator either manually or by using DHCP client service. Your system administrator can tell you which method to use. (Most modern LAN networks use DHCP.) NOTE Verify that the signal generator is connected to the LAN using a 100Base- T LAN or 10Base- T LAN cable.
Using IO Interfaces Using LAN Configuring the VXI-11 for LAN (ESG/PSG/E8663B) Utility > GPIB/RS-232 LAN For details on each key, use the Key and Data Field Reference. For additional SCPI command information, refer to the SCPI Command Reference. NOTE To communicate with the signal generator over the LAN, you must enable the VXI-11 SCPI service. Select VXI-11 until On is highlighted. (Default condition is On.) Use a 10Base-T LAN cable to connect the signal generator to the LAN.
Using IO Interfaces Using LAN Manually Configuring the Agilent MXG LAN Utility > IO Config Your hostname can be up to 20 characters long. SCPI commands: :SYSTem:COMMunicate:LAN:CONFig MANual :SYSTem:COMMunicate:LAN:CONFig? For details on each key, use the key help (described in User’s Guide). For additional SCPI command information, refer to the SCPI Command Reference.
Using IO Interfaces Using LAN DHCP Configuration If the DHCP server uses dynamic DNS to link the hostname with the assigned IP address, the hostname may be used in place of the IP address. Otherwise, the hostname is not usable. For more information on the DHCP configuration, refer to “Configuring the DHCP LAN (Agilent MXG)” on page 33 or “Configuring the DHCP LAN (ESG/PSG/E8663B)” on page 33.
Using IO Interfaces Using LAN Configuring the DHCP LAN (Agilent MXG) AUTO (DHCP/Auto-IP): Request a new IP address in the following sequence: 1) from the DHCP (server-based LAN), 2) Auto-IP (private network without a network administrator) or if neither is available, 3) Manual setting is selected. DHCP: Request a new IP address from the DHCP server each power cycle. Confirming this action configures the signal generator as a DHCP client.
Using IO Interfaces Using LAN Setting up Private LAN You can connect the Agilent MXG, ESG, PSG or E8663B directly to a PC using a crossover cable. To do this, you should either choose to set IP addresses of the PC and signal generator to differ only in the last digit (example: PC’s IP: 1.1.1.1 and Signal generator’s IP: 1.1.1.2); or you can use the DHCP feature or Auto- IP feature if your PC supports them. For more information go to www.agilent.
Using IO Interfaces Using LAN For additional information on troubleshooting your LAN connection, refer to the Help in the Agilent IO Libraries and documentation for LAN connections and problems. Table 2-1 Ping Responses Normal Response for UNIX A normal response to the ping command will be a total of 9 or 10 packets received with a minimal average round- trip time. The minimal average will be different from network to network. LAN traffic will cause the round- trip time to vary widely.
Using IO Interfaces Using LAN NOTE The following sections are specific to Agilent IO Libraries versions M and earlier and apply only to the Windows NT platform. Using VISA Assistant Use the VISA Assistant, available with the Agilent IO Library versions M and earlier, to communicate with the signal generator over the LAN interface. However, you must manually configure the VISA LAN client. Refer to the Help menu for instructions on configuring and running the VISA Assistant program. 1.
Using IO Interfaces Using LAN Figure 2-3 IO Config Form (Windows NT) Check to see that the Default Protocol is set to Automatic. 1. Run the IO Config program 2. Click on TCPIP in the Configured Interfaces text box. If there is no TCPIP0 in the box, follow the steps shown in the section “Using VISA Assistant” on page 36 3. Click the Edit button. 4. Click the radio button for AUTO (automatically detect protocol). 5. Click OK, OK to end the IO Config program.
Using IO Interfaces Using LAN Configuring for VXI-11 The Agilent IO library has a program, IO Config, that is used to setup the computer/signal generator interface for the VXI- 11 protocol. Download the latest version of the Agilent IO library from the Agilent website. Refer to the Agilent IO library user manual, documentation, and Help menu for information on running the IO Config program and configuring the VXI- 11 interface. Use the IO Config program to configure the LAN client.
Using IO Interfaces Using LAN Using Sockets LAN NOTE Users with Windows XP operating systems and newer can use this section to better understand how to use the signal generator with port settings. For more information, refer to the help software of the IO libraries being used. Sockets LAN is a method used to communicate with the signal generator over the LAN interface using the Transmission Control Protocol/Internet Protocol (TCP/IP).
Using IO Interfaces Using LAN NOTE The Windows 2000 operating systems use a command prompt style interface for the Telnet client. Refer to the Figure 2- 7 on page 42 for an example of this interface. Windows XP operating systems and newer can use this section to better understand how to use the signal generator with port settings. For more information, refer to the help software of the IO libraries being used.
Using IO Interfaces Using LAN Using Telnet On a PC With a Host/Port Setting Menu GUI 1. On your PC, click Start > Run. 2. Type telnet then click the OK button. The Telnet connection screen will be displayed. 3. Click on the Connect menu then select Remote System. A connection form is displayed. See Figure 2- 5. 4. Enter the hostname, port number, and TermType then click Connect. • Host Name−signal generator’s IP address or hostname • Port−5023 • Term Type−vt100 5. At the SCPI> prompt, enter SCPI commands.
Using IO Interfaces Using LAN Figure 2-7 Telnet 2000 Window The Standard UNIX Telnet Command Synopsis telnet [host [port]] Description This command is used to communicate with another host using the Telnet protocol. When the command telnet is invoked with host or port arguments, a connection is opened to the host, and input is sent from the user to the host. Options and Parameters The command telnet operates in character- at- a- time or line- by- line mode.
Using IO Interfaces Using LAN When you connect to the signal generator, the UNIX window will display a welcome message and a SCPI command prompt. The instrument is now ready to accept your SCPI commands. As you type SCPI commands, query results appear on the next line. When you are done, break the Telnet connection using an escape character. For example, Ctrl-],where the control key and the ] are pressed at the same time. The following example shows Telnet commands: $ telnet myinstrument 5023 Trying....
Using IO Interfaces Using LAN Figure 2-8 FTP Screen The following steps outline a sample FTP session from the MS- DOS Command Prompt: 1. On the PC click Start > Programs > Command Prompt. 2. At the command prompt enter: ftp < IP address > or < hostname > 3. At the user name prompt, press enter. 4. At the password prompt, press enter. You are now in the signal generator’s user directory. Typing help at the command prompt will show you the FTP commands that are available on your system. 5.
Using IO Interfaces Using RS-232 (ESG, PSG, and E8663B Only) Using RS-232 (ESG, PSG, and E8663B Only) NOTE The RS- 232 serial interface is available on the ESG signal generators. The PSG and E8663B’s AUXILIARY INTERFACE connector is compatible with ANSI/EIA232 (RS- 232) serial connection but GPIB and LAN are recommended for making faster measurements and when downloading files. Refer to the User’s Guide. The RS- 232 serial interface can be used to communicate with the signal generator.
Using IO Interfaces Using RS-232 (ESG, PSG, and E8663B Only) SICL Agilent SICL can be used to develop applications for the RS- 232 interface. See Agilent’s website for information on SICL. Setting Up the RS-232 Interface 1. Setting the RS- 232 Interface Baud Rate (ESG/PSG/E8663B) Select a baud rate of 9600. SCPI commands: :SYSTem:COMMunicate:SERial:BAUD :SYSTem:COMMunicate:SERial:BAUD? For details on each key, use the key help (described in User’s Guide).
Using IO Interfaces Using RS-232 (ESG, PSG, and E8663B Only) 2. Setting the RS- 232 Echo Softkey Toggle RS-232 Echo Off On until Off is highlighted. Selecting On echoes or returns characters sent to the signal generator and prints them to the display. SCPI commands: :SYSTem:COMMunicate:SERial:ECHO ON|OFF :SYSTem:COMMunicate:SERial:ECHO? For details on each key, use the key help (described in User’s Guide). For additional SCPI command information, refer to the SCPI Command Reference. 3.
Using IO Interfaces Using RS-232 (ESG, PSG, and E8663B Only) Verifying RS-232 Functionality You can use the HyperTerminal program available on your computer to verify the RS- 232 interface functionality. To run the HyperTerminal program, connect the RS- 232 cable between the computer and the signal generator and perform the following steps: 1. On the PC click Start > Programs > Accessories > Communications > HyperTerminal. 2. Select HyperTerminal. 3.
Using IO Interfaces Using RS-232 (ESG, PSG, and E8663B Only) Character Format Parameters The signal generator uses the following character format parameters when communicating via RS- 232: • Character Length: Eight data bits are used for each character, excluding start, stop, and parity bits. • Parity Enable: Parity is disabled (absent) for each character. • Stop Bits: One stop bit is included with each character. If You Have Problems 1.
Using IO Interfaces RS-232 Programming Interface Examples RS-232 Programming Interface Examples NOTE • • • • The portions of the programming examples discussed in this section are taken from the full text of these programs that can be found in Chapter 3, “Programming Examples.
Using IO Interfaces RS-232 Programming Interface Examples Interface Check Using VISA and C This portion of the example program “Interface Check Using VISA and C” on page 51, uses VISA library functions to communicate with the signal generator. The program verifies that the RS- 232 connections and interface are functional. In this example the COM2 port is used. The serial port is referred to in the VISA library as ‘ASRL1’ or ‘ASRL2’ depending on the computer serial port you are using.
Using IO Interfaces RS-232 Programming Interface Examples Queries for RS-232 Using VISA and C This portion of the example program “Queries for RS- 232 Using VISA and C” on page 52, uses VISA library functions to communicate with the signal generator. The program verifies that the RS- 232 connections and interface are functional. The following program example is available on the signal generator Documentation CD- ROM as rs232ex2.cpp.
Using IO Interfaces Using USB (Agilent MXG) Using USB (Agilent MXG) CAUTION USB cables are not industrial graded and potentially allows data loss in noisy environments. USB cables do not have a latching mechanism and the cables can be pulled out of the PC or instrument relatively easily. The maximum length for USB cables is 30 m, including the use of inline repeaters. NOTE The USB interface is available only on the Agilent MXG signal generator. The Agilent MXG’s USB 2.
Using IO Interfaces Using USB (Agilent MXG) Selecting I/O Libraries for USB CAUTION The Agilent MXG’s USB interface requires Agilent IO Libraries Suite 14.1 or newer to run properly. For more information on connecting instruments to the USB, refer to the Agilent Connection Expert in the Agilent IO Libraries Help. The I/O libraries can be downloaded from the National Instrument website, http://www.ni.com, or Agilent’s website, http://www.agilent.com. The following is a discussion on these libraries.
Using IO Interfaces Using USB (Agilent MXG) Setting Up the USB Interface Rear Panel Interface (Mini–B 5 pin) To use USB, connect the USB cable (Refer to Table 2- 3, “USB Interface Cable,” on page 55, for USB cable information.) between the computer and the signal generator’s rear panel Mini- B 5- pin USB connector.
Using IO Interfaces Using USB (Agilent MXG) Verifying USB Functionality Mini-B 5 Pin Rear Panel Connector NOTE For information on verifying your Mini- B 5 pin USB (rear panel) functionality, refer to the Agilent Connection Expert in the Agilent IO Libraries Help. The Agilent IO libraries are included with your signal generator or Agilent GPIB interface board, or they can be downloaded from the Agilent website: http://www.agilent.com.
3 Programming Examples • “Using the Programming Interface Examples” on page 58 • “GPIB Programming Interface Examples” on page 62 • “LAN Programming Interface Examples” on page 101 • “RS- 232 Programming Interface Examples (ESG/PSG/E8663B Only)” on page 131 Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide 57
Programming Examples Using the Programming Interface Examples Using the Programming Interface Examples The programming examples for remote control of the signal generator use the GPIB, LAN, and RS- 232 interfaces and demonstrate instrument control using different IO libraries and programming languages. Many of the example programs in this chapter are interactive; the user will be prompted to perform certain actions or verify signal generator operation or functionality.
Programming Examples Using the Programming Interface Examples Running C++ Programs When using Microsoft Visual C++ 6.0 to run the example programs, include the following files in your project. When using the VISA library: • add the visa32.lib file to the Resource Files • add the visa.h file to the Header Files When using the NI- 488.2 library: • add the GPIB- 32.OBJ file to the Resource Files • add the windows.h file to the Header Files • add the Deci- 32.
Programming Examples Using the Programming Interface Examples Running C# Examples To run the example program State_Files.cs on page 326, you must have the .NET framework installed on your computer. You must also have the Agilent IO Libraries installed on your computer. The .NET framework can be downloaded from the Microsoft website. For more information on running C# programs using .NET framework, see Chapter 6.
Programming Examples Using the Programming Interface Examples You can start a new Standard EXE project and add the required references. Once the required references are included, you can copy the example programs into your project and add a command button to Form1 that will call the program. The example Visual Basic 6.0 programs are available on the signal generator Documentation CD- ROM, enabling you to cut and paste the examples into your project.
Programming Examples Using GPIB Using GPIB GPIB enables instruments to be connected together and controlled by a computer. GPIB and its associated interface operations are defined in the ANSI/IEEE Standard 488.1- 1987 and ANSI/IEEE Standard 488.2- 1992. See the IEEE website, http://www.ieee.org, for details on these standards. The following sections contain information for installing a GPIB interface card or NI- GPIB interface card for your PC or UNIX- based system.
Programming Examples GPIB Programming Interface Examples GPIB Function Statements (Command Messages) Function statements are the basis for GPIB programming and instrument control. These function statements, combined with SCPI, provide management and data communication for the GPIB interface and the signal generator. This section describes functions used by different IO libraries. For more information, refer to the NI- 488.
Programming Examples GPIB Programming Interface Examples Library Function Statement Initialization Command SICL The Agilent SICL function puts an instrument, identified by the id parameter, into remote mode and disables the front panel keys. Pressing the Local key on the signal generator front panel restores manual operation. The parameter id is the session identifier.
Programming Examples GPIB Programming Interface Examples Library Function Statement Initialization Command NI- 488.2 The NI- 488.2 library function places the interface in local mode and allows operation of the signal generator’s front panel keys. The ud parameter in the parameter list is the interface or device descriptor. ibloc (int ud) SICL The Agilent SICL function puts the signal generator into Local operation; enabling front panel key operation. The id parameter identifies the session.
Programming Examples GPIB Programming Interface Examples Library Function Statement Initialization Command NI- 488.2 The NI- 488.2 library function addresses the GPIB and writes data to the signal generator. The parameter list includes the instrument address, session id, and the data to send. ibwrt(parameter list) SICL The Agilent SICL function converts data using the format string. The format string specifies how the argument is converted before it is output.
Programming Examples GPIB Programming Interface Examples 20 ! 30 ! 40 ! 50 ! 60 ! 70 ! 80 ! 90 ! 100 ! 110 ! CLEAR and RESET the controller and type in the following commands and then 120 ! RUN the program: 130 ! 140 !****************************************************************************** 150 ! 160 Sig_gen=719 ! Declares a variable to hold the signal generator's address 170 LOCAL Sig_gen ! Places the signal generator into Local mode 180 CLEAR Sig_gen ! Clears an
Programming Examples GPIB Programming Interface Examples // Connect a GPIB cable from the PC GPIB card to the signal generator // Enter the following code into the source .cpp file and execute the program // // *************************************************************************************** #include "stdafx.h" #include #include "windows.h" #include "Decl-32.
Programming Examples GPIB Programming Interface Examples // PROGRAM DESCRIPTION:This example program verifies that the GPIB connections and // and interface are functional. // Turn signal generator power off then on and then run the program // //**************************************************************************************** #include #include #include "StdAfx.h" #include
Programming Examples GPIB Programming Interface Examples The following program example is available on the signal generator Documentation CD- ROM as basicex2.txt. 10 !************************************************************************* 20 ! 30 ! 40 ! 50 ! 60 ! functional front panel keys are disabled except for 70 ! the Local and Contrast keys. 80 ! command will disable the Local key.
Programming Examples GPIB Programming Interface Examples Local Lockout Using NI-488.2 and C++ This example uses the NI- 488.2 library to set the signal generator local lockout mode. Launch Microsoft Visual C++ 6.0, add the required files, and enter the following code into your .cpp source file. niex2.
Programming Examples GPIB Programming Interface Examples SetRWLS(GPIB0, Address); // Places device in Remote with Lockout State. cout<< "The signal generator should now be in LOCAL LOCKOUT. Verify that all keys"<
Programming Examples GPIB Programming Interface Examples 220 PRINT "Present source CW frequency is: ";F/1.
Programming Examples GPIB Programming Interface Examples • resets the signal generator • queries the signal generator for various settings • reads the various settings The following program example is available on the signal generator Documentation CD- ROM as niex3.cpp. //************************************************************************************* // PROGRAM NAME: niex3.cpp // // PROGRAM DESCRIPTION: This example demonstrates the use of query commands.
Programming Examples GPIB Programming Interface Examples rdVal[ibcntl] = '\0'; // Null character indicating end of array // Prints signal generator power level cout<<"Source power (dBm) is : "<
Programming Examples GPIB Programming Interface Examples • • • • • resets the signal generator queries the instrument (CW frequency, power level, frequency mode, and RF state) reads responses into the rdBuffer (CW frequency, power level, and frequency mode) turns signal generator RF state off verifies RF state off The following program example is available on the signal generator Documentation CD- ROM as visaex3.cpp.
Programming Examples GPIB Programming Interface Examples viScanf(vi, "%t", rdBuffer); // Reads response into rdBuffer // Prints the source frequency printf("Source CW frequency is : %s\n", rdBuffer); printf("Press any key to continue\n"); printf("\n"); // Prints new line character to the display getch(); viPrintf(vi, "POW:AMPL?\n"); // Querys the power level viScanf(vi, "%t", rdBuffer); // Reads the response into rdBuffer // Prints the source power level printf("Source power (dBm) is : %s\n", rdBuf
Programming Examples GPIB Programming Interface Examples • turns signal generator RF state off • verifies RF state off The following program example is available on the signal generator Documentation CD- ROM as visaex4.cpp. //**************************************************************************************** // PROGRAM FILE NAME: visaex4.cpp // // PROGRAM DESCRIPTION: This example demonstrates query commands. The signal generator // frequency and power level.
Programming Examples GPIB Programming Interface Examples viPrintf(vi, "FREQ:CW?\n"); // Query the CW frequency viScanf(vi, "%t", rdBuffer); // Read signal generator response printf("Source CW frequency is : %s\n", rdBuffer); viPrintf(vi, "POW:AMPL -2.3 dBm\n"); // Print the frequency // Set the power level to -2.
Programming Examples GPIB Programming Interface Examples Launch Microsoft Visual C++ 6.0, add the required files, and enter the code into your .cpp source file. visaex5.cpp performs the following functions: • • • • • • • • error checking resets the signal generator sets up the EXT 2 connector on the signal generator for FM sets up FM path 2 coupling to AC sets up FM path 2 deviation to 20 kHz sets carrier frequency to 700 MHz sets the power level to - 2.
Programming Examples GPIB Programming Interface Examples printf("Example program to set up the signal generator\n"); printf("for an AC-coupled FM signal\n"); printf("Press any key to continue\n"); printf("\n"); getch(); printf("\n"); viPrintf(vi, "*RST\n"); // Resets the signal generator viPrintf(vi, "FM:SOUR EXT2\n"); // Sets EXT 2 source for FM viPrintf(vi, "FM:EXT2:COUP AC\n"); // Sets FM path 2 coupling to AC viPrintf(vi, "FM:DEV 20 kHz\n"); // Sets FM path 2 deviation to 20 kHz viPrintf(vi, "
Programming Examples GPIB Programming Interface Examples // PROGRAM FILE NAME:visaex6.cpp // // PROGRAM DESCRIPION:This example generates an internal FM signal at a 900 // MHz carrier frequency and a power level of -15 dBm. The FM rate is 5 kHz and the peak // deviation 100 kHz // //**************************************************************************************** #include #include "StdAfx.h" #include #include #include
Programming Examples GPIB Programming Interface Examples viPrintf(vi, "OUTP:STAT ON\n"); // Turns on RF output printf("\n"); // Prints a carriage return // Print user information printf("Power level : -15 dBm\n"); printf("FM state : on\n"); printf("RF output : on\n"); printf("Carrier Frequency : 900 MHZ\n"); printf("Deviation : 100 kHZ\n"); printf("Internal modulation : 5 kHz\n"); printf("\n"); // Print a carrage return // Close the sessions viClose(vi); viClose(defaultRM); } Generating a Step-Swept
Programming Examples GPIB Programming Interface Examples { ViSession defaultRM, vi;// Declares variables of type ViSession // vi establishes instrument communication ViStatus viStatus = 0;// Declares a variable of type ViStatus // for GPIB verifications viStatus=viOpenDefaultRM(&defaultRM); // Initialize VISA session // Open session to GPIB device at address 19 viStatus=viOpen(defaultRM, "GPIB::19::INSTR", VI_NULL, VI_NULL, &vi); if(viStatus){// If problems, then prompt user printf("Could not open ViSessi
Programming Examples GPIB Programming Interface Examples and a .01 second dwell period for each point. A loop is used to generator 5 sweep operations. The signal generator triggers each sweep with the :INIT command. There is a wait introduced in the loop to allow the signal generator to complete all operations such as set up and retrace before the next sweep is generated. visaex11.
Programming Examples GPIB Programming Interface Examples The following program example is available on the signal generator Documentation CD- ROM as visaex11.cpp. //************************************************************************ // PROGRAM FILE NAME: visaex11.cpp // // PROGRAM DESCRIPTION: This program sets up the signal generator to // sweep from 1-2 GHz. A loop and counter are used to generate 5 sweeps. // Each sweep consists of 101 points with a .01 second dwell at each point.
Programming Examples GPIB Programming Interface Examples // set the start and stop frequency for the sweep stat = viPrintf(inst, "FREQ:START 1GHZ\n"); stat = viPrintf(inst, "FREQ:STOP 2GHZ\n"); // setup dwell per point stat = viPrintf(inst, "SWEEP:DWELL %e\n", dwell); // setup number of points stat = viPrintf(inst, "SWEEP:POINTS %d\n", npoints); // set interface timeout to double the expected sweep time // sweep takes (~15ms + dwell) per point * number of points // the timeout should not be shorter then t
Programming Examples GPIB Programming Interface Examples } Saving and Recalling States Using VISA and C In this example, instrument settings are saved in the signal generator’s save register. These settings can then be recalled separately; either from the keyboard or from the signal generator’s front panel. Launch Microsoft Visual C++ 6.0, add the required files, and enter the following code into your .cpp source file. visaex8.
Programming Examples GPIB Programming Interface Examples // for GPIB verifications long lngDone = 0; // Operation complete flag viStatus=viOpenDefaultRM(&defaultRM); // Initialize VISA session // Open session to gpib device at address 19 viStatus=viOpen(defaultRM, "GPIB::19::INSTR", VI_NULL, VI_NULL, &vi); if(viStatus){// If problems, then prompt user printf("Could not open ViSession!\n"); printf("Check instruments and connections\n"); printf("\n"); exit(0);} printf("\n"); viClear(vi); // Clears the s
Programming Examples GPIB Programming Interface Examples lngDone=0; // Reset the operation complete flag viPrintf(vi, "*RCL 1\n"); // Recalls stored register #1 state viPrintf(vi, "*OPC?\n"); // Checks for operation complete while (!lngDone) viScanf (vi ,"%d",&lngDone); // Waits for setup to complete // Print user information printf("The signal generator has been returned to it's Register #1 state\n"); printf("Press Enter to continue\n"); printf("\n"); // Prints new line character getch(); //
Programming Examples GPIB Programming Interface Examples // PROGRAM DESCRIPTION:In this example, the data questionable status register is read. // The data questionable status register is enabled to read an unleveled condition. // The signal generator is then set up for an unleveled condition and the data // questionable status register read. The results are then displayed to the user. // The status questionable register is then setup to monitor a modulation error condition.
Programming Examples GPIB Programming Interface Examples printf("* Set frequency to maximum value\n"); printf("* Turn On signal generator's RF Output\n"); printf("* Check signal generator's display for the UNLEVEL annunciator\n"); printf("\n"); printf("Press Enter when ready\n"); printf("\n"); getch(); // Waits for keyboard user input viPrintf(vi, "STAT:QUES:POW:ENAB 2\n"); // Enables the Data Questionable // Power Condition Register Bits // Bits '0' and '1' viPrintf(vi, "STAT:QUES:POW:COND?\n"); // Q
Programming Examples GPIB Programming Interface Examples printf("\n"); printf("Press Enter when ready\n"); printf("\n"); getch(); // Waits for keyboard user input viPrintf(vi, "STAT:QUES:MOD:ENAB 16\n"); // Enables the Data Questionable // Modulation Condition Register // bits '0','1','2','3' and '4' viPrintf(vi, "STAT:QUES:MOD:COND?\n"); // Querys the register for any // set bits viScanf(vi, "%s", rdBuffer); // Reads the decimal sum of the // set bits num=(int (rdBuffer[1]) -('0')); // Converts
Programming Examples GPIB Programming Interface Examples } Reading the Service Request Interrupt (SRQ) Using VISA and C This example demonstrates use of the Service Request (SRQ) interrupt. By using the SRQ, the computer can attend to other tasks while the signal generator is busy performing a function or operation. When the signal generator finishes its operation, or detects a failure, then a Service Request can be generated.
Programming Examples GPIB Programming Interface Examples #include "windows.h" #include
Programming Examples GPIB Programming Interface Examples printf("Press Enter to continue\n"); printf("\n"); getch(); viPrintf(vi, "*CLS\n");// Clears signal generator status byte viPrintf(vi, "STAT:OPER:NTR 8\n");// Sets the Operation Status Group indicate a // negative transition in Bit 3 (Sweeping) // which will set a corresponding event in of a sweep. // Negative Transition Filter to // the Operation Event Register.
Programming Examples GPIB Programming Interface Examples viStatus = viDisableEvent(vi, VI_ALL_ENABLED_EVENTS,VI_ALL_MECH); viStatus = viUninstallHandler(vi, VI_EVENT_SERVICE_REQ, interupt, rdBuffer); viStatus = viClose(vi); viStatus = viClose(defaultRM); return 0; } // The following function is called when an SRQ event occurs. Code specific to your // requirements would be entered in the body of the function.
Programming Examples GPIB Programming Interface Examples Using 8757D Pass-Thru Commands (PSG with Option 007 Only) Pass- thru commands enable you to send operating instructions to a PSG that is connected to a 8757D scalar analyzer system. This section provides setup information and an example program for using pass- thru commands in a ramp sweep system. Equipment Setup To send pass- thru commands, set up the equipment as shown in Figure 3- 1.
Programming Examples GPIB Programming Interface Examples GPIB Address Assignments Figure 3- 1 describes how GPIB addresses should be assigned for sending pass- thru commands. These are the same addresses used in Example 3- 1. Table 3-1 Instrument GPIB Address Key Presses/Description PSG/E8663B 19 Press Utility > GPIB/RS-232 LAN > GPIB Address > 19 > Enter. 8757D 16 Press LOCAL > 8757 > 16 > Enter. 8757D (Sweeper) 19 This address must match the PSG. Press LOCAL > SWEEPER > 19 > Enter.
Programming Examples GPIB Programming Interface Examples 40 OUTPUT 717;"SYST:LANG SCPI";END 50 WAIT .5 60 OUTPUT 717;"OUTP:STAT OFF" 70 OUTPUT 717;"*OPC?" 80 ENTER 717; Reply 90 OUTPUT 717;"SYST:LANG COMP";END 100 WAIT .5 110 OUTPUT 716;"C2" 120 END Setting the PSG Sweep Time Requirements (PSG with Firmware ≥4.92) By default, the PSG sweep time is automatically adjusted to the fastest possible sweep when exiting Pass- Thru mode.
Programming Examples LAN Programming Interface Examples 115 OUTPUT 717;”RC1” LAN Programming Interface Examples NOTE The LAN programming examples in this section demonstrate the use of VXI- 11 and Sockets LAN to control the signal generator. To use these programming examples you must change references to the IP address and hostname to match the IP address and hostname of your signal generator.
Programming Examples LAN Programming Interface Examples VXI-11 Programming Using SICL and C++ The following program uses the VXI- 11 protocol and SICL to control the signal generator. Before running this code, you must set up the interface using the Agilent IO Libraries IO Config utility. vxisicl.
Programming Examples LAN Programming Interface Examples // Open SICL instrument handle using VXI-11 protocol sprintf(instNameBuf, "lan[%s]:inst0", instrumentName); id = iopen(instNameBuf);// Open instrument session itimeout(id, 1000);// Set 1 second timeout for operations printf("Setting frequency to 1 Ghz...\n"); iprintf(id, "freq 1 GHz\n");// Set frequency to 1 GHz printf("Waiting for source to settle...
Programming Examples LAN Programming Interface Examples // NOTE: You must have the Agilent Libraries installed on your computer to run // this program // // PROGRAM DESCRIPTION:This example uses the VXI-11 protocol and VISA to query // the signal generator for its ID string. The ID string is then printed to the // screen. Next the signal generator is set for a -5 dBm power level and then // queried for the power level. The power level is printed to the screen.
Programming Examples LAN Programming Interface Examples status = viWrite(instr, (ViBuf)"*IDN?\n", 6, &retCount); // Read the sig gen response status = viRead(instr, (ViBuf)buffer, MAX_COUNT, &retCount); buffer[retCount]= '\0'; // Indicate the end of the string printf("Signal Generator ID = "); // Print header for ID printf(buffer); // Print the ID string printf("\n"); // Print carriage return // Flush the read buffer // Set sig gen power to -5dbm status = viWrite(instr, (ViBuf)"POW:AMPL -5dbm\n",
Programming Examples LAN Programming Interface Examples 2. At the UNIX prompt in your home directory type: cc -Aa -O -o lanio lanio.c 3. At the UNIX prompt in your home directory type: ./lanio xxxxx “*IDN?” where xxxxx is the hostname for the signal generator. Use this same format to output SCPI commands to the signal generator. The int main1() function will output a sequence of commands in a program format. If you want to run a program using a sequence of commands then perform the following: 1.
Programming Examples LAN Programming Interface Examples 5. After you cd to the directory where the lanio.exe file is located, type in the following command at the command prompt: lanio xxxxx “*IDN?”. For example: C:\SocketIO\Lanio\Debug>lanio xxxxx “*IDN?” where the xxxxx is the hostname of your signal generator. Use this format to output SCPI commands to the signal generator in a line by line format from the command prompt. 6. Type exit at the command prompt to quit the program.
Programming Examples LAN Programming Interface Examples • • • • • error checks queries signal generator for ID sets frequency on signal generator to 2.5 GHz sets power on signal generator to –5 dBm gets option letter from argument vector and checks for end of file (EOF) The following programming examples are available on the signal generator Documentation CD- ROM as lanio.c and getopt.c. /*************************************************************************** * $Header: lanio.
Programming Examples LAN Programming Interface Examples * - Windows 95, using Microsoft Visual C++ 4.0 Standard Edition * - Windows NT 3.51, using Microsoft Visual C++ 4.0 * + Be sure to add * + Compile both lanio.c and getopt.c WSOCK32.LIB to your list of libraries! * + Consider re-naming the files to lanio.cpp and getopt.cpp * * Considerations: * - On UNIX systems, file I/O can be used on network sockets.
Programming Examples LAN Programming Interface Examples #else /* UNIX with BSD sockets */ # include /* for connect and socket*/ # include /* for sockaddr_in */ # include /* for gethostbyname */ # define SOCKET_ERROR (-1) # define INVALID_SOCKET (-1) typedef int SOCKET; #endif /* WINSOCK */ #ifdef WINSOCK /* Declared in getopt.c. See example programs disk.
Programming Examples LAN Programming Interface Examples #ifdef WINSOCK int init_winsock(void) { WORD wVersionRequested; WSADATA wsaData; int err; wVersionRequested = MAKEWORD(1, 1); wVersionRequested = MAKEWORD(2, 0); err = WSAStartup(wVersionRequested, &wsaData); if (err != 0) { /* Tell the user that we couldn't find a useable */ /* winsock.dll. */ fprintf(stderr, "Cannot initialize Winsock 1.1.
Programming Examples LAN Programming Interface Examples * * $Return: (int) . . . . . . . . A file descriptor similar to open(1).
Programming Examples LAN Programming Interface Examples { fprintf(stderr,"unable to create socket to '%s': %s\n", hostname, strerror(errno)); return INVALID_SOCKET; } return s; } /*************************************************************************** * > $Function: commandInstrument$ * * $Description: send a SCPI command to the instrument.$ * * $Parameters: $ * (FILE *) . . . . . . . . . file pointer associated with TCP/IP socket. * (const char *command) * $Return: . . SCPI command string.
Programming Examples LAN Programming Interface Examples /************************************************************************** * recv_line(): similar to fgets(), but uses recv() **************************************************************************/ char * recv_line(SOCKET sock, char * result, int maxLength) { #ifdef WINSOCK int cur_length = 0; int count; char * ptr = result; int err = 1; while (cur_length < maxLength) { /* Get a byte into ptr */ count = recv(sock, ptr, 1, 0); /* If no chars to
Programming Examples LAN Programming Interface Examples * Simpler UNIX version, using file I/O. recv() version works too. * This demonstrates how to use file I/O on sockets, in UNIX.
Programming Examples LAN Programming Interface Examples /********************************************************* * Send command to signal generator *********************************************************/ command_err = commandInstrument(sock, command); if (command_err) return COMMAND_ERROR; /********************************************************* * Read response from signal generator ********************************************************/ count = recv(sock, tmp_buf, 1, 0); /* read 1 char */ ch = t
Programming Examples LAN Programming Interface Examples numBytes = atol(result); } if (numBytes) { resultBytes = 0; /* Loop until we get all the bytes we requested. */ /* Each call seems to return up to 1457 bytes, on HP-UX 9.
Programming Examples LAN Programming Interface Examples if (recv_line(sock, result+1, maxLength-1) == NULL) return 0; /* REMOVE trailing newline, if present. And terminate string. */ resultBytes = strlen(result); if (result[resultBytes-1] == '\n') resultBytes -= 1; result[resultBytes] = '\0'; } } while (0); return resultBytes; } /************************************************************************* * > $Function: showErrors$ * * $Description: Query the SCPI error queue, until empty.
Programming Examples LAN Programming Interface Examples puts(result_str); } while (1); } /*************************************************************************** * > $Function: isQuery$ * * $Description: Test current SCPI command to see if it a query. $ * * $Return: (unsigned char) . . . non-zero if command is a query. 0 if not.
Programming Examples LAN Programming Interface Examples if ( *query != ')' ) { q = 1 ; } } return q ; } /*************************************************************************** * > $Function: main$ * * $Description: Read command line arguments, and talk to signal generator. Send query results to stdout. $ * * $Return: (int) . . .
Programming Examples LAN Programming Interface Examples case 'n': number = 1; break ; case 'e': show_errs = 1; break ; case 'u': case '?': usage(basename); exit(1) ; } /* now look for hostname and optional */ if (optind < argc) { destination = argv[optind++] ; strcpy(command, ""); if (optind < argc) { while (optind < argc) { /* provided; only one command string */ strcat(command, argv[optind++]); if (optind < argc) { strcat(command, " "); } else { strcat(command, "\n");
Programming Examples LAN Programming Interface Examples /****************************************************** /* open a socket connection to the instrument /******************************************************/ #ifdef WINSOCK if (init_winsock() != 0) { exit(1); } #endif /* WINSOCK */ instSock = openSocket(destination, SCPI_PORT); if (instSock == INVALID_SOCKET) { fprintf(stderr, "Unable to open socket.\n"); return 1; } /* fprintf(stderr, "Socket opened.
Programming Examples LAN Programming Interface Examples /* read a line from */ while ( gets(charBuf) != NULL ) { if ( !strlen(charBuf) ) continue ; if ( *charBuf == '#' || *charBuf == '!' ) continue ; strcat(charBuf, "\n"); if (!quiet) { if (number) { char num[10]; sprintf(num,"%d: ",number); fwrite(num, strlen(num), 1, stdout); } fwrite(charBuf, strlen(charBuf), 1, stdout) ; fflush(stdout); } if ( isQuery(charBuf) ) { long bufBytes; /* Put the query response into the same buffer as the*/ /* c
Programming Examples LAN Programming Interface Examples { commandInstrument(instSock, charBuf); } if (number) number++; } } if (show_errs) { showErrors(instSock); } #ifdef WINSOCK closesocket(instSock); close_winsock(); #else close(instSock); #endif /* WINSOCK */ return 0; } /* End of lanio.
Programming Examples LAN Programming Interface Examples char *charBuf = (char *) malloc(INPUT_BUF_SIZE); /*********************************************/ /* open a socket connection to the instrument*/ /*********************************************/ #ifdef WINSOCK if (init_winsock() != 0) { exit(1); } #endif /* WINSOCK */ instSock = openSocket("xxxxxx", SCPI_PORT); /* Put your hostname here */ if (instSock == INVALID_SOCKET) { fprintf(stderr, "Unable to open socket.
Programming Examples LAN Programming Interface Examples getopt(3C) getopt(3C) PROGRAM FILE NAME: getopt.c getopt - get option letter from argument vector SYNOPSIS int getopt(int argc, char * const argv[], const char *optstring); extern char *optarg; extern int optind, opterr, optopt; PRORGAM DESCRIPTION: getopt returns the next option letter in argv (starting from argv[1]) that matches a letter in optstring.
Programming Examples LAN Programming Interface Examples optarg = NULL; if (scan == NULL || *scan == '\0') { if (optind == 0) optind++; if (optind >= argc || argv[optind][0] != '-' || argv[optind][1] == '\0') return(EOF); if (strcmp(argv[optind], "--")==0) { optind++; return(EOF); } scan = argv[optind]+1; optind++; } c = *scan++; posn = strchr(optstring, c); /* DDP */ if (posn == NULL || c == ':') { fprintf(stderr, "%s: unknown option -%c\n", argv[0], c); return('?'); } posn++; if (*posn == ':') { if
Programming Examples LAN Programming Interface Examples Sockets LAN Programming Using Java In this example the Java program connects to the signal generator via sockets LAN. This program requires Java version 1.1 or later be installed on your PC. To run the program perform the following steps: 1. In the code example below, type in the hostname or IP address of your signal generator. For example, String instrumentName = (your signal generator’s hostname). 2. Copy the program as ScpiSockTest.
Programming Examples LAN Programming Interface Examples new OutputStreamWriter(t.getOutputStream())); BufferedReader in = new BufferedReader( new InputStreamReader(t.getInputStream())); System.out.println("Setting frequency to 1 GHz..."); out.write("freq 1GHz\n"); // Sets frequency out.flush(); System.out.println("Waiting for source to settle..."); out.write("*opc?\n"); // Waits for completion out.flush(); String opcResponse = in.readLine(); if (!opcResponse.equals("1")) { System.err.
Programming Examples LAN Programming Interface Examples Sockets LAN Programming Using PERL This example uses PERL to control the signal generator over the sockets LAN interface. The signal generator frequency is set to 1 GHz, queried for operation complete and then queried for it’s identify string. This example was developed using PERL version 5.6.0 and requires a PERL version with the IO::Socket library. 1.
Programming Examples RS-232 Programming Interface Examples (ESG/PSG/E8663B Only) # Send identification query print $sock "*IDN?\n"; $response = <$sock>; chomp $response; print "Instrument ID: $response\n"; RS-232 Programming Interface Examples (ESG/PSG/E8663B Only) • • • • “Interface Check Using HP BASIC” on page 131 “Interface Check Using VISA and C” on page 132 “Queries Using HP Basic and RS- 232” on page 134 “Queries for RS- 232 Using VISA and C” on page 135 Before Using the Examples Before using the
Programming Examples RS-232 Programming Interface Examples (ESG/PSG/E8663B Only) 110 ! 120 ! Run HP BASIC, type in the following commands and then RUN the program 130 ! 140 !****************************************************************************** 150 ! 160 INTEGER Num 170 CONTROL 9,0;1 ! Resets the RS-232 interface 180 CONTROL 9,3;9600 ! Sets the baud rate to match the sig gen 190 STATUS 9,4;Stat ! Reads the value of register 4 200 Num=BINAND(Stat,7) ! Gets the AND value 210
Programming Examples RS-232 Programming Interface Examples (ESG/PSG/E8663B Only) #include "StdAfx.h" #include #include
Programming Examples RS-232 Programming Interface Examples (ESG/PSG/E8663B Only) Queries Using HP Basic and RS-232 This example program demonstrates signal generator query commands over RS- 232. Query commands are of the type *IDN? and are identified by the question mark that follows the mnemonic. rs232ex2.
Programming Examples RS-232 Programming Interface Examples (ESG/PSG/E8663B Only) Queries for RS-232 Using VISA and C This example uses VISA library functions to communicate with the signal generator. The program verifies that the RS- 232 connections and interface are functional. Launch Microsoft Visual C++, add the required files, and enter the following code into your .cpp source file. rs232ex2.
Programming Examples RS-232 Programming Interface Examples (ESG/PSG/E8663B Only) ViSessiondefaultRM, instr;// Declares type ViSession variables ViUInt32retCount; // Return count for string I/O ViCharbuffer[MAX_COUNT];// Buffer for string I/O status = viOpenDefaultRM(&defaultRM);// Initializes the system // Open communication with Serial Port 2 status = viOpen(defaultRM, "ASRL2::INSTR", VI_NULL, VI_NULL, &instr); if(status){// If problems, then prompt user printf("Could not open ViSession!\n"); printf("
4 Programming the Status Register System This chapter provides the following major sections: • “Overview” on page 138 • “Status Register Bit Values” on page 148 • “Accessing Status Register Information” on page 149 • “Status Byte Group” on page 154 • “Status Groups” on page 156 Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide 137
Programming the Status Register System Overview Overview NOTE Some of the status bits and register groups only apply to select signal generators with certain options.
Programming the Status Register System Overview Overall Status Byte Register Systems • “N5181A/82A/83A: Overall Status Byte Register System (1 of 2)” on page 140 • “N5 181A/82A/83A: Overall Status Byte Register System (2 of 2)” on page 141 • “E8663B: Overall Status Byte Register System (1 of 2)” on page 142 • “E8663B: Overall Status Byte Register System (2 of 2)” on page 143 • “E4428C/38C: Overall Status Byte Register System (1 of 2)” on page 144 • “E4428C/38C: Overall Status Byte Register System (2 of 2)”
Programming the Status Register System Overview Figure 4-1 140 N5181A/82A/83A: Overall Status Byte Register System (1 of 2) Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
Programming the Status Register System Overview Figure 4-2 N5181A/82A/83A: Overall Status Byte Register System (2 of 2) Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide 141
Programming the Status Register System Overview Figure 4-3 142 E8663B: Overall Status Byte Register System (1 of 2) Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
Programming the Status Register System Overview Figure 4-4 E8663B: Overall Status Byte Register System (2 of 2) Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide 143
Programming the Status Register System Overview Figure 4-5 144 E4428C/38C: Overall Status Byte Register System (1 of 2) Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
Programming the Status Register System Overview Figure 4-6 E4428C/38C: Overall Status Byte Register System (2 of 2) Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide 145
Programming the Status Register System Overview Figure 4-7 146 E8257D/67D: Overall Status Byte Register System (1 of 2) Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
Programming the Status Register System Overview Figure 4-8 E8257D/67D: Overall Status Byte Register System (2 of 2) Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide 147
Programming the Status Register System Status Register Bit Values Status Register Bit Values Each bit in a register is represented by a decimal value based on its location in the register (see Table 4- 1). • To enable a particular bit in a register, send its value with the SCPI command. Refer to the signal generator’s SCPI command listing for more information. • To enable more than one bit, send the sum of all the bits that you want to enable. • To verify the bits set in a register, query the register.
Programming the Status Register System Accessing Status Register Information Accessing Status Register Information 1. Determine which register contains the bit that reports the condition. Refer to Figure 4- 1 on page 140 through Figure 4- 8 on page 147 for register location and names. 2. Send the unique SCPI query that reads that register. 3. Examine the bit to see if the condition has changed.
Programming the Status Register System Accessing Status Register Information The polling method works well if you do not need to know about changes the moment they occur.
Programming the Status Register System Accessing Status Register Information The query command *SRE? returns the decimal value of the sum of the bits previously enabled with the *SRE command. To query the Status Byte Register, send the command *STB?. The response will be the decimal sum of the bits which are set to 1. For example, if bit 7 and bit 3 are set, the decimal sum will be 136 (bit 7 = 128 and bit 3 = 8).
Programming the Status Register System Accessing Status Register Information *ESR? (event status register) queries and clears the Standard Event Status Register which is part of the Standard Event Status Group. *OPC, *OPC? (operation complete) sets bit #0 in the Standard Event Status Register to 1 when all commands have completed. The query stops any new commands from being processed until the current processing is complete, then returns a 1.
Programming the Status Register System Accessing Status Register Information Table 4-2 Effects of :STATus:PRESet Registera Value after :STATus:PRESet :STATus:OPERation:ENABle 0 :STATus:OPERation:NTRansition 0 :STATus:OPERation:PTRransition 32767 :STATus:OPERation:BASeband:ENABle 0 :STATus:OPERation:BASeband:NTRansition 0 :STATus:OPERation:BASeband:PTRransition 32767 :STATus:QUEStionable:CALibration:ENABle 32767 :STATus:QUEStionable:CALibration:NTRansition 32767 :STATus:QUEStionable:CALibr
Programming the Status Register System Status Byte Group Status Byte Group The Status Byte Group includes the Status Byte Register and the Service Request Enable Register. This is the named status register for the E4438C. However, not all signal generator models use all of the shown events (i.e. some use only a subset of the E4438C’s status registers).
Programming the Status Register System Status Byte Group Status Byte Register Table 4-3 Status Byte Register Bits Bit Description 0,1 Unused. These bits are always set to 0. 2 Error/Event Queue Summary Bit. A 1 in this bit position indicates that the SCPI error queue is not empty. The SCPI error queue contains at least one error message. 3 Data Questionable Status Summary Bit. A 1 in this bit position indicates that the Data Questionable summary bit has been set.
Programming the Status Register System Status Groups Status Groups The Standard Operation Status Group and the Data Questionable Status Group consist of the registers listed below. The Standard Event Status Group is similar but does not have negative or positive transition filters or a condition register.
Programming the Status Register System Status Groups Standard Event Status Group The Standard Event Status Group is used to determine the specific event that set bit 5 in the Status Byte Register. This group consists of the Standard Event Status Register (an event register) and the Standard Event Status Enable Register. This is the named status register for the E4438C. However, not all signal generator models use all of the shown events (i.e. some use only a subset of the E4438C’s status registers).
Programming the Status Register System Status Groups Standard Event Status Register Table 4-4 Bit Standard Event Status Register Bits Description 0 Operation Complete. A 1 in this bit position indicates that all pending signal generator operations were completed following execution of the *OPC command. 1 Request Control. This bit is always set to 0. (The signal generator does not request control.) 2 Query Error. A 1 in this bit position indicates that a query error has occurred.
Programming the Status Register System Status Groups Standard Operation Status Group NOTE Some of the bits in this status group do not apply to the E4428C, E8257D, E8267D, E8663B, and the N5181A/82A/83A, and returns zero when queried. See Table 4- 5 on page 160 for more information. The Agilent MXG SCPI command :STAT:OPER:SUPP, can suppress the managing of this status group and save 50 us from the switching time. Refer to the SCPI Command Reference.
Programming the Status Register System Status Groups Standard Operation Condition Register The Standard Operation Condition Register continuously monitors the hardware and firmware status of the signal generator. Condition registers are read only. Table 4-5 Standard Operation Condition Register Bits Bit Description 0a I/Q Calibrating. A 1 in this position indicates an I/Q calibration is in process. 1 Settling. A 1 in this bit position indicates that the signal generator is settling. 2 Unused.
Programming the Status Register System Status Groups Standard Operation Transition Filters (negative and positive) The Standard Operation Transition Filters specify which types of bit state changes in the condition register set corresponding bits in the event register. Changes can be positive (0 to 1) or negative (1 to 0).
Programming the Status Register System Status Groups Baseband Operation Status Group NOTE This status group does not apply to the E4428C, E8257D, and the E8663B, and if queried, returns zero. See Table 4- 6 on page 163 for more information. This status group does not apply to the N5181A/82A/83A. (If queried, the signal generator will not respond.) The Baseband Operation Status Group is used to determine the specific event that set bit 10 in the Standard Operation Status Group.
Programming the Status Register System Status Groups Baseband Operation Condition Register The Baseband Operation Condition Register continuously monitors the hardware and firmware status of the signal generator. Condition registers are read only. Table 4-6 Baseband Operation Condition Register Bits Bit Description 0 Baseband 1 Busy. A 1 in this position indicates the signal generator baseband is active. 1 Baseband 1 Communicating.
Programming the Status Register System Status Groups Baseband Operation Event Register The Baseband Operation Event Register latches transition events from the condition register as specified by the transition filters. Event registers are destructive read only. Reading data from an event register clears the content of that register.
Programming the Status Register System Status Groups Data Questionable Status Group NOTE Some of the bits in this status group do not apply to the E4428C, E8257D, E8267D, E8663B, and the N5181A/82A/83A, and returns zero when queried. Other bits have changed state content. See Table 4- 7 on page 166 for more information. The Data Questionable Status Group is used to determine the specific event that set bit 3 in the Status Byte Register.
Programming the Status Register System Status Groups Data Questionable Condition Register The Data Questionable Condition Register continuously monitors the hardware and firmware status of the signal generator. Condition registers are read only. Table 4-7 Data Questionable Condition Register Bits Bit Description 0, 1, 2 Unused. These bits are always set to 0. 3 Power (summary). This is a summary bit taken from the QUEStionable:POWer register.
Programming the Status Register System Status Groups Response: The decimal sum of the bits set to 1 Example: The decimal value 520 is returned. The decimal sum = 512 (bit 9) + 8 (bit 3). Data Questionable Transition Filters (negative and positive) The Data Questionable Transition Filters specify which type of bit state changes in the condition register set corresponding bits in the event register. Changes can be positive (0 to 1) or negative (1 to 0).
Programming the Status Register System Status Groups Data Questionable Power Status Group NOTE Some of the bits in this status group do not apply to the E4428C, E8257D, E8267D, E8663B, and the N5181A/82A/83A, and returns zero when queried. See Table 4- 8 on page 169 for more information. The Data Questionable Power Status Group is used to determine the specific event that set bit 3 in the Data Questionable Condition Register.
Programming the Status Register System Status Groups Data Questionable Power Condition Register The Data Questionable Power Condition Register continuously monitors the hardware and firmware status of the signal generator. Condition registers are read only. Table 4-8 Data Questionable Power Condition Register Bits Bit Description 0a Reverse Power Protection Tripped. A 1 in this bit position indicates that the reverse power protection (RPP) circuit has been tripped. There is no output in this state.
Programming the Status Register System Status Groups Data Questionable Power Event Enable Register The Data Questionable Power Event Enable Register lets you choose which bits in the Data Questionable Power Event Register set the summary bit (bit 3 of the Data Questionable Condition Register) to 1.
Programming the Status Register System Status Groups Data Questionable Frequency Status Group NOTE Some bits in this status group do not apply to the N5181A/82A/83A, E4428C, E8257D, and the E8663B and returns zero when queried. See Table 4- 9 on page 172 for more information. The Data Questionable Frequency Status Group is used to determine the specific event that set bit 5 in the Data Questionable Condition Register.
Programming the Status Register System Status Groups Data Questionable Frequency Condition Register The Data Questionable Frequency Condition Register continuously monitors the hardware and firmware status of the signal generator. Condition registers are read- only. Table 4-9 Data Questionable Frequency Condition Register Bits Bit Description 0 Synth. Unlocked. A 1 in this bit position indicates that the synthesizer is unlocked. 1 10 MHz Ref Unlocked.
Programming the Status Register System Status Groups Data Questionable Frequency Event Enable Register Lets you choose which bits in the Data Questionable Frequency Event Register set the summary bit (bit 5 of the Data Questionable Condition Register) to 1. Command: STATus:QUEStionable:FREQuency:ENABle , where is the sum of the decimal values of the bits you want to enable.
Programming the Status Register System Status Groups Data Questionable Modulation Status Group NOTE This status group does not apply to the N5181A and the N5182A, and returns zero when queried. See Table 4- 10 on page 175 for more information. The Data Questionable Modulation Status Group is used to determine the specific event that set bit 7 in the Data Questionable Condition Register.
Programming the Status Register System Status Groups Data Questionable Modulation Condition Register The Data Questionable Modulation Condition Register continuously monitors the hardware and firmware status of the signal generator. Condition registers are read- only. Table 4-10 Bit Data Questionable Modulation Condition Register Bits Description 0 Modulation 1 Undermod. A 1 in this bit position indicates that the External 1 input, ac coupling on, is less than 0.97 volts. 1 Modulation 1 Overmod.
Programming the Status Register System Status Groups Data Questionable Modulation Event Enable Register The Data Questionable Modulation Event Enable Register lets you choose which bits in the Data Questionable Modulation Event Register set the summary bit (bit 7 of the Data Questionable Condition Register) to 1. 176 Command: STATus:QUEStionable:MODulation:ENABle where is the sum of the decimal values of the bits you want to enable.
Programming the Status Register System Status Groups Data Questionable Calibration Status Group NOTE Some bits in this status group do not apply to the N5181A/82A/83A, E4428C, E8257D, and the E8663B, and return zero when queried. See Table 4- 11 on page 178 for more information. The Data Questionable Calibration Status Group is used to determine the specific event that set bit 8 in the Data Questionable Condition Register.
Programming the Status Register System Status Groups Data Questionable Calibration Condition Register The Data Questionable Calibration Condition Register continuously monitors the calibration status of the signal generator. Condition registers are read only. Table 4-11 Data Questionable Calibration Condition Register Bits Bit Description 0a I/Q Calibration Failure. A 1 in this bit position indicates that the I/Q modulation calibration experienced a failure. 1b DCFM/DCΦM Zero Failure.
Programming the Status Register System Status Groups Data Questionable Calibration Event Enable Register The Data Questionable Calibration Event Enable Register lets you choose which bits in the Data Questionable Calibration Event Register set the summary bit (bit 8 of the Data Questionable Condition register) to 1. Command: STATus:QUEStionable:CALibration:ENABle , where is the sum of the decimal values of the bits you want to enable.
Programming the Status Register System Status Groups Data Questionable BERT Status Group NOTE This status group applies only to the E4438C with Option UN7. The Data Questionable BERT Status Group is used to determine the specific event that set bit 12 in the Data Questionable Condition Register.
Programming the Status Register System Status Groups Data Questionable BERT Condition Register The Data Questionable BERT Condition Register continuously monitors the hardware and firmware status of the signal generator. Condition registers are read only. Table 4-12 Data Questionable BERT Condition Register Bits Bit Description 0 No Clock. A 1 in this bit position indicates no clock input for more than 3 seconds. 1 No Data Change.
Programming the Status Register System Status Groups Data Questionable BERT Transition Filters (negative and positive) The Data Questionable BERT Transition Filters specify which type of bit state changes in the condition register set corresponding bits in the event register. Changes can be positive (0 to 1) or negative (1 to 0).
5 NOTE Creating and Downloading Waveform Files The ability to play externally created waveform data in the signal generator is available only in the N5182A with Option 651, 652 or 654, E4438C ESG Vector Signal Generators with Option 001, 002, 601, or 602, and E8267D PSG Vector Signal Generators with Option 601 or 602.
Creating and Downloading Waveform Files Overview of Downloading and Extracting Waveform Files Overview of Downloading and Extracting Waveform Files The signal generator lets you download and extract waveform files. You can create these files either external to the signal generator or by using one of the internal modulation formats (ESG/PSG only). The signal generator also accepts waveforms files created for the earlier E443xB ESG signal generator models.
Creating and Downloading Waveform Files Understanding Waveform Data Waveform Data Requirements To be successful in downloading files, you must first create the data in the required format.
Creating and Downloading Waveform Files Understanding Waveform Data The maximum value for a single unsigned byte is 255 (11111111 or 28−1), but you can use multiple bytes to represent larger values. The following shows two bytes and the resulting integer value: 01101110 10110011= 28339 (decimal value) The maximum value for two unsigned bytes is 65535. Since binary strings lengthen as the value increases, it is common to show binary values using hexadecimal (hex) values (base 16), which are shorter.
Creating and Downloading Waveform Files Understanding Waveform Data Little Endian Order The lowest order byte that contains bits 0–7 comes first. Bit Position 7 Data 0 15 14 13 12 11 10 1 1 1 0 1 0 0 1 6 5 4 3 2 1 1 0 1 1 0 1 LSB 9 8 Hex values = E9 B7 1 1 MSB Big Endian Order The highest order byte that contains bits 8–15 comes first.
Creating and Downloading Waveform Files Understanding Waveform Data Byte Swapping While the processor for the development platform determines the byte order, the recipient of the data may require the bytes in the reverse order. In this situation, you must reverse the byte order before downloading the data. This is commonly referred to as byte swapping.
Creating and Downloading Waveform Files Understanding Waveform Data Voltage DAC Range Input Range Binary Data Hex Data 65535 32767 01111111 11111111 7FFF Vmax 32768 1 00000000 00000001 0001 0 Volts 32767 32766 0 -1 00000000 00000000 11111111 11111111 0000 FFFF Vmin 0 -32768 10000000 00000000 8000 Notice that it takes only 15 bits (215) to reach the Vmax (positive) or Vmin (negative) values. The MSB determines the sign of the value.
Creating and Downloading Waveform Files Understanding Waveform Data NOTE Whenever you interchange files between signal generator models, ensure that all scaling is adequate for that signal generator’s waveform. Interpolation Interpolation 32767 Max input value Scaling effect DAC over-range No over-range -32768 There is no single scaling value that is optimal for all waveforms. To achieve the maximum dynamic range, select the largest scaling value that does not result in a DAC over- range error.
Creating and Downloading Waveform Files Understanding Waveform Data NOTE FIR filter capability is only available on the N5182A with Option 651, 652, or 654, the E4438C with Option 001, 002, 601, or 602, and on the E8267D with Option 601 or 602. 2’s Complement Data Format The signal generator requires signed values for the input data. For binary data, two’s complement is a way to represent positive and negative values. The most significant bit (MSB) determines the sign.
Creating and Downloading Waveform Files Understanding Waveform Data NOTE The signal generator can accept separate I and Q files created for the earlier E443xB ESG models. For more information on downloading E443xB files, see “Downloading E443xB Signal Generator Files” on page 228. The following figure illustrates interleaving I and Q data. Remember that it takes two bytes (16 bits) to represent one I or Q data point.
Creating and Downloading Waveform Files Waveform Structure Waveform Structure To play back waveforms, the signal generator uses data from the following three files: • File header • Marker file • I/Q file All three files have the same name, the name of the I/Q data file, but the signal generator stores each file in its respective directory (headers, markers, and waveform). For information on file extractions, see “Commands for Downloading and Extracting Waveform Data” on page 204.
Creating and Downloading Waveform Files Waveform Structure 4 3 2 1 Marker Number Position Marker Byte 0000 1 0 1 1 Reserved Example of Setting a Marker Byte Binary 0000 0101 Hex 05 Sets markers 1 and 3 on for a waveform point The following example shows a marker binary file (all values in hex) for a waveform with 200 points. Notice the first marker point, 0f, shows all four markers on for only the first waveform point.
Creating and Downloading Waveform Files Waveform Phase Continuity NOTE If you download I/Q data using a file name that currently resides on the signal generator, it also overwrites the existing marker file setting all bits to zero and the file header setting all parameters to unspecified. Waveform A waveform consists of samples. When you select a waveform for playback, the signal generator loads settings from the file header.
Creating and Downloading Waveform Files Waveform Phase Continuity Sampled Sinewave with Phase Discontinuity Phase discontinuity Waveform length Avoiding Phase Discontinuities You can easily avoid phase discontinuities for periodic waveforms by simulating an integer number of cycles when you create your waveform segment. NOTE If there are N samples in a complete cycle, only the first N- 1 samples are stored in the waveform segment.
Creating and Downloading Waveform Files Waveform Phase Continuity Sampled Sinewave with No Discontinuity Added sample Waveform length The following figures illustrate the influence a single sample can have. The generated 3- tone test signal requires 100 samples in the waveform to maintain periodicity for all three tones. The measurement on the left shows the effect of using the first 99 samples rather than all 100 samples.
Creating and Downloading Waveform Files Waveform Memory Waveform Memory The signal generator provides two types of memory, volatile and non- volatile. You can download files to either memory type. Volatile Random access memory that does not survive cycling of the signal generator power. This memory is commonly referred to as waveform memory (WFM1) or waveform playback memory. To play back waveforms, they must reside in volatile memory.
Creating and Downloading Waveform Files Waveform Memory Table 5-2 Signal Generators and Non-Volatile Memory Types Non- Volatile Memory Type Model of Signal Generator N5182A with Option 651, 652, or 654 E4438C with Option 001, 002, 601, or 602 E8267D Option 601 or 602 User PRAM – x x Instrument State x x x Waveform Sequences (multiple I/Q files played together) x x x The following figure on Figure 5- 1 on page 200 shows the locations within the signal generator for volatile and non- volatile
Creating and Downloading Waveform Files Waveform Memory Figure 5-1 Root directory Agilent MXG (Only): 4 USER E443xB Volatile waveform data1 NONVOLATILE E443xB Non-volatile waveform data1 MXG (only) USB media: File listing with extensions1, 2 ARBI ARBQ NVARBI NVARBQ Non-volatile Waveform sequences Non-volatile waveform data (internal storage1, 3) SEQ HEADER WAVEFORM MARKERS SECUREWAVE Volatile waveform directory BBG1 Volatile waveform data HEADER 1For information on using the E443xB direc
Creating and Downloading Waveform Files Waveform Memory As shown in the examples, waveforms can cause the signal generator to allocate more memory than what is actually used, which decreases the amount of available memory. NOTE In the first block of data of volatile memory that is allocated for each waveform file, the file header requires 512 bytes (N5182A) or 256 bytes (E4438C/E8267D).
Creating and Downloading Waveform Files Waveform Memory For more information on default cluster sizes for FAT file structures, refer to Table 5- 3 on page 202 and to http://support.microsoft.com/.
Creating and Downloading Waveform Files Waveform Memory Volatile and Non-Volatile Memory (N5182A) Table 5-4 N5182A Volatile (BBG) and Non-Volatile (Internal Storage and USB Media) Memory Volatile (BBG) Memory Option Non- Volatile (Internal Storage and USB Media) Memory Size Option Size N5182Aa 651/652/654 (BBG) 8 MSa (40 MB) Standard (N5182A) 100 MSa (512 MB) 019 64 MSa (320 MB) USB memory stick user determined a.On the N5182A, 512 bytes is reserved for each waveform’s header file (i.e.
Creating and Downloading Waveform Files Commands for Downloading and Extracting Waveform Data Table 5-6 E4438C and E8267D Non-Volatile (NVWFM) Memory Non- Volatile (NVWFM) Memory Option Size E4438C and E8267D Standard 3 MSa (15 MB) 005 (Hard disk) 1.2 GSa (6 GB) Commands for Downloading and Extracting Waveform Data You can download I/Q data, the associated file header, and marker file information (collectively called waveform data) into volatile or non- volatile memory.
Creating and Downloading Waveform Files Commands for Downloading and Extracting Waveform Data Encrypted I/Q Files and the Securewave Directory The signal generator uses the securewave directory to perform file encryption (extraction) and decryption (downloads). The securewave directory is not an actual storage directory, but rather a portal for the encryption and decryption process.
Creating and Downloading Waveform Files Commands for Downloading and Extracting Waveform Data command for downloading waveform data (#ABC represents the block data): :MMEM:DATA "",#ABC "" the I/Q file name and file path within the signal generator # indicates the start of the data block A the number of decimal digits present in B B a decimal number specifying the number of data bytes to follow in C C the actual binary waveform data The following example demonstrates this str
Creating and Downloading Waveform Files Commands for Downloading and Extracting Waveform Data Table 5-7 Downloading Unencrypted Files for No Extraction (Extraction allowed on the Agilent MXGa Only) Download Method/ Memory Type Command Syntax Options SCPI/volatile memory MMEM:DATA "WFM1:", MMEM:DATA "MKR1:", MMEM:DATA "HDR1:", SCPI/volatile memory with full directory path MMEM:DATA "user/bbg1/waveform/", MMEM:DATA "
Creating and Downloading Waveform Files Commands for Downloading and Extracting Waveform Data Table 5-9 Downloading Unencrypted Files for Extraction Download Method/ Memory Type Command Syntax Options SCPI/non- volatile memorya MEM:DATA:UNPRotected MEM:DATA:UNPRotected MEM:DATA:UNPRotected MEM:DATA:UNPRotected MEM:DATA:UNPRotected MEM:DATA:UNPRotected MEM:DATA:UNPRotected MEM:DATA:UNPRotected MEM:DATA:UNPRotected FTP/volatile memoryb put /user/bbg1/waveform/ put /use
Creating and Downloading Waveform Files Commands for Downloading and Extracting Waveform Data Table 5-11 Downloading Encrypted Files for Extraction Download Method/Memory Type Command Syntax Options SCPI/volatilea memory MEM:DATA:UNPRotected "/user/bbg1/securewave/file_name", MEM:DATA:UNPRotected "SWFM1:file_name", MEM:DATA:UNPRotected "file_name@SWFM1", SCPI/non- volatile memorya MEM:DATA:UNPRotected "/user/securewave/file_name", MEM:DATA:UNPRotected "SNVWF
Creating and Downloading Waveform Files Commands for Downloading and Extracting Waveform Data FTP Procedures There are three ways to FTP files: • use Microsoft’s® Internet Explorer FTP feature • use the PC’s or UNIX command window • use the signal generator’s internal web server following the firmware requirements in the table below Signal Generator Firmware Version (Required for Web Server Compatibility) N518xA All E44x8C ≥ C.03.10 E82x7D, E8663B All Using Microsoft’s Internet Explorer 1.
Creating and Downloading Waveform Files Commands for Downloading and Extracting Waveform Data 2. From the PC command prompt or UNIX command line, type ftp . Where instrument name is the signal generator’s hostname or IP address. 3. At the User: prompt in the ftp window, press Enter (no entry is required). 4. At the Password: prompt in the ftp window, press Enter (no entry is required). 5.
Creating and Downloading Waveform Files Creating Waveform Data For more examples of get command usage refer to Table 5- 14. Table 5-14 Get Command Examples Command Results Local Remote Notes Incorrect get /user/waveform/file file1 get /user/marker/file file1 Results in file1 containing only the marker data. get /user/waveform/file file1.wfm get /user/marker/file file1.mkr Correct Creates a waveform file and a compatible marker file.
Creating and Downloading Waveform Files Creating Waveform Data Code Algorithm This section uses code from the C++ programming example “Importing, Byte Swapping, Interleaving, and Downloading I and Q Data—Big and Little Endian Order” on page 249 to demonstrate how to create and scale waveform data. There are three steps in the process of creating an I/Q waveform: 1. Create the I and Q data. 2. Save the I and Q data to a text file for review. 3.
Creating and Downloading Waveform Files Creating Waveform Data Line 7–11 Code Description—Create I and Q data Create a loop to do the following: • Generate and scale the I data (DAC values). This example uses a simple sine equation, where 2*3.14 equals one waveform cycle. Change the equation to fit your application. — The array pointer, index, increments from 0–499, creating 500 I data points over one period of the sine waveform.
Creating and Downloading Waveform Files Creating Waveform Data 2. Save the I/Q data to a text file to review. The following lines of code export the I and Q data to a text file for validation. After exporting the data, open the file using Microsoft Excel or a similar spreadsheet program, and verify that the I and Q data are correct. Line 12 13 14 15 16 17 18 19 Line 12 Code Description—Saving the I/Q Data to a Text File char *ofile = "c:\\temp\\iq.
Creating and Downloading Waveform Files Creating Waveform Data Line 20 21 22 23 24 25 26 27 28 29 30 Line 20 21–29 Code—Interleaving and Byte Swapping for Little Endian Order char iqbuffer[NUMSAMPLES*4]; for(index=0; index> 8) & 0xFF; iqbuffer[index*4+1] = ivalue & 0xFF; iqbuffer[index*4+2] = (qvalue >> 8) & 0xFF; iqbuffer[index*4+3] = qvalue & 0xFF; } return 0; Code Description—Interleaving a
Creating and Downloading Waveform Files Creating Waveform Data Line 21–29 Code Description—Interleaving and Byte Swapping for Little Endian Order the I and Q data), and interleave the I and Q data.
Creating and Downloading Waveform Files Downloading Waveform Data Line 20 21 22 23 24 25 26 Line 20 Code—Interleaving I and Q data for Big Endian Order short iqbuffer[NUMSAMPLES*2]; for(index=0; index
Creating and Downloading Waveform Files Downloading Waveform Data For advanced programming languages, this section closely examines the code algorithm for downloading I/Q waveform data by breaking the programming examples into functional parts and explaining the code in generic terms. This is done to help you understand the code algorithm in downloading the interleaved I/Q data, so you can leverage the concept into your programming environment.
Creating and Downloading Waveform Files Downloading Waveform Data Line 1 2 3–5 Code Description—Open a Connection Session with the Signal Generator Sets up a structure (indicated above by io) used by subsequent function calls to establish a LAN connection to the signal generator. • agt_newconnection() is the function of Agilent Waveform Download Assistant used in MATLAB to build a connection to the signal generator.
Creating and Downloading Waveform Files Downloading Waveform Data Line 6 Code Description—Download the I/Q data Download the I/Q waveform data to the signal generator by using the function call (agt_waveformload) from the Agilent Waveform Download Assistant. Some of the arguments are optional as indicated below, but if one is used, you must use all arguments previous to the one you require.
Creating and Downloading Waveform Files Downloading Waveform Data Line 1 2 Code Description—Open a Connection Session Assign the signal generator’s LAN hostname, IP address, or GPIB address to a character string. • This example uses the Agilent IO library’s iopen() SICL function to establish a LAN connection with the signal generator. The input argument, lan[hostname or IP address] contains the device, interface, or commander address.
Creating and Downloading Waveform Files Downloading Waveform Data Line 9 Code Description—Download the I/Q data Calculate the total number of bytes, and store the value in the integer variable defined in line 8. In this code, numsamples contains the number of waveform points, not the number of bytes. Because it takes four bytes of data, two I bytes and two Q bytes, to create one waveform point, we have to multiply numsamples by four.
Creating and Downloading Waveform Files Loading, Playing, and Verifying a Downloaded Waveform Line 15 Code Description—Download the I/Q data Send the generated waveform data stored in the I/Q array (iqbuffer) to the signal generator. • iwrite() sends the data specified in iqbuffer to the signal generator (session identifier specified in id). • The third argument of iwrite(), bytesToSend, contains the length of the iqbuffer in bytes. In this example, it is 2000.
Creating and Downloading Waveform Files Loading, Playing, and Verifying a Downloaded Waveform NOTE When you copy a waveform file, marker file, or header file information from volatile or non- volatile memory, the waveform and associated marker and header files are all copied. Conversely, when you delete an I/Q file, the associated marker and header files are deleted. It is not necessary to send separate commands to copy or delete the marker and header files.
Creating and Downloading Waveform Files Loading, Playing, and Verifying a Downloaded Waveform Verifying the Waveform Perform this procedure after completing the steps in the previous procedure, “Playing the Waveform” on page 225. 1. Connect the signal generator to an oscilloscope as shown in the figure. 2. Set an active marker point on the first waveform point for marker one. NOTE Select the same waveform selected in “Playing the Waveform” on page 225.
Creating and Downloading Waveform Files Using the Download Utilities Send the following SCPI command: :MMEMory:CATalog? "WFM1:" 2. Select the waveform segment file(s) from the volatile memory waveform list: Send the following SCPI command: :SOURce:RADio:ARB:WAVeform "WFM1:" 3. Save the waveform segment(s) (“”, “”, ...
Creating and Downloading Waveform Files Downloading E443xB Signal Generator Files • Agilent Waveform Download Assistant: http://www.agilent.com/find/downloadassistant This software provides functions for the MATLAB environment to download waveform data. Features Agilent Signal Studio Toolkit 2 Downloads encrypted waveform files Agilent IntuiLinka Agilent Waveform Download Assistant X Downloads complex MATLAB waveform data X Downloads MATLAB files (.
Creating and Downloading Waveform Files Downloading E443xB Signal Generator Files Storage Locations for E443xB ARB files Place waveforms in either volatile memory or non- volatile memory. The signal generator supports the E443xB directory structure for waveform file downloads (i.e. “ARBI:”, “ARBQ:”, “NVARBI:”, and “NVARBQ:”, see also “SCPI Commands” on page 231).
Creating and Downloading Waveform Files Downloading E443xB Signal Generator Files E443xB 14-Bit Data I data Q data 1100110110111001 Marker bits 14 data bits 0000100111011001 Reserved bits 14 data bits Subtracts 8192, Left Shifts, and Adds Zeros—Removes Marker and Reserved Bits (16-Bit Data Format) 16-bit I data 16-bit Q data 11 1001011011100100 Marker bits removed 00 1000011101100100 Bits added Reserved bits removed Bits added • Creates a marker file and places the marker information, bits 14
Creating and Downloading Waveform Files Programming Examples SCPI Commands Use the following commands to download E443xB waveform files into the signal generator. NOTE To avoid overwriting the current waveform in volatile memory, before downloading files into volatile memory (WFM1), change the file name or turn off the ARB. For more information, on manually turning off the ARB, refer to the User’s Guide. To turn off the ARB remotely, send: :SOURce:RADio:ARB:STATe OFF.
Creating and Downloading Waveform Files Programming Examples C++ Programming Examples This section contains the following programming examples: • • • • • • “Creating and Storing Offset I/Q Data—Big and Little Endian Order” on page 232 “Creating and Storing I/Q Data—Little Endian Order” on page 236 “Creating and Downloading I/Q Data—Big and Little Endian Order” on page 238 “Importing and Downloading I/Q Data—Big Endian Order” on page 242 “Importing and Downloading Using VISA—Big Endian Order” on page 245 “
Creating and Downloading Waveform Files Programming Examples // 1.) Create Simple IQ Signal ***************************************** // This signal is a single tone on the upper // side of the carrier and is usually refered to as // a Single Side Band Suppressed Carrier (SSBSC) signal. // It is nothing more than a cosine wavefomm in I // and a sine waveform in Q.
Creating and Downloading Waveform Files Programming Examples // Find the Maximum amplitude in I and Q to normalize the data between +-1 maxAmp = Iwave[0]; minAmp = Iwave[0]; for( i=0; i Iwave[i] ) minAmp = Iwave[i]; if( maxAmp < Qwave[i] ) maxAmp = Qwave[i]; else if( minAmp > Qwave[i] ) minAmp = Qwave[i]; } maxAmp = fabs(maxAmp); minAmp = fabs(minAmp); if( minAmp > maxAmp ) maxAmp = minAmp; // Convert to short integers and interl
Creating and Downloading Waveform Files Programming Examples // signal generator char *filename = “C:\\Temp\\PSGTestFile”; FILE *stream = NULL; stream = fopen(filename, “w+b”);// Open the file if (stream==NULL) perror (“Cannot Open File”); int numwritten = fwrite( (void *)waveform, sizeof( short ), points*2, stream ); fclose(stream);// Close the file // 3.
Creating and Downloading Waveform Files Programming Examples Creating and Storing I/Q Data—Little Endian Order On the documentation CD, this programming example’s name is “CreateStore_Data_c++.txt.” This C++ programming example (compiled using Metrowerks CodeWarrior 3.
Creating and Downloading Waveform Files Programming Examples for (int i=0; i
Creating and Downloading Waveform Files Programming Examples Creating and Downloading I/Q Data—Big and Little Endian Order On the documentation CD, this programming example’s name is “CreateDwnLd_Data_c++.txt.” This C++ programming example (compiled using Microsoft Visual C++ 6.
Creating and Downloading Waveform Files Programming Examples // Create arrays to hold the I and Q data int idata[NUMSAMPLES]; int qdata[NUMSAMPLES]; // save the number of sampes into numsamples int numsamples = NUMSAMPLES; // Fill the I and Q buffers with the sample data for(int index=0; index
Creating and Downloading Waveform Files Programming Examples int ivalue = idata[index]; int qvalue = qdata[index]; iqbuffer[index*4] = (ivalue >> 8) & 0xFF; // high byte of i iqbuffer[index*4+1] = ivalue & 0xFF; // low byte of i iqbuffer[index*4+2] = (qvalue >> 8) & 0xFF; // high byte of q iqbuffer[index*4+3] = qvalue & 0xFF; // low byte of q } // Big Endian order data, uncomment the following lines of code. // Interleave the I and Q data.
Creating and Downloading Waveform Files Programming Examples // Send parts 1, 2, and 3 iwrite(id, cmd, strlen(cmd), 0, 0); // Send part 4. Be careful to use the correct command here. In many // programming languages, there are two methods to send SCPI commands: // Method 1 = stop at the first ‘0’ in the data // Method 2 = send a fixed number of bytes, ignoring ‘0’ in the data. // You must find and use the correct command for Method 2.
Creating and Downloading Waveform Files Programming Examples Importing and Downloading I/Q Data—Big Endian Order On the documentation CD, this programming example’s name is “impDwnLd_c++.txt.” This C++ programming example (compiled using Metrowerks CodeWarrier 3.0) assumes that the data is in big endian order and performs the following functions: • error checking • binary file importing from the PC or workstation. • binary file download to the signal generator.
Creating and Downloading Waveform Files Programming Examples if( fseek( file, 0, SEEK_END ) < 0 ) { fprintf(stderr,"Cannot seek to the end of file.\n" ); return 0; } long lenToSend = ftell(file); printf("File size = %d\n", lenToSend); if (fseek(file, 0, SEEK_SET) < 0) { fprintf(stderr,"Cannot seek to the start of file.
Creating and Downloading Waveform Files Programming Examples fprintf(stderr, "Could not allocate memory for copy buffer\n"); } fclose(file); iclose(id); return 0; } 244 Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
Creating and Downloading Waveform Files Programming Examples Importing and Downloading Using VISA—Big Endian Order On the documentation CD, this programming example’s name is “DownLoad_Visa_c++.txt.” This C++ programming example (compiled using Microsoft Visual C++ 6.
Creating and Downloading Waveform Files Programming Examples // // IMPORTANT: // Configure the following three lines correctly before compiling and running char* instOpenString ="TCPIP0::xxx.xxx.xxx.
Creating and Downloading Waveform Files Programming Examples long lenToSend = ftell(file);// Number of bytes in the file printf("File size = %d\n", lenToSend); if (fseek(file, 0, SEEK_SET) < 0) { fprintf(stderr,"Cannot lseek to the start of file.
Creating and Downloading Waveform Files Programming Examples { numRead = fread(buf, sizeof(char), BUFFER_SIZE, file); viWrite(vi, buf, numRead, 0); } while (numRead == BUFFER_SIZE); // Send the terminating newline and EOI viSetAttribute( vi, VI_ATTR_SEND_END_EN, 1 ); char* newLine = "\n"; viWrite(vi, (unsigned char*)newLine, 1, 0); delete [] buf; } else { fprintf(stderr, "Could not allocate memory for copy buffer\n"); } fclose(file); viClose(vi); viClose(defaultRM); return 0; } 248 Agilent N518x
Creating and Downloading Waveform Files Programming Examples Importing, Byte Swapping, Interleaving, and Downloading I and Q Data—Big and Little Endian Order On the documentation CD, this programming example’s name is “impDwnLd2_c++.txt.” This C++ programming example (compiled using Microsoft Visual C++ 6.
Creating and Downloading Waveform Files Programming Examples // This is a text file to which we will write the // I and Q data just for debugging purposes. It is // a good programming practice to check your data // in this way before attempting to write it to // the instrument. char *ofile = “c:\\SignalGenerator\\data\\iq.
Creating and Downloading Waveform Files Programming Examples while(!done) { i1 = fgetc(infile); // read the first byte if(i1==EOF) break; i2 = fgetc(infile); // read the next byte if(i2==EOF) break; ivalue=i1+i2*256; // put the two bytes together // note that the above format is for a little endian // processor such as Intel.
Creating and Downloading Waveform Files Programming Examples if (outfile==NULL) perror (“Error opening file to write”); for(index=0; index
Creating and Downloading Waveform Files Programming Examples // // 0 gives 0 V output 32767 gives positive full-scale output // From these ranges, it appears you should offset the // data by 8192 and scale it by 4. However, due to the // interpolators in these products, it is better to scale // the data by a number less than four. Commonly a good // choice is 70% of 4 which is 2.8.
Creating and Downloading Waveform Files Programming Examples // The SCPI command has four parts. // Part 1 = :MEM:DATA “filename”, // Part 2 = length of Part 3 when written to a string // Part 3 = length of the data in bytes. // Part 4 = the buffer of data This is in s from above. // Build parts 1, 2, and 3 for the I data. sprintf(cmd, “:MEM:DATA \”ARBI:FILE1\”, #%d%d”, strlen(s), bytesToSend); // Send parts 1, 2, and 3 iwrite(id, cmd, strlen(cmd), 0, 0); // Send part 4.
Creating and Downloading Waveform Files Programming Examples iwrite(id, iqbuffer, bytesToSend, 0, 0); iwrite(id, “\n”, 1, 1, 0); printf(“Loaded FILE2 using the E4438C, E8267C and E8267D format\n”); return 0; } MATLAB Programming Examples This section contains the following programming examples: • “Creating and Storing I/Q Data” on page 255 • “Creating and Downloading a Pulse” on page 258 Creating and Storing I/Q Data On the documentation CD, this programming example’s name is “offset_iq_ml.m.
Creating and Downloading Waveform Files Programming Examples phaseInc = 2*pi*cycles/points; phase = phaseInc * [0:points-1]; Iwave = cos(phase); Qwave = sin(phase); % 2.) Save waveform in internal format ********************************* % Convert the I and Q data into the internal arb format % The internal arb format is a single waveform containing interleaved IQ % data. The I/Q data is signed short integers (16 bits).
Creating and Downloading Waveform Files Programming Examples end % Save the data to a file % Note: The waveform is saved as unsigned short integers. However, % the acual bit pattern is that of signed short integers and % that is how the Agilent MXG/ESG/PSG interprets them.
Creating and Downloading Waveform Files Programming Examples Creating and Downloading a Pulse NOTE This section applies only to the Agilent MXG and the PSG. For the Agilent MXG, the maximum frequency is 6 GHz, and the pulsepat.m program’s SOURce:FREQuency 20000000000 value must be changed as required in the following programs. For more frequency information, refer to the signal generator’s Data Sheet. On the documentation CD, this programming example’s name is “pulsepat.m.
Creating and Downloading Waveform Files Programming Examples % arrange the i- samples and scale the amplitude to simulate an antenna scan % pattern comprised of 10 pulses i = .707*[rise on fall off... [.9*[rise on fall off]]... [.8*[rise on fall off]]... [.7*[rise on fall off]]... [.6*[rise on fall off]]... [.5*[rise on fall off]]... [.4*[rise on fall off]]... [.3*[rise on fall off]]... [.2*[rise on fall off]]... [.
Creating and Downloading Waveform Files Programming Examples [status, status_description] = agt_sendcommand(io, 'SOURce:FREQuency 20000000000'); [status, status_description] = agt_sendcommand(io, 'POWer 0'); % define the ARB sample clock for playback sampclk = 40000000; % download the iq waveform to the PSG baseband generator for playback [status, status_description] = agt_waveformload(io, IQData, 'pulsepat', sampclk, 'play', 'no_normscale', Markers); % turn on RF output power [status, status_description ]
Creating and Downloading Waveform Files Programming Examples NOTE For the Agilent MXG, the SOURce:FREQuency 20000000000 value must be changed as required in the following programs. For more information, refer to the Data Sheet. barker.m This programming example calculates and downloads an arbitrary waveform file that simulates a simple 7–bit barker RADAR signal to the PSG vector signal generator. chirp.
Creating and Downloading Waveform Files Programming Examples Visual Basic Programming Examples Creating I/Q Data—Little Endian Order On the documentation CD, this programming example’s name is “Create_IQData_vb.txt.” This Visual Basic programming example, using Microsoft Visual Basic 6.
Creating and Downloading Waveform Files Programming Examples AMPLITUDE = 32767 ' Scale the amplitude for full range of the signal generators ' I/Q modulator DAC pi = 3.
Creating and Downloading Waveform Files Programming Examples On Error GoTo file_error For index = 0 To (numPoints) data = iq_data(index) Put #FileHandle, index + 1, data 'Write the I/Q data to the file Next index Close #FileHandle Call MsgBox("Data written to file " & strFilename, vbOKOnly, "Download") Exit Sub file_error: MsgBox Err.
Creating and Downloading Waveform Files Programming Examples Downloading I/Q Data On the signal generator’s documentation CD, this programming example’s name is “Download_File_vb.txt.” This Visual Basic programming example, using Microsoft Visual Basic 6.0, downloads the file created in “Creating I/Q Data—Little Endian Order” on page 262 into non- volatile memory using a LAN connection. To use GPIB, replace the instOpenString object declaration with “GPIB::19::INSTR”.
Creating and Downloading Waveform Files Programming Examples Private Sub Download_File() ' The following four lines declare IO objects and instantiate them. Dim rm As VisaComLib.ResourceManager Set rm = New AgilentRMLib.SRMCls Dim SigGen As VisaComLib.FormattedIO488 Set SigGen = New VisaComLib.FormattedIO488 ' NOTE: Use the IP address of your signal generator in the rm.Open declaration Set SigGen.IO = rm.Open("TCPIP0::000.000.000.
Creating and Downloading Waveform Files Programming Examples Get #FileHandle, index + 1, data '(index+1) is the record number iq_data(index) = data Next index Close #FileHandle 'Close the file 'Write the command to the Header string. NOTE: syntax Header = "MEM:DATA ""/USER/WAVEFORM/IQ_DataVB""," 'Now write the data to the signal generator's non-volatile memory (NVWFM) SigGen.WriteIEEEBlock Header, iq_data SigGen.WriteString "*OPC?" 'Wait for the operation to complete response = SigGen.
Creating and Downloading Waveform Files Programming Examples As discussed at the beginning of this section, I and Q waveform data is interleaved into one file in 2’s compliment form and a marker file is associated with this I/Q waveform file. In the Output commands, USING “#,K” formats the data. The pound symbol (#) suppresses the automatic EOL (End of Line) output. This allows multiple output commands to be concatenated as if they were a single output.
Creating and Downloading Waveform Files Programming Examples Program Comments (Continued) 20: Sets the number of points in the waveform. 30: Allocates integer data array for I and Q waveform points. 40: Sets HP BASIC to use degrees for cosine and sine functions. 50: Sets up first loop for I waveform points. 60: Calculate and interleave I waveform points. 70: End of loop 80 Sets up second loop for Q waveform points. 90: Calculate and interleave Q waveform points. 100: End of loop.
Creating and Downloading Waveform Files Programming Examples Creating and Downloading Waveform Data Using HP BASIC for UNIX On the documentation CD, this programming example’s name is “hpbasicUx.txt.” The following program shows you how to download waveforms using HP Basic for UNIX. The code is similar to that shown for HP BASIC for Windows, but there is a formatting difference in line 130 and line 140.
Creating and Downloading Waveform Files Programming Examples 290 END Program Comments 10: Program file name 20: Sets the number of points in the waveform. 30: Allocates integer data array for I and Q waveform points. 40: Sets HP BASIC to use degrees for cosine and sine functions. 50: Sets up first loop for I waveform points. 60: Calculate and interleave I waveform points. 70: End of loop 80 Sets up second loop for Q waveform points. 90: Calculate and interleave Q waveform points.
Creating and Downloading Waveform Files Programming Examples Creating and Downloading E443xB Waveform Data Using HP BASIC for Windows On the documentation CD, this programming example’s name is “e443xb_hpbasicWin2.txt.” The following program shows you how to download waveforms using HP Basic for Windows into volatile ARB memory. This program is similar to the following program example as well as the previous examples.
Creating and Downloading Waveform Files Programming Examples 250 OUTPUT @Esg;END 260 ASSIGN @Esg TO * 270 ASSIGN @Esgb TO * 280 PRINT 290 PRINT "*END*" 300 END Program Comments 10: Program file name. 20 Sets the number of points in the waveform. 30: Defines arrays for I and Q waveform points. Sets them to be integer arrays. 40: Sets HP BASIC to use degrees for cosine and sine functions. 50: Sets up loop to calculate waveform points. 60: Calculates I waveform points.
Creating and Downloading Waveform Files Programming Examples Creating and Downloading E443xB Waveform Data Using HP Basic for UNIX On the documentation CD, this programming example’s name is “e443xb_hpbasicUx2.txt.” The following program shows you how to download waveforms using HP BASIC for UNIX. It is similar to the previous program example. The difference is the way the formatting for the most significant bit (MSB) on lines is handled.
Creating and Downloading Waveform Files Programming Examples 300 END Program Comments 10: Program file name. 20 Sets the number of points in the waveform. 30: Defines arrays for I and Q waveform points. Sets them to be integer arrays. 40: Sets HP BASIC to use degrees for cosine and sine functions. 50: Sets up loop to calculate waveform points. 60: Calculates I waveform points. 70: Calculates Q waveform points. 80: End of loop.
Creating and Downloading Waveform Files Troubleshooting Waveform Files Troubleshooting Waveform Files Symptom Possible Cause Attempting to download a waveform that has the same name as the waveform currently being played by the signal generator. ERROR 224, Text file busy To solve the problem, either change the name of the waveform being downloaded or turn off the ARB. ERROR 628, DAC over range The amplitude of the signal exceeds the DAC input range.
Creating and Downloading Waveform Files Troubleshooting Waveform Files Configuring the Pulse/RF Blank (Agilent MXG) If the default marker is used, toggle the Pulse/RF Blank (None) softkey to None. For more information on markers, refer to “Marker File” on page 193. SCPI commands: [:SOURce]:RADio[1]:ARB:MDEStination:PULSe NONE|M1|M2|M3|M4 [:SOURce]:RADio[1]:ARB:MDEStination:PULSe? For details on each key, use the key help. Refer to “Getting Help (Agilent MXG)” on page 18 and the User’s Guide.
Creating and Downloading Waveform Files Troubleshooting Waveform Files 278 Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
6 NOTE Creating and Downloading User-Data Files Some features apply to only the E4438C with Option 001, 002, 601, or 602 and E8267D with Option 601 or 602. These exceptions are indicated in the sections. On the Agilent MXG, the internal baseband generator speed upgrade Options 670, 671, and 672 are option upgrades that require Option 651 and 652 to have been loaded at the factory (refer to the Data Sheet for more information). Any references to 651, 652, or 654 are inclusive of 671, 672, and 674.
Creating and Downloading User-Data Files Overview Overview User data is a generic term for various data types created by the user and stored in the signal generator. This includes the following data (file) types: Bit This file type lets the user download payload data for use in streaming or framed signals. It lets the user determine how many bits in the file the signal generator uses. Binary This file type provides payload data for use in streaming or framed signals.
Creating and Downloading User-Data Files Signal Generator Memory Signal Generator Memory The signal generator provides two types of memory, volatile and non- volatile. NOTE User BIT, and User PRAM references are only applicable to the E4438C with Options 001, 002, 601, or 602, and E8267D with Options 601 or 602. User FIR references are only applicable to the N5182A with Options 651, 652, or 654, E4438C with Options 001, 002, 601, or 602, and E8267D with Options 601 or 602.
Creating and Downloading User-Data Files Signal Generator Memory Table 7-1 Signal Generators and Non-Volatile Memory Types Non- Volatile Memory Type Model of Signal Generator N5182A with Option 651, 652, or 654 E4438C with Option 001, 002, 601, or 602 E8267D Option 601 or 602 All Other modelsa I/Q x x x – Marker x x x – File header x x x – Sweep List x x x – User PRAM – x x – User Binary x x x – User Bit – x x – User FIR x x x – Instrument State x x x x Wav
Creating and Downloading User-Data Files Signal Generator Memory Root directory Agilent MXG (Only): Internal Storage media (i.e.
Creating and Downloading User-Data Files Signal Generator Memory (see table on page 284). For example, referring to table on page 284, if the drive size is 15 MB and if the file is less than or equal to 4k bytes, the file uses only one 4 KB cluster of memory. For files larger than 4 KB, and with a drive size of 15 MB, the signal generator allocates additional memory in multiples of 4KB clusters. For example, a file that has 21,538 bytes consumes 6 memory clusters (24,000 bytes).
Creating and Downloading User-Data Files Signal Generator Memory Table 8 Maximum Signal Generator Memory Volatile (WFM1/PRAM) Memory Option Non- Volatile (NVWFM) Memory Size Option Size N5182A 651, 652, 654a (BBG) 40 MB Standard 019 320 MB USB memory stick 512 MB user determined E4438C and E8267D 001, 601 32 MB Standard 002 (BBG)b 128 MB 005 (Hard disk) 6 GB 602 (BBG) 256 MB ---- ---- 512 MB (BBG)b a.
Creating and Downloading User-Data Files User File Data (Bit/Binary) Downloads (E4438C and E8267D) Table 8-1 User-Data File Memory Location User- Data File Type Download Memory Access Memory PRAM Volatile Volatile Instrument State Non- volatile Non- volatile FIR Non- volatile Non- volatile Flatness Non- volatile Non- volatile Bit and binary files increase in size when the signal generator loads the data from non- volatile to volatile memory.
Creating and Downloading User-Data Files User File Data (Bit/Binary) Downloads (E4438C and E8267D) The signal generator accepts externally created and downloaded user file data for real- time modulation formats that have user file as a data selection (shown as <“file_name”> in the data selection SCPI command). When you select a user file, the signal generator incorporates the user file data (payload data) into the modulation format’s data fields.
Creating and Downloading User-Data Files User File Data (Bit/Binary) Downloads (E4438C and E8267D) timeslots/frames User File Bit Order (LSB and MSB) The signal generator views the data from the most significant bit (MSB) to the least significant bit (LSB). When you create your user file data, it is important that you organize the data in this manner. Within groups (strings) of bits, a bit’s value (significance) is determined by its location in the string.
Creating and Downloading User-Data Files User File Data (Bit/Binary) Downloads (E4438C and E8267D) SCPI Command :MEM:DATA:BIT <"file_name">,, :MEM:DATA:BIT "3byte",23, # 1 3 Z&x ASCII representation of the data (3 bytes) Start block data number of bytes number of decimal digits Bits of interest Downloaded Data: 0 1 0 1 1 0 1 0 0 0 1 0 0 1 1 0 0 1 1 1 1 0 0 0 MSB Hex Value: ASCII Representation: Byte 1 5A Byte 2 26 Byte 3 78 & x Z Ignored bit (LSB) The following figure
Creating and Downloading User-Data Files User File Data (Bit/Binary) Downloads (E4438C and E8267D) more 4- bit nibbles. To make the last nibble, the signal generator adds bits with a value of zero. The signal generator does not show the added bits in the bit editor and ignores the added bits when it modulates the data onto the signal, but these added bits do appear in the hex value displayed in the bit file editor.
Creating and Downloading User-Data Files User File Data (Bit/Binary) Downloads (E4438C and E8267D) Binary File Type Data With the Binary file type, the signal generator sees all of the bytes within the downloaded file and attempts to use all of the data bits. When using this file type, the biggest challenge is creating the data, so that the signal generator uses all of the bits (bytes) contained within the file. This is referred to as using an even number of bytes.
Creating and Downloading User-Data Files User File Data (Bit/Binary) Downloads (E4438C and E8267D) Framed Binary Data When using framed data, ensure that you use an even number of bytes and that the bytes contain enough bits to fill the data fields within a timeslot or frame. When there are not enough bits to fill a single timeslot or frame, the signal generator replicates the data pattern until it fills the timeslot/frame.
Creating and Downloading User-Data Files User File Data (Bit/Binary) Downloads (E4438C and E8267D) PRAM. (Volatile memory resides on the BBG.) Table 8- 2 shows the maximum file sizes by modulation format and baseband generator option. Table 8-2 Maximum User File Size Baseband Generator Option Modulation Format 001, 601 002 602 Customa TDMAa 800 kB 3.2 MB 6.4 MB CDMAb GPSb W- CDMAb 10 kB 10 kB 10 kB a.File size with no other files residing in volatile memory. b.
Creating and Downloading User-Data Files User File Data (Bit/Binary) Downloads (E4438C and E8267D) Calculating Volatile Memory (PRAM) Usage for Unframed Data Use this procedure to calculate the memory size for either a bit or binary file. To properly demonstrate this process, the procedure employs a user file that contains 70 bytes (560 bits), with the bit file using only 557 bits. 1.
Creating and Downloading User-Data Files User File Data (Bit/Binary) Downloads (E4438C and E8267D) AUTOGEN_PRAM_1 file size. If you select different user files for the timeslots within a frame, the user file that produces the largest number of frames determines the size of the AUTOGEN_PRAM_1 file. Use this procedure to calculate the volatile memory usage for a GSM signal with two active timeslots and two user binary files.
Creating and Downloading User-Data Files User File Data (Bit/Binary) Downloads (E4438C and E8267D) 8. Round the memory block value up to the next highest integer value. For this example, the AUTOGEN_PRAM_1 file will use 20 blocks of memory for a total of 20480 bytes. 9. Determine the number of memory blocks that the original files occupy in volatile memory. The files do not share memory blocks, so you must determine how many memory blocks each file occupies.
Creating and Downloading User-Data Files User File Data (Bit/Binary) Downloads (E4438C and E8267D) the file data in bytes C :MEM:DATA “bin:my_file”,#324012%S!4&07#8g*Y9@7...
Creating and Downloading User-Data Files User File Data (Bit/Binary) Downloads (E4438C and E8267D) Line Code Description—Download User File Data 1 Define an integer variable (bytesToSend) to store the number of bytes to send to the signal generator. 2 Calculate the total number of bytes, and store the value in the integer variable defined in line 1. 3 Create a string large enough to hold the bytesToSend value as characters.
Creating and Downloading User-Data Files User File Data (Bit/Binary) Downloads (E4438C and E8267D) Line 8 Code Description—Download User File Data Send the user file data stored in the array (databuffer) to the signal generator. • iwrite() sends the data specified in databuffer to the signal generator (session identifier specified in id). • The third argument of iwrite(), bytesToSend, contains the length of the databuffer in bytes. In this example, it is 2000.
Creating and Downloading User-Data Files User File Data (Bit/Binary) Downloads (E4438C and E8267D) Table 8-3 Bit File Type SCPI Commands Type Command Syntax Query :MEM:DATA:BIT? <"file_name"> Within the context of a program this query extracts the user file data. Executing the query in a command window causes it to return the following information: ,.
Creating and Downloading User-Data Files User File Data (Bit/Binary) Downloads (E4438C and E8267D) Table 8-4 Binary File Type Commands Command Type Command Syntax Query :MEM:DATA? "bin:file_name" This returns information on the named file: ,. Within the context of a program, this query extracts the user file, provided it was download with the proper command.
Creating and Downloading User-Data Files User File Data (Bit/Binary) Downloads (E4438C and E8267D) :RADio:CUSTom:DATA "BIT:file_name" :RADio:CUSTom:DATA "BIN:file_name" Framed Data :RADio:GSM:SLOT0|1|2|3|4|5|6|7:NORMal:ENCRyption "BIT:file_name" :RADio:GSM:SLOT0|1|2|3|4|5|6|7:NORMal:ENCRyption "BIN:file_name" 3. Configure the remaining signal parameters. 4.
Creating and Downloading User-Data Files User File Data (Bit/Binary) Downloads (E4438C and E8267D) Modifying a Bit File with a Hex Editor 1. FTP the file to your PC/UNIX. For information on using FTP, see FTP Procedures. Ensure that you use binary file transfers during FTP operations. 2. Modify the file using a hex editor program. If you need to decrease or increase the number of bits of interest, change the file header hex value.
Creating and Downloading User-Data Files User File Data (Bit/Binary) Downloads (E4438C and E8267D) Using the Signal Generator’s Internal Web Server 1. Enter the signal generator’s hostname or IP address in the URL. http:// or 2. Click the Signal Generator FTP Access button located on the left side of the window. The signal generator files appear in the web browser’s window. 3.
Creating and Downloading User-Data Files User File Data (Bit/Binary) Downloads (E4438C and E8267D) Figure 8-1 GSM Multiframe Transmission When you select a user file as the data source for a framed transmission, the signal generator’s firmware loads PRAM with the framing protocol of the active TDMA format. This creates a file named AUTOGEN_PRAM_1 in addition to a copy of the user file.
Creating and Downloading User-Data Files User File Data (Bit/Binary) Downloads (E4438C and E8267D) Figure 8-2 Mapping User File Data to a Single Timeslot NOTE Compliant with the GSM standard, which specifies 156.25- bit timeslots, the signal generator uses 156- bit timeslots and adds an extra guard bit to every fourth timeslot. For this protocol configuration, the signal generator’s firmware loads PRAM with the bits defined in the following table. (These bits are part of the 32- bit word per frame bit.
Creating and Downloading User-Data Files User File Data (Bit/Binary) Downloads (E4438C and E8267D) Event 1 output is set to 0 or 1 depending on the sync out selection, which enables the EVENT 1 output at either the beginning of the frame, beginning of a specific timeslot, or at all timeslots (SCPI command, :RADio:GSM:SOUT FRAME|SLOT|ALL). Because timeslots are configured and enabled within the signal generator, a user file can be individually assigned to one or more timeslots.
Creating and Downloading User-Data Files User File Data (Bit/Binary) Downloads (E4438C and E8267D) continuous data stream. This means that it does not apply to a downloaded PRAM file type (covered later in this chapter). In parallel mode, for a 256QAM modulation scheme, Custom has the capability to reach a data rate of up to 400 Mbps. The FIR filter width is what determines the data rate. The following table shows the maximum data rate for each modulation type.
Creating and Downloading User-Data Files Pattern RAM (PRAM) Data Downloads (E4438C and E8267D) 32QAM (5 bits per symbol) bit rate = bits per symbol x symbol rate 10 Msps 20 ns 10.000001 Msps 100 ns NOTE: The pulse widths values are only for example purposes. The actual width may vary from the above values. Pattern RAM (PRAM) Data Downloads (E4438C and E8267D) NOTE This section applies only to the E4438C with Option 001, 002, 601, or 602, and the E8267D with Option 601 or 602.
Creating and Downloading User-Data Files Pattern RAM (PRAM) Data Downloads (E4438C and E8267D) E4438C ESG Customa E2867D PSG TDMAb Customa a. For ESG, requires Option 001, 002, 601, or 602, for PSG requires Option 601 or 602. b. Real-time TDMA modulation formats require Option 402 and include EDGE, GSM, NADC, PDC, PHS, DECT, and TETRA. PRAM files differ from bit and binary user files.
Creating and Downloading User-Data Files Pattern RAM (PRAM) Data Downloads (E4438C and E8267D) Table 8-5 PRAM Data Byte Bit Function Value 1 Reserved 0 2 Burst 3 Reserved 0 Always 0 4 Reserved 1 Always 1 5 Reserved 0 Always 0 6 EVENT1 Output 0/1 To have the signal generator output a single pulse at the EVENT 1 connector, set this bit to 1.
Creating and Downloading User-Data Files Pattern RAM (PRAM) Data Downloads (E4438C and E8267D) Pattern Reset EVENT 1 Output Reserved (Bit = 0) Reserved (Bit = 1) Reserved (Bit = 0) Burst Reserved (Bit = 0) Data Table 8-6 PRAM Byte Patterns and Bit Positions Bit Position 7 6 5 4 3 2 1 0 --- Bit Pattern 1 1 0 1 0 1 0 1 213 1 1 0 1 0 1 0 0 212 1 1 0 1 0 0 0 1 209 1 1 0 1 0 0 0 0 208 1 0 0 1 0 1 0 1 149 1 0 0 1 0 0 0 1 145 1 0 0 1 0
Creating and Downloading User-Data Files Pattern RAM (PRAM) Data Downloads (E4438C and E8267D) PRAM File Size Because volatile memory resides on the baseband generator (BBG), the maximum PRAM file size depends on the installed baseband generator option, as shown in Table 8- 7. Table 8-7 Maximum PRAM User File Size (Payload Bits Only) Baseband Generator Option Modulation Format Custom TDMA 001, 601 002 602 8 Mbitsa 32 Mbitsa 64 Mbitsa a. File size with no other files residing in volatile memory.
Creating and Downloading User-Data Files Pattern RAM (PRAM) Data Downloads (E4438C and E8267D) Minimum File Size A PRAM file requires a minimum of 60 bytes to create a signal. If the downloaded file contains less than 60 bytes, the signal generator replicates the file until the file size meets the 60 byte minimum. This replication process occurs after you select the file and turn the modulation format on.
Creating and Downloading User-Data Files Pattern RAM (PRAM) Data Downloads (E4438C and E8267D) Command Syntax :MEMory:DATA:PRAM:FILE:LIST <"file_name">,[,,<...>] The decimal equivalent of an unsigned 8- bit integer value. For a list of usable decimal values and their meaning with respect to the generated signal, see Table 8- 6 on page 312.
Creating and Downloading User-Data Files Pattern RAM (PRAM) Data Downloads (E4438C and E8267D) :MEMory:DATA:PRAM:FILE:BLOCk <"file_name">,#ABC <"file_name"> the file name as it will appear in the signal generator # indicates the start of the block data A the number of decimal digits present in B B a decimal number specifying the number of data bytes to follow in C C the PRAM file data in bytes :MEMory:DATA:PRAM:FILE:BLOCk “my_file”,#324012%S!4&07#8g*Y9@7...
Creating and Downloading User-Data Files Pattern RAM (PRAM) Data Downloads (E4438C and E8267D) Line Code Description—Download PRAM File Data 1 Define an integer variable (bytesToSend) to store the number of bytes to send to the signal generator. 2 Store the total number of PRAM bytes in the integer variable defined in line 1. numbytes contains the length of the databuffer array referenced in line 8.
Creating and Downloading User-Data Files Pattern RAM (PRAM) Data Downloads (E4438C and E8267D) Line 8 Code Description—Download PRAM File Data Send the PRAM file data stored in the array, databuffer, to the signal generator. • iwrite() sends the data specified in databuffer (PRAM data) to the signal generator (session identifier specified in id). • The third argument of iwrite(), bytesToSend, contains the length of the databuffer in bytes. In this example, it is 240.
Creating and Downloading User-Data Files Pattern RAM (PRAM) Data Downloads (E4438C and E8267D) :RADio:GSM:STATe On Modulating and Activating the Carrier Use the following commands to modulate the carrier and turn on the RF output. For a complete listing of SPCI commands, refer to the SCPI Command Reference. :FREQuency:FIXed 1.8GHZ :POWer:LEVel -10.
Creating and Downloading User-Data Files Pattern RAM (PRAM) Data Downloads (E4438C and E8267D) CAUTION Ensure that you do not use the :MEMory:DATA:PRAM:FILE:BLOCk command to download an extracted file. If you use this command, the signal generator will treat the file as a new PRAM file and translate the LSB of each byte into a 32- bit word, corrupting the file data. Command Syntax This section lists the commands for extracting PRAM files and downloading extracted PRAM files.
Creating and Downloading User-Data Files Pattern RAM (PRAM) Data Downloads (E4438C and E8267D) Table 8-10 Downloading a File for Extraction Download Method/ Memory Type Command Syntax Options SCPI/non- volatile memory :MEM:DATA:UNPRotected "NVWFM:file_name", :MEM:DATA:UNPRotected "file_name@NVWFM", :MEM:DATA:UNPRotected "/user/waveform/file_name", FTP/volatile memorya put /user/bbg1/waveform/file_name FTP/non- volatile put /user/waveform/file_
Creating and Downloading User-Data Files FIR Filter Coefficient Downloads (N5182A, E4438C and E8267D) 60 byte PRAM file prior to downloading 60 byte PRAM file after downloading FIR Filter Coefficient Downloads (N5182A, E4438C and E8267D) NOTE If you encounter problems with this section, refer to “Data Transfer Troubleshooting (N5182A, E4438C and E8267D Only)” on page 340. The signal generator accepts finite impulse response (FIR) filter coefficient downloads.
Creating and Downloading User-Data Files FIR Filter Coefficient Downloads (N5182A, E4438C and E8267D) The sampling period (Δt) is equal to the inverse of the sampling rate (FS). The sampling rate is equal to the symbol rate multiplied by the oversample ratio. For example, the GSM symbol rate is 270.83 ksps. With an oversample ratio of 4, the sampling rate is 1083.32 kHz and Δt (inverse of FS) is 923.088 nsec.
Creating and Downloading User-Data Files FIR Filter Coefficient Downloads (N5182A, E4438C and E8267D) FIR Filter Data for Custom Modulation The following remote command selects user FIR filter data as the active filter for a custom modulation format. :RADio:CUSTom:FILTer <"file_name"> This command selects the user FIR filter, specified by the file name, as the active filter for the custom modulation format.
Creating and Downloading User-Data Files Save and Recall Instrument State Files Save and Recall Instrument State Files NOTE References to waveform files and some of the other data file types mentioned in the following sections are not available for all models and options of signal generator. Refer to the instrument’s Data Sheet for the signal generator and options being used. The signal generator can save instrument state settings to memory.
Creating and Downloading User-Data Files Save and Recall Instrument State Files The recall function recalls a saved instrument state. If there is a data file associated with the instrument state, the file will be loaded along with the instrument state. The following command recalls the instrument state saved in register 01, sequence 1. *RCL 01,1 Save and Recall Programming Example Using VISA and C# The following programming example uses VISA and C# to save and recall signal generator instrument states.
Creating and Downloading User-Data Files Save and Recall Instrument State Files Perform the following steps to run the State_Files program. 1. Copy the State_Files.cs file from the CD–ROM programming examples section to the directory where the .NET Framework is installed. 2. Change the TCPIP0 address in the program from TCPIP0::000.000.000.000 to your signal generator’s address. 3. Save the file using the .cs file name extension. 4. Run the Command Prompt program. Start > Run > "cmd.exe".
Creating and Downloading User-Data Files Save and Recall Instrument State Files // The Agilent VISA library must be installed on your computer for this example to run. // Important: Replace the visaOpenString with the IP address for your signal generator. // //**************************************************************************************** using System; using System.IO; using System.Text; using System.Runtime.InteropServices; using System.Collections; using System.Text.
Creating and Downloading User-Data Files Save and Recall Instrument State Files bool quit = false; while (!quit)// Get user input { Console.Write("1) Backup state files\n" + "2) Restore state files\n" + "3) Quit\nEnter 1,2,or 3. Your choice: "); string choice = Console.
Creating and Downloading User-Data Files Save and Recall Instrument State Files the local directory (identified by a ".STA" file name extension) to the signal generator.*/ static public void RestoreInstrumentState(uint device) { DirectoryInfo di = new DirectoryInfo(".");// Instantiate object class FileInfo[] rgFiles = di.GetFiles("*.STA"); // Get the state files foreach(FileInfo fi in rgFiles) { Match m = Regex.Match(fi.Name, @"^(\d)_(\d\d)"); if (m.Success) { string sequence = m.Groups[1].
Creating and Downloading User-Data Files Save and Recall Instrument State Files string catalog = ReadDevice(device); /* Match the catalog listing for state files which are named (sequence#)_(register#) e.g. 0_01, 1_01, 2_05*/ Match m = Regex.Match(catalog, "\"(\\d_\\d\\d),"); while (m.Success) { // Grab the matched filename from the regular expresssion string nextFile = m.Groups[1].ToString(); // Retrieve the file and store with a .STA extension // in the current directory Console.
Creating and Downloading User-Data Files Save and Recall Instrument State Files string retValue = ""; byte[] buf = new byte[MAX_READ_DEVICE_STRING]; // 1024 bytes maximum read uint retCount; if (VisaInterop.Read(device, buf, (uint)buf.Length -1, out retCount) == 0) { retValue = Encoding.ASCII.GetString(buf, 0, (int)retCount); } return retValue; } /* The following method reads a SCPI definite block from the signal generator and writes the contents to a file on your computer.
Creating and Downloading User-Data Files Save and Recall Instrument State Files NOT appended to the block and END is not sent at the conclusion of the write.*/ static public void WriteFileBlock(uint device, string fileName) { // Make sure that the file exists, otherwise sends a null block if (File.Exists(fileName)) { FileStream fs = new FileStream(fileName, FileMode.Open); // Send the definite block header: #{lengthDataLength}{dataLength} string fileSize = fs.Length.
Creating and Downloading User-Data Files Save and Recall Instrument State Files LoadConfig = 4 } // Declaration of VISA attribute constants public enum VisaAttribute { SendEndEnable = 0x3FFF0016, TimeoutValue = 0x3FFF001A } // This class provides a way to call the unmanaged Agilent IO Library VISA C // functions from the C# application public class VisaInterop { [DllImport("agvisa32.dll", EntryPoint="viClear")] public static extern int Clear(uint session); [DllImport("agvisa32.
Creating and Downloading User-Data Files Save and Recall Instrument State Files [DllImport("agvisa32.dll", EntryPoint="viOpenDefaultRM")] public static extern int OpenDefaultRM(out uint session); [DllImport("agvisa32.dll", EntryPoint="viRead")] public static extern int Read( uint session, byte[] buf, uint count, out uint retCount); [DllImport("agvisa32.dll", EntryPoint="viSetAttribute")] public static extern int SetAttribute(uint vi, VisaAttribute attribute, uint attrState); [DllImport("agvisa32.
Creating and Downloading User-Data Files User Flatness Correction Downloads Using C++ and VISA User Flatness Correction Downloads Using C++ and VISA This sample program uses C++ and the VISA libraries to download user–flatness correction values to the signal generator. The program uses the LAN interface but can be adapted to use the GPIB interface by changing the address string in the program. You must include header files and resource files for library functions needed to run this program.
Creating and Downloading User-Data Files User Flatness Correction Downloads Using C++ and VISA //************************************************************************************ // PROGRAM NAME:FlatCal.cpp // // PROGRAM DESCRIPTION:C++ Console application to input frequency and amplitude // pairs and then download them to the signal generator. // // NOTE: You must have the Agilent IO Libraries installed to run this program.
Creating and Downloading User-Data Files User Flatness Correction Downloads Using C++ and VISA if (status)//if any errors then display the error and exit the program { fprintf(stderr, "viOpen failed (%s)\n", instOpenString); return -1; } printf("Example Program to Download User Flatness Corrections\n\n"); printf("Enter number of frequency and amplitude pairs: "); int num = 0; scanf("%d", &num); if (num > 0) { int lenArray=num*2;//length of the pairsList[] array.
Creating and Downloading User-Data Files User Flatness Correction Downloads Using C++ and VISA { sprintf((char*)str,":corr:flat:pair %s %c %s\n",pairsList[2*j], c, pairsList[2*j+1]); // << on SAME line! viWrite(vi, str,strlen((char*)str),0); } //store the downloaded correction pairs to PSG memory const char* fileName = "flatCal_data";//user flatness file name //write the SCPI command to the buffer str sprintf((char*)str, ":corr:flat:store \"%s\"\n", fileName);//write to buffer viWrite(vi,str,strlen((char*)
Creating and Downloading User-Data Files Data Transfer Troubleshooting (N5182A, E4438C and E8267D Only) Data Transfer Troubleshooting (N5182A, E4438C and E8267D Only) NOTE The section, User FIR Filter Coefficient File Download Problems, applies to the N5182A with Option 651, 652, or 654; the E4438C with Option 001, 002, 601, or 602; and the E8267D with Option 601 or 602.
Creating and Downloading User-Data Files Data Transfer Troubleshooting (N5182A, E4438C and E8267D Only) Requirement for Continuous User File Data Transmission “Integer Number of Timeslots” Requirement for Multiple-Timeslots If a user file fills the data fields of more than one timeslot in a continuously repeating framed transmission, the user file is restarted after the last timeslot containing completely filled data fields. For example, if the user file contains enough data to fill the data fields of 3.
Creating and Downloading User-Data Files Data Transfer Troubleshooting (N5182A, E4438C and E8267D Only) Table 8-13 PRAM Download - Symptoms and Causes Symptom Possible Cause PRAM download exceeds the size of PRAM memory. ERROR - 223, Too much data Either use a smaller pattern or get more memory by ordering the appropriate hardware option.
Creating and Downloading User-Data Files Data Transfer Troubleshooting (N5182A, E4438C and E8267D Only) User FIR Filter Coefficient File Download Problems Table 8-15 User FIR File Download Trouble - Symptoms and Causes Symptom Possible Cause There is not enough memory available for the FIR coefficient file being downloaded. ERROR - 321, Out of memory To solve the problem, either reduce the file size of the FIR file or delete unnecessary files from memory. User FIR filter has too many symbols.
Creating and Downloading User-Data Files Data Transfer Troubleshooting (N5182A, E4438C and E8267D Only) 344 Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
Index Symbols .
Index modifying hex editor 303 order, user file 288 status, monitoring 149 values 148 bits and bytes 185 byte order byte swapping 188 changing byte order 188 interleaving I/Q data 215 C C AC- coupled FM signals generating externally applied 79 CW signals, generating 77 data questionable status register, reading 90 FM signals, generating internally applied 81 reading the service request interrupt 94 Sockets LAN, programming 105 states, saving and recalling 88 C and VISA GPIB queries 75 GPIB, interface check
Index BERT status 180 calibration status 177 frequency status 171 modulation status 174 power status 168 status 165 status register reading, using VISA and C 90 data questionable registers BERT event 182 BERT event enable 182 BERT, condition 181 calibration condition 178 calibration event 178 calibration event enable 179 condition 166 event 167 event enable 167 frequency condition 172 frequency event 172 frequency event enable 173 modulation condition 175 modulation event 175 modulation event enable 176 pow
Index esg 205 psg 205 waveform data 204 enter function 66 errors 19, 35 ESE commands 151 esg See Agilent esg even number of samples 195 event enable register description 156 event registers description 156 example programs See programming examples 231 examples pass- thru commands 98 save and recall 326 Telnet 43 external media See USB media external memory See USB media externally applied AC- coupled FM signals generate, using VISA and C 79 extract user file data 320–321 extracting PRAM files 319 filter da
Index using VISA and C 68 verifying operation 25 GPIB address psg, setting address 24 guides ix H hardware layers, remote programming 2 status, monitoring 149 help mode setting Agilent mxg 18 e8663b 18 esg 18 psg 18 hex editor binary file, modifying 302 bit file, modifying 303 hexadecimal data 262 hostname 29, 101 hostname, setting Agilent mxg 31 Agilent mxg menus 29 DHCP LAN, e8663b 33 DHCP LAN, esg 33 DHCP LAN, psg 33 DHCP/Auto I/P LAN, Agilent mxg 33 esg/psg/e8663b 31 esg/psg/e8663b menus 30 HP BASIC 9
Index suite, overview 5 USB, selecting for 54 VISA LAN, troubleshooting 36 IP address LAN interface 29 LAN, assigning 29 setting 29, 30, 33 setting Agilent mxg 31 setting esg/psg/e8663b 31 iremote 63 J JAVA 61, 128 Java example 61, 128 K kjkj 201 L LabView 9 LAN Auto- IP configuration 32 config 36 configuration Agilent mxg 31, 33 esg/psg/e8663b 31 menu, Agilent mxg 29 menu, esg/psg/e8663b 30, 33 summary, Agilent mxg 15 web server 10 DHCP configuration 32 establishing a connection 219, 221 hostname 29 int
Index location user- data file type available memory, checking 285 bit 285 FIR 285 flatness 285 instrument state 285 PRAM 285 locations 198, 281 non- volatile (NVWFM) 205 signal generator, maximum 285 size 202, 284 volatile (WFM1) 205 volatile and non- volatile 281 memory usage user file data custom 293 TDMA 293 Microsoft .
Index file size 313 minimum 314 file size, determining 313 files command syntax, for restoring 319 command syntax, for storing 319 extracting 319 modifying 321 non- volatile memory, storing 319 understanding 310 volatile memory, restoring 319 volatile memory framed data, usage 294 unframed data, usage 294 waveform, viewing 312 private LAN, using 34 problems user file downloads 340 FIR filter downloads 343 programming 8757d, using pass- thru 99 creating waveform data 212 downloading waveform data 218 guide i
Index USB 53 remote programming hardware layers 2 software layers 2 RS- 232 address 50, 131 baud rate 46 cable 47 configuration 46 echo, setting 46 format parameters 49 HP Basic, using queries 51, 134 interface 46 interfaces 3 IO libraries 45 overview 45 program examples 50, 131 programming examples, queries using VISA and C 52, 135 programming examples, using VISA and C 51, 132 settings, baud rate 50, 131 verifying operation 48 S samples even number 195 waveform 195 save and recall 325 scaling I/Q data 18
Index PERL 130 UNIX 105 Windows 106 software layers, remote programming 2 libraries, IO 5 SRE commands 151 SRQ command 150 SRQ method, status registers 150 standard event status enable register 158 group 157 register 158 standard operation condition register 160 event enable register 161 event register 161 transition filters 161 state files 325 states saving and recalling, using VISA and C 88 status byte e8663b overall register system 142, 143 esg overall register system 144, 145 group 154 mxg overall regis
Index U unencrypted files downloading for extraction 207, 320 downloading for no extraction 207, 321 extracting I/Q data 320 unframed data, usage volatile memory, PRAM 294 USB cable 55 functionality, verification 56 interface 3 IO libraries 54 setting up 55 using, Agilent mxg 53 verifying operation 56 usb media file extensions 201 user data file, modifying 302 files, creating 279 files, downloading 279 memory 281 root directory 283 user documentation ix user file data, continuous transmission requirements 3
Index programming language 9 references 60 Visual C++ NI- 488.