Agilent Technologies Signal Generators E8663B RF Analog E4428C/38C ESG RF N5183A MXG Microwave E8257D/67D PSG Microwave N5161A/62A/81A/82A MXG RF Creating and Downloading Waveform Files Agilent Technologies
Notices © Agilent Technologies, Inc. 2006 -2009 Warranty No part of this manual may be reproduced in any form or by any means (including electronic storage and retrieval or translation into a foreign language) without prior agreement and written consent from Agilent Technologies, Inc. as governed by United States and international copyright laws. The material contained in this document is provided “as is,” and is subject to being changed, without notice, in future editions.
Contents Creating and Downloading Waveform Files Overview of Downloading and Extracting Waveform Files . . . . . . . . . . . . . . . . . . . . . . . . . .2 Waveform Data Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3 Understanding Waveform Data . . . . . . . . . . . . Bits and Bytes . . . . . . . . . . . . . . . . . . . . LSB and MSB (Bit Order) . . . . . . . . . . . . Little Endian and Big Endian (Byte Order) . Byte Swapping . . . . . . . . . . . . . . . .
Contents E443xB Data Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 Storage Locations for E443xB ARB files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 SCPI Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 Programming Examples. . . . . . . . . . . . C++ Programming Examples . . . . . . MATLAB Programming Examples . .
Creating and Downloading Waveform Files NOTE The ability to play externally created waveform data in the signal generator is available only in the N5162A/82A 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 N5162A/82A 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 47. 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 22.
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 I/Q File The I/Q file contains the interleaved I and Q data points (signed 16–bit integers for each I and Q data point). Each I/Q point equals one waveform point. The signal generator stores the I/Q data in the waveform directory.
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. NOTE The MXG’s ARB Waveform File Cache is limited to 128 files. Consequently, once the 128 file cache limit has been reached, the waveform switching speed will be much slower for files loaded into the volatile waveform memory (BBG).
Creating and Downloading Waveform Files Waveform Memory following file types share this memory: Table 2 Signal Generators and Non–Volatile Memory Types Non–Volatile Memory Type Model of Signal Generator N5162A, N5182A with Option 651, 652, or 654 E4438C with Option 001, 002, 601, or 602 E8267D Option 601 or 602 I/Q x x x Marker x x x File header x x x Sweep List x x x User Data x x x User PRAM – x x Instrument State x x x Waveform Sequences (multiple I/Q files played toget
Creating and Downloading Waveform Files Waveform Memory Figure 2-1 Root directory Agilent MXG (Only): 4 USER E443xB Volatile waveform data1 ARBI NONVOLATILE E443xB Non–volatile waveform data1 ARBQ NVARBI MXG (only) USB media: File listing with extensions1, 2 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 (N5162A/82A) 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 3 on page 20 and to http://support.microsoft.com/.
Creating and Downloading Waveform Files Waveform Memory Volatile and Non–Volatile Memory (N5162A/82A) Table 4 N5162A/82A 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 N5162A/82A1 651/652/654 (BBG) 8 MSa (40 MB) Standard (N5182A) 800 MSa (4 GB)2 019 (BBG) 64 MSa (320 MB) USB Flash Drive (UFD) user determined 1.
Creating and Downloading Waveform Files Commands for Downloading and Extracting Waveform Data Table 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 SCPI Command Line Structure The signal generator expects to see waveform data as block data (binary files). The IEEE standard 488.2–1992 section 7.7.6 defines block data.
Creating and Downloading Waveform Files Commands for Downloading and Extracting Waveform Data Table 7 Downloading Unencrypted Files for No Extraction (Extraction allowed on the Agilent MXG1 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 9 Downloading Unencrypted Files for Extraction Download Method/ Memory Type Command Syntax Options SCPI/non–volatile memory1 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 memory2 put /user/bbg1/waveform/ put /user
Creating and Downloading Waveform Files Commands for Downloading and Extracting Waveform Data Table 11 Downloading Encrypted Files for Extraction Download Method/Memory Type Command Syntax Options SCPI/volatile1 memory MEM:DATA:UNPRotected "/user/bbg1/securewave/file_name", MEM:DATA:UNPRotected "SWFM1:file_name", MEM:DATA:UNPRotected "file_name@SWFM1", SCPI/non–volatile memory1 MEM:DATA:UNPRotected "/user/securewave/file_name", MEM:DATA:UNPRotected "SNVWFM
Creating and Downloading Waveform Files Commands for Downloading and Extracting Waveform Data FTP Procedures CAUTION NOTE Avoid using the *OPC? or *WAI commands to verify that the FTP process has been completed. These commands can potentially hang up due to the processing of other SCPI parser operations. Refer to the SCPI Command Reference.
Creating and Downloading Waveform Files Commands for Downloading and Extracting Waveform Data CAUTION NOTE Get and Put commands write over existing files by the same name in destination directories. Remember to change remote and local filenames to avoid the loss of data. If a filename has a space, quotations are required around the filename. Always transfer the waveform file before transferring the marker file.
Creating and Downloading Waveform Files Commands for Downloading and Extracting Waveform Data Table 13 Put Command Examples Command Results Local Remote Notes Correct put /user/waveform/ put /user/marker/ Creates a waveform file and a compatible marker file.
Creating and Downloading Waveform Files Creating Waveform Data Creating Waveform Data This section examines the C++ code algorithm for creating I/Q waveform data by breaking the programming example into functional parts and explaining the code in generic terms. This is done to help you understand the code algorithm in creating the I and Q data, so you can leverage the concept into your programming environment.
Creating and Downloading Waveform Files Creating Waveform Data Line 1 2 3 4 5 6 7 8 9 10 11 Line 32 Code—Create I and Q data const int NUMSAMPLES=500; main(int argc, char* argv[]); { short idata[NUMSAMPLES]; short qdata[NUMSAMPLES]; int numsamples = NUMSAMPLES; for(int index=0; index
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 44. 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 44.
Creating and Downloading Waveform Files Using the Download Utilities 1. List the waveform files from the volatile memory waveform list: 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 NOTE Agilent Intuilink is not available for the Agilent MXG. • 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 IntuiLink1 X Downloads complex MATLAB waveform data X Downloads MATLAB files (.
Creating and Downloading Waveform Files Downloading E443xB Signal Generator Files E443xB Data Format The following diagram describes the data format for the E443xB waveform files. This file structure can be compared with the new style file format shown in “Waveform Structure” on page 11. If you create new waveform files for the signal generator, use the format shown in “Waveform Data Requirements” on page 3.
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 51 “Creating and Storing I/Q Data—Little Endian Order” on page 55 “Creating and Downloading I/Q Data—Big and Little Endian Order” on page 56 “Importing and Downloading I/Q Data—Big Endian Order” on page 60 “Importing and Downloading Using VISA—Big Endian Order” on page 62 “Impor
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 #include #include #include #include // Choose a GPIB, LAN, or RS-232 connection char* instOpenString =”lan[galqaDhcp1]”; //char* instOpenString =”gpib0,19”; // Pick some maximum number of samples, based on the // amount of memory in your computer and the signal generator.
Creating and Downloading Waveform Files Programming Examples // spreadsheet to help spot any problems. FILE *outfile = fopen(ofile, “w”); if (outfile==NULL) perror (“Error opening file to write”); for(index=0; index
Creating and Downloading Waveform Files Programming Examples { fprintf(stderr, “iopen failed (%s)\n”, instOpenString); return -1; } // Declare variables to hold portions of the SCPI command int bytesToSend; char s[20]; char cmd[200]; bytesToSend = numsamples*4; // calculate the number of bytes sprintf(s, “%d”, bytesToSend); // create a string s with that number of bytes // The SCPI command has four parts.
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; } 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 // as needed. //********************************************************************************** #include #include #include #include "visa.h" // // IMPORTANT: // Configure the following three lines correctly before compiling and running char* instOpenString ="TCPIP0::xxx.xxx.xxx.
Creating and Downloading Waveform Files Programming Examples return 0; } if( fseek( file, 0, SEEK_END ) < 0 ) { fprintf(stderr,"Cannot lseek to the end of file.\n" ); return 0; } 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 viWrite(vi, s2, strlen((char*)s2), 0); long numRead; // Send file in BUFFER_SIZE chunks to the signal generator do { 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 a
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 72 • “Creating and Downloading a Pulse” on page 75 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.Description Close #FileHandle End Sub Downloading I/Q Data On the signal generator’s documentation CD, this programming example’s name is “Download_File_vb.txt.
Creating and Downloading Waveform Files Programming Examples ' data requirements for file downloads. The waveform data 'IQ_DataVB' is ' downloaded to the signal generator's non-volatile memory(NVWFM) ' " /USER/WAVEFORM/IQ_DataVB". For volatile memory(WFM1) download to the ' " /USER/BBG1/WAVEFORM/IQ_DataVB" directory. ' ' You must reference the Agilent VISA COM Resource Manager and VISA COM 1.0 Type ' Library in your Visual Basic project in the Project/References menu. ' The VISA COM 1.
Creating and Downloading Waveform Files Programming Examples FileHandle = FreeFile() On Error GoTo errorhandler With SigGen 'Set up the signal generator to accept a download .IO.Timeout = 5000 'Timeout 50 seconds .WriteString "*RST" 'Reset the signal generator.
Creating and Downloading Waveform Files Programming Examples HP Basic Programming Examples This section contains the following programming examples: • “Creating and Downloading Waveform Data Using HP BASIC for Windows®” on page 84 • “Creating and Downloading Waveform Data Using HP BASIC for UNIX” on page 86 • “Creating and Downloading E443xB Waveform Data Using HP BASIC for Windows” on page 88 • “Creating and Downloading E443xB Waveform Data Using HP Basic for UNIX” on page 89 Creating and Downloading Wave
Creating and Downloading Waveform Files Programming Examples 170 Ndigits$=VAL$(Ndigits) 180 WAIT 1 190 OUTPUT @PSG USING "#,K";":MMEM:DATA ""WFM1:data_file"",#" 200 OUTPUT @PSG USING "#,K";Ndigits$ 210 OUTPUT @PSG USING "#,K";Nbytes$ 220 WAIT 1 230 OUTPUT @PSGb;Int_array(*) 240 OUTPUT @PSG;END 250 ASSIGN @PSG TO * 260 ASSIGN @PSGb TO * 270 PRINT 280 PRINT "*END*" 290 END Program Comments 10: Program file name 20: Sets the number of points in the waveform.
Creating and Downloading Waveform Files Programming Examples Program Comments (Continued) 230: Sends the binary data. Note that PSGb is the binary IO path. 240: Sends an End–of–Line to terminate the transmission. 250 to 260: Closes the connections to the signal generator. 290: End the program. Creating and Downloading Waveform Data Using HP BASIC for UNIX On the documentation CD, this programming example’s name is “hpbasicUx.txt.
Creating and Downloading Waveform Files Programming Examples 210 OUTPUT @PSG USING "#,K";Nbytes$ 220 WAIT 1 230 OUTPUT @PSGb;Int_array(*) 240 WAIT 2 241 OUTPUT @PSG;END 250 ASSIGN @PSG TO * 260 ASSIGN @PSGb TO * 270 PRINT 280 PRINT "*END*" 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.
Creating and Downloading Waveform Files Programming Examples Program Comments (Continued) 250 to 260: Closes the connections to the signal generator. 290: End the program. 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.
Creating and Downloading Waveform Files Programming Examples 190 OUTPUT @Esgb;Iwfm_data(*) 200 OUTPUT @Esg;END 210 OUTPUT @Esg USING "#,K";":MMEM:DATA ""ARBQ:file_name_1"",#" 220 OUTPUT @Esg USING "#,K";Ndigits$ 230 OUTPUT @Esg USING "#,K";Nbytes$ 240 OUTPUT @Esgb;Qwfm_data(*) 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.
Creating and Downloading Waveform Files Programming Examples 10 ! RE-SAVE "ARB_IQ_file" 20 Num_points=200 30 ALLOCATE INTEGER Iwfm_data(1:Num_points),Qwfm_data(1:Num_points) 40 DEG 50 FOR I=1 TO Num_points 60 70 Iwfm_data(I)=INT(8191*(SIN(I*360/Num_points))+8192) Qwfm_data(I)=INT(8191*(COS(I*360/Num_points))+8192) 80 NEXT I 90 PRINT "Data Generated" 100 Nbytes=2*Num_points 110 ASSIGN @Esg TO 719;FORMAT ON 120 ASSIGN @Esgb TO 719;FORMAT OFF 130 Nbytes$=VAL$(Nbytes) 140 Ndigits=LEN(N
Creating and Downloading Waveform Files Troubleshooting Waveform Files Program Comments (Continued) 80: End of loop. 160 and 210: The I and Q waveform files have the same name 90 to 300 See the table on page 87 for program comments. 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.
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 11. 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 Programming Guide and the User’s Guide.
Index Numerics D 2’s complement data format, 9 Agilent e8663b global settings, configuring, 92 Pulse/RF Blank, configuring, 92 esg global settings, configuring, 92 memory allocation, non- volatile memory, 20 Pulse/RF Blank, configuring, 92 Waveform Download Assistant, 47 mxg global settings, configuring, 92 memory allocation, non- volatile memory, 19 Waveform Download Assistant, 47 psg global settings, configuring, 92 memory allocation, non- volatile memory, 20 Pulse/RF Blank, configuring, 92 Waveform Do
Index F files decryption, 23 encryption, 22, 23 encryption, agilent mxg (only), 23 extraction commands and file paths, 24 header information, 11, 23 transfer methods, 23 waveform download utilities, 46 waveform structure, 11 FTP downloading and extracting files, commands, 26–27 methods, 23 procedures for downloading files, 28 web server procedure, 30 G global settings Agilent mxg, 92 e8663b, 92 esg, 92 psg, 92 H M marker file, 11, 23 MATLAB download utility, 47 downloading data, 38 programming examples,
Index e443xb files, 84 HP Basic, 84 introduction, 50 MATLAB, 72 Visual Basic, 79, 81 Pulse/RF Blank e8663b, setting, 92 esg, setting, 92 n5161a/62a/81a/82a/83a, setting, 92 psg, setting, 92 S samples even number, 13 waveform, 13 scaling I/Q data, 7 SCPI file transfer methods, 23 SCPI commands command line structure, 24 download e443xb files, 50 encrypted files, 25, 27 extraction, 22, 24, 25, 27 no extraction, 24, 25 unencrypted files, 25 securewave directory decryption, file, 23 downloading encrypted files
Index waveform generation C++, 51 HP Basic, using, 84 MATLAB, using, 72 Visual Basic 6.