从Cleware USB-ADC 2读取值的Python模块
clewareADC的Python项目详细描述
Description
用于Cleware USB-ADC 2的非官方python接口 cython-hidapi。
本软件按“原样”提供,无任何形式的保证,明示或 默示的,包括但不限于适销性保证, 适合特定目的和不侵权。在任何情况下 作者或版权所有者应对任何索赔、损害或其他 责任,无论是在合同诉讼、侵权诉讼或其他诉讼中, 不属于或与软件、使用或其他交易有关 软件。
License
CLEWAREADC是根据麻省理工学院的许可证(见许可证)提供的。
Install
下载clewareadc:
git clone https://gitlab.com/darkforce/clewareADC.git cd clewareADC
使用设置工具安装:
python setup.py install
Usage
下面的代码将列出所有连接的USB-ADC 2设备,并连接到找到的第一个设备 并从两个通道中打印10个值,按13.621V的比例缩放:
importtimefromclewareADCimportClewareADCdeviceList=ClewareADC.listDevices()iflen(deviceList)<1:raiseException('No ADCs found')fordeviceindeviceList:print('Found ADC at {} with serial number {}'.format(device[0],device[1]))print('')withClewareADC(13.621,deviceList[0][1])asadc:print('Reading from ADC {} with 13.621V scaling:'.format(deviceList[0][1]))foriinrange(10):ch0=adc.readChannel(0)ch1=adc.readChannel(1)print(' Ch 0: {}V, Ch 1: {}V'.format(ch0,ch1))time.sleep(1.00)