Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmxRegisterSignalEvent for Counter Output Event

Hello!

 

I am using the following code for counting digital impulses:

 

 DAQmxClearTask(DICounterTaskHandle0); 

DAQmxCreateTask("", out DICounterTaskHandle0);

DAQmxCreateCICountEdgesChan(DICounterTaskHandle0, "Dev1/ctr0", "COUNTER0", DAQmx_Val_Rising, 0, DAQmx_Val_CountUp);

DAQmxStartTask(DICounterTaskHandle0);

 

Its working fine, but I have to receive an event when the counter reaches a given value. So I put

DAQmxRegisterSignalEvent(DICounterTaskHandle0, DAQmx_Val_CounterOutputEvent, 0, CounterOutputCallBackFunction, (IntPtr)null);

after the CreateCI... function. Then the error comes at the StartTask with the code: -200800.

 

Thx for any help!

0 Kudos
Message 1 of 4
(3,671 Views)

Hi TarPista,

 

the error you have got in this situation is probably:

 

"Event source signal specified is not supported with the Measurement Type and/or Sample Timing Type of the task."

 

The reason is, that you tried to register counter output event for counter input action and this is not supported.

You can only register for counter output events on a counter output task.

  

Regards,

 

Jiri Keprt

 

NI EE Czech Republic 

CLA, CTA

0 Kudos
Message 2 of 4
(3,648 Views)

For what you are wanting to do, probably the best thing to do is to create a counter output task with the source signal being what you want to measure.  Then, you can use this event to get notified when the count has reached a particular value.

 

As a sidenote, it looks like you're maybe trying to use the DAQmx C API from a .Net language?  If that's the case, note that we do have a DAQmx .Net API.

Thanks,

Andy McRorie
NI R&D
0 Kudos
Message 3 of 4
(3,602 Views)

Hi TarPista,

 

I'm not sure if you've gotten your application working correctly or not, but figured I'd give a little advice.  To get a DAQmx event based on the number of events on a signal, the easiest way to do this is actually to configure a pulse generation task.  Use the signal you want to count edges on as the source of the counter.  Configure both pulse high time and pulse low time to be the number of events you want to trigger your DAQmx event.  You can then use DAQmxRegisterSignalEvent to use DAQmx_Val_CounterOutputEvent.  This is a little backwards from what one would expect (doing counter output to receive event notification for edges on a signal), but will definitely allow you to get notification after a given number of events arrives.  

 

I hope this helps,

Dan

0 Kudos
Message 4 of 4
(3,601 Views)