10-17-2024 04:59 PM - edited 10-17-2024 05:04 PM
Im trying to detect the falling edge of the digital signal coming in Dev1/port0/line0 of NI-6345 using NIDAQMX python library.
This is my code snippet
with nidaqmx.Task() as task:
channel=task.di_channels.add_di_chan(channel)
task.timing.cfg_change_detection_timing(rising_edge_chan="/Dev1/port0/line0",
falling_edge_chan="/Dev1/port0/line0",
sample_mode=AcquisitionType.CONTINUOUS)
start=time.time()
while True:
sample= task.read()
print(f"Falling edge detected: {sample}")
break
difftime= time.time()-start
print("difftime=",difftime)
but I'm getting the following error
Traceback (most recent call last):
File "/home/user/measurePulse.py", line 201, in <module>
waitUntilSignalTransition()
File "/home/user/measurePulse.py", line 95, in waitUntilSignalTransition
sample= task.read()
File "/home/user/.pyenv/versions/3.10.7/lib/python3.10/site-packages/nidaqmx/task/_task.py", line 623, in read
_, samples_read, _ = self._interpreter.read_digital_lines(
File "/home/user/.pyenv/versions/3.10.7/lib/python3.10/site-packages/nidaqmx/_library_interpreter.py", line 4541, in read_digital_lines
self.check_for_error(error_code, samps_per_chan_read=samps_per_chan_read.value)
File "/home/user/.pyenv/versions/3.10.7/lib/python3.10/site-packages/nidaqmx/_library_interpreter.py", line 6408, in check_for_error
raise DaqReadError(extended_error_info, error_code, samps_per_chan_read)
nidaqmx.errors.DaqReadError: A hardware failure has occurred. The operation could not be completed as specified.
Task Name: _unnamedTask<0>
Status Code: -50152
I'm a bit new with NI cards, and I couldn't figure out if the NI6345 digital lines can detect edges.
Any help on this matter is greatly appreciated
10-17-2024 05:42 PM
What do you want to do after detecting the falling edge?
10-18-2024 09:13 AM
I wanted to detect the falling edge of the signal and return from this function.
10-18-2024 12:54 PM
So, you need a way to detect a digital edge transition to proceed/do something in software.
10-18-2024 02:00 PM
Exactly