07-20-2015 08:38 AM
I have a single line (e.g. Dev1/port0/line7) that I want to continuously read and also detect digital change events and the very same line. As far as I understand the DAQmx .NET library this isn't possible because configuring the timing for the change detected and also as a sample clock won't work, or am I wrong (at least I get an erro)? Here is the code so far
var emergencyStopButtonTask = new NationalInstruments.DAQmx.Task("Emergency stop button task"); var emergencyStopButtonDIChannel = emergencyStopButtonTask.DIChannels.CreateChannel( deviceName + "/port0/line7", "", ChannelLineGrouping.OneChannelForAllLines); emergencyStopButtonDIChannel.DigitalFilterEnable = true; emergencyStopButtonDIChannel.DigitalFilterMinimumPulseWidth = 10.24e-6; emergencyStopButtonTask.Timing.ConfigureChangeDetection( deviceName + "/port0/line7", // The line where to detect rising edges "", SampleQuantityMode.ContinuousSamples ); emergencyStopButtonTask.DigitalChangeDetection += new DigitalChangeDetectionEventHandler(emergencyStopButtonTask_DigitalChangeDetection); emergencyStopButtonTask.Timing.ConfigureSampleClock( "", 1000.0, SampleClockActiveEdge.Rising, SampleQuantityMode.ContinuousSamples ); emergencyReader = new DigitalSingleChannelReader(emergencyStopButtonTask.Stream); emergencyReaderAsyncCallback = new AsyncCallback(EmergencyStopButtonReaderAsyncCallback); emergencyStopButtonTask.SynchronizeCallbacks = true; emergencyStopButtonTask.Control(TaskAction.Verify); emergencyStopButtonTask.Start(); emergencyReader.BeginReadSingleSampleSingleLine(emergencyReaderAsyncCallback, emergencyStopButtonTask);
Of course, because I poll the value of the line every 1 ms dropping the change detection event could be a solution. But I simply want to know if my code is wrong or the DAQmx .NET library does not support the functionality I want. Any other solution then simply dropping the digital change event?
07-23-2015 02:42 AM
Hi,
Only one task can access one line at a time. You would have to reconfigure the task every time. I would recommend doing software change detection.
07-23-2015 10:05 AM
Thank you for your reply. How do I implement software change detection?
07-24-2015 09:05 AM
Implement it wherever you process the acquired date.