11-30-2015 04:15 PM
using (NationalInstruments.DAQmx.Task writeClockTask = new NationalInstruments.DAQmx.Task("Write Clock Task"))
{
writeClockTask.DOChannels.CreateChannel("PXI1Slot6/Port3/Line5", "Clock", ChannelLineGrouping.OneChannelForEachLine);
writeClockTask.Timing.ConfigureSampleClock("", 20000, SampleClockActiveEdge.Rising,
SampleQuantityMode.FiniteSamples, digitalSampleCount);
DigitalSingleChannelWriter clockWriter = new DigitalSingleChannelWriter(writeClockTask.Stream);
clockWriter.SynchronizeCallbacks = true;
readDataTask = new NationalInstruments.DAQmx.Task("Read Data Task");
readDataTask.DIChannels.CreateChannel("PXI1Slot6/Port3/Line3", "Data", ChannelLineGrouping.OneChannelForEachLine);
readDataTask.Timing.ConfigureChangeDetection("PXI1Slot6/PFI5", "PXI1Slot6/PFI5", SampleQuantityMode.FiniteSamples, 16);
readDataTask.DigitalChangeDetection += (s, e) =>
{
Console.WriteLine("Digital change detection detected.");
};
//dataReader = new DigitalSingleChannelReader(readDataTask.Stream);
//dataReader.SynchronizeCallbacks = true;
//dataReader.BeginReadWaveform((digitalSampleCount - 1) / 2, new AsyncCallback(CallBack), readDataTask);
readDataTask.Start();
clockWriter.WriteWaveform(true, clockWaveform);
writeClockTask.WaitUntilDone();
}
I have the above code, where I'm trying to simultaneously write a waveform on PXI1Slot6/Port/Line5, and sample data on PXI1Slot6/Port3/Line3. However, the event handler for readDataTask.DigitialChangeDetection is throwing a DaqException:
NationalInstruments.DAQmx.DaqException was unhandled Error=-201020 HResult=-2146233087 Message=Lines specified do not support change detection. Select lines that support change detection. Channel: port4/line5 Task Name: Read Data Task Status Code: -201020 Source=NationalInstruments.DAQmx
Notice that the channel is port4/line5. Why? I haven't configured the tasks for go after port4/line5, so why is that causing this code to throw an exception?
I'm using a PXIe-6535 digital IO module
12-01-2015 12:54 PM
CurtisHx,
in your configure line you specify a PFI line to use for the rising and falling edges.
readDataTask.Timing.ConfigureChangeDetection("PXI1 Slot6/PFI5", "PXI1Slot6/PFI5", SampleQuantityMode.FiniteSamples, 16);
The fuction itself is actually looking for a specific line call such as when you created the channel earlier.
"PXI1Slot6/Port3/Line5"
Odds are its getting to this line and is not sure how to use PXI1SLOT6/PFI5 so it is just assigning it to port4/line5.
I cannot find a text text based example that shows this, but using the example at the bottom of the link below shows some of the fommating for the ConfigureChangeDetection function.
http://www.ni.com/white-paper/4102/en/
Hopefully this helps you out,
CyanRyan