03-06-2009 08:02 AM
Hi,
I'm using a PCI-6602 card with CVI 8.5 and I need to trig on event.
On every pulse I received, I need to do some actions like increasing a counter, send a message on Rs232 etc.. I don't want to do any loop checking that the counter value has changed. I would like to use a callback to execute this code only on the edge or counter value event.
My problem is that I don't know which function can do this. Is there any way to get an event on a pci-6602?
Thanks
James
Solved! Go to Solution.
03-12-2009 08:59 AM
Hello.
It's completely possible to create a callback that will allow you to do what you want when a edge will occur on an external signal you define.
To do this, you can for exemple create a counting edges task that will use one of the 6602 counters,and the set your external signal to be the source of your sample clock.You'll then be able to register a callback with the function DAQmxRegisterSignalEvent, and your callback will be called each time an edge will occur on your specified sample clock source.
Here's 2 links that explain the events in DAQmx and how to handle them in CVI. The example ReadDigChan-ChangeDetectionEvent.pr that ships with DAQmx examples (Hardware Input and Output<<DAQmx<<Digital measurements) can be very useful to understand how to do. This example creates a signal event callback to detect change detection for digital inputs.
Regards.
03-18-2009 10:34 AM
Hi,
Thanks for your answer.
I'm not sure I understand well what you said. Is this code corresponding to it?
DAQmxCreateTask("",&Task1);
DAQmxCreateCICountEdgesChan (Task1,"Dev2/ctr0", "", DAQmx_Val_Rising, 0, DAQmx_Val_CountUp);
DAQmxSetTimingAttribute (Task1, DAQmx_SampClk_Src, "/Dev2/PFI39");
DAQmxCfgChangeDetectionTiming (Task1, "/Dev2/PFI39", "Dev2/port0/line31", DAQmx_Val_ContSamps, 1);
DAQmxRegisterSignalEvent (Task1, DAQmx_Val_ChangeDetectionEvent,0,ChangeDetectionCallback,NULL);
James
03-19-2009 12:11 PM
Hello.
The function DAQmxRegisterSignalEvent allows you to choose on which event you want to run your callback. For you, the event will be Sample Clock and not Change detection Event.
Regards.
03-19-2009 12:31 PM
That's right. If made it earlier without change detection and it works.
thanks for your help.