07-28-2017 11:31 AM
I am trying to trouble shoot a problem with counter reading that occurs only under some circumstances. If a certain sequence of actions happens in my software, running a multisample read on a CounterReader returns the following error:
By setting Number of Samples per Channel to -1, you indicated that all available data should be read. This is not valid for acquisitions without a buffer. Specify a value greater than or equal to zero for Number of Samples per Channel. Do not specify a value of zero for Buffer Size when configuring the input buffer.
My code is:
myXCounterTask = gcnew Task("X Counter"); myXCounterTask->CIChannels->CreateLinearEncoderChannel (..) myXCounterTask->Timing->ConfigureSampleClock("/Dev1/PFI0", 8000, SampleClockActiveEdge::Rising, SampleQuantityMode::ContinuousSamples, numberOfSamples ); myXCounterTask->Stream->Buffer->InputBufferSize = numberOfSamples * 20; counterXInReader = gcnew CounterReader(myXCounterTask->Stream); array<double>^ posX = counterXInReader->ReadMultiSampleDouble(-1);
What is confusing is that this code works fine generally, but fails if certain sequences daqmx commands are run previously, which makes me think that I am not initializing something correctly and depending on it to be in a default state. I'm trying to understand which buffer the error is referring to, and how I can check it's size? It is apparently not the Task's buffer, since that is set. Are there other buffers associated with the CounterReader?
07-30-2017 02:24 PM
After a lot of further testing, the problem had to do with the order in which different hardware devices in my system were being initialized. For reasons I do not yet fully understanding, doing it in a certain order seemed to reset part of the DAQ state, which is probably why I got the confusing error message.
I will say though that some documentation would have made this a lot easier to trouble shoot. There is so little information provided by NI that if you google the error message, this thread is now the #1 result.