Posted Mon, 08 May 2023 13:35:43 GMT by Kobierski, Marianne
I am trying to collect spectrum data from an RSA306B.<br> <br> Using the signalvu program the data trace looks good: clear shape and max values around -30 dBm. How do I get this data trace via the RSA_API though? I tried two approaches without success: <ol> <li>Using &quot;SPECTRUM&quot; commands - there doesn't seem to be a way to set maxhold on.</li> <li>Using &quot;DPX&quot; commands - data is the right shape but wrong values.</li> </ol>
Posted Mon, 08 May 2023 13:40:17 GMT by Kobierski, Marianne
<p>Attachments: Figure of nice signalvu trace, figure of &quot;SPECTRUM&quot; command data (without maxhold and with trying to set maxhold using the dpx command for it*), figure of &quot;DPX&quot; command data (right shape wrong values).</p> <p></p> <p>* Added this line to the end of the config_spectrum function as it seems to be the only way to set maxhold on. Didn't seem to have any effect.:</p> <pre style="background-color:#2b2b2b;color:#a9b7c6;font-family:'JetBrains Mono',monospace;font-size:9.8pt;">rsa.DPX_SetSpectrumTraceType(RSA_API.SpectrumTraces.SpectrumTrace1<span style="color:#cc7832;">, </span>RSA_API.TraceType.TraceTypeMaxHold) </pre>
Posted Mon, 08 May 2023 13:45:58 GMT by Kobierski, Marianne
<p>Here is the code for the &quot;SPECTRUM&quot; commands approach:</p> <p style="margin-left:36px;"><span style="font-size:9.8pt;"><span style="font-family:&quot;JetBrains Mono&quot;;"><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">theDll = ctypes.util.find_library(</span></span><span style="background:#2b2b2b;"><span style="color:#d1dacc;">&quot;C:</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">\\</span></span><span style="background:#2b2b2b;"><span style="color:#d1dacc;">Tektronix</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">\\</span></span><span style="background:#2b2b2b;"><span style="color:#d1dacc;">RSA_API</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">\\</span></span><span style="background:#2b2b2b;"><span style="color:#d1dacc;">lib</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">\\</span></span><span style="background:#2b2b2b;"><span style="color:#d1dacc;">x64</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">\\</span></span><span style="background:#2b2b2b;"><span style="color:#d1dacc;">RSA_API.dll&quot;</span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">)<br> rsa = ctypes.cdll.LoadLibrary(theDll)<br> search_connect(rsa)<br> specSet = config_spectrum(rsa)</span></span><br> <span style="background:#2b2b2b;"><span style="color:#d2d9e1;">trace = acquire_spectrum(rsa</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">, </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">specSet</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">, </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">measurement_time)<br> freq = create_frequency_array(specSet)</span></span></span></span></p> <p style="margin-left:36px;"><span style="font-size:9.8pt;"><span style="font-family:&quot;JetBrains Mono&quot;;"><span style="background:#2b2b2b;"><span style="color:#eed3bc;">def </span></span><span style="background:#2b2b2b;"><span style="color:#ffcf83;">config_spectrum</span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">(rsa</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">, </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">center_frequency=</span></span><span style="background:#2b2b2b;"><span style="color:#cadbe7;">15e6</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">, </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">reference_level=-</span></span><span style="background:#2b2b2b;"><span style="color:#cadbe7;">20</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">, </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">frequency_span=</span></span><span style="background:#2b2b2b;"><span style="color:#cadbe7;">30e6</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">, </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">res_bandwidth=</span></span><span style="background:#2b2b2b;"><span style="color:#cadbe7;">10e3</span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">):<br> &#160;&#160;&#160; rsa.SPECTRUM_SetEnable(c_bool(</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">True</span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">))</span></span></span></span></p> <p style="margin-left:36px;"><span style="font-size:9.8pt;"><span style="font-family:&quot;JetBrains Mono&quot;;"><span style="color:#d2d9e1;"><span style="background:#2b2b2b;">rsa.CONFIG_SetCenterFreq(c_double(center_frequency))<br> &#160;&#160;&#160; rsa.CONFIG_SetReferenceLevel(c_double(reference_level))</span></span></span></span></p> <p style="margin-left:36px;"><span style="font-size:9.8pt;"><span style="font-family:&quot;JetBrains Mono&quot;;"><span style="color:#d2d9e1;"><span style="background:#2b2b2b;">rsa.SPECTRUM_SetDefault()<br> &#160;&#160;&#160; specSet = RSA_API.Spectrum_Settings()<br> &#160;&#160;&#160; rsa.SPECTRUM_GetSettings(byref(specSet))</span></span></span></span></p> <p style="margin-left:36px;"><span style="font-size:9.8pt;"><span style="font-family:&quot;JetBrains Mono&quot;;"><span style="color:#d2d9e1;"><span style="background:#2b2b2b;">specSet.window = RSA_API.SpectrumWindows.SpectrumWindow_Kaiser<br> &#160;&#160;&#160; specSet.verticalUnit = RSA_API.SpectrumVerticalUnits.SpectrumVerticalUnit_dBm<br> &#160;&#160;&#160; specSet.span = frequency_span<br> &#160;&#160;&#160; specSet.rbw = res_bandwidth</span></span></span></span></p> <p style="margin-left:36px;"><span style="font-size:9.8pt;"><span style="font-family:&quot;JetBrains Mono&quot;;"><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">rsa.SPECTRUM_SetSettings(specSet)<br> &#160;&#160;&#160; rsa.SPECTRUM_GetSettings(byref(specSet))<br> &#160;&#160;&#160; rsa.SPECTRUM_SetTraceType(RSA_API.SpectrumTraces.SpectrumTrace1</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">, True, </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">RSA_API.SpectrumDetectors.SpectrumDetector_PosPeak)</span></span></span></span></p> <p style="margin-left:36px;"><span style="font-size:9.8pt;"><span style="font-family:&quot;JetBrains Mono&quot;;"><span style="background:#2b2b2b;"><span style="color:#eed3bc;">def </span></span><span style="background:#2b2b2b;"><span style="color:#ffcf83;">acquire_spectrum</span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">(rsa</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">, </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">specSet</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">, </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">measurement_time):<br> &#160;&#160;&#160; ready = c_bool(</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">False</span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">)<br> &#160;&#160;&#160; traceArray = c_float * specSet.traceLength<br> &#160;&#160;&#160; traceData = traceArray()<br> &#160;&#160;&#160; outTracePoints = c_int(</span></span><span style="background:#2b2b2b;"><span style="color:#cadbe7;">0</span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">)<br> &#160;&#160;&#160; traceSelector = RSA_API.SpectrumTraces.SpectrumTrace1</span></span></span></span></p> <p style="margin-left:36px;"><span style="font-size:9.8pt;"><span style="font-family:&quot;JetBrains Mono&quot;;"><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">rsa.DEVICE_Run()<br> &#160;&#160;&#160; time.sleep(measurement_time)<br> &#160;&#160;&#160; rsa.SPECTRUM_AcquireTrace()<br> &#160;&#160;&#160; </span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">while not </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">ready.value:<br> &#160;&#160;&#160;&#160;&#160;&#160;&#160; rsa.SPECTRUM_WaitForDataReady(c_int(</span></span><span style="background:#2b2b2b;"><span style="color:#cadbe7;">100</span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">)</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">, </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">byref(ready))<br> &#160;&#160;&#160; rsa.SPECTRUM_GetTrace(traceSelector</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">, </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">specSet.traceLength</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">, </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">byref(traceData)</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">,<br> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">byref(outTracePoints))<br> &#160;&#160;&#160; rsa.DEVICE_Stop()<br> &#160;&#160;&#160; </span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">return </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">np.array(traceData)</span></span></span></span></p> <p>And here is the code for the &quot;DPX&quot; approach:</p> <p style="margin-left:36px;"><span style="font-size:9.8pt;"><span style="font-family:&quot;JetBrains Mono&quot;;"><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">freq = config_DPX(rsa)<br> fb = acquire_dpx_frame(rsa</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">, </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">measurement_time)<br> trace = extract_dpx_spectrum(fb)</span></span></span></span></p> <p style="margin-left:36px;"><span style="font-size:9.8pt;"><span style="font-family:&quot;JetBrains Mono&quot;;"><span style="background:#2b2b2b;"><span style="color:#eed3bc;">def </span></span><span style="background:#2b2b2b;"><span style="color:#ffcf83;">config_DPX</span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">(rsa</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">, </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">center_frequency=</span></span><span style="background:#2b2b2b;"><span style="color:#cadbe7;">15e6</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">, </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">reference_level=-</span></span><span style="background:#2b2b2b;"><span style="color:#cadbe7;">20</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">, </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">frequency_span=</span></span><span style="background:#2b2b2b;"><span style="color:#cadbe7;">30e6</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">, </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">res_bandwidth=</span></span><span style="background:#2b2b2b;"><span style="color:#cadbe7;">10e3</span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">):<br> &#160;&#160;&#160; </span></span><span style="background:#2b2b2b;"><span style="font-style:italic;"><span style="color:#cadcc6;">&quot;&quot;&quot;<br> &#160;&#160;&#160; </span></span></span><a href="https://forum.tek.com/viewtopic.php?f=588&amp;t=139112"><span style="background:#2b2b2b;"><span style="font-style:italic;"><span style="color:#cadcc6;">https://forum.tek.com/viewtopic.php?f=588&amp;t=139112</span></span></span></a><br> <span style="background:#2b2b2b;"><span style="font-style:italic;"><span style="color:#cadcc6;">&#160;&#160;&#160; &quot;&quot;&quot;<br> &#160;&#160;&#160; </span></span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">yTop = reference_level<br> &#160;&#160;&#160; yBottom = yTop - </span></span><span style="background:#2b2b2b;"><span style="color:#cadbe7;">100<br> &#160;&#160;&#160; </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">yUnit = RSA_API.VerticalUnitType.VerticalUnit_dBm</span></span></span></span></p> <p style="margin-left:36px;"><span style="font-size:9.8pt;"><span style="font-family:&quot;JetBrains Mono&quot;;"><span style="color:#d2d9e1;"><span style="background:#2b2b2b;">dpxSet = RSA_API.DPX_SettingStruct()<br> &#160;&#160;&#160; rsa.CONFIG_SetCenterFreq(c_double(center_frequency))<br> &#160;&#160;&#160; rsa.CONFIG_SetReferenceLevel(c_double(reference_level))</span></span></span></span></p> <p style="margin-left:36px;"><span style="font-size:9.8pt;"><span style="font-family:&quot;JetBrains Mono&quot;;"><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">rsa.DPX_SetEnable(c_bool(</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">True</span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">))<br> &#160;&#160;&#160; rsa.DPX_SetParameters(c_double(frequency_span)</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">, </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">c_double(res_bandwidth)</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">, </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">c_int(</span></span><span style="background:#2b2b2b;"><span style="color:#cadbe7;">801</span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">)</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">, </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">c_int(</span></span><span style="background:#2b2b2b;"><span style="color:#cadbe7;">1</span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">)</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">,<br> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">yUnit</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">, </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">c_double(yTop)</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">, </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">c_double(yBottom)</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">, </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">c_bool(</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">False</span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">)</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">,<br> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">c_double(</span></span><span style="background:#2b2b2b;"><span style="color:#cadbe7;">1.0</span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">)</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">, </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">c_bool(</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">False</span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">))<br> &#160;&#160;&#160; rsa.DPX_SetSogramParameters(c_double(</span></span><span style="background:#2b2b2b;"><span style="color:#cadbe7;">1e-3</span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">)</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">, </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">c_double(</span></span><span style="background:#2b2b2b;"><span style="color:#cadbe7;">1e-3</span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">)</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">,<br> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">c_double(reference_level)</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">, </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">c_double(reference_level - </span></span><span style="background:#2b2b2b;"><span style="color:#cadbe7;">100</span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">))<br> &#160;&#160;&#160; rsa.DPX_Configure(c_bool(</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">True</span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">)</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">, </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">c_bool(</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">True</span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">))</span></span></span></span></p> <p style="margin-left:36px;"><span style="font-size:9.8pt;"><span style="font-family:&quot;JetBrains Mono&quot;;"><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">rsa.DPX_SetSpectrumTraceType(RSA_API.SpectrumTraces.SpectrumTrace1</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">, </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">RSA_API.TraceType.TraceTypeMaxHold)</span></span></span></span></p> <p style="margin-left:36px;"><span style="font-size:9.8pt;"><span style="font-family:&quot;JetBrains Mono&quot;;"><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">rsa.DPX_GetSettings(byref(dpxSet))<br> &#160;&#160;&#160; dpxFreq = np.linspace((center_frequency - frequency_span / </span></span><span style="background:#2b2b2b;"><span style="color:#cadbe7;">2</span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">)</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">, </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">(center_frequency + frequency_span / </span></span><span style="background:#2b2b2b;"><span style="color:#cadbe7;">2</span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">)</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">, </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">dpxSet.bitmapWidth)<br> &#160;&#160;&#160; </span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">return </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">dpxFreq</span></span></span></span></p> <p style="margin-left:36px;"><span style="font-size:9.8pt;"><span style="font-family:&quot;JetBrains Mono&quot;;"><span style="background:#2b2b2b;"><span style="color:#eed3bc;">def </span></span><span style="background:#2b2b2b;"><span style="color:#ffcf83;">acquire_dpx_frame</span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">(rsa</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">, </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">measurement_time):<br> &#160;&#160;&#160; frameAvailable = c_bool(</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">False</span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">)<br> &#160;&#160;&#160; ready = c_bool(</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">False</span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">)<br> &#160;&#160;&#160; fb = RSA_API.DPX_FrameBuffer()</span></span></span></span></p> <p style="margin-left:36px;"><span style="font-size:9.8pt;"><span style="font-family:&quot;JetBrains Mono&quot;;"><span style="color:#d2d9e1;"><span style="background:#2b2b2b;">rsa.DEVICE_Run()<br> &#160;&#160;&#160; rsa.DPX_Reset()<br> &#160;&#160;&#160; time.sleep(measurement_time)</span></span></span></span></p> <p style="margin-left:36px;"><span style="font-size:9.8pt;"><span style="font-family:&quot;JetBrains Mono&quot;;"><span style="background:#2b2b2b;"><span style="color:#eed3bc;">while not </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">frameAvailable.value:<br> &#160;&#160;&#160;&#160;&#160;&#160;&#160; rsa.DPX_IsFrameBufferAvailable(byref(frameAvailable))<br> &#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">while not </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">ready.value:<br> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; rsa.DPX_WaitForDataReady(c_int(</span></span><span style="background:#2b2b2b;"><span style="color:#cadbe7;">100</span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">)</span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">, </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">byref(ready))<br> &#160;&#160;&#160; rsa.DPX_GetFrameBuffer(byref(fb))<br> &#160;&#160;&#160; rsa.DPX_FinishFrameBuffer()<br> &#160;&#160;&#160; rsa.DEVICE_Stop()<br> &#160;&#160;&#160; </span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">return </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">fb</span></span></span></span></p> <p style="margin-left:36px;"><span style="font-size:9.8pt;"><span style="font-family:&quot;JetBrains Mono&quot;;"><span style="background:#2b2b2b;"><span style="color:#eed3bc;">def </span></span><span style="background:#2b2b2b;"><span style="color:#ffcf83;">extract_dpx_spectrum</span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">(fb):<br> &#160;&#160;&#160; </span></span><span style="background:#2b2b2b;"><span style="color:#d8d8d8;"># When converting a ctypes pointer to a numpy array, we need to<br> &#160;&#160;&#160; # explicitly specify its length to dereference it correctly<br> &#160;&#160;&#160; </span></span><span style="background:#2b2b2b;"><span style="color:#d8d8da;">dpxBitmap </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">= np.array(fb.spectrumBitmap[:fb.spectrumBitmapSize])</span></span></span></span></p> <p style="margin-left:36px;"><span style="font-size:9.8pt;"><span style="font-family:&quot;JetBrains Mono&quot;;"><span style="background:#2b2b2b;"><span style="color:#d8d8d8;"># Grab trace data and convert from W to dBm<br> &#160;&#160;&#160; # </span></span><a href="http://www.rapidtables.com/convert/power/Watt_to_dBm.htm"><span style="background:#2b2b2b;"><span style="color:#d8d8d8;">http://www.rapidtables.com/convert/power/Watt_to_dBm.htm</span></span></a><br> <span style="background:#2b2b2b;"><span style="color:#d8d8d8;">&#160;&#160;&#160; # Note: fb.spectrumTraces is a pointer to a pointer, so we need to<br> &#160;&#160;&#160; # go through an additional dereferencing step<br> &#160;&#160;&#160; </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">raw_trace = np.array(fb.spectrumTraces[</span></span><span style="background:#2b2b2b;"><span style="color:#cadbe7;">0</span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">][:fb.spectrumTraceLength])&#160; </span></span><span style="background:#2b2b2b;"><span style="color:#d8d8d8;"># 0 indicates trace 1<br> &#160;&#160;&#160; </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">trace = </span></span><span style="background:#2b2b2b;"><span style="color:#cadbe7;">10 </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">* np.log10(</span></span><span style="background:#2b2b2b;"><span style="color:#cadbe7;">1000 </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">* raw_trace) + </span></span><span style="background:#2b2b2b;"><span style="color:#cadbe7;">30<br> &#160;&#160;&#160; </span></span><span style="background:#2b2b2b;"><span style="color:#eed3bc;">return </span></span><span style="background:#2b2b2b;"><span style="color:#d2d9e1;">trace</span></span></span></span></p> <p style="margin-left:36px;"></p>
Posted Tue, 09 May 2023 23:31:53 GMT by Teles, Afonso
Hi Marianne,<br> <br> The RSA API gives you direct access to the samples from the RSA ADC, it requires significant post-processing work to then transform that into a dBm measurement.<br> Additionally, the RSA API is unsupported and only meant for very specific cases where it's needed (Linux platforms or high transfer rate applications).<br> <br> Instead I would suggest you use the SignalVu-PC programming interface: <a href="https://www.tek.com/en/manual/spectrum-analyzer/signalvu-pc-vector-signal-analysis-software-programmer-manual-rsa306">https://www.tek.com/en/manual/spectrum-analyzer/signalvu-pc-vector-signal-analysis-software-programmer-manual-rsa306</a><br> This interface allows you to get the spectrum trace with just one SCPI command, with all the processing being handled by the SignalVu-PC application.<br> &#160;
Posted Wed, 17 May 2023 15:55:10 GMT by Kobierski, Marianne
<p>Hi Afonso,&#160;</p> <p>Thanks for the reply, I hadn’t realized that the api access data direct from the ADC.&#160;</p> <p>I actually started by trying the SignalVu route as I would love to use SCPI commands, however I’ve been unable to connect to the device via python using pyvisa or NI visa. Using tekvisa is a extremely undesirable last option as we need to run this on computers that have existing NI programs that require use of the NI visa driver, and it doesn’t seem to be possible to have both nivisa and tekvisa installed at the same time.&#160;</p> <p>Attempts to connect to the device that I’ve tried so far:</p> <ul> <li>Locating it via VISA Interactive Control - either the spectrum RSA306B isn’t showing up on the device list, or it’s not possible to open comms with it (visa error “the resource is valid, but VISA cannot currently access it”)</li> <li>Locating it via Tektronix’s OpenChoice Instrument Manager - I can see a GPIB “instrument” with *IDN “TEKTRONIX,SignalVu-PC,8acd6a6, FV:4.1.0022.0”, but I believe this is the SignalVu software and not the spectrum analyser itself. If I try to update the search criteria, “USB” is set to “off” with no way I can see to turn it on.</li> </ul> <p>Do you have any suggestions on how I can connect to and send SCPI commands to the RSA306B? The SignalVu manual seems to require either an Ethernet connection or comms over a GPIB port, neither of which is possible with this device. Any suggestions would be greatly appreciated!</p>
Posted Wed, 17 May 2023 22:16:20 GMT by Teles, Afonso
<p>Hi Marianne,</p> <p></p> <p>1) It is possible to have TekVISA and NI VISA installed at the same time, although it usually requires TekVISA be installed before NI VISA.<br> <br> 2) My suggestion was to do programmatic control of SignalVu-PC instead of the RSA306B directly. SignalVu-PC has its own programmatic control interface that shows up as &quot;GPIB8::1::INSTR&quot; and identifies itself as SignalVu-PC, just as you saw when you did &quot;*IDN?&quot;.</p> <p>3) The RSA itself doesn't have an interface that communicates with VISA and does not use SCPI commands. So you will not be able to find the RSA on any VISA software.</p> <p><br> So. my suggestion is to connect SIgnalVu-PC to the RSA306B, open TekVISA to generate the virtual GPIB interface in VISA and run a python script using pyvisa to communicate with virtual GPIB interface of SignalVu-PC.</p>
Posted Wed, 17 Jan 2024 10:06:25 GMT by Kobierski, Marianne

It's months later, but I wanted to say thank you Afonso, your advice put me on the right track and I was able to connect to the Spectrum analyzer and program it.

With OpenChoice Instrument Manager I could see the device with the name GPIB8::1::INSTR as you mentioned, and as long as I had SignalVU-PC open on my laptop and connected to the spectrum analyzer I was able to connect with my python program using the following code:

import pyvisa  # 1.13.0 is installed
from pyvisa.resources import USBInstrument
rm = pyvisa.ResourceManager()
list_instruments = rm.list_resources()

<find the index of GPIB8::1::INSTR in list_instruments>

spectrum_analyzer: USBInstrument = rm.open_resource(list_instruments[index])

Thanks again for your help!

Posted Wed, 17 Jan 2024 22:10:07 GMT by Teles, Afonso
Glad to hear you got it working and thanks for sharing how you did it!

You must be signed in to post in this forum.