addpath(['C:\Programme\National Instruments\NI-DAQ\Include'])
loadlibrary 'C:\WINDOWS\system32\nidaq32.dll' 'nidaq.h' addheader nidaqcns alias mynidaq
%Wie include ich die Konstanten von nidaqcns?
%libfunctions mynidaq;
%Listet die zur Verfgung gestellten Funktionen auf
%ARGUMENTS USED BY DLL FUNCTIONS
%The values of the function parameters (most of them starting with "ND_")
%are stored in the header file "nidaqcns.h".
%Either you can manualy enter the numerical values (open the header file
%and you will see the constants with some numbers behind. Just take the
%numbers and skip the "L" afterwards.
%Or you can use the file "loadNIcns.m" (Sorry I don't know anymore who
%generated that file. Probably Scot Hirsch or Tom. Let me know so I can add it).
%Just run the file and locate "nidaqcns.h". The you can give the output a
%name (testo=ans) and save this object testo (right click on testo in the
%Workspace and save it as testo.m). Now you can access each constant via
%"testo.CONSTANT".
deviceNumber= 1;
%Hardware Device ID. Get this with daqhwinfo('nidaq') or with Max
gpctrNum=testo.ND_COUNTER_0;
%ID Number of the counter you want to use. I used counter number 0,
%the aktual number is stored in testo
action=testo.ND_RESET;
application=testo.ND_PULSE_TRAIN_GNR;
%application=testo.ND_SINGLE_PULSE_GNR;
%Determines for what purpose you want to use your counter; e.g.
%generate a pulse train (or single pulse)
paramID1=testo.ND_COUNT_1;
paramID2=testo.ND_COUNT_2;
sourceSpec=testo.ND_LOW_TO_HIGH;
action2=testo.ND_PROGRAM;
gpctrNumOut=testo.ND_GPCTR0_OUTPUT;
%CALLING OF THE NEEDED FUNCTIONS (Explanation of the functions in nidaqpc.hlp)
calllib ('mynidaq', 'GPCTR_Control', deviceNumber, gpctrNum, action)
calllib ('mynidaq', 'GPCTR_Set_Application', deviceNumber, gpctrNum, application)
calllib ('mynidaq', 'GPCTR_Change_Parameter', deviceNumber, gpctrNum, testo.ND_SOURCE, testo.ND_INTERNAL_100_KHZ)
%With this function one can change the timebase to 100 kHz
calllib ('mynidaq', 'GPCTR_Change_Parameter', deviceNumber, gpctrNum, paramID1, 2e5)
calllib ('mynidaq', 'GPCTR_Change_Parameter', deviceNumber, gpctrNum, paramID2, 4e5)
calllib ('mynidaq', 'Select_Signal', deviceNumber, gpctrNumOut, gpctrNumOut, sourceSpec)
calllib ('mynidaq', 'GPCTR_Control', deviceNumber, gpctrNum, action2)