From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
11-01-2016 05:48 PM
Hi NI Community,
Not sure if this is the right place to start. But, someone must have had a similar issue.
We are using C# to talk to our NI 6323 board.
We have two analog inputs that need to be read. (No problem setting that up.)
Here are the inputs:
static private Task SensorInput; //needs to be read 10,000 per second
static private Task InputVoltage; //needs input every 2 seconds
reader = new AnalogMultiChannelReader(SensorInput.Stream);
data = reader.ReadWaveform(10,000);
Trouble is we need the "InputVoltage" to be read every two seconds and it sometimes gets "locked out" by the 10,000 samples per second stream going on for the "SensorInput"
Is there a way to raise the "priority" of the InputVoltage task so that it always reads a value. Often we only get the exception NationalInstruments.DAQmx.DaqException: The specified resource is reserved. The operation could not be completed as specified.
Brian
11-02-2016 05:15 PM
Hello,
What exactly do you mean by being locked out? How are you architecting the system for it to read?
Generally, there is not a way to set a priority to be higher than another. What you can do, however, is set up the task to be hardware timed before starting the task. Then, what you can do is have a loop that does not wait for necessaryily 10,000 samples to come in, but instead just set each task to read "-1" samples, which reads all that are available. This will allow the tasks to never stop to wait, and the code will continue to flow.
Best,
Shamik C
Applications Engineer
National Instruments
11-02-2016 05:23 PM
To be more precise, the two tasks are run on separate threads, one fires every 1 second and reads 10,000 samples (and averages them), the other reads every 2 seconds and read 10 samples (and averages them)
The thread reading every two seconds encounters an exception thrown by daqmx (resource is unavailable) because of the 10,000 sample per second task hogging access to the board.
What you're suggesting is read them in the same thread, I assume.
Please provide a c# code snippet for setting "hardware timing".
11-03-2016 04:02 PM
When you set up the tasks, you can configure the timing similar to below.
// Create a new task myTask = new Task(); // Create a virtual channel myTask.AIChannels.CreateVoltageChannel(physicalChannelComboBox.Text, "", (AITerminalConfiguration)(-1), Convert.ToDouble(minimumValueNumeric.Value), Convert.ToDouble(maximumValueNumeric.Value), AIVoltageUnits.Volts); // Configure the timing parameters myTask.Timing.ConfigureSampleClock("", Convert.ToDouble(rateNumeric.Value), SampleClockActiveEdge.Rising, SampleQuantityMode.ContinuousSamples, 1000); // Verify the Task myTask.Control(TaskAction.Verify); myTask.Stream.
What exception is being thrown? Could you possibly send a screenshot?
11-03-2016 05:24 PM - edited 11-03-2016 05:25 PM
This is the exception:
10/22/2016 12:54:57:6859 Error: Input Averaging Ex: NationalInstruments.DAQmx.DaqException: The specified resource is reserved. The operation could not be completed as specified.
Task Name: _unnamedTask<C>
Status Code: -50103
at nNIMSSAIL100.StatusObserverT<nNIMSSAIL100::ApiTraits<nNIMSSAIL100:: DotNetApi> >.CheckWithName(StatusObserverT<nNIMSSAIL100::ApiTraits<nNIMSSAIL100:: DotNetApi> >* , tCaseInsensitiveBasicString<unsigned short\,_STL::char_traits<unsigned short>\,_STL::allocator<unsigned short>\,nNIDMXS100::tLocaleConsideringWideStringComparitor\,nNIDMXS100::tLocaleConsideringWideStringCaseForcer>* pName)
at nNINETAI2005100.ReadAnlWfmGeneric(Task task, Int32 samplesPerChannel, Double timeout, WaveformAttributeModes mode)
at NationalInstruments.DAQmx.Internal.AnalogMultiChannelReaderImpl.ReadWaveformGeneric(Int32 samplesPerChannel)
at NationalInstruments.DAQmx.AnalogMultiChannelReader.ReadWaveform(Int32 samplesPerChannel)
at WindowsFormsApplication5.Form1.InputAveraging() in C:\DEV\Test1011\trunk\Form1.cs:line 6844