Guest User

Untitled

a guest
Apr 20th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. #import PyDAQmx
  2. #from PyDAQmx import Task
  3. import numpy as np
  4. import time
  5. import pdb
  6. import weakref
  7. from ctypes import *
  8.  
  9. import sys
  10. sys.path.insert(1, 'nidaqmx-python')
  11. from nidaqmx import Task
  12.  
  13. high = np.array([1], dtype=np.uint8)
  14. low = np.array([0], dtype=np.uint8)
  15.  
  16. # Simple class that can be used to control one Digital output line
  17. class DO:
  18. def __init__(self, dev):
  19. self.chan = dev
  20. self.high()
  21. # self.do_channels.add_do_chan(dev)
  22. # self.write(False)
  23.  
  24. def __del__(self):
  25. print(self)
  26. self.low()
  27.  
  28. def high(self):
  29. with Task() as task:
  30. task.do_channels.add_do_chan(self.chan)
  31. task.write(True)
  32.  
  33. def low(self):
  34. with Task() as task:
  35. task.do_channels.add_do_chan(self.chan)
  36. task.write(False)
  37.  
  38. if __name__ == '__main__':
  39. dig_0 = DO('/cDAQ1Mod1/port0/line0')
  40. dig_0.high()
  41. time.sleep(2)
  42.  
  43. #dig_0 = DI('/cDAQ1Mod4/port0/line0/')
  44. #if(dig_0.read()):
  45. # print('High')
  46. #else:
  47. # print('Low')
  48. #with nidaqmx.Task() as task:
  49. # task.do_channels.add_do_chan('/cDAQ1Mod1/port0/line0')
  50. # task.write(False)
Advertisement
Add Comment
Please, Sign In to add comment