Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I store recorded Data in an array? (C#)

Solved!
Go to solution
Hello everybody, I´m a freshman in programming, so it's probably an easy answer for you guys. I'm using Microsoft Visual Studio 2005 and C# together with the Measurement Studio 2008. My Hardware: NI 6036E I would like to have an analog output and the opportunity to measure a signal simultaneously. I used the wizard and it works pretty fine. I was also able to add some code in order to get my desired signal type. Now my problem: I am also able to record a signal via the wizard, but I just see it on the waveformgraph. I would like to store this signal in an array in order to conduct an FFT. How can a store this signal? Thanks for your help! I appreciate it! Heiko
0 Kudos
Message 1 of 6
(5,145 Views)

Heiko,

 

You can create an array of type AnalogWaveform<double>[]. You can then save the acquired data to this value.

 

-Adri

 

Adri Kruger
National Instruments
LabVIEW Product Marketing
0 Kudos
Message 2 of 6
(5,139 Views)

Thanks for the hint! It seems to work. But now I have trouble with the FFT. I’m using the following code:

 

AnalogWaveform<double>[] wf=e.GetData();

waveformGraphInputSignal.PlotWaveforms(wf);

ComplexDouble[] fftOutput= NationalInstruments.Analysis.Dsp.Transforms.RealFft(wf); 

 

When I do it like this, I'll get the following error message: “Cannot convert from ‘NationalInstruments.AnalogWaveform<double>[] to ‘double[]’” I understand the error message but how can I solve the problem? Thanks again!

 

 
0 Kudos
Message 3 of 6
(5,123 Views)
Solution
Accepted by topic author okeih

I found it out myself:-)

 

AnalogWaveform<double>[] wf=e.GetData(); 

waveformGraphInputSignal.PlotWaveforms(wf);

double[] recordedData = wf[0].GetRawData();

ComplexDouble[] fftOutput = NationalInstruments.Analysis.Dsp.Transforms.RealFft(recordedData); 

double[] magoutput = new double[fftOutput.Length];

 

for (int i = 0; i < fftOutput.Length; i++)

{

magoutput[i] = fftOutput[i].Magnitude;

 

}

waveformGraph2.Plots[0].PlotY(magoutput, 100, 1);

0 Kudos
Message 4 of 6
(5,118 Views)

Hi again,

 

as I mentioned before, I was able to conduct the FFT with   Analysis.Dsp.Transforms.RealFft”. But actually I would like to have the result onesided.

 

So I tried to use “SpectralMeasurements.Measurements.AmplitudePhaseSpectrum”. But I have trouble with the parameters.

 

I found a descriprtion for the parameters, but that doesn’t help much. Do you have any example how to use the method? 

 

Thanks Heiko

0 Kudos
Message 5 of 6
(5,103 Views)

Heiko,

 

There is example code that is documented in the Measurement Studio Help for the Measurements.ApmlitudePhaseSpectrum Method. A trick for pulling up the help for a particular method is to place your cursor in the method name and hit F1.

 

-Adri

 

Adri Kruger
National Instruments
LabVIEW Product Marketing
0 Kudos
Message 6 of 6
(5,095 Views)