Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx fft measurement

we want to test a usb-6008 with DAQmx driver and measurement studio for calculating fft of signal.
do you have a programming tutorial step by step description?Smiley Sad 
0 Kudos
Message 1 of 6
(5,317 Views)

We don't have any setp by step examples of how to do this, but there are C# and VB.NET examples that show you how to acquire an analog input signal continuously. Then all you need to do is use the Measurements.AmplitudePhaseSpectrum() function to give you the results of the fft of the acquired signal. You will need DAQmx 7.5 to use the USB devices with DAQmx. See the DAQmx examples under ..\MeasurementStudio2003\DotNET\Examples

Bilal Durrani
NI
0 Kudos
Message 2 of 6
(5,304 Views)

Hi

Thanks for quick response.

Unfortunately, i could not find the

NationalInstruments.Analysis.SpectralMeasurements.Measurements.AmplitudePhaseSpectrum

function under Measurement Studio DAQmx examples.

pls check our codes, how can we use that function.

have you got any similar codes?

Private taskRunning As Boolean
Private myTask As Task
Private analogInReader As AnalogMultiChannelReader
Private analogCallback As AsyncCallback
Private data As Double(,)

Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click
     Try
         
taskRunning = True
         
myTask = New Task("aiTask")

         
myTask.AIChannels.CreateVoltageChannel(Dev1/ai0, "Voltage", AITerminalConfiguration.Differential, Convert.ToDouble(-20), Convert.ToDouble(20), AIVoltageUnits.Volts)

       myTask.Timing.ConfigureSampleClock("", Convert.ToDouble(1000), SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples, 256)

       myTask.Control(TaskAction.Verify)

       analogInReader =

New AnalogMultiChannelReader(myTask.Stream)
       analogInReader.SynchronizingObject =
Me
       analogCallback = New AsyncCallback(AddressOf AnalogInCallback)

        analogInReader.BeginReadMultiSample(Convert.ToInt32(numChannel.Text), analogCallback,

Nothing)

Catch exception As DaqException

      MessageBox.Show(exception.Message)
      taskRunning =

False
      myTask.Dispose()
End Try
End Sub

Private Sub AnalogInCallback(ByVal ar As IAsyncResult)
Try
If taskRunning = True Then

data = analogInReader.EndReadMultiSample(ar)

            WaveformGraph1.PlotYMultiple(data)

            analogInReader.BeginReadMultiSample(Convert.ToInt32(Convert.ToDouble(numChannel.Text)), analogCallback, Nothing)

End If
Catch ex As DaqException
MessageBox.Show(ex.Message)
taskRunning = False
myTask.Dispose()
btnStop.Enabled = False
btnStart.Enabled = True
End Try
End Sub

Message Edited by Oguz on 08-15-2005 09:28 AM

Message Edited by Oguz on 08-15-2005 09:31 AM

0 Kudos
Message 3 of 6
(5,305 Views)
Hi Oguz,

I believe that Bilal meant that there were examples for Continuous Analog Input, not specifically for FFTs.

Another point of clarification is that the Measurments.AmplitudePhaseSpectrum Method is only included in the Enterprise Edition of Measurement Studio.

You can find a description of the Measurements.AmplitudePhaseSpectrum Method by navigating to:

Start >> All Programs >> National Instruments >> Measurement Studio 7.1 for VS .NET 2003 >> Measurement Studio Documentation

Then select "Measurement Studio" under the Filter pull down.

Now navigate the help tree to
"NI Measurment Studio Help >> NI Measurement Studio .NET Class Library >> Reference >> National Instruments.Analysis.SpectralMeasurements >> Measurements Class >> Methods >> AmplitudePhaseSpectrum Method"

Here is the help file decription:


Measurements.AmplitudePhaseSpectrum Method

Calculates the single-sided, scaled amplitude spectrum magnitude and amplitude spectrum phase of a real, time-domain signal.

[Visual Basic]
Public Shared Sub AmplitudePhaseSpectrum( _
   ByVal signal As Double(), _
   ByVal unWrap As Boolean, _
   ByVal dt As Double, _
   ByRef amplitudeSpectrum As Double(), _
   ByRef phaseSpectrum As Double(), _
   ByRef df As Double _
)
[C#]
public static void AmplitudePhaseSpectrum(
   double[] signal,
   bool unWrap,
   double dt,
   out double[] amplitudeSpectrum,
   out double[] phaseSpectrum,
   out double df
);
Hope this helps Oguz, have a good one!

Dan Weiland
Applications Engineer
National Instruments

Dan Weiland
0 Kudos
Message 4 of 6
(5,281 Views)

Hi,

Thanks DWeiland,

i am a new starter to measurement studio.

i found function but is there an example showing how to use it?

0 Kudos
Message 5 of 6
(5,276 Views)
Hi Oguz,

There aren't any examples that use that function explicitly, but the example found here:

C:\Program Files\National Instruments\MeasurementStudioVS2003\DotNET\Examples\Analysis\PowerFrequencyEstimator

uses the same Measurements class, so you may be able to get started there.

Here is a slightly more detailed description of the function parameters, as described in the Measurement Studio help file.

Parameters

signal
The input, time-domain signal, usually in volts. At least three cycles of the signal must be contained in the time-domain record for analysis and estimates based on this spectrum to be valid.
unWrap
The input that decides if the phase is unwrapped. If set to true, it enables phase unwrapping on the output phase, phaseSpectrum. If set to false, the method does not unwrap the output phase.
dt
The sample period of the time-domain signal, usually in seconds. dt is also 1/fs where fs is the sampling frequency of the time-domain signal.
amplitudeSpectrum
The single-sided amplitude spectrum magnitude. If the input signal is in volts, this value is in volts rms.
phaseSpectrum
The single-sided amplitude spectrum phase in radians.
df
The line frequency interval of the power spectrum. If dt is in seconds, this value is in hertz.

Dan Weiland
Applications Engineer
National Instruments
Dan Weiland
0 Kudos
Message 6 of 6
(5,267 Views)