11-02-2016 12:02 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" (on a separate thread)
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-03-2016 10:06 AM
Hey Brian,
Are you doing a hardware timed task or a software timed task? From the information provided, what I think is occurring is that you are attempting to use the same sample clock at two different rates. Since the SensorInput task has reserved the sample clock, the InputVoltage task cannot use the sample clock.
This documentation should give some information on the issue that you are seeing. It discusses why you may be getting this issue and different solutions to the issue.
Can I Sample Different Channels at Different Rates with My Multifunction DAQ Device?: http://digital.ni.com/public.nsf/allkb/96FD2F4685065C7686256F25006EE8DE
Regards,
Hannah L.
Applications Engineering
National Instruments
11-03-2016 10:51 AM
The link doesnt work. Please keep in mind Im using c# and the daqmx driver to access the board.
The two tasks Im using are on separate threads.
11-04-2016 11:47 AM
Brian,
I apologize for the link not working. I understand that you are using C# and the daqmx driver, but how are you configuring your timing? Are you doing software timed tasks or hardware timed tasks? You still need to configure timing even if you are using C#.
I have attached the link again below. If it does not work, you can use any search engine to look for the article.
Can I Sample Different Channels at Different Rates with My Multifunction DAQ device?
The article is independent of the coding environment that you are using, instead focusing on whether the hardware will allow for sampling multiple channels at different rates.
Thanks,
Hannah
Applications Engineering
National Instruments
11-09-2016 08:16 PM
Unfortunately there is no good example to perform multiple analog channel reads.
My assumption is that you need to assign two streams to the input--but not function appears to allow that. For example:
static private Task FlowSensorInput;
FlowSensorInput = new Task();
static private AnalogMultiChannelReader readerFlowSensor;
readerFlowSensor = new AnalogMultiChannelReader(FlowSensorInput.Stream);
Which, finally, leads to my question: How does one apply another stream to readerFlowSenor? (It appears I can only read from one stream (FlowSensorInput.Stream)
11-10-2016 04:29 PM
BCES,
You will not be able to do two separate tasks. As taken from that documentation I posted earlier, "On X-series cards, the STC3 chip allows for one analog input task, one analog output task, and one digital input/output task."
There is a workaround that you could try. From the documentation I provided above: "In general, if you need to sample at different rates on multiple channels, the easiest and recommended way to do this is to sample all channels at the higher rate and discard any additional samples in software."
You will want to channel expand in your task, which you can do by using the colon operator as shown in the following link: Physical Channel Syntax. You will then sample both channels, and can programmatically discard the extra data to get the lower sampling rate. The following link gives more information about the recommended way to do multi-channel reads in C#: Reading and Writing Analog Waveform Data.
Regards,
Hannah L.
Applications Engineering
National Instruments