04-19-2018 05:31 PM
Hello friends,
Let's consider a hypothetical situation where I have an application and in it I configure my analog output in finite sample quantity mode such that it is going to output 10000 samples out of analog output channel 0. The configuration could look something like the following...
private Task _task; private AnalogSingleChannelWriter _writer;
private double[] _sampleArrayToOutput = new[] { /*10000 arbitrary values go here*/ }; _task = new Task("AnalogOutputTask"); _task.AOChannels.CreateVoltageChannel("Dev4/ao0", "ao0", -10, 10, AOVoltageUnits.Volts); _task.Timing.ConfigureSampleClock("", SamplingInfo.SampleRate, SampleClockActiveEdge.Rising,
SampleQuantityMode.FiniteSamples, 10000); _task.Control(TaskAction.Verify); _writer = new AnalogMultiChannelWriter(_task.Stream);
Then the code to start the analog output could look something like the following...
_writer.WriteWaveform(false, _sampleArrayToOutput); _task.Start();
Let's assume that it takes 2 seconds to complete the output of all 10000 samples. And let's say that 1 second after calling _task.Start() I want the hardware to immediately stop outputting samples out of analog output 0, even though it has not finished outputting all 10000 samples.
How can I achieve this?
04-19-2018 06:46 PM
Maybe a better question is the following. If I were to call _task.Stop() at the "1 second mark" in the example situation described above, will I see any more samples show up on the analog output connection? Or will I see no additional samples and the output will be left at whatever it's most recently written sample voltage was?
04-20-2018 04:34 PM - edited 04-20-2018 04:37 PM
Why can't you just set the number of samples to 5000 instead of 10000? Keep the rate the same so that the program stops after 1 second instead of 2 seconds. As for your question about whether or not the samples would continue to output after stopping them, it might depend on your sample clock source. I'd try it out and see what your results are!