From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

FieldPoint Family

cancel
Showing results for 
Search instead for 
Did you mean: 

Low-Frequency measurements using counter/timer

I am trying to measure speed, and am using the FP-502 counter timer module to count the pulses from my sensor. The field point example that uses a fixed width gate pulse will not work for my appliation because I need a gate pulse so big that it updates way to slow.

Does anybody have any sugestions on how to measure a low frequency signal using a counter/timer?

Thanks

Dan

Dan Shangraw, P.E.


   

0 Kudos
Message 1 of 10
(5,285 Views)
Hi Dan,

About two weeks ago I had some trouble gettings started with a similar task. I posted an question and an answer to myself that includes the code I used to get thing working.

Please see my question titled,

"Using the FP-CTR-502 to count pulses from FP-PG-522 gives me eratic counts when I use two of the NI examples!"

The answer includes the LV code (quick hacks of NI examples) and the IAK file that was used.

This should get you started.

I don't rember how slow the example would go but I seem to remember sub-HZ measurements.

It was in hopes of helping others that I posted these files.

Hopefully it is what you need.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 10
(5,283 Views)
Ben,

Thanks for your response but your example looks like what I tried. I am trying to determine the frequency at the low end a 22 Hz signal and at the high end a 122 Hz signal. I need an update rate of .01 seconds.

My problem is that I can't get the accuracy I need to measure the low frequency signal at the fast update rate.

Dan

Dan Shangraw, P.E.


   

0 Kudos
Message 3 of 10
(5,281 Views)
Dan,
This is an alternative method of measuring frequency. It won't give you a fixed update rate, but you will have be able to have a faster update rate than the LabVIEW example without lossing a lot of resoltion.
Instead of measuring how many pulses come during a fixed period, we measure how long it takes a fixed number of pulses to pass. Many of the same principals from the LabVIEW example will apply. Configure a counter to have the internal time base (1kHz or 32 kHz) as its timebase. The gate is the output from a second counter (gate counter). The source of the gate counter is your signal. It's terminal count is set to the number of pulses you want in each measurement. It's output is set to toggle.
If you are measuring a 40 Hz signal us
ing the 1kHz timebase and have set the terminal count to 4. You would then expect to return a count of 100. This would then correspond to 100/4 = 25 counts per period or 25 ms per period or 40 Hz.
The measurement period will vary depending on the signal. With a slower signal (lower frequency) it will take longer for the gate counter to reach it's terminal count, than with a higher frequency signal.
Message 4 of 10
(5,281 Views)
Good info Carl! Thank you.

Dan,

Do I understand you correctly in that you want to read an updated value 100 times a second?

If so, I would urge you go with Carl's suggestion and crank up the timebase and see if that get's you where you want to go. You may end up running into a road-block when you approach an update rate that is 1/2 the freq. you are measuring (I don't think this is Nyquist but it is odd that it kicks in at the same point). This aslo assumes a 50% duty cycle pulse.

Please keep us posted if you come up with an example that works for you.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 5 of 10
(5,283 Views)
After sleeping on it, I would like to retract my 1/2 comment.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 6 of 10
(5,281 Views)
Hello guys

Thanks for all your sugestions I have the final results. I got it to work but I would like to add some comments for anybody who is trying to attempt this.

Triggeing on the gate is a must for low frequency measurements. I used the divide by sugestion however using a factor of 3 only gets you about 60 Hz after that you can't sample fast enough. My application required me to measure from 0 to 150 Hz. I added a "gear shifter" routine where the terminal count was set to 3 on frequencies lower then 45 Hz and 15 for frequiencies greater than 45 Hz. Using a terminal count of 15 for all measurements made the udate rate on really low frequencies way to slow i.e. .5 seconds for 20Hz (check the math on this).

I a
lso needed to cascade the counters. At low frequencies the count went higher than 6550. Using the previos channel function of the fieldpoint module enable me to get 32 bit worth of terminal count data.

Finally I needed to add a timeout condition for 0 Hz. If there are no pulses coming from the senser the program displays the last value read. That won't be 0. So I added a time out routine that if I didn't see a pule in a certian amout of time, output 0 and reset the gate count.

Thank you for you help you relly saved me. I hope my comments made sense.

Dan

Dan Shangraw, P.E.


   

0 Kudos
Message 7 of 10
(5,283 Views)
I am trying to do the same type of application and was wondering if I could see that code that you wrote to accomplish this!  It would help me tremendously!
0 Kudos
Message 8 of 10
(4,954 Views)
Hi Dan,

Your comments were very usefull to me. In fact I understand all the theory about counters and their particular conditions to use them in low frequency analisys.

In fact I am realy in a very beginner state of LV programming and I realy dont undertand a lot of concepts yet.

I just wonder if you can  post your code or part of it here in the forum... I am trying to develop an aplication to read frequencies from  0 to 30Hz and all the examples I found in developer zone are not good for my case.

Please, help me...

Regards,

Marcio Vitor
0 Kudos
Message 9 of 10
(4,356 Views)

Hello Marcio,

I noticed another post by tcrower that was answered by another AE.  They posted the code at the other posting and helped him through some other problems as well.  I hope this helps you.

Steven T.

http://forums.ni.com/ni/board/message?board.id=110&message.id=3619&requireLogin=False

Message 10 of 10
(4,334 Views)