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;

You must be signed in to post in this forum.