Agilent Technologies E1441A Oven User Manual


 
62 Agilent E1441A Application Information
Chapter 2
/* define pi for sin(x)/x calculation, initalize other variables */
pi = 3.141592654;
max_v = 0;
idx = 0;
/* do this for Borland EasyWin programs */
#if defined(__BORLANDC__) && !defined (__WIN32__)
_InitEasyWin();
#endif
/* 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);
/* compute sin(x)/x waveform */
for (i=-2047; i<2048; i++)
{
j = (ViReal64)i;
if(i==0) j=1.E-38;
sinxwave[i+2048] = ((sin(2*pi*0.53125*j/256))/(0.53125*j/256)*0.159154943092);
}
/* download the computed waveform into E1441A volatile memory */
err = viPrintf(funcgen,"DATA VOLATILE");
for ( i=0; i < 4096; i++ )
{
err = viPrintf( funcgen, ",%f", sinxwave[i] );
}
err = viPrintf(funcgen,"\n");
if(err != VI_SUCCESS) err_handler(funcgen, err);
/* copy the arbitrary waveform data from volatile memory to a */
/* named non-volatile memory location */
err=viPrintf(funcgen, "DATA:COPY MYSINE\n");
if(err != VI_SUCCESS) err_handler(funcgen, err);
/* select the user defined arbitrary waveform by name */
err=viPrintf(funcgen, "SOURce:FUNCtion:USER MYSINE\n");
if(err != VI_SUCCESS) err_handler(funcgen, err);
/* configure the E1441A to output a 5 Vp-p, 5 kHz arb wave */
/* APPly command is first since it sets some functions that */
/* follow */
err=viPrintf(funcgen, "SOURce:APPLy:USER 5000, 5, 0\n");
if(err != VI_SUCCESS) err_handler(funcgen, err);
/* Check for system errors. */
err=viQueryf(funcgen, "syst:err?\n", "%t", buf);
if(err != VI_SUCCESS) err_handler(funcgen, err);
printf("System error response = %s\n\n", buf);