控制scpi仪器的简易库

easy-scpi的Python项目详细描述


简单的SCPI

一个简单而健壮的库,使与SCPI(可编程仪器的标准控制)仪器的通信变得容易。创建连接到实际仪表的仪表对象后,将使用类似于属性的格式向仪表发送命令。当为特定工具创建控制器时,该类对于继承非常有用。使用PyVISA完成与仪器的通信。

Install with python -m pip install easy-scpi

API

SCPI命令

通过将SCPI代码通过层次关系转换为属性,然后调用它,可以执行通用SCPI命令通过不向调用传递参数,可以查询仪器属性。不带参数的命令通过向调用传递空字符串来运行。

示例

# import packageimporteasy_scpiasscpi# Connect to an instrumentinst=scpi.Instrument(<port>)# Read the voltage [MEASure:VOLTage:DC?]inst.measure.voltage.dc()# orinst.meas.volt.dc()# Set the voltage to 1 V [MEASure:VOLTage:DC 1]inst.measure.voltage.dc(1)# orinst.source.voltage('1')# Execute a command to take a reading [SYSTem:ZCORrect:ACQuire]inst.syst.zcor.aqc('')

方法

Instrument(<;port>;,backend='',**resource_params):创建SCPI工具的实例后端用于创建VISA Resource Manager。连接后,resource_参数将传递给VISA resource

connect():将对象实例连接到指定端口上的实际仪器

disconnect():断开仪器与程序的连接,关闭端口。

write(<;msg>;):msg发送到仪器

read():从工具获取最近的响应。

query(<;msg>;):msg发送到仪器并返回其响应

reset():将仪器设置为默认状态。

init():初始化测量仪器。

属性

backend:返回使用的Visa后端的名称。[只读]

inst:返回实例使用的资源。[只读]

端口:通信端口。

rid:与工具关联的资源id[只读]

resource_params:返回创建时传递的资源参数。[只读]

timeout:仪器的通信超时[只读]

id:仪器的制造商id。[只读]

value:仪器的当前值[只读]

已连接:仪器是否已连接。[只读]

已连接:已连接的别名

完整示例

与Tektronix PWS4305一起使用
# scpi controllerimporteasy_scpiasscpiclassPowerSupply(scpi.Instrument):def__init__(self):scpi.SCPI_Instrument.__init__(self,port=None,timeout=5,read_termination='\n',write_termination='\n')# other initialization code...#--- public methods ---@propertydefvoltage(self):"""        Returns the voltage setting        """returnself.source.volt.level()@voltage.setterdefvoltage(self,volts):"""        Sets the voltage of the instrument        """self.source.volt.level(volts)@propertydefcurrent(self):"""        Returns the current setting in Amps        """returnself.source.current.level()@current.setterdefcurrent(self,amps):"""        Set the current of the instrument        """self.source.current.level(amps)defon(self):"""        Turns the output on        """self.output.state('on')defoff(self):"""        Turns the output off        """self.output.state('off')

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java线程;创建一个单独的线程来定期执行某些操作   用java将SonarQube升级到5.2失败。util。同时发生的CancellationException:空   在线程对象上调用start时,线程上设置的java优先级无效   java如何在不使用reduce()或last()折叠的情况下获取通量的最后一项   java如何从ArrayList中获取元素?   应用了逻辑的JavaTwitterAPI   在这种情况下,怎样才能不让自己重复?安卓的java   JavaAndroid:线程可运行和处理程序。在run方法中发布问题(Handler.postXX在预期情况下不会按时运行)   java log4j grok与管道故障   使用循环返回命令选项时出现问题/仅运行一个命令(JAVA)   java双重比较问题   使用vertx的JWT公钥/私钥身份验证中的java握手   用Java将WMA和AAC音频转换为MP3   解析字符串java get index   与具有不同数据类型的密钥同名的java JSON