Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import PyDAQmx
- #from PyDAQmx import Task
- import numpy as np
- import time
- import pdb
- import weakref
- from ctypes import *
- import sys
- sys.path.insert(1, 'nidaqmx-python')
- from nidaqmx import Task
- high = np.array([1], dtype=np.uint8)
- low = np.array([0], dtype=np.uint8)
- # Simple class that can be used to control one Digital output line
- class DO:
- def __init__(self, dev):
- self.chan = dev
- self.high()
- # self.do_channels.add_do_chan(dev)
- # self.write(False)
- def __del__(self):
- print(self)
- self.low()
- def high(self):
- with Task() as task:
- task.do_channels.add_do_chan(self.chan)
- task.write(True)
- def low(self):
- with Task() as task:
- task.do_channels.add_do_chan(self.chan)
- task.write(False)
- if __name__ == '__main__':
- dig_0 = DO('/cDAQ1Mod1/port0/line0')
- dig_0.high()
- time.sleep(2)
- #dig_0 = DI('/cDAQ1Mod4/port0/line0/')
- #if(dig_0.read()):
- # print('High')
- #else:
- # print('Low')
- #with nidaqmx.Task() as task:
- # task.do_channels.add_do_chan('/cDAQ1Mod1/port0/line0')
- # task.write(False)
Advertisement
Add Comment
Please, Sign In to add comment