Beruflich Dokumente
Kultur Dokumente
Introduction
This pages illustrates the use of the inexpensive (about $150) PMD USB-1208FS data
acquisi on device from Measurement Compu ng. It makes use of PyUniversalLibrary, an
open-source wrapper of Measurement Compu ng's Universal Library.
The following examples were made with PyUL Release 20050624. The pre-compiled win32
binaries of this version are compa ble with the Enthought Edi on of Python 2.4 (Release
1.0.0, 2006-08-02 12:20), which is what was used to run these examples.
In [ ]:
# example1.py
import UniversalLibrary as UL
import time
BoardNum = 0
Gain = UL.BIP5VOLTS
Chan = 0
tstart = time.time()
data = []
times = []
while 1:
DataValue = UL.cbAIn(BoardNum, Chan, Gain)
data.append( DataValue )
times.append( time.time()-tstart )
if times[-1] > 1.0:
break
import pylab
pylab.plot(times,data,'o-')
pylab.xlabel('time (sec)')
pylab.ylabel('ADC units')
pylab.show()
https://scipy-cookbook.readthedocs.io/items/Data_Acquisition_with_PyUL.html 1/9
12/27/2018 Data acquisition with PyUL — SciPy Cookbook documentation
When I ran this, I had a func on generator genera ng a sine wave connected to pins 1 and 2
of my device. This should produce a figure like the following:
https://scipy-cookbook.readthedocs.io/items/Data_Acquisition_with_PyUL.html 2/9
12/27/2018
In [ ]: Data acquisition with PyUL — SciPy Cookbook documentation
#example2.py
import UniversalLibrary as UL
import time
BoardNum = 0
Gain = UL.BIP5VOLTS
Chan = 0
tstart = time.time()
data = []
times = []
while 1:
DataValue = UL.cbAIn(BoardNum, Chan, Gain)
EngUnits = UL.cbToEngUnits(BoardNum, Gain, DataValue)
data.append( EngUnits )
times.append( time.time()-tstart )
if times[-1] > 1.0:
break
import pylab
pylab.plot(times,data,'o-')
pylab.xlabel('time (sec)')
pylab.ylabel('Volts')
#pylab.savefig('example2.png',dpi=72)
pylab.show()
https://scipy-cookbook.readthedocs.io/items/Data_Acquisition_with_PyUL.html 3/9
12/27/2018 Data acquisition with PyUL — SciPy Cookbook documentation
Now the output values are in volts:
https://scipy-cookbook.readthedocs.io/items/Data_Acquisition_with_PyUL.html 4/9
12/27/2018
In [ ]: Data acquisition with PyUL — SciPy Cookbook documentation
#example3.py
import UniversalLibrary as UL
import Numeric
import pylab
BoardNum = 0
Gain = UL.BIP5VOLTS
LowChan = 0
HighChan = 0
Count = 2000
Rate = 3125
Options = UL.CONVERTDATA
ADData = Numeric.zeros((Count,), Numeric.Int16)
# convert to Volts
data_in_volts = [ UL.cbToEngUnits(BoardNum, Gain, y) for y in ADData]
https://scipy-cookbook.readthedocs.io/items/Data_Acquisition_with_PyUL.html 5/9
12/27/2018 Data acquisition with PyUL — SciPy Cookbook documentation
The output looks much be er:
https://scipy-cookbook.readthedocs.io/items/Data_Acquisition_with_PyUL.html 6/9
12/27/2018
In [ ]: Data acquisition with PyUL — SciPy Cookbook documentation
#example4.py
import UniversalLibrary as UL
import Numeric
import pylab
BoardNum = 0
Gain = UL.BIP5VOLTS
LowChan = 0
HighChan = 0
Count = 2000
Rate = 10000
Options = UL.CONVERTDATA
ADData = Numeric.zeros((Count,), Numeric.Int16)
# convert to Volts
data_in_volts = [ UL.cbToEngUnits(BoardNum, Gain, y) for y in ADData]
data_in_volts = Numeric.array(data_in_volts) # convert to Numeric array
https://scipy-cookbook.readthedocs.io/items/Data_Acquisition_with_PyUL.html 7/9
12/27/2018 Data acquisition with PyUL — SciPy Cookbook documentation
For this example, I've turned up the frequency on the func on generator to 480 Hz. You can
see, indeed, that's what the psd() func on tells us:
A achments
example1.png
example2.png
https://scipy-cookbook.readthedocs.io/items/Data_Acquisition_with_PyUL.html 8/9
12/27/2018 example3.png Data acquisition with PyUL — SciPy Cookbook documentation
example4.png
https://scipy-cookbook.readthedocs.io/items/Data_Acquisition_with_PyUL.html 9/9