数据采集用串行设备控制器。目前支持欧米茄DPG-4000压力传感器和Gwinstek LCR-821米。
serialdaq的Python项目详细描述
串行数据
本模块定义了控制Omega DPG-4000压力传感器的类 以及Gwinstek LCR-821米。此实现的特点是自动连接到设备(通过扫描可用的串行端口),并提供有限或无限时间数据采集(和保存到文件)的方法。
每个设备的类都是serial device类的子类,允许扩展以用于其他串行设备(只需继承serialdevice并定义get_reading()方法,以及baud和data_columns属性)。
安装
要安装serialdaq,请使用pip(或类似工具):
pip install serialdaq
文档
如果只连接了一个设备,该软件包将自动检测该设备; 如果没有,请指定端口。每10秒收集一次,除非计数。 数据保存到指定的文件(需要文件名)。
LCR仪表示例
importserialdaqlcr=serialdaq.LCRMeter()lcr.start_collection('output_filename.csv')
欧米茄压力传感器示例
importserialdaqomega=serialdaq.PressureSensor()omega.start_collection('output_filename.csv')
使用此模块的其他方法
importserialdaqserialdaq.serial_ports()# list all available serial portsserialdaq.list_devices()# list all devicesomega=serialdaq.PressureSensor('COM5')# connect to a specific portomega.get_reading()# get a single readingomega.start_collection('output_filename.csv',# output filename (required)dt=5,# sample interval (seconds)count=20,# number of readings to getlabel='50um')# single label for dataomega.start_collection('output_filename.csv',# output filename (required)dt=10,# sample interval (seconds)count=10,# number of readings to getlabel=['50um','trial1'])# multiple labels for data