Skip to main content

Posts

Showing posts from March, 2018

Programming NI DAQmx board in Python: easier than you think!

For my DIY microscope I had a task - generate a train of digital pulses which simulate camera trigger, so that other devices (galvo and laser) are synched. I wanted to do it in Python , so that it seamlessly integrates in my data acquisition and analysis Jupyter notebook. After some quick search I found a PyDAQmx library which seemed mature and had good examples to begin with. Installation was smooth: download, unzip, open Anaconda prompt, python setup.py install After only 30 min fiddling, I was able to solve my problem in just a few lines of code: Holy crap, it just works, out of the box. Oscilloscope shows nice digital pulses every 100 ms, each 1 ms long. The code is much shorter and cleaner than would be in C, C#, or LabView. PyDAQmx appears to be a full-power wrapper around native NI DAQmx drivers (yes, they need to be installed), so presumably it can do all that can be done in C or even LabView (this statement needs to be tested). One can use PyDAQmx to control ga