AnsweredAssumed Answered

Binary transfer of PNA SDATA using NI Meas Studio 8

Question asked by ljcorsa on Dec 5, 2007
Latest reply on Dec 12, 2007 by ljcorsa
I'm using VB.NET in VS2005 with NI Meas Studio 8.1.  I'm trying to take advantage of binary transfers to improve data throughput.  I am currently running with ASCII format, and all is well.  As is their tradition, NI has foisted the problem off on hp^H^HAgilent since they haven't got a PNA handy.


pna = CType(NationalInstruments.VisaNS.ResourceManager.GetLocalManager().Open(PNAaddr.Text), NationalInstruments.VisaNS.MessageBasedSession)
pna.TerminationCharacterEnabled = True
pna.Timeout = 4000
pnaReader = New NationalInstruments.VisaNS.MessageBasedSessionReader(CType(pna, NationalInstruments.VisaNS.MessageBasedSession))
pnaReader.BinaryEncoding = BinaryEncoding.DefiniteLengthBlockData
pnaReader.BinaryEncoding = BinaryEncoding.RawLittleEndian

s = pna.Query(":SYST:FPRESET; *OPC?" & vbCrLf)
pna.Write(":FORM ASCII,0" & vbCrLf)
pna.Write(":SENS1:FREQ:START 1525000000;STOP  1600000000" & vbCrLf)
pna.Write(":DISP:WINDOW1:TRACE1:Y:SCALE:RLEVEL -30; RPOSITION 8; PDIVISION 5" & vbCrLf)
pna.Write(":SOURCE:POWER +10" & vbCrLf)
pna.Write(":SENS1:SWEEP:POINTS " & Npts & vbCrLf)
pna.Write(":CALC1:PARAMETER:DEFINE 'Meas1',S21; *WAI" & vbCrLf)
pna.Write(":DISP:WINDOW1:STATE ON; *WAI" & vbCrLf)
pna.Write(":DISP:WINDOW1:TRACE1:FEED 'Meas1'; *WAI" & vbCrLf)
pna.Write(":CALC1:PARAMETER:SELECT 'Meas1'; *WAI" & vbCrLf)
pna.Write(":SENSE:SWEEP:MODE CONT; *WAI" & vbCrLf)
pna.Write(":INIT:CONT ON; *WAI" & vbCrLf)
s = pna.Query(":SENSE:SWEEP:MODE HOLD; GROUPS:COUNT 1; :SENSE:SWEEP:MODE GROUPS; *OPC?" & vbCrLf)
pna.Write(":FORMAT REAL,64;:FORMAT:BORDER NORMAL" & vbCrLf)
pna.Write(":CALC1:DATA? SDATA" & vbCrLf)
Sdata = pnaReader.ReadDoubles(Npts * 2)
pna.Write(":INIT:CONT ON; *WAI" & vbCrLf)
pna.Write(":SENSE:SWEEP:MODE CONT; *WAI" & vbCrLf)


I have tried several variations on SWAPPED/NORMAL, RawBigEndian vs     little, etc.  I get data arrays returned, but they do not resemble the values I get from the ASCII transfer, and sometimes I don't even get all the data (the array size is less than Npts*2). 

I do have Try/Catch and :SYST:ERR? checking in the production code, but removed it for clarity.  Does anyone have any code working with NI and binary data blocks?

Thanks!
Larry Corsa  

Outcomes