Hello, I have added two channels to a task and I can read one but when I try to read the second, I get an out of range error.
flowMeterTask.AIChannels.CreateCurrentChannel(flowsensor1name, "FlowRate1Voltage", sensorMeasurementType, minCurrentIn, maxCurrentIn, AICurrentUnits.Amps);
flowMeterTask.AIChannels.CreateCurrentChannel(flowsensor2name, "FlowRate2Voltage", sensorMeasurementType, minCurrentIn, maxCurrentIn, AICurrentUnits.Amps);
flowMeterTask.Timing.ConfigureSampleClock("", samplingRate, SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples, numberOfSamples);
reader = new AnalogMultiChannelReader(flowMeterTask.Stream);
dataSensor2.Add(reader.ReadSingleSample()); //says out of range here
Solved! Go to Solution.
Thanks for the reply! wouldn't that just be reading my sensor 1 though since it is channel 0?
also update: I am able to read data for a while and then after about 95 samples per channel it hits that out of range exception.
I guess I am not getting an out of range error anymore. it just hangs at some point when trying to read the sensors. Sometimes its the first sensor read and sometimes its the second. I am able to read from a single sensor all the way through every time but when I add the second one it hangs up at some point. Thanks for any ideas or input
Maybe an example project with multiple channels would help to reference but I was not able to find any. Does anyone know of one?
I realized I was actually reading twice instead of grabbing the whole array of values at once like this:
dynamic temp = reader.ReadSingleSample();