控制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 toString()方法打印空值   java大型IN子句   如何使用JavaSpring在JavaScriptjQuery中设置post路径   java ByteArrayOutputStream已上载到服务器   java为什么轮询在SocketIO上获取数据“无法加载请求的项”?   java源代码应该以UTF8格式保存   Java数据库轮询器?   在Java中将double转换为float   java AccessDeniedException:C:\Windows\System32\drivers\etc\hosts