Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Digital change detection and continuous read on the same line

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?

0 Kudos
Message 1 of 4
(4,249 Views)

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.

0 Kudos
Message 2 of 4
(4,203 Views)

Thank you for your reply. How do I implement software change detection?

0 Kudos
Message 3 of 4
(4,190 Views)

Implement it wherever you process the acquired date.

0 Kudos
Message 4 of 4
(4,176 Views)