11-29-2006 03:05 PM
Hello Mtonsager,
It sounds like you are making all the right calls to implement the filter.
To test the filtering, assuming you are counting rising edges, you should be produce a 50% duty cycle signal with a half period of 2.5us or less (or whichever minimum pulse width threshold you use). This would be equivalent to a frequency output of: [1/(2x2.5us)]=0.2Mhz or greater. You can also set the frequency to 0.2MHz and reduce the duty cycle below 0.5 so that the high pulses are less than 2.5us.
If the frequency is lower (i.e. pulses are wider) the edge count task should increment. If the frequency is higher (i.e. pulses are narrower) the edge count task should remain steady. You can use a property node to update the frequency and duty cycle of the counter while the task is running.
Hope this helps,
Jennifer O.
11-30-2006 08:32 AM
Hello,
Thanks for the help again Jennifer!
I think I may have figured it out. What I was doing was enabling the CountEdgesDigitalFilterEnable filter like this:
t.Control(TaskAction.Verify);
t.CIChannels.All.CountEdgesDigitalFilterEnable = true;
t.CIChannels.All.CountEdgesDigitalFilterMinimumPulseWidth = 5.0e-6;
BUT, should have enabled the filter like this instead:
t.Control(TaskAction.Verify);
t.Timing.SampleClockDigitalFilterEnable = true;
t.Timing.SampleClockDigitalFilterMinimumPulseWidth = 5.0e-6;
There are so many filters that I didn't know which one to use. Apparently, I am supposed to enable the " SampleClockDigitalFilterEnable" filter and not the "CountEdgesDigitalFilterEnable " filter because now it seems to be filtering out the pulses correctly.
I guess the next question(s) would be why/where/How would you implement the "CIChannels.All.CountEdgesDigitalFilterEnable" filter?
Thanks everyone for your help!
Mtonsager
11-30-2006
09:55 AM
- last edited on
01-02-2024
02:18 PM
by
migration-bot
Hello Mtonsager,
The call you make will depend on the task you set up. If you set a digital task, then you will want the digital filter. If you set a count edges task you will want to use a count edges filter. Refer to Enabling the Digital Filters for Counter/Timer Devices in NI-DAQmx to see how the call corresponds to the task. You will notice in this KnowledgeBase, that the task being used is the Counter Input Frequency and the filter that is set is the Counter Input Frequency Digital Filter.
If you would like to filter a clock signal as you mention in previous post, this is also a valid option. This will not enable you to test the filter with a count edges task, but will enable you to see the filter working by the fact that you will not receive any new input samples if your pulses are narrower than the guaranteed filter pulse width. This filter would be enabled on your input task, while the count edges filter would be enabled on a count edges task.
Regards,
Jennifer O.
11-30-2006 10:40 AM
I guess not receiving a signal is what I expected to happen. So, maybe what I am thinking is I am either setting up the counter Reader wrong when I implement the CountEdgesDigitalFilterEnable filter or I am looking in the wrong place for the count.
Here is how I am getting my count after I set up my counter input task and it's sample clock:
myCounterReader =
new CounterReader(t.Stream);myCallBack =
new AsyncCallback(CounterReadCallback);myCounterReader.SynchronizingObject =
this;myCounterReader.BeginReadSingleSampleDouble( myCallBack,
null);The next lines are in the CallBack method reading the values:
double data = myCounterReader.EndReadSingleSampleDouble(ar);myCounter = myCounter + data;
this is how I am reading my counts and they always output whatever the set initial count is ( I usually use 1 to increment "myCounter" by 1 each time). So, then when I recieve this pulse/initial count in the callback method I just increment my own counter "myCounter" that I setup in my code.There must be another way to do this using the CountEdgesDigitalFilterEnable filter that will output a larger number than the initial count, right? For example if the counter's initial count was 0 and the counter itself would to the counting and I would just read the number (ie 3 or 4) then the counter's buffer would go back to 0. Am I on the right track?
Thanks,
Mtonsager
12-05-2006 08:48 AM
Hello,
Would anyone know the answer to the previous question above?
Thanks in advance,
Mtonsager
12-05-2006
12:10 PM
- last edited on
01-02-2024
02:18 PM
by
migration-bot
Hi Mtonsager,
Assuming you are using "simple" event counting, the count is returned when the software requests the count. There is no count buffer, only a count register. Let's assume that we are receiving a signal with 10 rising edges. The count register will increment with each rising edge: 0, 1, 2, 3...10. The read of the count will return the current count in the register (not the change in count). The software might read 0,0,0,1,1,2,2,2,2...10. Therefore your application would read the count directly and there would be no need to add the current count to the previous count.
If you set the filter such that your pulses are narrower than the minimum pluse width, none of the counts would register and the values would be read back as initial count (i.e. 0,0,0,0...)
If you perform "buffered" event counting, then the value from the count register is latched into the read buffer every time there is an edge at the counter's gate. If the count does not change between two active edges of the gate signal, the count in the register will remain the same. Depending on the hardware you use the value may or may not be latched into the buffer. The counter/timer boards and M-Series devices will not latch the count again, while the E-Series devices will relatch the count.
The count does not return to zero. The only time the count is set is during the initial setup. If you need to reset the count you can subtract out a particular value in software.
Hope this helps,
Jennifer O.