Loading ADoutputs.py +81 Changes for ADoutputs.py: 81 added lines, 0 removed lines. Original line number Diff line number Diff line # -*- coding: utf-8 -*- """ Created on Wed May 30 15:27:17 2018 @author: martindrech """ from __future__ import absolute_import, division, print_function from mcculw import ul from mcculw.enums import DigitalIODirection, ULRange from examples.props.digital import DigitalProps from examples.props.ao import AnalogOutputProps from mcculw.ul import ULError ao_range = ULRange.BIP10VOLTS class daq_DO(object): def __init__(self, out_num): self.board_num = 0 self.digital_props = DigitalProps(self.board_num) # Find the first port that supports output, defaulting to None # if one is not found. self.port = next( (port for port in self.digital_props.port_info if port.supports_output), None) # If the port is configurable, configure it for output if self.port != None and self.port.is_port_configurable: try: ul.d_config_port( self.board_num, self.port.type, DigitalIODirection.OUT) except ULError as e: self.show_ul_error(e) self.out_num = out_num def set_digital_out(self, bit_value): try: # Output the value to the board ul.d_bit_out(self.board_num, self.port.type, self.out_num, bit_value) except ULError as e: self.show_ul_error(e) def get_digital_out(self): try: state = ul.d_bit_in(self.board_num, self.port.type, self.out_num) print(state) except ValueError: return 0 class daq_AO(object): def __init__(self, out_num): self.board_num = 0 self.ao_props = AnalogOutputProps(self.board_num) self.out_num = out_num def set_analog_out(self, value): #ao_range = self.ao_props.available_ranges[0] try: ul.v_out(self.board_num, self.out_num, ao_range, value) except ULError as e: self.show_ul_error(e) def get_analog_out(self): #ao_range = self.ao_props.available_ranges[0] try: state = ul.a_in(self.board_num, self.out_num, ao_range) print(state) except ValueError: return 0 ###################################################################################### No newline at end of file Loading
ADoutputs.py +81 Changes for ADoutputs.py: 81 added lines, 0 removed lines. Original line number Diff line number Diff line # -*- coding: utf-8 -*- """ Created on Wed May 30 15:27:17 2018 @author: martindrech """ from __future__ import absolute_import, division, print_function from mcculw import ul from mcculw.enums import DigitalIODirection, ULRange from examples.props.digital import DigitalProps from examples.props.ao import AnalogOutputProps from mcculw.ul import ULError ao_range = ULRange.BIP10VOLTS class daq_DO(object): def __init__(self, out_num): self.board_num = 0 self.digital_props = DigitalProps(self.board_num) # Find the first port that supports output, defaulting to None # if one is not found. self.port = next( (port for port in self.digital_props.port_info if port.supports_output), None) # If the port is configurable, configure it for output if self.port != None and self.port.is_port_configurable: try: ul.d_config_port( self.board_num, self.port.type, DigitalIODirection.OUT) except ULError as e: self.show_ul_error(e) self.out_num = out_num def set_digital_out(self, bit_value): try: # Output the value to the board ul.d_bit_out(self.board_num, self.port.type, self.out_num, bit_value) except ULError as e: self.show_ul_error(e) def get_digital_out(self): try: state = ul.d_bit_in(self.board_num, self.port.type, self.out_num) print(state) except ValueError: return 0 class daq_AO(object): def __init__(self, out_num): self.board_num = 0 self.ao_props = AnalogOutputProps(self.board_num) self.out_num = out_num def set_analog_out(self, value): #ao_range = self.ao_props.available_ranges[0] try: ul.v_out(self.board_num, self.out_num, ao_range, value) except ULError as e: self.show_ul_error(e) def get_analog_out(self): #ao_range = self.ao_props.available_ranges[0] try: state = ul.a_in(self.board_num, self.out_num, ao_range) print(state) except ValueError: return 0 ###################################################################################### No newline at end of file