Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Setup of NI 9401 for pulse and digital input

Hi there, I'm new to this and it's all a little overwhelming - please let me know if I miss any necessary info. I am taking over a project that has the NI cDAQ-9188 with several modules (including NI 9401). 

 

I'm working with distributed fiber optic strain sensors and need to send a 5V TTL pulse to an interrogator using a BNC cable to start and end measurements. I know that you have to configure the NI 9401 by nibble, so I can set the first group of channels to send out a TTL pulse. Additionally, I would not only like to send a pulse, but also acquire the output data from the interrogator. The interrogator has a USB 3.0 Type B port, so I can use a cable with stripped wires, but I am stuck on how to connect the USB wires correctly to the NI 9401 pins. Is this even possible with this module?

 

I also need to communicate with the module by appending to an existing python GUI script. Can anyone point me in the direction of some examples that show how to communicate with the module to have one half send out the TTL pulse, and the other half accept digital input?

 

Thank you for any help...

 

 

0 Kudos
Message 1 of 2
(1,156 Views)

I hooked up an oscilloscope and found that the below python code works for the NI9401 in sending 2 pulses, with a temporary timer in between. Although it works, I know that this is not the best method.

import nidaqmx
import time as t

task = nidaqmx.Task()
task.do_channels.add_do_chan("/cDAQ9188-16D66BBMod1/port0/line0")
task.start()
for n in range(2):
	task.write(True)
	t.sleep(0.25)
	task.write(False)
	t.sleep(0.25)
task.stop
task.close()

 

I wanted to be able to specify the parameters of the pulse doing something like what I show below. I thought writing a boolean array to the task would specify the pulse, but as written this code does not produce anything (not even any errors). Any suggestions?

import nidaqmx
from nidaqmx.constants import Edge, AcquisitionType, LineGrouping
import numpy as np

# Timing Settings
fs = 1.0 # sampling frequency (Hz)
start_nsamp = 5 # number of samples for start (5 gives 2 rising edges)
stop_nsamp = 7 # number of samples for stop (7 gives 3 rising edges)

value = np.array([0,1,1,0,1,1,0], dtype=np.bool)

with nidaqmx.Task() as task:
	task.do_channels.add_do_chan("/cDAQ9188-16D66BBMod1/port0/line0", line_grouping=LineGrouping.CHAN_PER_LINE)
	task.timing.cfg_samp_clk_timing(fs,source="",active_edge=Edge.RISING,sample_mode=AcquisitionType.FINITE,samps_per_chan=start_nsamp)
	task.write(value)

 

0 Kudos
Message 2 of 2
(1,078 Views)