A Python programming interface for MicroDAQ DAQ devices.
Project description
Microdaq
This package allows users to use data acquisition under MicroDAQ hardware with Python2.7 and Python 3. It provides an interface between the MLink driver and Python application. The package works with Windows x86/x64, Linux x86/x64, MacOS x64 and EABI ARM machines.
Installation
pip install microdaq
If already installed, upgrading could be done by
pip install microdaq --upgrade
Examples
Sample programs are located in examples
directory. In order to run them,
connect MicroDAQ device to your computer and run chosen script without any
additional steps. For example: python exmaples/ai-demo.py
Scripts from 'examples/complex' require additional packages to work.
They could be installed via pip install -r requirements/examples.txt
command.
LED control example
Turn on and turn off LED 1.
import time
import microdaq
mdaq = microdaq.Device(ip='10.10.1.1')
mdaq.led_write(led=1, state=True)
time.sleep(1.0)
mdaq.led_write(led=1, state=False)
Analog input
Read analog input channels 1 and 2.
import microdaq
mdaq = microdaq.Device(ip='10.10.1.1')
data = mdaq.ai_read(channels=[1, 2], ai_range=[-10, 10])
for i, volt in enumerate(data):
print('Channel[%d]: %f V' % (i, volt))
Continuous data acquisition
Read analog input from channel 1, 100 kHz sampling period for a 0.1 second. Expected 10 000 samples.
import microdaq
mdaq = microdaq.Device("10.10.1.1")
mdaq.ai_scan_init(
channels=[1],
ai_range=[-10, 10],
is_differential=[False],
rate=100000,
duration=0.1)
data = mdaq.ai_scan(
scan_count=10000,
timeout=True)
for sample in data:
print('%f V' % sample)
Analog output
Set 1.0V and 2.0V to analog output channels 1 and 2 respectively. Used range 0-5 volts.
import microdaq
mdaq = microdaq.Device(ip='10.10.1.1')
mdaq.ao_write(
channels=[1, 2],
ao_range=microdaq.AORange.AO_5V_UNI,
data=[1.0, 2.0])
PWM
Generate PWM signal on two channels A and B (PWM module 1).
import microdaq
mdaq = microdaq.Device(ip='10.10.1.1')
mdaq.pwm_init(module=1, period=1000)
mdaq.pwm_write(module=1, duty_a=25, duty_b=50)
Encoder
Read encoder position.
import time
import microdaq
mdaq = microdaq.Device(ip='10.10.1.1')
mdaq.enc_init(module=1, init_value=0)
for i in range(30):
time.sleep(0.1)
enc = mdaq.enc_read(module=1)
print('position: %d\tdir: %d' % (enc[0], enc[1]))
DSP with Scilab XCOS model
Load and run application generated by MicroDAQ Toolbox for Scilab.
Toolbox available is here: https://atoms.scilab.org/toolboxes/microdaq/1.2.2
Application overview:
import os
import microdaq
mdaq = microdaq.Device(ip='10.10.1.1')
model = os.path.join("resources", "signal-model.out")
mdaq.dsp_init(dsp_application=model, rate=100, duration=-1)
mdaq.dsp_start()
print("DSP is running: %s" % mdaq.dsp_is_done())
mdaq.dsp_stop()
print("DSP is running: %s" % mdaq.dsp_is_done())
Tests
This sections is meant to be for package's developers/contributors. Tests for API
layer which does not required connected MicroDAQ device could be triggered by
pytest tests/test_api.py
.
Additional requirements needed:
pip install -r requirements/tests.txt
License
The BSD license. For more information read LICENSE.md file.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file microdaq-1.4.0.tar.gz
.
File metadata
- Download URL: microdaq-1.4.0.tar.gz
- Upload date:
- Size: 18.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 233ec4abab918cb1d6fce5bde63322205cce513f81bf04c89920ac24fa57ebda |
|
MD5 | 34faffd2e162372c90e3f254fed235f1 |
|
BLAKE2b-256 | 68255ffeb81b92d8119ba78246934858656b15c9007f2514e2ef80051bf84d59 |
File details
Details for the file microdaq-1.4.0-py2.py3-none-any.whl
.
File metadata
- Download URL: microdaq-1.4.0-py2.py3-none-any.whl
- Upload date:
- Size: 261.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b2f314d4774df7a44a340cd28cc8cb1898d5c5d41e07998190dfff1a5219a12 |
|
MD5 | efc504699cfc8fbfc12b0599a57d9dd5 |
|
BLAKE2b-256 | cae2ae5bc7df5624c644d48e477b25bd704939b9aea414b7c6466535d8f33890 |