Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Does anyone can convert AnalogWaveform to DoubleWaveform?

I got error message: cannot convert from 'NationalInstruments.AnalogWaveform' to 'NationalInstruments.LabVIEW.Interop.DoubleWaveform' while I tried the function of extract_single_tone_information. anyone can help me to convert the AnalogWaveform to DoubleWaveform (time signal)? thanks a lot... my example: using NationalInstruments; using NationalInstruments.DAQmx; using NationalInstruments.LabVIEW.Interop; using singletone; //dll that saved from 'Extract Single Tone Information 1 Chan.vi' AnalogMultiChannelReader reader; AnalogWaveform[] w; Task tk = new Task(); for (int c = 0; c < channel.Length; c++) tk.AIChannels.CreateVoltageChannel(string.Format("Dev{0}/ai{1}", 1, channel[c]), channel[c].ToString(), AITerminalConfiguration.Rse, -10.0, 10.0, AIVoltageUnits.Volts); tk.Timing.ConfigureSampleClock("", 250000 / channel.Length, SampleClockActiveEdge.Falling, SampleQuantityMode.FiniteSamples, sample); reader = new AnalogMultiChannelReader(tk.Stream); w = reader.ReadWaveform(sample); tk.Stop(); tk.Dispose(); singletone.Advanced_search searchmode = new Advanced_search(); singletone.Measurement_info minfo; singletone.Exported_signals signal_out; for (int c = 0; c < w.Length; c++) { singletone.NI_MAPro.extract_single_tone_information_1ch( w[c], export_mode.detected__32signal, searchmode, out frequency[c], out amplitude[c], out phase[c], out signal_out, out minfo); }
0 Kudos
Message 1 of 6
(4,314 Views)

@dysonx wrote:
I got error message: cannot convert from 'NationalInstruments.AnalogWaveform' to 'NationalInstruments.LabVIEW.Interop.DoubleWaveform' while I tried the function of extract_single_tone_information. anyone can help me to convert the AnalogWaveform to DoubleWaveform (time signal)? thanks a lot... my example: using NationalInstruments; using NationalInstruments.DAQmx; using NationalInstruments.LabVIEW.Interop; using singletone; //dll that saved from 'Extract Single Tone Information 1 Chan.vi' AnalogMultiChannelReader reader; AnalogWaveform[] w; Task tk = new Task(); for (int c = 0; c < channel.Length; c++) tk.AIChannels.CreateVoltageChannel(string.Format("Dev{0}/ai{1}", 1, channel[c]), channel[c].ToString(), AITerminalConfiguration.Rse, -10.0, 10.0, AIVoltageUnits.Volts); tk.Timing.ConfigureSampleClock("", 250000 / channel.Length, SampleClockActiveEdge.Falling, SampleQuantityMode.FiniteSamples, sample); reader = new AnalogMultiChannelReader(tk.Stream); w = reader.ReadWaveform(sample); tk.Stop(); tk.Dispose(); singletone.Advanced_search searchmode = new Advanced_search(); singletone.Measurement_info minfo; singletone.Exported_signals signal_out; for (int c = 0; c < w.Length; c++) { singletone.NI_MAPro.extract_single_tone_information_1ch( w[c], export_mode.detected__32signal, searchmode, out frequency[c], out amplitude[c], out phase[c], out signal_out, out minfo); }

I suggest you repost your code in a format easier to read by clicking on the Insert Code icon.

0 Kudos
Message 2 of 6
(4,302 Views)
Sorry, but there is no any Insert Code icon on my browsers (both IE & Chrome and both PCs), I don't know why NI forum can not be loaded completely. I just want to convert AnalogWaveform to Waveform (time signal) in C#, why AnalogWaveform in C# is different with the Waveform in LabVIEW? Thank nyc !
0 Kudos
Message 3 of 6
(4,288 Views)

@dysonx wrote:
Sorry, but there is no any Insert Code icon on my browsers (both IE & Chrome and both PCs), I don't know why NI forum can not be loaded completely. I just want to convert AnalogWaveform to Waveform (time signal) in C#, why AnalogWaveform in C# is different with the Waveform in LabVIEW? Thank nyc !

I am using Firefox and Chrome and I see the toolbar with the Insert Code icon with both.

0 Kudos
Message 4 of 6
(4,280 Views)

Hi nyc,

Now I can see the edit toobar. attached picture is the error screenshoot.

 

using NationalInstruments;
using NationalInstruments.DAQmx;
using NationalInstruments.LabVIEW.Interop;
using singletone; //dll that saved from 'Extract Single Tone Information 1 Chan.vi'

AnalogMultiChannelReader reader; AnalogWaveform[] w; Task tk = new Task();
for (int c = 0; c < channel.Length; c++) tk.AIChannels.CreateVoltageChannel(string.Format("Dev{0}/ai{1}", 1, channel[c]), channel[c].ToString(), AITerminalConfiguration.Rse, -10.0, 10.0, AIVoltageUnits.Volts); tk.Timing.ConfigureSampleClock("", 250000 / channel.Length, SampleClockActiveEdge.Falling, SampleQuantityMode.FiniteSamples, sample); reader = new AnalogMultiChannelReader(tk.Stream); w = reader.ReadWaveform(sample); tk.Stop(); tk.Dispose(); singletone.Advanced_search searchmode = new Advanced_search(); singletone.Measurement_info minfo; singletone.Exported_signals signal_out; for (int c = 0; c < w.Length; c++) { singletone.NI_MAPro.extract_single_tone_information_1ch(w[c], export_mode.detected__32signal, searchmode, out frequency[c], out amplitude[c], out phase[c], out signal_out, out minfo); }
0 Kudos
Message 5 of 6
(4,248 Views)

I tried to build the LabVIEW format waveform, not tested yet, but syntax is ok Smiley Frustrated

 

using NationalInstruments;
using NationalInstruments.DAQmx;
using NationalInstruments.LabVIEW.Interop;
using singletone; //dll that saved from 'Extract Single Tone Information 1 Chan.vi'

AnalogMultiChannelReader reader;
AnalogWaveform[] w;
Task tk = new Task();

for (int c = 0; c < channel.Length; c++)
	tk.AIChannels.CreateVoltageChannel(string.Format("Dev{0}/ai{1}", 1, channel[c]), channel[c].ToString(),
	AITerminalConfiguration.Rse, -10.0, 10.0, AIVoltageUnits.Volts);
tk.Timing.ConfigureSampleClock("", 250000 / channel.Length, SampleClockActiveEdge.Falling, SampleQuantityMode.FiniteSamples, sample);
reader = new AnalogMultiChannelReader(tk.Stream);
w = reader.ReadWaveform(sample);
tk.Stop();
tk.Dispose();

singletone.Advanced_search searchmode = new Advanced_search();
singletone.Measurement_info minfo;
singletone.Exported_signals signal_out;
DoubleWaveform[] wf = new DoubleWaveform[w.Length];

for (int c = 0; c < w.Length; c++)
{
        wf[c].YData = w[c].GetRawData();
        wf[c].StartTime = w[0].Samples[0].TimeStamp;
        wf[c].DeltaT = w[c].Samples[1].TimeStamp.Subtract(w[c].Samples[0].TimeStamp).TotalSeconds;
	singletone.NI_MAPro.extract_single_tone_information_1ch(wf[c], export_mode.detected__32signal, searchmode, out frequency[c], out amplitude[c], out phase[c], out signal_out, out minfo);
}

 

0 Kudos
Message 6 of 6
(4,241 Views)