60 Agilent E1441A Application Information
Chapter 2
AM Modulation and Instrument State Storage
/* 1441_AM.C - This program sets up the E1441A to output an AM waveform. */
/* The program also stores the configuration in memory for subsequent */
/* recall. */
#include <stdio.h>
#include <visa.h>
/*** FUNCTION PROTOTYPE ***/
void err_handler (ViSession vi, ViStatus x);
#define DEVICE_ADDRESS "GPIB-VXI0::80::INSTR"
void main(void)
{
char buf[512] = {0};
ViStatus err;
ViSession defaultRM, funcgen;
/* Open resource manager and Function Generator sessions*/
err=viOpenDefaultRM(&defaultRM);
if(err != VI_SUCCESS) err_handler(funcgen, err);
err=viOpen(defaultRM, DEVICE_ADDRESS, VI_NULL,VI_NULL, &funcgen);
if(err != VI_SUCCESS) err_handler(funcgen, err);
/* Set the timeout value to 10 seconds. */
viSetAttribute(funcgen, VI_ATTR_TMO_VALUE, 10000);
/* Reset the module. */
err=viPrintf(funcgen, "*RST\n");
if(err != VI_SUCCESS) err_handler(funcgen, err);
/* Set the output amplitude to be set for 50 ohm load. */
err=viPrintf(funcgen, "OUTPut:LOAD 50\n");
if(err != VI_SUCCESS) err_handler(funcgen, err);
/* configure the E1441A to output a 5 Vp-p, 5 kHz sine wave */
/* with a 2.5V offset. APPly command is first since it */
/* presets some functions that follow */
err=viPrintf(funcgen, "SOURce:APPLy:SIN 5000, 2, 2.5\n");
if(err != VI_SUCCESS) err_handler(funcgen, err);
/* set the amplitude modulation source, set a modulation depth */
/* of 80%, the modulation waveshape to sine, the modulating */
/* frequency to 200 Hz, and enable AM modulation */
err=viPrintf(funcgen, "SOURce:AM:SOURce BOTH\n"); /* AM from internal */
if(err != VI_SUCCESS) err_handler(funcgen, err);
err=viPrintf(funcgen, "SOURce:AM:DEPTh 80\n"); /* mod depth 80% */
if(err != VI_SUCCESS) err_handler(funcgen, err);
err=viPrintf(funcgen, "SOURce:AM:INTernal:FUNCtion SIN\n"); /* AM shape SIN */
if(err != VI_SUCCESS) err_handler(funcgen, err);
err=viPrintf(funcgen, "SOURce:AM:INTernal:FREQuency 200\n"); /* AM freq 200 Hz */
if(err != VI_SUCCESS) err_handler(funcgen, err);