Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Create a new AnalogWaveform variable with an irregular sample interval

Hi All,

 

I would like to sample some data at a low rate. Currently, I have a DaqTaskComponent which takes a single sample, and saves it into a global AnalogWaveform variable using .Append(). Here is a snippet of the code:

Public VoltageWaveform As NationalInstruments.AnalogWaveform(Of Double)

...

            ' Acquire some data from the DAQ:
            Dim acquiredData() As Double = DaqTaskComponent1.Read
            ' Create a variable to store the time stamp:
            Dim Times(0) As NationalInstruments.PrecisionDateTime
            ' Get the current time:
            Times(0) = PrecisionDateTime.Now
            
            ' Append the data to the analog waveform:
            VoltageWaveform.Append(DaqTaskComponent1.Read)           'This works
            VoltageWaveform.Append(DaqTaskComponent1.Read, Times)  'This does NOT work

            ' Plot the results:
            WaveformPlot1.PlotWaveform(Of Double)(VoltageWaveform)

 The line which is marked as "This does NOT work", fails because the "VoltageWaveform.Timing.SampleInterval = None". In order to use Append() in this way, SampleInterval must be "Irregular". However, .SampleInterval is a read only property.

 

Therefore my questions are:

1) is there any way to change the SampleInterval for an AnalogWaveform programatically?

2) Failing 1), is there a better way to implement what I am describing? I would like to add data as I see fit to an AnalogWaveform variable. Or is there another type of variable which would be more appropriate? I am only sampling at 0.5Hz or so. I would like to use an AnalogWaveform or equivalent variable to take advantage of the WPF features of Measurement Studio.

 

Thanks!

 

Damien

0 Kudos
Message 1 of 3
(5,897 Views)

Hi Defrost,

 

If you're using a daq task, I would recommend considering a continuous daq task and then altering the timing settings for that task. You should be able to find an example for this in the NI DAQ folder on your PC.

 

Kind regards,

Matt H
Applications Engineer
National Instruments UK
0 Kudos
Message 2 of 3
(5,847 Views)

Hi Matt,

 

Thanks for your help. I've found the example you are talking about (GlobalContinuousAI_USB.2010), and I've got it working. I can see that it also saves the time data, however I have a few questions:

1) The example uses a global "daq task" set using the Measurement & Automation Explorer (MAX). When using it in this way, does this effect its portability to another machine? I would like to develop software on my computer, and generate an install file for someone else to use. In which case, I would need only to install my software on a new machine (and possibly the NI drivers?), and be able to use the NI hardware.

2) I tried to change my software such that it uses a continuous sampling interval. I successfully changed it, however it did not save any time stamps. Is there a way to setup a daq task using the NI DAQ Assistant such that it also saves the time information?

3) This question is a bit unrelated - are there any examples that show how to manipulate the WaveformGraph controls programmatically? What is the best way to get the graphs to display the time on the x-axis?

 

Thanks,

 

Damien

0 Kudos
Message 3 of 3
(5,798 Views)