Measure Frequency C#
Hi,
There was a question posted earlier asking about measuring frequency using C# and a multifunction DAQ that got my interested in th e topic.
I found this example using a counter but it throws an error at startup.
https://decibel.ni.com/content/docs/DOC-16563
There are 2 tasks, an AITask and a counter task.
The error occurs when trying to setup the input frequency terminal.
counterTask = new Task();
counterTask.CIChannels.CreateFrequencyChannel(counterComboBox.Text, "",
Convert.ToDouble(minValueTextBox.Text),
Convert.ToDouble(maxValueTextBox.Text), edge,
CIFrequencyMeasurementMethod.LargeRangeTwoCounter, 0.001,
(long)divisorNumericUpDown.Value, CIFrequencyUnits.Hertz);
counterTask.Timing.ConfigureImplicit(SampleQuantityMode.ContinuousSamples, 1000);
// Setup the Counter Input Frequency Terminal to be the Start Trigger from the AI Task
counterTask.CIChannels.All.FrequencyTerminal = aiTask.Triggers.StartTrigger.Terminal.ToString() ;
Here's the Error
Error 1 'NationalInstruments.DAQmx.StartTrigger' does not contain a definition for 'Terminal' and no extension method 'Terminal' accepting a first argument of type 'NationalInstruments.DAQmx.StartTrigger' could be found (are you missing a using directive or an assembly reference?)
I'm using Visual Studio 2008, Measurement Studio 2008 Ver 8.5, DAQmx 9.5.5 and NET 3.5.
Am I missing something?
Thanks
Curt
Hi Curt
Do you have the proper references included in your project? I am able to run this code as it is with no errors. You should see NationalInstruments.DAQmx under the references of your project.
This reference is in this path.
C:\Program Files (x86)\National Instruments\MeasurementStudioVS2010\DotNET\Assemblies\Current\NationalInstruments.DAQmx.dll
regards
Chris S.
Attachments:
Screenshot_1.jpg 26 KB
Similar Messages
-
How to Measure Frequency to RPM NI-DAQmx Tasks
Hello,
I am trying to measure frequency using NI DAQmx task and then convert this to an RPM if at all possible.
I have the following hardware options at my disposal.
I have SCXI 1126 Module along with a SCXI 1327 terminal, as well as a PXI 6289 Multifunction DAQ.
I have wired in a mag sensor to ai7 on my 1126 and when I pass a metallic object I get a amplitude of 6 - 8 so I am able to read the mag sensor.
What I am trying to do is to somehow convert this analog measurement into a RPM while only utilizing the NI DAQmx task.
Any help would be appreciated.
Tim
Solved!
Go to Solution.
Attachments:
Freq Set Up.jpg 2993 KBSo I would select new in "Custom Scaling"
Then would I select linear?
Your calculations are simple but I am unsure if this would give me the desired result. From my attachment I am seeing an input amplitude of 6 Hz for each pulse. What I mean by this is that every time I bring a ferrous object near my mag pick up I get a pulse, this is what I was trying to illustrate in the attachment. The analog pulse comes in a 6 Hz so I would simply multiple this pulse by 60 (assuming I get one pulse per rotation) to get RPM?
How would this make sense if I only input one pulse for a long duration of time?
I have notice the amplitude of the pulse input increases with increased pulse frequency. Does this mean the lowest RPM I can record is 360 RPM?
Tim -
How do you measure frequency using the onboard counter on PCMCIA 6024-E
I am using LABView 6.1 and NI-DAQ 7.2 with a SCXI-1000 chassis and a PCMCIA 6024-E on a laptop. I need to measure a frequency of about 3KHz and would like to do that using an 1180 direct through connector.
Firstly, should I see this 1180 in MAX like any other module?
And secondly, how do I use this 6024-E card to measure frequency? Which pins are supposed to be used on it to measure, and will I see the counter run in the test window in MAX according to the frequency measured?
I know NI also have a frequency module for the SCXI chassis. So lastly, will it be better to use that, rather than measure directly off the 6024-E?
Any help, advise or comments will be greatly appreciated!
Thanks!Hello,
I think I can help out with some of your questions. First, the 1180 module won�t show up in MAX since it is really just a feedthrough cable which allows you access to your unused signals from the DAQ card.
You definitely can measure frequency using your 6024E. An example installs with NI-DAQ 7.2 which shows how to accomplish this. To access this example go to the LabVIEW start up screen and hit the Find Example button. When the Example Finder opens up browse to the following location: Hardware Input and Output -> DAQ -> Counters -> DAQ-STC -> Measure Frequency (DAQ-STC).vi
This example measures frequency and has a connection diagram on the front panel. The documentation for the example can be accessed by going to File -> VI properties -> Document
ation, after you have opened the VI.
You are correct that we offer a frequency input module for SCXI (SCXI-1126). This module would be useful if your input voltages are non-TTL, or if you need to measure more than one channel of frequency signals. This module has an input range of +/- 250Vrms and 8 input channels.
I hope this helps! Let me know if there is anything I can help with or clarify.
Ken S.
Applications Engineering
National Instruments -
Hello,
I am trying to measure frequency using NI 9402 in NI cDAQ9178 chassis. I am setting the clock for my counter channel to be my chassis ai Sample Clock.
I am able to measure frequency above 20 Hz. For frequencies less than 20Hz, I get the following error:
DAQmx Error: Multiple Sample Clock pulses were detected within one period of the input signal. Use a Sample Clock rate that is slower than the input signal. Ifyou are using an external Sample Clock, ensure that clock signal is within the jitter and voltage level specifications and without glitches.Task Name: _unnamedTask<0>
Status Code: -201314
Setting the Rate to 1 also not does resolve the issue.
OTHER DETAILS:
* Running on 64 bit, Win7 platform.
* NIDAQmx Driver Version: 14.5
I had posted regarding this earlier and I was told that this might be because the counter is armed immediately before the first sample is taken. The recommendation was to add a hardware-timed delay using the DAQmxSetStartTrigDelay method to the AI task. I have added this delay but I still receive the same error message. The previous post I had mentioned can be found below:
http://forums.ni.com/t5/Multifunction-DAQ/Cannot-measure-frequency-below-20-Hz-on-a-NIDAQ-9178-chassis/td-p/1537274
I have also attached my current code which has the delay. Is this a bug in the driver? If yes, can we have a CAR# to track this?
Thanks.
Regards,
Varun Hariharan
The MathWorksAlright so I got everything working correctly in both C and LabVIEW code.
The problems is in fact with the first sample, as John_P1 suggested. You simply need to delay that first sample from being requested. It is simple to do this in software instead of hardware.
If you are using CVI, just add #include <utility.h> to the top of your .c file and then add a delay before your DAQmxErrChk (DAQmxStartTask(AItaskHandle)); line.
Comment out / remove the DAQmxSetStartTrigDelay(AItaskHandle,10); line, as it wasn't doing what we thought it would. (Hardware delay).
I added Delay (.05); to delay long enough for the full period of the input signal at 20 Hz.
Depending on your frequency, this value may need to be adjusted. 100ms wouldn't be a bad idea.
This is expected behavior, and I don't think we need a CAR.
Let me know what you think!
-CB -
How to Measure frequency of less than 300 Hz
Is it possible to measure frequency without a counter module? All I have is a cDAQ with 9205, 9221 and 9263 modules.
Hello,
I am assuming that you want to measure analog frequency, since you have analog input and output hardware. There is a useful LabView Help file titled Measuring Analog Frequency. You will be able to measure analog frequency using just software and no counters. However, this involves using Fast Fourier Transform (FFT) functions that are only available in LabView Full and Professional versions. Please also take a look at the examples in the Example Finder. Some helpful ones are titled … Signal Generation and Processing.vi, Spectrum Measurements.vi, and Simple Spectrum Analyzer (sim).vi. These example’s block diagrams are a little busy, however you can see how they are using simulated signals with the FFT Power Spectrum.vi. Note that the example titled Spectrum Measurements.vi uses express functions. These functions are going to involve less programming, but offer lower program efficiency.
Samantha
National Instruments
Applications Engineer -
Measure Frequency of Digital Signal from DAQ-Board
I'm using a National Instruments DAQ board and I need to measure the
frequency of a digital signal from my data acquisition board.
I know the measure frequency.vi (In diagram - data acquisition -
counter), but i don´t understand yours implementation mainly in input
"counter". Because i don't understand the relationship of board channel (for
signal acquiring ) and the measure frequency.vi.
Thanks in advance,
[email protected]Hi,
Attached is a vi which models your signal, and provides a way to measure the average frequency over a window of time. It converts the signal to a sequence of periods. I usually start with this approach because you can save the data in a much more compact form if your sampling rate is high. Obviously over a specified period of time, if there are no zero crossings the frequency is zero, so I was a little incoherent before. The real issue is the latency caused by averaging. Your frequency measurement is most accurate half your window size before the current time, so smaller windows give you more up to date measurements, but also more noisy. If you need the most up to date measurement, then you have to use the time since the last crossing which is the case where the frequency never goes to zero. That's probably not a realistic situation. If you needed less latency, you could use a prediction algorithm.
Also, there are a number of signal measuring and processing vi's that LV gives you, for instance pulse measurements that could be used to partially implement this or other approaches, but I normally steer clear of them unless they fit exactly due to having to convert back and forth to the waveform data type.
Have fun!
Attachments:
DigRandFreq.png 62 KB
DigitalRandomFreq.vi 34 KB -
Can I measure frequency with a SCXI-1120 module and SCXI-1320 terminal block?
I am attempting to measure a square wave from a directional encoder to display RPM of a dynamometer. The waveform will have a frequency of 0-4KHz, with 3.6KHz being nominal, at about 5volts RMS. How can I measure the frequency of this waveform with the hardware I am currently using? In addition to what is listed above, I am using a PCI6034E GPIB card and LabView software.
In order to measure frequency, I would not recommend to use the SCXI-1120, but the SCXI 1126, which is a programmable isolated F-to-V module.
If by any reason you do not want to use SCXI-1126, then I would suggest to use the counter/timers of your board. The counter/timers are TTL compatible, and are the devices that we mostly recommend for doing precise frequency measurements.
In order to have access to the counter/timers of your board through your SCXI chassis, you will need SCXI-1180, which is basically a feedtrhough panel for your DAQ board.
Once we have access to the counter/timers through the SCXI chassis, we can proceed with the coding.
I found a pretty good webpage that clearly explains how to perform frequency measurement with the DAQ-S
TC counter/timers (DAQ-STC is the type of counter/timer chip that you DAQ device has). Here is the link to it:
Pulse Width & Frequency Measurements
As you will see, this link contains tutorials, application notes and example programs. I would recommend to pay special attention to the example program called: DAQ-STC: Measuring frequency.
Good luck with your application! -
How do i measure frequency?
lets say theres this signal in volts. if you plot the signal it forms a sine graph. is there any way to use labview to determine the frequency of the signal? i've tried to use the "measure frequency vi" but my device is connected to a virtual channel, and i dont think that VI supports that...
Hi Polly,
There are several ways to measure frequency in LabVIEW. You can measure the frequency of a pulse train using DAQ hardware (counters). You can also just take a buffer of data and simply use LabVIEW functions to read the frequency of the buffer. An example function would be Extract Single Tone Information.vi. There are many other functions as well. Hope that helps.
Ron -
Pins at a PCI MIO-16E-1 to Measure Frequency(DAQ-STC).vi?
I want to measure frequency with the
"Measure Frequency(DAQ-STC).vi".
Can't find the appropriate connector pins
in the manual of my PCI MIO-16E-1.
Can someone confirm or correct me?
Signal - PFI1/GPCTR1_SOURCE
SignalGND - PFI9/GPCTR0_GATE
PFI8/GPCTR0_SOURCE - PFI4/GPCTR1_GATE
Thanks in advance
ManfredManfred,
You can find this information by going to the http://www.ni.com/manuals site and viewing the E-series manual. There is a table which shows the pin number, name, and function for each pin.
Pin 10 - PFI1/Trig2
Pin 11 - PFI0/Trig1
Pin 43 - PFI2/Convert
Pin 42 - PFI3/GPCTR1_Source
Pin 41 - PFI4/GPCTR1_Gate
Pin 40 - GPCTR1_out
Pin 6 - PFI5/Update
Pin 5 - PFI6/WFTRIG
Pin 3 - PFI9/GPCTR0_Gate
Pin 2 - GPCTR0_Out
Pin 4,39,35,36 - DGND
Mark -
Counter 1 - Measure Frequency & Counter 0 - Generate PWM POSSIBLE?
Is this POSSIBLE with a NI-6025E DAQ card? Can I use the two counters to generate % control a TTL PWM signal and at the same time measure frequency from a circuit? This is my connection.
GPCTR1_SOURCE - connected to find frequency circuit
GPCTR1_OUT - connected to GPCTR0_GATE
GPCTR1-GATE - not in use
GPCTR0_SOURCE - not in use
GPCTR0_OUT - connected to DC motor circuit
GPCTR0-GATE - connected to GPCTR1_OUT
My concern is that changing or controlling the TTL PWM might change the frequency reading. This is because COUNTER O is connected to COUNTER 1.I understand to measure frequency of a signal there are TWO methods. A ONE counter method and a TWO counter method. I need to measure a frequency between 1 Hz to 200 Hz. Is the ONE counter method possible? What is the ONE counter method?
-
How to measure frequencies of two sources simultaneously using 6602?
I am using pci-6602 & LabView to measure frequencies of two sources. I wired Measure Frequency (NI-TIO).vi to do it, but it seems the counter only works at one channel at a time. Can anybody send me an example vi?
Many thanks in advance
ZYuanHi ZYuan,
To measure the frequencies simultaneously, you would need to duplicate the code for the single counter example twice and link the error cluster from one set to the next. I don't have a specific example but the following example can be used as a guide.
Simultaneous Buffered-Event Counting on All Eight Counters of the 6602 or 6608 Devices
http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=B45EACE3DC9F56A4E034080020E74861&p_node=DZ52325&p_source=External
Hope that helps. Have a good day.
Ron -
Measure frequency by singalExpress V2.0
I am trying to use 6602 to measure frequency ( 2 Counters mode), but i get an error
"Sample period too Short" even i increase the Measurement Time....
Attached the Screen Capture, could anyone help me?
Attachments:
freq_measure.JPG 232 KBDear all, i try to set using 2 counter to measure single point frequency...but why the program SE warm me that the " Sample period too short" , How can i solve this problems??
Attachments:
freq_measure.JPG 232 KB -
How to measure frequency with PCI-4474 card
Hi,
I'm trying to measure frequency with PCI-4474 card.
Any sample code available?
Thanks.Hi,
Thank you for posting the the NI forums. There aren’t any example programs that ship with the DSA drivers. Will you be using this with the Sound and Vibration Toolkit? If so, there are numerous examples that install with this software package. Check out the LabVIEW Example Finder >> Toolkits and Modules >> Sound and Vibration Toolkit.
In addition to this, you could also use the signal processing VIs that ship with LabVIEW. There are also examples that ship with LabVIEW that use these VI in Example Finder >> Analyzing and Processing Signals FFT and Frequency Analysis. There is an entire Signal Processing palette that should contain the functionality that you need.
I hope this helps. Post back if you have further questions.
Ed W.
Applications Engineer
National Instruments -
Error out problems with measuring frequency VI
I am having some error out problems with measure frequency VI. The instructions is change error out from indicator to control but does not work. Anyone can help? The VI is attached
Attachments:
Measure Frequency VI error.vi 27 KBThis VI does not have an error out. Obviously, you replaced a subVI that did have an error out with this one, otherwise you would not have been able to create this wire.
Simply remove the wire or save the subVI with another name then modify it to have the error out that you are looking for.
Hope that this helps,
Bob
Bob Young - Test Engineer - Lapsed Certified LabVIEW Developer
DISTek Integration, Inc. - NI Alliance Member
mailto:[email protected] -
Measuring frequencies present in an analog signal
Hello,
I want to measure the frequencies present in an incoming analog pulse signal.
I tried it as shown in the vi using ‘Extract single tone information.vi’ which was showing the value as ‘39m’ I dont understand what is this value. Can someone explain the right way of measuring the frequencies present in the signal so that I can feed them to my bandpass filter limits.
Thanks.
Solved!
Go to Solution.
Attachments:
Measure_Frequency.vi 102 KBHello,
The acquired analog signal is pretty much filtered as shown in the attached image.
Now I am collecting data for 5 seconds (collecting 2500 samples using collector.vi ) and finding the single tone frequency from it and plotting the measured frequency after 5secs in a waveform chart.
But I am confused with these1)The original detected signal has an amplitude of above 1.6V but the measured amplitude only shows 0.6V and 2) how the waveform chart has a plot plotted over the duration of 5seconds when the frequency is measured for every 5seconds data I mean shouldn’t the chart has a plotted value of HeartRate plotted for every 5 seconds.
Can someone explain a bit about these.
Thanks.
Attachments:
Freq.JPG 74 KB
Frequencyplot.vi 94 KB
Maybe you are looking for
-
How can I upload my photos to a memory stick from my iPad
-
Test Scripts for financials modules
Hi, I am looking for detailed test scripts covering all test scenarios for system testing in financials modules. I am interested in Purchasing, Payables, Cash Management, Projects and Fixed Assets. I also need for Receivables and Order Management. Do
-
HI everybody, In my project i have to set some thing in JTextpane. What my problem is User enter the characters in textpane after press the enter button the contents of the textpane is paste in another textpane and first textpane will be clear . In t
-
The security-role-assignment references an invalid security-role: Certifica
In Oracle Enterprise Pack for Eclipse, I failed to deploy an application in debug mode. The error I noticed in my domain log is: weblogic.management.DeploymentException: [HTTP:101168]The security-role-assignment references an invalid security-role: C
-
JDBC extensions and oracle execution
We've been using the format for date comparisons in JDBC of SELECT COUNT(*) FROM WELL WHERE PI_COMP_DATE <= {d '1910-12-31'} ) )) A question about this is what does the driver do to the "d" operator? Is the string converted into an optimal date type