Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI
29 ratings:
 2.82 out of 5     Rate this Document

Measuring Frequency With the FP-CTR-500/502

Primary Software: Driver Software>>NI-FieldPoint
Primary Software Version: 4.0.1
Primary Software Fixed Version: N/A
Secondary Software: N/A
Hardware: FieldPoint>>Discrete I/O Modules>>FP-CTR-502, FieldPoint>>Discrete I/O Modules>>FP-CTR-500

Problem:
How can I Measure Frequency with the FP-CTR-500/502?

Solution:
There are two methods that can be used to measure frequency with the FP-CTR-500. The first method provides a general overview of the techniques used for frequency measurement. The second provides a shortcut that can be used in LabVIEW & LabWindows/CVI when using a FP-10xx serial controller or when using LabVIEW RealTime when using a FP/cFP-20xx network controller running embedded code. Both methods give the same accuracy because the accuracy is dependent upon the period of the gate or time between count resets. Also, the maximum frequency either method can measure is 50 kHz.

Method 1: Theory


    Considerations for Method 1:
  • Only Method for measuring frequency with a FP-160x or a cFP/FP-20xx used as a FP-160x (i.e. no LabVIEW RT code)
  • Must allow a gate pulse that is long enough that you have time to read the status of the Gate (high or low) then read the count from the counter then send a reset command (Total of 2 Reads and 1 Write + software delay and % uncertainty of network delay). Typically most people set a Gate with a period of `2 seconds. Can be accurate but limits the frequency of updates to the host. You can use the output of the status to determine if your Gate period is long enough to account for this time. If (before the 2 reads and 1 write have completed) the gate signal goes high and the counter starts counting again: the channel status changes to Overflow since last read.


To measure frequency with the CTR-500, use one counter channel to generate a fixed-width positive gating pulse and another to count the number of pulses (of the signal being measured) which occur during that time. Each different pulse width used requires a separate counter channel and output. Since there are four outputs, up to four different gating pulses may be generated simultaneously. Each gating pulse can be used to control as many counter channels as desired, so up to seven signals may be measured using the same gating pulse, or up to four if separate gating pulses are used for each.

Set up the gating pulse

The gating pulse is a one shot pulse which is set up as described in the CTR-500 manual. Pick a counter channel, output channel, and gate channel, and then connect them as described. When this is set up correctly, you will be able to generate a new pulse (and take a new frequency measurement) each time you either (a) send a reset command to the gating pulse counter channel or (b) read the gating pulse counter channel (if you have set the channel to reset on read). Because of the polling mechanism used by Lookout, you should NOT use the reset on read mode with Lookout (or if you are using the FP-1600 network module).

Set up the frequency counter

When generation of the gating pulses is working correctly, you can set up counter channels to use this gating pulse for measuring input signal frequency. Set up each counter channel to use its external count input and the same gate input as the gating pulse counter channel. In this way, the frequency counter will indicate the number of periods of the input signal which occur during the gating pulse.

Performing a measurement

To perform a measurement, start by resetting the gating pulse channel. This will start the gating pulse. Wait until the gating pulse is over (either by polling the state of the output or by inserting a fixed-length wait), and then read the frequency counter channel. Divide this count by the length of the gating pulse (in seconds) to generate a frequency. You can then reset the frequency counter channel or just subtract off its current value from the next measurement.

Method 2: Shortcut


    Considerations for Method 2:
  • Can only be used with a serial interface (FP-1000,1001 or a FP/cFP-20xx running LV RT embedded application). Also, if any other client (i.e. FieldPoint Explorer/MAX,LabVIEW FieldPoint FP Read, or Datasocket Read) is monitoring the counter module then this method is INVALID.
  • Basically this method allows for increased frequency of updates because you don't have to have a period to read and reset the counter. The count is automatically reset every time you read.

The shortcut method takes advantage of the Read Reset Mode and timestamps. By setting a counter to have a Read Reset Mode of Reset On Read, every time that a reading is made, the counter is reset back to 0. This gives the number of counts that occurred in between the current reading and the last one. By subtracting the timestamp of the last read from the current timestamp (easiest to do in LabVIEW & LabWindows/CVI), you have the number of counts that occurred during a specific period of time. You can then divide the count by the elapsed time to get the frequency.

Other Considerations
  • How Fast of a Frequency Can I Measure?
    • The counter module can accurately count edges up to a frequency of 50 kHz. That is to say, if a rising edges occur faster than 20 microseconds apart, then the counter module will miss some edges.

  • How Accurately Can I Measure My Frequency?
    • Using either of the above methods, the accuracy of the frequency measurement is dependent on the length of the gating pulse (Method 1) or the time between each read (Method 2) and is given by accuracy = ± 1/ T, where T is the period of the gating pulse or the time between each read. A one second gating pulse gives ± 1 Hz accuracy, 2 seconds gives ±0.5 Hz, etc. Gating pulse length is a trade-off between accuracy and measurement speed.

  • Special considerations doing high frequency measurements.
    • Because the register on the counter is only 16-bit, when measuring frequencies close to 50kHz, the maximum accuracy you can attain is ±0.762951Hz and then maximum period or time between reads without a rollover of the register is 1.3107s. The latter may be more important when doing method one with FP-16xx because, depending on network traffic, you may not be able to gaurantee that you can read the Gate status, read the count, then reset the count in 1.3 seconds. Or, your application may require greater than ±0.7Hz accuracy. In either case you can overcome these limitations between cascading counters (i.e. using two 16-bit counters as a 32 bit-counter). Learn more from the links below.


Related Links:
Developer ZoneTutorial: Configuring an FP-CTR-500/502 Module Using FieldPoint Explorer
KnowledgeBase 2I0I6I5F:How Can I Create a 32-bit Counter Using the FP-CTR-500/502?
KnowledgeBase 3ARE14GP: How Does the FieldPoint Frequency Measurement Shipping Example Work?
Developer Zone Example: Measure Frequency with LabVIEW and FieldPoint Using FP-CTR-500/502
Developer Zone Example: Creating a 32-bit Counter Using the FP-CTR-500/502
Developer Zone Example: Measuring Low Frequencies with LabVIEW and FieldPoint Using [c]FP-CTR-500/502
Developer Zone Example: Using the FP-CTR-500/502 to Measure Three Different Frequencies in LabVIEW 6.0
Product Reference: FP-CTR-500 and cFP-CTR-500 Operating Instructions
Product Reference: FP-CTR-502 and cFP-CTR-502 Operating Instructions

Attachments:


method2.GIFmethod1.GIF


Report Date: 01/12/2000
Last Updated: 07/20/2007
Document ID: 1TB63SUS

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit