Discussion:
configuring a PFI pin as a counter source/gate
(too old to reply)
9845567540
2006-05-09 07:10:20 UTC
Permalink
I have a NI 6229 M series DAQ. I would like to perform a pulse width measurement using the same. There are two counters (ctr0 and ctr1) in the board. I would like to know if i can configure any PFI pin as a patricular counter's source / gate input??...
 
Jesse O
2006-05-09 22:40:08 UTC
Permalink
You should be able to route any PFI to a counter as long as it is not
in use by another task.  You can view the available device routes
in Measurement and Automation Explorer (MAX).  To find your device
routes in MAX, expand Devices and Interfaces >> NI-DAQmx Devices
and select your device then select the Device Routes tab.  I have
attached a picture of my PCI-6251 device routes.

Regards,

Jesse O.
Applications Engineering
National Instruments


pfi.JPG:
Loading Image...
Jennifer O
2007-02-02 16:10:11 UTC
Permalink
Hello Sandia,
First, follow the directions above to make sure the terminals are available for routing.  You can see in the above image, that for the device shown, PFI15 can be directly routed to Ctr0Source. After confirming that your device also supports this routing, you can use the following function to connect terminals in CVI.
You will find the following information in the DAQmx C Reference Help.

int32 DAQmxConnectTerms (const char sourceTerminal[], const char destinationTerminal[], int32 signalModifiers);

Simply specify the terminals you would like to connect for the source and destination.  Options for the signal modifier include:





DAQmx_Val_DoNotInvertPolarity

(Do not invert the signal).

DAQmx_Val_InvertPolarity


(Invert the signal).
Alternatively, you can set terminals with property nodes for the channel you set up.  For example:
int32 __CFUNC DAQmxSetCIFreqTerm(TaskHandle taskHandle, const char channel[], const char *data);
Hope this helps,
Jennifer O.Applications EngineerNational Instruments
Sandia_Mike
2007-02-06 01:10:11 UTC
Permalink
Still don't quite have it correct.  I get a non-fatal run-time error, shown below.  Is the sequence I'm using correct?  Or perhaps I can't re-route the connections when I'm trying to measure frequency?
 
Error message:
Specified route cannot be satisfied, because it requires resources that are currently in use by another route. 
Property: DAQmx_CI_Freq_Term
Property: DAQmx_CI_Freq_StartingEdge
Source Device: DAQBoard
Source Terminal: PFI8
 
Required Resources in use by
Source Device: DAQBoard
Source Terminal: PFI15
Destination Device: DAQBoard
Destination Terminal: Ctr0Source
 
The task creation routine for the frequency measurement is:
   DAQmxCreateTask("DAQClockFrequency", &taskOut);
 
  // Create a route between a source and destination terminal
  DAQmxConnectTerms ("/DAQBoard/PFI15", "/DAQBoard/Ctr0Source",        DAQmx_Val_DoNotInvertPolarity);   DAQmxCreateCIFreqChan(taskOut, "DAQBoard/ctr0",  // PFI8 is default Ctr0 Source  "Frequency", 1000000, 3000000,  DAQmx_Val_Hz, DAQmx_Val_Rising,   DAQmx_Val_HighFreq2Ctr, 0.001,   4, "");  
  DAQmxCfgImplicitTiming(taskOut, DAQmx_Val_FiniteSamps, NUM_SAMPLES);
Jennifer O
2007-02-07 04:10:08 UTC
Permalink
Try setting up your task, then use DAQmxSetCIFreqTerm(taskHandle,"", "DAQBoard/PFI15"); to use PFI15 for the counter source before starting the task.  You may need to reset your board to free up any resources previously reserved.  You can do this by selecting your board in Measurement and Automation Explorer (MAX) and clicking Reset Device. 
 
I set this up with an M-Series board using the DigFreq-Buff-Cont-LargeRange2Ctr.c shipping example found in your National Instruments directory under NI-DAQ/Examples/DAQmx ANSI C/Counter/Measure Digital Frequency.
 
Hope this helps,
 
Jennifer O.
Sandia_Mike
2007-02-07 17:40:11 UTC
Permalink
Just as a final note, this application works now.  The essential code lines are:

DAQmxCreateTask("DAQClockFrequency", &taskOut);

 

DAQmxCreateCIFreqChan(taskOut, "DAQBoard/ctr0", // PFI8 is default Ctr0 Source

   "Frequency", 1000000, 3000000, DAQmx_Val_Hz, DAQmx_Val_Rising,

   DAQmx_Val_HighFreq2Ctr, 0.001, 4, "");

 

// Layout error on circuit board, grounding PFI8. Reroute around error. The alternate function,

// DAQmxConnectTerms ("/DAQBoard/PFI15", "/DAQBoard/Ctr0Source", etc.

// does not seem to work here.

DAQmxSetCIFreqTerm(taskOut,"", "/DAQBoard/PFI15");  // the initial '/' was required

 

DAQmxCfgImplicitTiming(taskOut, DAQmx_Val_FiniteSamps, NUM_SAMPLES);

 

The measurement task is started and samples taken in a separate function call.  The only issue here is that the initial sample is incorrect.  The value of NUM_SAMPLES is 200, so I just set the Sample zero value to equal the Sample one value.

 
 
davygora
2008-06-12 12:10:09 UTC
Permalink
Is there some manual for C# (.NET 2.0)? Because I have the same problem. I want to route the PFI0 channel to the counter gate and I know that it should work with my card (checked it in MAX). Thanks in advance.
RT4CY
2008-06-13 23:10:06 UTC
Permalink
duplicate <a href="http://forums.ni.com/ni/board/message?board.id=250&amp;message.id=40772" target="_blank"> post</a>
Loading...