01-30-2014 08:25 AM
I am writing a Measurement Studio 2013 .NET application using the DAQ Application Wizard. My hardware consists of a 9174 Chassis, 9401 IO and 9205 AI. I would like to be able to run the AI continuously and get data every N samples with an external sampling clock. (The external sampling clock is generated using a 9174 Pulse Counter which generates N pulses on an edge). The AI works on start - however, I am having problems stopping data input. It seems like continuous mode using the DAQ Component Model requires data acquisition to complete before reading can be stopped or task can be stopped.
Here's the partial code the Wizard generated
partial class DaqAnalogInputTaskComponent : ContinuousInputDaqComponent<AnalogMultiChannelReader, AnalogWaveform<double>[]> { private static readonly object EventDataReady = new object(); private const int DefaultNumberOfSamplesToRead = 1000; private static readonly TimeSpan DefaultTimeout = TimeSpan.FromMilliseconds(10000); private AnalogWaveform<double>[] data = null; ...
public virtual void Configure() { // This code was generated by Measurement Studio. Changes to this // file may cause incorrect behavior and will be lost if the code // is regenerated. AIChannels.CreateVoltageChannel("AnalogInput/ai0", "Intensity", AITerminalConfiguration.Rse, -10, 10, AIVoltageUnits.Volts); Timing.ConfigureSampleClock("/cDAQ1/Ctr3InternalOutput", 1000, SampleClockActiveEdge.Falling, SampleQuantityMode.ContinuousSamples, 1000); ...
If I call
myDaqAnalogInputComponent.StopRead()
my application hangs...
Stopping the reading by calling
Task.Control(TaskAction.Abort);
generates a -200279 Exception in protected override void EndReadContinuous(IAsyncResult result)
What is the correct way to stop such a Component (Continuous Input with Async clock)? I have browsed the examples for Analog Voltage Continuous Input with External Clock - however, these are non-component examples.
Appreciate any pointers here, thanks!
01-31-2014 01:00 PM
I will be looking into this issue to see if I can find some resources and help out. If I understood correctly this is in .NET and not in LabVIEW and you recieved the -200279 error?
01-31-2014 01:07 PM
Yes, via Measurement Studio .NET. Not using LabView. Thanks!
02-03-2014 04:44 PM
Thanks for the info, hopefully I should have something soon to post to help out.
02-05-2014 03:49 PM
A few more questions to help me wrap my head around this issue. If I understood correctly, you are trying to get data every N samples with your external clock. Is there a reason you are using continuous samples, instead of using finite samples to get the N samples you require? Also, if you could clarify what you meant by "Component" it would help me understand. From what I do understand, you want to know how to stop an data acquisition of an AI input? Please correct me if I am wrong.
02-12-2014 12:29 PM
Using continuous samples in the AI. The AI clock, as mentioned, is clocked externally for a counter. This design pattern allows for retriggering the hardware (using an extenal counter set up this way) while the AI runs continuously. The "Component" model refers to .NET DAQ component as documented here http://zone.ni.com/reference/en-XX/help/370473H-01/mstudiowebhelp/html/createdaqappnet/. This is the C# design pattern that the DAQ Assistant (http://zone.ni.com/reference/en-XX/help/370473H-01/mstudiowebhelp/html/createdaqapp/) tool generates.
Thanks!
02-13-2014 06:03 PM
Hello garyg100,
You said you looked at one of the examples, are you able to run that and have it perform as expected? I understand it's not in the same form as your current application but is there a reason you don't want to use the example? Also, would it be possible for you to post screen caps of the errors you see when you try to stop the task and also the code you use for stopping and closing the task.
02-17-2014 03:42 PM
There are no C# examples that do what I need.
My code snippet is in my first posting - reposting my stop code snippet below:
If I call
myDaqAnalogInputComponent.StopRead()
my application hangs...
Stopping the reading by calling
Task.Control(TaskAction.Abort);
generates a -200279 Exception in protected override void EndReadContinuous(IAsyncResult result)
I am just looking for someone to confirm that a continuous input task (clocked using an pulse counter) can be stopped gracefully or if there is an issue here.