TexasMatt Posted August 7, 2023 Share Posted August 7, 2023 Hello, Anybody else noticed that calling v_in.py is changing the state of the digital output lines? when this function gets called ' value = ul.v_in_32(board_num, channel, ai_range)' then the USB-1808 DIGITAL lines are being reset to 0. Link to comment Share on other sites More sharing options...
0 DAQman Posted August 9, 2023 Share Posted August 9, 2023 Hello, The ul.d_config_port function will reset the port but not the ul.v_in_32 function. I used the program below to verify what I said. At the completion of the program, the digital outputs remained high. Best regards, John from __future__ import absolute_import, division, print_function from builtins import * # @UnusedWildImport from mcculw import ul from mcculw.device_info import DaqDeviceInfo from mcculw.enums import DigitalIODirection, DigitalPortType try: from console_examples_util import config_first_detected_device except ImportError: from .console_examples_util import config_first_detected_device def run_example(): # By default, the example detects and displays all available devices and # selects the first device listed. Use the dev_id_list variable to filter # detected devices by device ID (see UL documentation for device IDs). # If use_device_detection is set to False, the board_num variable needs to # match the desired board number configured with Instacal. use_device_detection = True dev_id_list = [] board_num = 0 try: if use_device_detection: config_first_detected_device(board_num, dev_id_list) daq_dev_info = DaqDeviceInfo(board_num) if not daq_dev_info.supports_analog_input: raise Exception('Error: The DAQ device does not support ' 'analog input') print('\nActive DAQ device: ', daq_dev_info.product_name, ' (', daq_dev_info.unique_id, ')\n', sep='') ul.d_config_port(board_num, DigitalPortType.AUXPORT, DigitalIODirection.OUT) ul.d_out(board_num, DigitalPortType.AUXPORT, 15) ai_info = daq_dev_info.get_ai_info() ai_range = ai_info.supported_ranges[0] channel = 0 # Get a value from the device if ai_info.resolution <= 16: # Use the v_in method for devices with a resolution <= 16 # (optional parameter omitted) value = ul.v_in(board_num, channel, ai_range) else: # Use the v_in_32 method for devices with a resolution > 16 # (optional parameter omitted) value = ul.v_in_32(board_num, channel, ai_range) # Display the value print('Value:', value) except Exception as e: print('\n', e) finally: if use_device_detection: ul.release_daq_device(board_num) if __name__ == '__main__': run_example() Link to comment Share on other sites More sharing options...
0 TexasMatt Posted August 9, 2023 Author Share Posted August 9, 2023 Hi John, If you run the example code you posted -- you are correct the DOUT line state is not changed when v'ul.v_in_32(x,y,z) is called. BUT In my application the DOUT is configured in one step. then later the Analog Input is read. I can repeat the behaviour with your example code, made into 2 parts: save part1 as a .py, run it. Observe the DOUTs go high. save part2 as a .py, run it. Observe the DOUTs are reset when the function 'ul.v_in32' is called. I did strip out the "config_first_detected" call, which also resets the DOUT state. I see similar behaviour when using the Analog Outputs. Writing to AO1 will reset AO0. ---part1 start-- from __future__ import absolute_import, division, print_function from builtins import * # @UnusedWildImport from mcculw import ul from mcculw.device_info import DaqDeviceInfo from mcculw.enums import DigitalIODirection, DigitalPortType try: from console_examples_util import config_first_detected_device except ImportError: from .console_examples_util import config_first_detected_device def run_example(): # By default, the example detects and displays all available devices and # selects the first device listed. Use the dev_id_list variable to filter # detected devices by device ID (see UL documentation for device IDs). # If use_device_detection is set to False, the board_num variable needs to # match the desired board number configured with Instacal. use_device_detection = True dev_id_list = [] board_num = 0 try: if use_device_detection: config_first_detected_device(board_num, dev_id_list) daq_dev_info = DaqDeviceInfo(board_num) if not daq_dev_info.supports_analog_input: raise Exception('Error: The DAQ device does not support ' 'analog input') print('\nActive DAQ device: ', daq_dev_info.product_name, ' (', daq_dev_info.unique_id, ')\n', sep='') ul.d_config_port(board_num, DigitalPortType.AUXPORT, DigitalIODirection.OUT) ul.d_out(board_num, DigitalPortType.AUXPORT, 15) except Exception as e: print('\n', e) finally: if use_device_detection: ul.release_daq_device(board_num) if __name__ == '__main__': run_example() ---part1 end--- ---part2 start-- from __future__ import absolute_import, division, print_function from builtins import * # @UnusedWildImport from mcculw import ul from mcculw.device_info import DaqDeviceInfo from mcculw.enums import DigitalIODirection, DigitalPortType try: from console_examples_util import config_first_detected_device except ImportError: from .console_examples_util import config_first_detected_device def run_example(): # By default, the example detects and displays all available devices and # selects the first device listed. Use the dev_id_list variable to filter # detected devices by device ID (see UL documentation for device IDs). # If use_device_detection is set to False, the board_num variable needs to # match the desired board number configured with Instacal. use_device_detection = True dev_id_list = [] board_num = 0 try: channel = 0 # Use the v_in_32 method for devices with a resolution > 16 # (optional parameter omitted) value = ul.v_in_32(0, channel, 1) # Display the value print('Value:', value) except Exception as e: print('\n', e) finally: if use_device_detection: ul.release_daq_device(board_num) if __name__ == '__main__': run_example() --end part2-- Link to comment Share on other sites More sharing options...
0 DAQman Posted August 9, 2023 Share Posted August 9, 2023 Here's what I think may be happening. Part 1 destroys the USB-1808 object by calling release_daq_device when it exits. Then in Part 2, you create a new object using board number zero when v_in_32 is called for the first time, and this new object may be responsible for resetting the device. Remove the release_daq_device function at the end of Part 1 and retest. John Link to comment Share on other sites More sharing options...
0 TexasMatt Posted September 4, 2023 Author Share Posted September 4, 2023 Hi John, Thank you for looking into this. Still having this problem. -removing 'release_daq_device' function does not fix the problem when calling 'value = ul.v_in_32(board_num, channel, ai_range)' the AUXPORT values are being reset. Of course this is a problem as I'm using the DOUT function to configure a DUT then attempting to use analog inputs to take some measurements. Any way to set digital outputs then later take a analog measurement? Link to comment Share on other sites More sharing options...
0 DAQman Posted September 5, 2023 Share Posted September 5, 2023 Please attach your .py program file. Link to comment Share on other sites More sharing options...
0 DAQman Posted September 5, 2023 Share Posted September 5, 2023 I believe you are using two separate programs called part1.py and part2.py. The first one to configures the outputs and the second one reads a voltage. When the first program runs, Windows assigns a process space for it to run in. Your program and our library are loaded into this space. Within this environment your program can make calls into our library to set digital IO and read voltages. However, when the program ends, everything is unload and the process space is destroyed. Then, the next program runs and the same thing happens. However, the one thing you're overlooking is that when the library loads, it resets the device and that is why your digital output return to be inputs. Link to comment Share on other sites More sharing options...
0 TexasMatt Posted September 7, 2023 Author Share Posted September 7, 2023 digital_out.py (attached) is run to set digital outputs. later in time, v_in.py (attached) is called to read analog inputs. there is another application (labview) calling these modules. I can run v_in.py in debug mode and step through the program, the digital outputs are reset when 'ul.v_in_32(board_num, channel, ai_range)' is called. part1.py, part2.py we're just used to demonstrate the behaviour digital_out.py v_in.py Link to comment Share on other sites More sharing options...
0 DAQman Posted September 7, 2023 Share Posted September 7, 2023 You have two separate programs. Digital_out uses device detection and v_in uses the board number assigned by InstaCal. They both just happen to be board number zero and both reset the device when run. Link to comment Share on other sites More sharing options...
Question
TexasMatt
Hello,
Anybody else noticed that calling v_in.py is changing the state of the digital output lines?
when this function gets called ' value = ul.v_in_32(board_num, channel, ai_range)'
then the USB-1808 DIGITAL lines are being reset to 0.
Link to comment
Share on other sites
8 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now