Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

count digital events on a Counter with pci-6602 with callback on CVI

Solved!
Go to solution

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 

 

 

 

 

 

 

 

0 Kudos
Message 1 of 5
(4,990 Views)

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.

0 Kudos
Message 2 of 5
(4,953 Views)

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

0 Kudos
Message 3 of 5
(4,913 Views)

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.

0 Kudos
Message 4 of 5
(4,897 Views)
Solution
Accepted by topic author julesjay

That's right. If made it earlier without change detection and it works.

 

 

thanks for your help.

0 Kudos
Message 5 of 5
(4,895 Views)