当前位置:网站首页>RSA306B,500,600系列API接口代码
RSA306B,500,600系列API接口代码
2022-08-04 15:11:00 【二十四桥_】
获取资料,下图是代码文件截图。
部分示例代码:
"""################SPECTRUM EXAMPLE################"""
def config_spectrum(cf=1e9, refLevel=0, span=40e6, rbw=300e3):
rsa.SPECTRUM_SetEnable(c_bool(True))
rsa.CONFIG_SetCenterFreq(c_double(cf))
rsa.CONFIG_SetReferenceLevel(c_double(refLevel))
rsa.SPECTRUM_SetDefault()
specSet = Spectrum_Settings()
rsa.SPECTRUM_GetSettings(byref(specSet))
specSet.window = SpectrumWindows.SpectrumWindow_Kaiser
specSet.verticalUnit = SpectrumVerticalUnits.SpectrumVerticalUnit_dBm
specSet.span = span
specSet.rbw = rbw
rsa.SPECTRUM_SetSettings(specSet)
rsa.SPECTRUM_GetSettings(byref(specSet))
return specSet
def create_frequency_array(specSet):
# Create array of frequency data for plotting the spectrum.
freq = np.arange(specSet.actualStartFreq, specSet.actualStartFreq
+ specSet.actualFreqStepSize * specSet.traceLength,
specSet.actualFreqStepSize)
return freq
def acquire_spectrum(specSet):
ready = c_bool(False)
traceArray = c_float * specSet.traceLength
traceData = traceArray()
outTracePoints = c_int(0)
traceSelector = SpectrumTraces.SpectrumTrace1
rsa.DEVICE_Run()
rsa.SPECTRUM_AcquireTrace()
while not ready.value:
rsa.SPECTRUM_WaitForDataReady(c_int(100), byref(ready))
rsa.SPECTRUM_GetTrace(traceSelector, specSet.traceLength, byref(traceData),
byref(outTracePoints))
rsa.DEVICE_Stop()
return np.array(traceData)
def spectrum_example():
print('\n\n########Spectrum Example########')
search_connect()
cf = 2.4453e9
refLevel = -30
span = 40e6
rbw = 10e3
specSet = config_spectrum(cf, refLevel, span, rbw)
trace = acquire_spectrum(specSet)
freq = create_frequency_array(specSet)
peakPower, peakFreq = peak_power_detector(freq, trace)
plt.figure(1, figsize=(15, 10))
ax = plt.subplot(111, facecolor='k')
ax.plot(freq, trace, color='y')
ax.set_title('Spectrum Trace')
ax.set_xlabel('Frequency (Hz)')
ax.set_ylabel('Amplitude (dBm)')
ax.axvline(peakFreq)
ax.text((freq[0] + specSet.span / 20), peakPower,
'Peak power in spectrum: {:.2f} dBm @ {} MHz'.format(
peakPower, peakFreq / 1e6), color='white')
ax.set_xlim([freq[0], freq[-1]])
ax.set_ylim([refLevel - 100, refLevel])
plt.tight_layout()
plt.show()
rsa.DEVICE_Disconnect()
边栏推荐
猜你喜欢
随机推荐
OAID是什么
ping的原理
C# TextBlock 上标
Roslyn 节点的 Span 和 FullSpan 有什么区别
数据链路层-------以太网协议
Next -19- 开启fancybox查看图片大图
Unity AR阴影投射透明地面 仅渲染模型实时阴影 Shader实现
7 天能找到 Go 工作吗?学学 Go 数组和指针试试
Legal education combined with VR panorama, intuitively feel and learn the spirit of the rule of law
李沐的深度学习笔记来了!
Android Sqlite3 basic commands
Bluetooth Technology|In the first half of the year, 1.3 million charging piles were added nationwide, and Bluetooth charging piles will become the mainstream of the market
24、shell编程-流程控制
普法教育结合VR全景,直观感受和学习法治精神
郑轻新生校赛和中工选拔赛题解
C# SolidWorks二次开发---工程图简单版标注孔信息
Roslyn 通过 nuget 统一管理信息
多线程编程之优先级翻转问题
基于 Next.js实现在线Excel
JCMsuite Application: Oblique Plane Wave Propagation Transmission Through Aperture