https://github.com/axopy/pymcc
Interface to Measurement Computing DAQs that works with AxoPy
https://github.com/axopy/pymcc
data-acquisition
Last synced: about 16 hours ago
JSON representation
Interface to Measurement Computing DAQs that works with AxoPy
- Host: GitHub
- URL: https://github.com/axopy/pymcc
- Owner: axopy
- License: mit
- Created: 2017-06-29T19:56:30.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-23T00:16:54.000Z (over 7 years ago)
- Last Synced: 2025-09-09T13:28:40.836Z (27 days ago)
- Topics: data-acquisition
- Language: Python
- Homepage:
- Size: 63.5 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
=====
pymcc
=====``pymcc`` provides access to Measurement Computing USB data acquisition
devices, thanks to `PyDAQFlex `_ (which
has been copied here so it is not necessary to install it separately).Dependencies
============- NumPy_
- PyUSB_*Note*: on Windows, you'll need to install a USB backend like libusb. See the
PyUSB_ README for more information... _NumPy: https://www.numpy.org/
.. _PyUSB: https://github.com/pyusb/pyusbSetup
=====This implementation has been verified to work with the USB-1608G, though it
should also work with other MCC USB DAQs. As long as the device supports analog
input, it should *just work* (TM). Start by installing the package on your
chosen platform. On Windows, that *should* be all that's needed. On Linux,
you'll need to install a udev rule (e.g. create a file
``/etc/udev/rules.d/61-mcc.rules``) for your device to be accessible by
non-root users. Populate the file with a line like the following::SUBSYSTEM=="usb", ATTR{idVendor}=="09db", ATTR{idProduct}=="0110", MODE="0666"
Replace the ``idProduct`` attribute with the product ID of your device (the
example above is for the USB-1608G). The product ID can be found using
``lsusb``. After creating the udev rule, you can log out of your account and
log back in. After adding the rule, you can reload the rules by logging out and
back in or using ``udevadm``. Finally, try running the
``examples/check_mccdaq.py`` script. If no errors occur, the device should be
set up correctly.Usage
=====``pymcc`` consists of low-level library (PyDAQFlex) as well as a high-level
wrapper called ``MccDaq``. You can create an ``MccDaq`` object and then poll
the device for samples... code-block:: python
from pymcc import MccDaq
# sample rate, in Hz
samp_rate = 2048
# number of samples to fetch per `read()` call
samp_per_read = 256
# range of channels to read from, zero-indexed, endpoint inclusive
ch = (0, 3)# create the device
dev = MccDaq(samp_rate, samp_per_read, channel_range=ch)# start the DAQ so it begins filling the internal buffer
dev.start()# request samples from the device
# this method blocks
# it only returns once the requested number of samples have been recorded
dev.read()# stop the device (call start() again to start over)
dev.stop()The doc strings in `` contain more details about the
parameters and methods of the ``MccDaq`` class.**Important Note**: the packet size when reading from the device is 512 bytes
when the device is enumerated as a high-speed USB device. This means for
a 16-bit device (like the USB-1608G), you must request a multiple of 256
*total* samples per read operation. For instance, if you are recording from one
channel (``channel_range=(0, 0)``), you need to set ``samples_per_read`` to
some integer multiple of 256. If you're using two channels, you can read 128
samples at a time (2 channels * 128 samples/read * 2 bytes/sample = 512
bytes/read). See Measurement Computing's `Message-based Firmware
Specification`_ for details... _Message-based Firmware Specification: https://www.mccdaq.com/pdfs/manuals/Message-based%20Firmware%20Specification.pdf>`