Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

query spectrum analyzer trace information into an array

I am currently working with LabWindows/CVI, and I am trying to query spectrum analyzer trace data (comma

separated data) into an ASCII format array (str_trace[]), where I use the

following three different kinds of commands; however, neither works.

 

No.1: ViQueryf(HP_E4407B, "TRAC:DATA? TRACE1 \n", "%s\n", &str_trace);

 

No.2: sprintf(write_buffer,"TRAC:DATA?TRACE1 \n");

      Send(0,HP_E4407B,write_buffer,strlen(write_buffer),1);

      Receive(0,HP_E4407B,read_buffer,numToRead,256);

      sscanf(read_buffer,"%s\n",&str_trace);

 

No.3: sprintf(write_buffer,"TRAC:DATA?TRACE1 \n");

      ibwrt(HP_E4407B,write_buffer,strlen(write_buffer));

      ibrd(HP_E4407B,read_buffer,numToRead);

      sscanf(read_buffer,"%s\n",&str_trace);

 

After getting the arry of str_trace, I am doing the following to separate them:

       char *result=NULL;

       result=strtok(str_trace,",");

       while(result!=NULL){

           data[i]=atof(result);

           result=strtok(str_trace,",");

           i=i+1;

       }   

 

Please help me to point out where the errors are. Thanks a lot!

0 Kudos
Message 1 of 6
(4,254 Views)
In the previous post, the retrieving command is actually: "TRAC:DATA? TRACE1". If anyone knows the answer, please let me know. Thanks a lot!
0 Kudos
Message 2 of 6
(4,244 Views)

What is the HP_E4407B parameter in your examples ? How do you set it ? For the first example it should be an instrument handle , returned by viOpen();

 

0 Kudos
Message 3 of 6
(4,233 Views)
HP_E4407B has been set to be my device.
0 Kudos
Message 4 of 6
(4,230 Views)
Hello yfguan,
       I recommend that you use the IVI Instrument Driver for your instrument.  You will also need to download the latest version of the IVI Compliance PackageHere is something to help you get started with IVI in CVI.

Cheers,

NathanT
0 Kudos
Message 5 of 6
(4,219 Views)

Hi NathanT,

    Thanks for your suggestion. However, is any possible ways I could just write several commands to do this, like I shows in my previous post? Thanks!

0 Kudos
Message 6 of 6
(4,208 Views)