Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Assigning PFI lines to counter

Again, "The second parameter is the channel name parameter that was used with the DAQmx Create Channel function.  If you left it blank, i.e. "", you can leave the second parameter blank."

You did indeed leave the channel name parameter blank in the DAQmx Create Channel function:

DAQmxCreateCIFreqChan (freqTask, "Dev1/ctr0", "", 2.0, 600000.0,
          DAQmx_Val_Hz, DAQmx_Val_Rising,
          DAQmx_Val_LowFreq1Ctr, 5, 4, "");

So your function needs to look like this:

DAQmxSetCIFreqTerm(freqTask, "", "/Dev1/PFI8");

 

 

0 Kudos
Message 21 of 27
(2,816 Views)
Can you explain that one more time?  Here's what I want to do:
1. Use the one counter method to measure frequency (I expect about 15kHz freq).
2. Connect my input to PFI15.

I plan to use the following call to create the counter task:

DAQmxCreateCIFreqChan (freqTask, "Dev1/ctr0", "", 2000.0, 20000.0,
          DAQmx_Val_Hz, DAQmx_Val_Rising,
          DAQmx_Val_LowFreq1Ctr, 5, 4, "");

So how do I write the call to connect ctr0 gate input to PFI15?  Does DAQmxSetCIFreqTerm() automatically use 4 inputs, so that I need to specify the first of 4 sequential inputs (i.e. PFI12) and the inputs are automatically assigned as src, gate, aux, and out?  Or what?



Thanks,

Bryan

0 Kudos
Message 22 of 27
(2,679 Views)
Two more questions...

1. In the function call:
DAQmxCreateCIFreqChan (freqTask, "Dev1/ctr0", "", 2000.0, 20000.0,
          DAQmx_Val_Hz, DAQmx_Val_Rising,
          DAQmx_Val_LowFreq1Ctr, 5, 4, "");
What is the value 5?  According to the help, it is:
measTime float64 The length of time to measure the frequency or period of a digital signal, when measMethod is DAQmx_Val_HighFreq2Ctr. Measurement accuracy increases with increased measurement time and with increased signal frequency.
But what are the units?  If I specify 5, is that 5 mSec?  Is it 5 Hz (since I used DAQmx_Val_Hz), or 1/5 of a sec (200 mSec)?  Or is the help saying that since I'm not using DAQmx_Val_HighFreq2Ctr, this parameter is ignored, in which case, what is the measurement period?  Does it then just measure from the DAQmxStartTask() until the time when the DAQmxCreateCIFreqChan() function is called?  My goal is to measure it once over a 100 mSec interval and again later over a 300 mSec interval (I realize I may have to create two different tasks to accomplish that.)

2. How about the parameter "4", which is divisor?  Since I expect to measure about 15kHz, what should I set for this parameter?  I'd like to be accurate to plus/minus 5 Hz (although better would be nice).

Thanks,
Bryan
0 Kudos
Message 23 of 27
(2,674 Views)
Does anyone have a guide for C# (.NET 2.0) for the same problem? I wish to assign the PFI0 channel to the counter gate, but I can't find any C# related information on this. Thanks in advance.
0 Kudos
Message 24 of 27
(2,451 Views)
Hi brubingh!  It sounds like you know more about the counters on NI products' than you do the DAQmx API, which is cool!

To answer some of your questions:
So how do I write the call to connect ctr0 gate input to PFI15?
That is what DAQmxSetCIFreqTerm does, yes.  What you pass in as the string is what is connected to the gate of the counter.  The source is whatever you set your timebase as (it should default to the 80MHzTimebase usually).  However, if you want to be explicit or use an external timebase then you could use DAQmxSetCICtrTimebaseSrc (and use DAQmxGetCICtrTimebaseSrc to see what it is using by default).  The aux and out aren't used for this operation.

1. In the function call:
DAQmxCreateCIFreqChan (freqTask, "Dev1/ctr0", "", 2000.0, 20000.0,
          DAQmx_Val_Hz, DAQmx_Val_Rising,
          DAQmx_Val_LowFreq1Ctr, 5, 4, "");
What is the value 5?  According to the help, it is:
You are correct, the value 5 is only used when doing DAQmx_Val_HighFreq2Ctr measurement method.  Otherwise it is ignored.  Similary for divisor.  Since you're using DAQmx_Val_LowFreq, the measurement can be thought of as Implicit.  The signal is routed to the gate of the counter and causes the value of the counter (which is counting the source, or timebase) to be latched so that your application can read it.  From that data we know that one period of your signal was X number of ticks of known timebase rate, and we can calculate the frequency.

Here is a good KB about counter measurements that I found (you can scroll down to the "How to Make a Frequency Measurement" section, probably): http://zone.ni.com/devzone/cda/tut/p/id/7111.
------
Zach Hindes
NI R&D
0 Kudos
Message 25 of 27
(2,421 Views)

hi ,guys,u just have to do like this ,i tried it and it was ok,1.DAQmxCreateCIFreqChan(taskHandle,"Dev1/ctr0","……)

2.DAQmxSetCIFreqTerm(taskHandle,"Dev1/ctr0","/Dev1/PFI12")

OKay, that is all, wish u good luck

0 Kudos
Message 26 of 27
(1,977 Views)
sorry,change PFI 12 TO PFI 15
0 Kudos
Message 27 of 27
(1,976 Views)