Thread: writing Marker values into a file with a N9000A CXA


Permlink Replies: 7 - Pages: 1 - Last Post: Sep 21, 2012 5:11 AM Last Post By: lupus
lupus

Posts: 4
Registered: 08/21/12
writing Marker values into a file with a N9000A CXA
Posted: Aug 21, 2012 10:25 AM
Click to report abuse...   Click to reply to this thread Reply
Hi,

I am trying to write Marker values (frequency and amplitude) as they show on the screen into a file. I have managed to do it for a single sweep but not a sequence of values corresponding to continuous sweeps (eg. a file with one line per sweep). Also, in case that is possible, any ideas on the maximum number of values that fit into the memory or a method of streaming the values to an external drive?

Thanks
daras


Posts: 873
Registered: 12/01/05
Re: writing Marker values into a file with a N9000A CXA
Posted: Aug 21, 2012 10:39 AM   in response to: lupus in response to: lupus
Click to report abuse...   Click to reply to this thread Reply
you have the wrong forum - you should post your question to the Signal Analyzer Forum
Forums admin


Posts: 36
Registered: 04/13/05
Re: writing Marker values into a file with a N9000A CXA
Posted: Aug 21, 2012 11:01 AM   in response to: daras in response to: daras
Click to report abuse...   Click to reply to this thread Reply
Post moved to SA forum
tabbott


Posts: 1,483
Registered: 07/24/09
Re: writing Marker values into a file with a N9000A CXA
Posted: Aug 22, 2012 9:15 AM   in response to: lupus in response to: lupus
Click to report abuse...   Click to reply to this thread Reply
Hi -

Are you referring to the Marker Logging feature?

Unfortunately CXA does not support this feature at present. CXA can log the measurement traces (up to 300) as spectrogram and store in a data file (one of the feature of option EDP), but it does not have marker information.

Regards -
lupus

Posts: 4
Registered: 08/21/12
Re: writing Marker values into a file with a N9000A CXA
Posted: Aug 22, 2012 11:04 AM   in response to: tabbott in response to: tabbott
Click to report abuse...   Click to reply to this thread Reply
Hi,

Thanks for the help. Yes, the Marker Logging feature looks like what I need. The spectrogram also contains the information I need, but 300 traces are too few for my application.

I have a sinusoidal signal that drifts in amplitude and frequency. The CXA can track the signal ("Signal Track" in Span menu) and the marker on the screen continuously indicates the amplitude and frequency of the peak. All I'm trying to do is to write the values that appear on the screen into a file. Typically I would like 1 value every 10 ms, for about 300 s, but I can settle for less if necessary.

Do you think I can program the CXA to do that? More generally, any idea on how to extract the frequency and amplitude values of the signal as a function of time?

Thanks again
Regards-

PS: The signal is around 20 MHz, it comes from a beatnote of two lasers and has a very low Signal/Noise ratio limited by photon shot noise (quantum limit) to about 40 dB in a 1 kHz Bandwidth. To track it I operate the CXA at 1 kHz BW with a span of 10 kHz, the signal moves up and down within that span at about 1 kHz/s or so.
tabbott


Posts: 1,483
Registered: 07/24/09
Re: writing Marker values into a file with a N9000A CXA
Posted: Aug 23, 2012 1:44 PM   in response to: lupus in response to: lupus
Click to report abuse...   Click to reply to this thread Reply
Hi -

To get the Frequency/Amplitude data of a Marker/Trace can be done by using the instrument SCPI command. You can refer to the instrument Programmer’s Reference Manual for details of the format of the command. There is also a command to retrieve the system time of the instrument, however, it’s only in Sec, not ms. To get the more precise time of each event, user may need to use the specific function in their program to query the system time of the PC. The entire process would be:
1. Set the instrument to single sweep mode (INIT:CONT 0).
2. Initiate a new sweep (:INIT:IMM). And use *OPC? command to determine if the sweep is completed.
3. Query the marker/trace value by using the corresponding commands.
4. Use specific function (depends on the programming environment) to get the system time.
5. Log the marker/trace value along with the system time.
6. Turn to step 2.

By the way, Agilent’s N9342C/44C HSA (Handheld Spectrum Analyzer) offers the Marker Logging feature. Instrument can continuously record the frequency and amplitude value of the marker in the file. And if with GPS option, the data also contains the GPS location. Refer to the User’s Guide on page 110 for details:
http://www.home.agilent.com/agilent/redirector.jspx?action=ref&cname=AGILENT_EDITORIAL&ckey=1951260&lc=eng&cc=US&nfr=-11143.0.00&pselect=SR.GENERAL

Regards -
lupus

Posts: 4
Registered: 08/21/12
Re: writing Marker values into a file with a N9000A CXA
Posted: Aug 24, 2012 2:01 AM   in response to: tabbott in response to: tabbott
Click to report abuse...   Click to reply to this thread Reply
Thanks a lot.

I'll try the programming.
lupus

Posts: 4
Registered: 08/21/12
Re: writing Marker values into a file with a N9000A CXA
Posted: Sep 21, 2012 5:11 AM   in response to: tabbott in response to: tabbott
Click to report abuse...   Click to reply to this thread Reply
Thanks for the help, we have written the program and it works well. I include the core part (in C) below for anyone who might need something similar. Depending on the required BW/span/precision the speed is varying, for our application the fastest we can do is about 1 point/7 ms (without tracking the signal).

/*********************************************************************
  • Program to perform a sweep and return the frequency and amplitude of the max, and track the signal
  • 1. Perform a sweep
  • 2. Write freq and amp of max into a file
  • 3. Set centre frequency to freq of max
  • Go to 1.
  • 12/09/2012
**********************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include "visa.h"
#include <sys/timeb.h>

void main ()
{
/*program variables*/
ViSession defaultRM, viMXA;
ViStatus viStatus = 0;
double dMaxA = 0, dMaxf = 0, cfreq, BW, span, swetim;
int Nscan, i, swepoin;
struct timeb tmb;
int starts, startm, stops, stopm, tdiff, datatim;
char swetyp10;
FILE *out;

/*open session to GPIB device at address 18 */
viStatus=viOpenDefaultRM (&defaultRM);
/* viStatus=viOpen (defaultRM, "GPIB0::18::INSTR", VI_NULL,VI_NULL,&viMXA); */
viStatus=viOpen (defaultRM, "TCPIP0::169.254.65.165::inst0::INSTR", VI_NULL,VI_NULL,&viMXA);

/*check opening session sucess*/
if(viStatus)
{
printf("Could not open a session!\n");
exit(0);
}

/*increase timeout to 60 sec*/
viSetAttribute(viMXA,VI_ATTR_TMO_VALUE,60000);

/*Clear the analyzer*/
viClear(viMXA);

/*Clear all event registers*/
viPrintf(viMXA, "*CLS\n");

/*Stop continuous sweep*/
viPrintf(viMXA, "INIT:CONT OFF\n");

/*Ask for number of scans*/
printf("Number of scans?\t");
scanf("%d", &Nscan);

/*open output file*/
out = fopen("output.txt","a");

/*Get and print system parameters*/
viQueryf(viMXA, "FREQ:CENT?\n", "%lf", &cfreq);
viQueryf(viMXA, "FREQ:SPAN?\n", "%lf", &span);
viQueryf(viMXA, "BAND?\n", "%lf", &BW);
viQueryf(viMXA, "SWEep:TIME?\n", "%lf", &swetim);
viQueryf(viMXA, "SWE:POIN?\n", "%ld", &swepoin);
viQueryf(viMXA, "SWE:TYPE?\n", "%s", &swetyp);

ftime(&tmb);
datatim = tmb.time;

fprintf(out, "Date (s): %ld\nCenter frequency (Hz): %lf\nSpan (Hz): %lf\nBandwidth (Hz): %lf\nSweep Time (s) %lf\nSweep Points: %ld\nSweep Type: %s\n"
, datatim, cfreq, span, BW, swetim, swepoin, swetyp);

/*Display Off*/
viPrintf(viMXA, "DISP:ENAB OFF\n");

/*Get start time*/
ftime(&tmb);
starts = tmb.time;
startm = tmb.millitm;

/*Loop of scans*/
for(i=1; i <= Nscan; i=i+1)
{
/* Initiate a sweep and wait for it to complete*/
viPrintf(viMXA, "INIT:IMM;*WAI\n");

/* Do a peak search */
viPrintf(viMXA, "CALC:MARK1:MAX\n");

/* Save frequency and amplitude of Mark1 into variables */
viQueryf(viMXA, "CALC:MARK1:Y?\n", "%lf", &dMaxA);
viQueryf(viMXA, "CALC:MARK1:X?\n", "%lf", &dMaxf);

/* Write the freq and amplitude at Marker 1*/
fprintf(out, "%lf\t %lf\n", dMaxf, dMaxA);
//printf("%lf\t %lf\n", dMaxf, dMaxA);

/* Center the display, only required if you need to track the signal*/
viPrintf(viMXA, "FREQ:CENT %lf Hz\n", dMaxf);
}

/*Get stop time, calculate time it took*/
ftime(&tmb);
stops = tmb.time;
stopm = tmb.millitm;
tdiff = (stops-starts)*1000 + (stopm - startm);
printf("timediff = %ld (milliseconds)\n", tdiff);

/*close output file*/
fclose(out);

/*Display On*/
viPrintf(viMXA, "DISP:ENAB ON\n");
viPrintf(viMXA, "INIT:CONT ON\n");

/* Close session */
viClose (viMXA);
viClose (defaultRM);
}


Point your RSS reader here for a feed of the latest messages in all forums