06-07-2017 04:49 AM
For my application I need to generate repeatedly triggered analog outputs with the NI USB-6216. The triggers are relatively fast (20-30 ms distance) in an irregular pattern. When I setup the signal generation and a trigger connection in the Data Acquisition Toolbox of MATLBA 2017a I am able to trigger the device, but not consistently. Most of the time it skips several triggers.
Is there a hardware limitation to retriggerable events? Or does it depend on the software? Unfortunately I will not be able to purchase a LabView license, so I am limited to the Matlab toolbox. At the moment I set a trigger connection between the external trigger and the analog output, but maybe there is a better workaround to achieve what I want to do.
If somebody has the solution to my problem or information on where I could further look for a solution I would be very thankful.
Best, Marina
06-09-2017 04:18 PM
Major question is how much data do you need to generate between triggers (N of points and rate)? You can not start a new sequence untill previous finishes.
With buffered generation you should be able to retrigger within 1 analog output point (1/250 kHz).
This lists the steps how to set it up.
http://www.ni.com/example/29787/en/
Obviously, only labview example, you will need to figure out alternative in text commands.
06-12-2017 08:44 AM
The signal that I generate is shorter than the inter-trigger time, I need 16 ms of signal, the next trigger only comes after a minimum time of 30 ms.
Thank you for posting the example, but as I do not have LabView I am uncertain that I will be able to code this function. I am using the Data Acquisition Toolbox which also seems to be the reason for the Problem, as it internally resets the stimulus and writes it again to the NI Card (if I understood it's inner workings correctly). This seems to take the time, so the card is unable to retrigger while Matlab is busy.
Thank you for your answer anyway.
Does anybody know a way to use this example outside of LabView (or even Matlab)?
06-12-2017 09:45 AM
I looked at the toolbox description, it is very limited in functions.
I would suggest to take a look at .Net interface for daqmx, it exports all required daqmx functions. I guess you can call them from Matlab, not only from visuall C# http://zone.ni.com/reference/en-XX/help/370466AD-01/daqhelp/netapp/.
06-24-2017 01:44 AM
I would take a look at the ANSI C examples for DAQmx and then consider using a MEX file or compiled library for MATLAB.
In particular, the example titled "MultVoltUpdates-IntClk-Retrig.c" and found on my computer at
C:\Users\Public\Documents\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Analog Out\Generate Voltage\Mult Volt Updates-Int Clk-Retriggerable
looks promising. I think that these are installed as part of the NI-DAQ package (you'd never guess from the path 😉 ) but a list of available text-based examples for NI-DAQmx can be found here.
06-27-2017 05:33 AM
You are right, this examples look very promising.
Unfortunately I cannot get even this simple example to work, as it does not seem to find the DAQmx functions. Upon compilation, I get errors that no reference was found to all the DAQmx functions (such as DAQmxCreateTask)... Do you know why this happens? I am using the example as it is. Is there a need to give the location of those functions? I did not find any instructions to getting started in the documentation and am not really familiar with C coding. It does find the NIDAQmx.h file after I included the path, but seemingly from there it does not excecute the actual driver functions.
06-27-2017 07:17 AM
If you're compiling a file and you already have the header, I would try looking into linking as the problem. I'm not sure what sort of compiler you have, but for a Linux GCC command line compiler, the flag you're looking for is likely to be "-L/my/path/to/library/daqmx.so -ldaqmx" or similar - in Windows I would look for a NIDAQmx.lib or similar.
This article might be useful: Location of ANSI C NI-DAQmx Library File for Windows.
06-28-2017 03:40 AM
Yes, I guess this is the problem, but I found the page meanwhile too and tried it. I am working on Windows and tried linking the NIDAQmx.lib, but the problem persists. Could be I don't get on with the compiler (Dev-C++), but I guess this is a different topic. I consider the question itself solved, as the examples should make it possible to achieve just what I was searching for. I just haven't succeeded in achieving it.
Thanks for the help!
06-28-2017 04:42 AM
I think this link should help - How Can I Use The NI-DAQmx ANSI C Function Library With GCC (on Windows)?
I haven't tried any of the things discussed but it's describing the problem you have, and Dev-C++ is a GCC compiler using mingw.