Recent Linux kernels support USBTMC out of the box. Connect your
instrument and check if /dev/usbtmc* exists. Set appropriate
permissions to /dev/usbtmc*
Open an interface to the USB instrument t0 = usbtmc('/dev/usbtmc0')
Write to listener: usbtmc_write(t0, '*IDN?')
Blocking read call [binary read], returns uint8 array data = usbtmc_read(t0, 10000)
Convert uint8 array to string, char(data)
import usbtmc
instr = usbtmc.Instrument(2391, 5973) // The 2391 and 5973 are USB idVendor and idProduct of the Agilent MSO7104A converted to decimal
print(instr.ask("\***IDN?"))
# returns 'AGILENT TECHNOLOGIES,MSO7104A,MY********,06.16.0001'
USBTMC是USB测试和测量类。这些命令是SCPI命令。必须加载的驱动程序系统驱动程序是
usb_tmc
(http://lxr.free-electrons.com/source/drivers/usb/class/usbtmc.c)。插入安捷伦设备后,请在dmesg
的输出中检查此项。波形发生器应该出现在/dev/usbtmcx
或/dev/ttySx
(用系统上的数字代替x)http://wiki.octave.org/Instrument_control_package(不是Python;是Octave,仅显示基本用法)。在
在Python中是相似的。见http://scruss.com/blog/tag/usbtmc/。在
首先检查
dmesg
当您插入Agilent设备并按照https://github.com/python-ivi/python-usbtmc上的说明操作时,dmesg
驱动程序已加载(创建udev规则,…,检查/dev/usbtmc0是否出现,等等)如果一切正常,编写一个简单的测试脚本,看看安捷伦设备是否响应:
然后编写一个Python“driver”,将标准TMC命令映射到Python函数(
read()
,write()
,…),就像https://gist.github.com/pklaus/2597049中的usbtmc.py
。这个在here里。在一个非常基本的波形发生器控制脚本在http://markjones112358.co.nz/projects/Python-Controlled-Function-Generator/
如果要设置频率,请编写SCPI命令
^{pr2}$FREQ
,后跟所需的值:如果您想设置一个振幅,您可以编写命令
VOLT
,后跟所需的值:复杂的部分是创建和下载二进制任意文件。在
不能直接用NumPy矩阵加载Agilent,因为它只接受特殊的二进制文件,所以必须将chirp矩阵转换成二进制文件。见http://cp.literature.agilent.com/litweb/pdf/E4400-90627.pdf第42页,62。也许可以将第62页的示例翻译成Python来生成二进制arb文件
当您创建波形二进制arb文件时,您可以使用SCPI write operationshttps://community.keysight.com/thread/20217(在C中)来传输它
当使用上面这样的Python驱动程序时,可以将其转换为Python:
binary_write("SOURce1:DATA:ARBitrary testarb,", z, true);
(二进制写入)见http://rfmw.em.keysight.com/spdhelpfiles/33500/webhelp/US/Content/__I_SCPI/DATA_Subsystem.htm
(在234页的用户指南http://cp.literature.agilent.com/litweb/pdf/33220-90002.pdf中,ff页也是相关SCPI命令的摘要。在网上搜索。在
在https://de.mathworks.com/company/newsletter/articles/downloading-a-custom-waveform-to-an-arbitrary-waveform-generator.html中是一个名为快速控制函数生成器的MATLAB工具箱,它解决了这个问题。在
相关问题 更多 >
编程相关推荐