Hi!

I am trying to read s-parameters from my PNA-X 5242A to Matlab using GPIB (Agilent USB-GPIB Adapter). I have managed to save the s-parameters in a file on the PNA-X with the 'CALC:DATA:SNP:PORTs:Save "1,2","C:/test/MyDatap.s2p"' command so the setup seems to work.

But when using 'CALC:DATA:SNP:PORTs? "1"' to transfer the data into Matlab I expected to get all the s-parameter data as a string but simply got output1 = "CH1_S11_1,S11" and output2 = #44824Ac Ð. It is output2 that confuses me!

Any help would be appreciated. Input buffersize maybe?

The complete code is given below.

obj5 = instrfind('Type', 'gpib', 'BoardIndex', 7, 'PrimaryAddress', 16, 'Tag', '');

fopen(obj5);

fprintf(obj5, ['SYST:PRES']);

output1=query(obj5, ['CALC:PAR:CAT?']);

output1

fprintf(obj5, ['CALC:PAR:SEL "CH1_S11_1"']);

fprintf(obj5, ['CALC:DATA:SNP:PORTs:Save "1,2","C:/test/MyDatap.s2p"']);

output2=query(obj5, ['CALC:DATA:SNP:PORTs? "1"']);

output2

fclose(obj5);

delete(obj5);

/Daniel

I am trying to read s-parameters from my PNA-X 5242A to Matlab using GPIB (Agilent USB-GPIB Adapter). I have managed to save the s-parameters in a file on the PNA-X with the 'CALC:DATA:SNP:PORTs:Save "1,2","C:/test/MyDatap.s2p"' command so the setup seems to work.

But when using 'CALC:DATA:SNP:PORTs? "1"' to transfer the data into Matlab I expected to get all the s-parameter data as a string but simply got output1 = "CH1_S11_1,S11" and output2 = #44824Ac Ð. It is output2 that confuses me!

Any help would be appreciated. Input buffersize maybe?

The complete code is given below.

obj5 = instrfind('Type', 'gpib', 'BoardIndex', 7, 'PrimaryAddress', 16, 'Tag', '');

fopen(obj5);

fprintf(obj5, ['SYST:PRES']);

output1=query(obj5, ['CALC:PAR:CAT?']);

output1

fprintf(obj5, ['CALC:PAR:SEL "CH1_S11_1"']);

fprintf(obj5, ['CALC:DATA:SNP:PORTs:Save "1,2","C:/test/MyDatap.s2p"']);

output2=query(obj5, ['CALC:DATA:SNP:PORTs? "1"']);

output2

fclose(obj5);

delete(obj5);

/Daniel

Mathworks has a PNA sample MatLab program at http://www.mathworks.com/matlabcentral/fileexchange/24219. I believe the sample utilizes a BIN BLOCK real-64 transfer which is more efficieint. Regardless if you use the BIN BLOCK method the sample may prove insightful.

Sincerely,

tsilchia.

## Attachments

You can unscramble it using this little snippet.

yours,

Raj

By the way, the easier way to get real imaginary pairs out would be to set the Touchstone data return format prior to requesting the data using the MMEM:STOR:TRAC:FORM:SNP command.

I need to write a routine that will reliably suck in whatever the PNA-X is currently measuring. I have a routine adapted from O. J. Danzy's routine, which I will include in this post.

My problem is that I would like for the program to initiate a new measurement, and wait for the measurement to complete before reading it into the computer, so I don't have to put huge pause statements to guarantee that I have fresh data. Any ideas about how to do this?

Yours

Raj

## Attachments

This will utilize group trigger to execute 1 sweep, wait for completion. If you sweep is long, then you may need to increase the timeout.

## Attachments

Tried out your code today, and the PNA-X replies with "Query Unterminated", eventually times out and returns no data. Tried to troubleshoot, and found the problem at line 51 with the binblockread(vi,...) statement. Did the addition of the new commands mess up the binblockread? Does it work OK on your system?

yours,

Raj

It seems highly unlikely that a user will want his/her measurements obliterated by a "preset the instrument" command just before reading in the data. Is there any way we can make Matlab learn what measurements are active and correctly select the measurement name? I thought that b/c of a bug, the measurement name always had to CH1_S11_1, as in:

yours,

Raj

I personally find dealing with measurement numbers easier than dealing with measurement names.

So let me put this out there as a challenge... :P

Can we get a Matlab function that gracefully retrieves whatever measurements are currently being measured. In other words, if we are currently measuring 3-port S-parameters, it should give us freq, S11, S21, S31, ..., S23, S33. If we are measuring 2-port S-parameters, it should give us freq, S11, S21, S12, S22. The routine should not preset the instrument just before reading in the data, and should wait until at least one full sweep has been completed.

I'm not sure how many Matlab users there are out there, but for me, this would be a *very* useful function. Looks like we have all the ingredients in place, but still some sticky errors coming out of the box...

Yours

Raj

But perhaps what you're talking about maybe useful. Can you give some more details about this function? is it in a recent firmware release, or is this a different Matlab routine?

Yours

Raj