05-04-2010 09:06 AM
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!
05-05-2010 03:58 AM
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
05-10-2010 01:06 PM
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.
05-10-2010 01:15 PM
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