def trigger_analog_input(self, port='ai2', samples=2, rate=100.0, edge_selection='R'): ''' Using PFI to Trigger an Analog Input Acquisition in port = AI port to read, 2 by default edge_selection = Rising by default out data = read data ''' daq = NiDAQlib.trigger_analog_input('{}/{}'.format(self.dev, port), int(samples), float(rate), edge_selection) data = NiDAQlib.read_analog_io_Diff(daq, int(samples)) NiDAQlib.disconnect(daq) return data
def write_analog_io(self, port='ao0', value='5'): ''' Writing voltage value (By default 5V) to analog output port in port = AO port to read, 0 by default value = Voltage value, 5V by default out data = write data ''' daq = NiDAQlib.connect_analog_write_io_port('{}/{}'.format(self.dev, port)) data = NiDAQlib.write_analog_io(daq, value) NiDAQlib.disconnect(daq) return data
def trigger_analog_output(self, port='ao1', value='1', edge_selection='R'): ''' Using PFI to Trigger an Analog Output Generation in port = AO port to read, 1 by default value = value = Voltage value, 5V by default edge_selection = Rising by default out data = read data ''' daq = NiDAQlib.trigger_analog_output('{}/{}'.format(self.dev, port), edge_selection) data = NiDAQlib.write_analog_io_trigger(daq, value) NiDAQlib.disconnect(daq) return data
def read_analog_io_Diff(self, port1='ai2', samples=2, rate=100.0): ''' Reading analog input port, differential mode (DIFF) in port = AI port to read, 2 by default samples = The number of samples, per channel, to read. 2 by default. out data = read data ''' daq = NiDAQlib.connect_analog_io_port_Diff('{}/{}'.format(self.dev, port1), int(samples), float(rate)) data = NiDAQlib.read_analog_io_Diff(daq, int(samples)) NiDAQlib.disconnect(daq) return data
def read_analog_io_RSE(self, port='ai2', samples=2, rate=100.0): ''' Reading analog input port, referenced single-ended (RSE) in port = AI port to read, 2 by default samples = The number of samples, per channel, to read. 2 by default. out data = read data ''' daq = NiDAQlib.connect_analog_io_port_RSE('{}/{}'.format(self.dev, port), int(samples), float(rate)) data = NiDAQlib.read_analog_io_RSE(daq, int(samples)) NiDAQlib.disconnect(daq) return data
def counter(self, port='ctr0', edge_selection='R', initialCount=0, delayInReadCounter=1.0): ''' Using PFI1 as a Counter Source in port = ctr0 port to read initialCount = 0 by default edge_selection = Rising by default delayInReadCounter = 1sec by default out data = read data ''' daq = NiDAQlib.counter_setup('{}/{}'.format(self.dev, port), edge_selection, int(initialCount)) data = NiDAQlib.counter_read(daq, float(delayInReadCounter)) NiDAQlib.disconnect(daq) return data
def read_di(self, port='0', line=None): ''' Reading digital input port or line in port = DO port to read, 0 by default line = DO line to read, None by default, define a value 0...7 when reading only one line out data = read data ''' if line: daq = NiDAQlib.connect_di_line('{}/{}/{}'.format(self.dev, port, line)) else: daq = NiDAQlib.connect_di_port('{}/{}'.format(self.dev, port)) data = NiDAQlib.read_di(daq) NiDAQlib.disconnect(daq) #sleep(0.1) logger.info("DI data: {}".format(data))
def write_do(self, data, port='0', line=None): ''' Writing digital output port or line in data = byte to write, in case of single line 0/1 port = DO port to write, 0 by default line = DO line to write, None by default, define a value 0...7 when setting only one line ''' data = int(data) logger.info("testlog, Indata: {}".format(data)) if line: daq = NiDAQlib.connect_do_line('{}/{}/{}'.format(self.dev, port, line)) else: daq = NiDAQlib.connect_do_port('{}/{}'.format(self.dev, port)) NiDAQlib.write_do(daq, data) NiDAQlib.disconnect(daq)