SHARE
TWEET

Untitled

a guest Jun 20th, 2019 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import sys
  2. import time
  3. import nidaqmx
  4.  
  5. def readControlSimulator(niDaqDevice = "Dev1"):
  6.  
  7.     # On NI-USB6501 all IOs are configurable.
  8.     # On NI-USB6525 port0 are outputs, port1 are inputs.
  9.     INPUT_PORT = 'port1'
  10.  
  11.     # read command line arguments
  12.     for arg in sys.argv[1:]:
  13.         niDaqDevice = arg
  14.  
  15.     # Set up NIDAQ line detection for all lines
  16.     with nidaqmx.Task() as task:        
  17.         # Will only work if using a compatible device.
  18.         try:
  19.             print("SET UP CHANGE DETECTION")
  20.             task.di_channels.add_di_chan(niDaqDevice + '/' + INPUT_PORT + '/line0:7')
  21.             task.timing.cfg_change_detection_timing(rising_edge_chan = niDaqDevice + '/' + INPUT_PORT + '/line0:7',
  22.                                                     falling_edge_chan = niDaqDevice + '/' + INPUT_PORT + '/line0:7',
  23.                                                     sample_mode=nidaqmx.constants.AcquisitionType.CONTINUOUS)
  24.  
  25.             def callback(task_handle, signal_type, callback_data):
  26.                 print("CHANGE LINE")
  27.                 return 0
  28.  
  29.             task.register_signal_event(nidaqmx.constants.Signal.CHANGE_DETECTION_EVENT, callback)
  30.             task.start()
  31.         except nidaqmx.DaqError as e:
  32.             print(str(e))
  33.  
  34.     time.sleep(10)
  35.  
  36. if __name__ == '__main__':
  37.     readControlSimulator()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top