07-26-2007 08:40 AM
I am trying to measure the frequency out of an encoder at a specific sample rate.
I am using an encoder to measure the rotational speed of a mechanical system. The velocity of this rotating system is not 100% constant it will have some speed variation.
I want to be able to measure the frequency of the encoder at a specific sample rate lets say 100Hz (samples per second). This way I can later run this data through a FFT and see what the frequency the speed variation is. This would be similar to measuring an analog signal with an A-D and setting it’s sample rate.
I am using
I tried using the example – “measure digital freq. buffered cont.” but I can’t seem to control the samples per second.
Thanks
Brian
07-27-2007 11:58 AM
With counter frequency (or period) measurements, the sample timing is "Implicit" because the pulse edges ARE the sampling clock. This is simply how the hardware works so you have to live with it.
When I did apps in the past requiring an FFT on freq data I measured with a counter, I would first derive the corresponding timestamps for the variable freq pulse train, and then I'd perform some type of interpolation to calculate "virtual" frequencies at the times corresponding to my desired constant sampling rate.
Another little tip is to remove your DC offset before performing the FFT. Simply subtracting a median value is often quite effective.
-Kevin P.
05-10-2008 11:25 PM
05-12-2008 09:38 AM
Hi Miaa,
Best that I can tell, Stewy was using a program from the LabVIEW Example Finder. Open LabVIEW and then go to Help >> Find Examples. Browse to Hardware Input and Output >> DAQmx >> Counter Measurements >>Digital Frequency. He was probably using one of the continuous buffered digital frequency measurement examples that can be found in this folder like ‘Meas Dig Frequency-Buffered-Cont-High Freq 2 Ctr.VI.”
Hope this is what you were looking for. A search on NI.com for “measure frequency” or other related terms might turn up additional examples.
05-12-2008 10:33 AM
I don’t remember which example I used. My goal was to measure frequency at a high sample rate with the USB-6210 module. I was able to achieve this. I set the counter up to measure a frequency on an external clock edge. I used the second counter to generate a pulse train output (my sample clock @ 1000hz). I connected the output of this pulse train (counter 1digital I/O connector pin 7) to the frequency counter sample input (counter 0 digital I/0 connector pin 3). I then hooked up the pulse train I wanted to measure in this case an encoder signal to (counter 0 digital I/O connector pin 2). I am able to measure the frequency variations of the encoder at a sample rate of 1000Hz. I can then run this through an FFT and see what the frequency components are of the velocity variations the encoder is seeing when connected to a mechanical rotating device.
I will attach a couple screen shots of my program.
I hope this makes sense.
Stewy
05-12-2008 05:33 PM
Thanks a lot Stewy for sharing that piece of information. Few questions:
1) In the worked examples of LabVIEW they define min and max value. I tried those examples and i am getting the error as attached. I have tried increasing the time out values to 2000 and still the same error , while measuring a ( 2Hz- 3KHz ) Pulse digital signal from a function generator. Kindly, explain if it is necessary to include the min/max values or not.
2) Also, since those examples were giving me error i tried your idea ( attached is the VI in LabVIEW8.5). Do we have to use PFI2 ? Cant we use regular channels like AI0 ? I am not trying to duplicate your VI ,,,instead i am trying different examples to learn the differences and accuracy in them 🙂
3) Sample clock in your VI is primarily controlling the better resolution than the sampling of DAQ board. Am i understanding that correctly ?
My application involves a digital squarewave whose frequency needs to be calculated. The range of this frequency is ( 2Hz- 3KHz ). This frequency from the sensor takes some time ( 3 sec ) to settle to a stable value. Once this is stable it needs to be measured and plotted. I have 4 different inputs whose frequency needs to be measured one by one. After 6 sec the input frequency varies to a different value. And have to repeat the same measuring criteria of frequency and plot them. I am using USB 6210 as my DAQ.
Let me know if my above observation is correct ( from conceptual grounds ) and also what is the mistake i am making in the attached VI.
05-13-2008 06:50 AM
Miaa
Your error is generated because your counter did not see any pulses before the timeout expired.
You want to use one of the counter inputs to measure your square wave signal. I suggest using Ctr/0 not AI0.
Yes, my example is for measuring frequency at a high sample rate. You won’t need to do this for your application.
I made a simple program for you to try (see attached).
Connect your signal to the Digital I/O terminal connector Pin-2 and you signal ground to Pin-5.
From the front panel of the program under “counters” select your device and counter 0. Example = Dev1/Ctr0
I set the timeout to 30 seconds so if the counter doesn’t see any pulses for 30 seconds it will generate an error.
You can find more examples under Help-Find Examples-Hardware Input and Output-Daqmx-Counter measurements-Digital Frequency.
Stewy
05-13-2008 09:15 PM
05-14-2008 07:18 AM
Miaa
I guess I don’t understand your application completely. The 6210 only has 2 counters so you can only measure 2 independent signals at the same time. To do this you would need to duplicate the counter setup vi’s in the program I sent you and pick the appropriate counters in the drop down boxes on the front panel ctr/0, ctr/1 and hook the signals to the proper terminals.
If you need a USB device with more counters you can look here
5 counters
10 counters
They say they will work with labview but I have not tried them.
Stewy
05-15-2008 06:55 AM
Hello Stewy, My application is pretty straight forward electrical circuit. I have a light to frequency sensor which gives a signal with 50% duty cylcle, square wave, TTL, whose min value of frequency to be detected is 5Hz and Max value is 10KHz. The Sensor is doing a good job on detection as i can see the variation when i connect an oscilloscope at the output pin of the sensor. There are 10 identical sensors. And there are 10 physcial activities. EACH sensor detecting its own activity ( and converting the light activity to frequency ).
I want to replace the oscilloscope with Labview. And display the 10 outputs together on ONE graph, if possible. And then use the data for mathematical calculations. The VI you sent me is working when i try to check the out put one by one and using the "low freq with 1 counter option". And thanks a lot for your help but, i am not clear on how were the values of rising and falling were calculated, and how were the counter values likes "low freq with 1 counter = 10105" were calculated ??
I also tried 2 sensors and its working but then again how were the values calculated , and is it possible to display 10 outputs( of sensor) using DAQ6210 ?