platform for control and data acquisistion application development

Using MicroDAQ with Python


Thanks to its flexibility, Python is one of the most popular programming languages. The PyMlink allows use MicroDAQ device in Python applications. All major features like data acquisition and DSP management functions are available now for Python users. 

PyMLink 

The PyMLink library is a Python programming interface for programming analog input, analog output, digital I/O, on MicroDAQ DAQ devices. The library can be used on Windows and Linux operating systems. The user can use PyMLink library to create data acquisition applications and control applications with real-time processing on MicroDAQ DSP core. PyMLink provides DSP management functions allowing the user to embed real-time processing on dedicated hardware in standard Python application. 


PyMLink (1.2.0) function reference

Digital I/O

  • dio_read - Reads DIO state
  • dio_write - Writes DIO state
  • dio_dir - Sets MicroDAQ DIO bank direction
  • dio_func - Sets DIO alternative function
  • led_write - Sets MicroDAQ D1 and D2 LED state
  • func_key_read - Reads MicroDAQ function key state
  • pwm_init - Setups MicroDAQ PWM outputs
  • pwm_write - Sets MicroDAQ PWM outputs
  • enc_init - Initializes encoder module
  • enc_read - Reads encoder position and motion
    direction

Analog I/O

  • ai_read - Reads MicroDAQ analog inputs
  • ai_scan_init - Inits AI scan
  • ai_scan - Starts scanning and reads scan data
  • ao_write - Writes data to MicroDAQ analog outputs

DSP managment

  • dsp_run - Executes DSP program
  • dsp_signal_read - Receives data from DSP
  • dsp_mem_write - Writes data to MicroDAQ memory
  • dsp_stop - Stops DSP program

Utility 

  • connect - Connects to MicroDAQ device  
  • reconnect - Connects to MicroDAQ device  
  • disconnect - Disconnects from MicroDAQ device
  • get_lib_version - Returns version of MLink library
  • get_fw_version - Returns version of MicroDAQ firmware
  • hw_info - Returns model of connected MicroDAQ device
More information you can find in __doc__ section of these methods.
Installation 

To install PyMLink, download the package manually, go to 'install' directory and run the command:


>> python setup.py install

*On Linux/MacOS run command with with administrator privileges.
Example code

This example show how to use PyMLink to connect and read eight analog input channels (AI1...AI8):

from py_mlink import PyMLink

try:
    mdaq = PyMLink.MLink('10.10.1.1')
    channels = [1,2,3,4,5,6,7,8]
    data = mdaq.ai_read(channels, [-10,10], False)

    for i, volt in enumerate(data):
        print 'Channel[%d]: %f V' % (i, volt)

except PyMLink.MLinkError, errval:
    print "Error:", errval
    


For more examples visit PyMLink repository on GitHub.