07-20-2015 10:25 AM - edited 07-20-2015 10:28 AM
I can't really find helpful information about how the sample clock is internally used/blocked. For example I configured a task to continuously read von Dev1/port0/line7 via the SampleClock event
var myTask = new NationalInstruments.DAQmx.Task("Emergency stop button task"); var diChannel = myTask.DIChannels.CreateChannel( device.DeviceID + "/port0/line7", "", ChannelLineGrouping.OneChannelForEachLine); diChannel.DigitalFilterEnable = true; diChannel.DigitalFilterMinimumPulseWidth = 10.24e-6; myTask.Timing.ConfigureSampleClock( "", 1000.0, SampleClockActiveEdge.Rising, SampleQuantityMode.ContinuousSamples ); myTask.SampleClock += myTask_SampleClock; var myReader = new DigitalSingleChannelReader(myTask.Stream); ... void emergencyStopButtonTask_SampleClock(object sender, SampleClockEventArgs e) { bool val = myReader.ReadSingleSampleSingleLine(); Console.WriteLine(val); }
This works just fine. Now I want create a second task, that waits for rising edges on Dev/port0/line6. The code is as follows
var mySecondTask = new NationalInstruments.DAQmx.Task("Proximity switch task"); mySecondDIChannel = mySecondTask.DIChannels.CreateChannel( device.DeviceID + "/port0/line6", "", ChannelLineGrouping.OneChannelForEachLine ); mySecondDIChannel.DigitalFilterEnable = true; mySecondDIChannel.DigitalFilterMinimumPulseWidth = 10.24e-6; mySecondTask.Timing.ConfigureChangeDetection( device.DeviceID + "/port0/line6", "", SampleQuantityMode.ContinuousSamples ); mySecondTask.SynchronizeCallbacks = true; mySecondTask.DigitalChangeDetection += new DigitalChangeDetectionEventHandler(mySecondTask_DigitalChangeDetection); ... void proximitySwitchTask_DigitalChangeDetection(object sender, DigitalChangeDetectionEventArgs e) { Console.WriteLine("Change event detected"); }
If I try to execute the code, I get the error "Specified route cannot be satisfied, because it requires resources that are currently in use by another route." I guess it's about the sample clock that is blocked by the first task. Why cant the second task use another clock? Can I share the clock between the tasks?
I mean it should be quite simple...!? But I have no clue where to find the informations to understand/solve the problem on my own. I found this http://digital.ni.com/public.nsf/allkb/3D99C0ECBCC9FA9C862576E800556235 but I can't apply this to .NET/C#.
Edit: I can't even set the clock source for the digital change detection. How do I do so because ConfigureChangeDetection() won't let me.
07-30-2015 09:20 AM
Hi Icm0,
what type of Device are you currently using? And what do you need the changedetection-path for?
I wouldn't be sure, that its about the sample clock, because you dont use a sampleclock with a change detection timing. The "sampleclock" for Changedetection is the Signal you are trying to detect changes in.
Regards,
Jan Göbel
Applications Engineer
07-30-2015 09:20 AM
*changedetection-task (not path 😉
07-31-2015 04:45 AM
Hi Icm0,
i have to correct myself. The Changedetection-Task does need a SampleClock. I assume you are using a cDAQ-Chassis with a DI-Module. Usually cDAQs only have one di/sampleclocktimebase. This means you can only specify one di/sampleclock. So you can only use one timed DI-Task with the whole device (even if you got 2 modules).
My approach would be, to do a normal timed DI-Task with all channels you want to monitor, and to realize the changedetection within your Program.
Best Regards,
Jan Göbel
Applications Engineer