11-27-2017 01:40 PM
I am trying to monitor a digital pulse that is infrequent and is ~100ms in duration. My system polls the input and will sometimes miss the pulse. I have been unable to find a method to use this input as an interrupt so that I do not miss it. My hardware is a cDAQ-9178 chassis and either a NI-9401 or NI-9403 DIO module.
Reason that I am missing the pulse is that I am also using a NI-9217 RTD module and reading all four channels in high-resolution mode takes ~800ms. During the NI-9217 read the pulse often occurs and is missed.
Is there a simple method to switch from polling this digital input to an interrupt?
11-28-2017 09:17 AM
I suspect what you're looking for is called "Digital Change Detection" in the DAQmx API.
Note that, in C Series, change detection is not supported on serial digital modules (such as the NI 9403), only parallel digital modules (such as the NI 9401).
11-28-2017 09:36 AM
How do currently have the tasks for the 9217 and 9401 configured? If these two modules are configured in separate tasks with different sample clocks, then the analog reading of the RTD shouldn't be interfering with the digital detection of the 9401.
What is the sampling rate of the 9401? Even 10 kHz should be sufficient to detect the 100ms periodic signal.
I'm not sure that an interrupt would be necessary if both modules are using individual sample clocks.
11-28-2017 12:14 PM
Thank you for your prompt reply. I am new LV user, only been doing LV for a couple of months (but have quite a bit of hardware and firmware experience on microcontrollers). I just simplified my application for illustration purposes. I am currently running both tasks in [1 Sample (On Demand)].
I believe you are suggesting using hardware triggering? Have not used that feature yet.
I have attached my VI.
11-29-2017 09:45 AM
From the attached code, I was unable to see how you've configured the sample clocks in your AI and DI tasks since you've imported them.
As Brandon recommended, the Digital Change Detection example will work with your 9401.
Digital Change Detection
You can modify this example above to read only a single sample like the code you've attached to this forum.
12-06-2017 03:16 PM
Sorry about the slow reply. I have switched from High-resolution mode to high-speed mode on the 9217 and implemented a moving average (on 4 samples) on the data. Since the averaging is moving, it does not really slow down my main loop that is polling for the input pulse on the DIO input. I can reliably catch the pulse now. I still need to investigate the Change Detection example. I was worried about using the free running mode clocking of the ADC because over time it would seem that the system would get out of sync if the code was not reading the buffer at exactly the same speed it was getting filled.