Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Edge Triggered Callback Function with E Series DAQCard

Hardware: DAQCard-AI-16XE-50
Software: NI-DAQ 6.9.1 call from C++

Q- Does anyone have sample code to initiate a callback function in C++ when a pulse edge is input to a DAQCard-AI-16XE-50? I am using ACH1 as the input channel. Pulse edge occurance will be low duty cycle.Below code doesnt work..
(I could use a latch & poll but edge triggering would be cleaner!)

status = Set_DAQ_Device_Info(1,ND_AI_FIFO_INTERRUPTS,
ND_INTERRUPT_EVERY_SAMPLE);
retValue=NIDAQErrorHandler(status,"Set_DAQ_Device_Info (FIFO Interrupts)",0);

status = Set_DAQ_Device_Info(1,ND_DATA_XFER_MODE_AI,
ND_INTERRUPTS);
retValue=NIDAQErrorHandler(status,"Set_DAQ_Device_Info",0);

status = Config_ATrig_Even
t_Message(1,1,"AI1",3,1,1,0,
0,0,0,0,(unsigned int)EdgeCallbackFunction);
retValue=NIDAQErrorHandler(status,"Config_ATrig_Event_Message",0);

Thanks Millions if you help!!
0 Kudos
Message 1 of 2
(2,639 Views)
Hi kittyKat,

The easiest way to create an interrupt service routine or callback function triggered on a digital edge is to use DAQ Event Messaging. In C, you can program for your DAQ board by using the function Config_DAQ_Event_Message. The different events you can account for are:
DAQ Event type 0 � Acquire or Generate N Scans
DAQ Event type 1 � Every N Scans
DAQ Event type 2 � Completed Operation or Stopped by Error
DAQ Event type 3 � Voltage out of bounds
DAQ Event type 4 � Voltage within bounds
DAQ Event type 5 � Analog Positive Slope Triggering
DAQ Event type 6 � Analog Negative Slope Triggering
DAQ Event type 7 � Digital Pattern Not Matched
DAQ Event type 8 � Digital Pattern Matched
DAQ Event type 9 � Counter Pulse Event

If you are not
using your analog input on your DAQ board, you can setup an analog input and use your external signal as an external clock. This would involve you using one of the shipping examples for analog input with an external clock and adding the DAQ Event Messaging for Event 1 and have the interval be 1 value. Therefore, your callback function will be called every scan or every time your signal pulses high (as the external clock). I've included some useful resources below.

Using DAQ Event Messaging under Windows NT/95/3.1
http://zone.ni.com/devzone/conceptd.nsf/webmain/159C194435C8CA5786256869005EF6AE?opendocument

DAQ Events and Occurrences
http://digital.ni.com/public.nsf/websearch/9F3DAD3E227E4203862566C2005B11EB?OpenDocument

Hope that helps. Have a good day.

Ron
Applications Engineering
National Instruments
Message 2 of 2
(2,639 Views)