11-28-2015 01:16 AM
11-28-2015 12:41 PM
@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.
11-29-2015 08:23 AM
11-29-2015 09:44 AM
@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.
11-30-2015 11:42 PM
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); }
12-01-2015 02:44 AM
I tried to build the LabVIEW format waveform, not tested yet, but syntax is ok
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); }