Parth Posted July 19 Share Posted July 19 Hello everyone, I am trying to control a vacuum pump using the miniLab 1008. By control i mean, i have to turn it on and off. I am using mcculw API for that and trying to write a code that can do that. Till now i am unable to find it. I would be really thankful if some of you can help me with it. Link to comment Share on other sites More sharing options...
DAQman Posted July 19 Share Posted July 19 Try the code below. It will set DIO0, DIO1, DIO2, and DIO3 low. Then, it will turn them on one at a time. from __future__ import absolute_import, division, print_function from builtins import * # @UnusedWildImport from time import sleep from mcculw import ul from mcculw.enums import DigitalIODirection, DigitalPortType, InterfaceType from mcculw.device_info import DaqDeviceInfo try: from console_examples_util import config_first_detected_device except ImportError: from .console_examples_util import config_first_detected_device def run_example(): board_num = 0 board_index = 0 find_device = "miniLab-1008" board_num = -1 ul.ignore_instacal() dev_list = ul.get_daq_device_inventory(InterfaceType.USB) if len(dev_list) > 0: for device in dev_list: if find_device in str(device): print(f"Found {str(device)} board number = {board_index}") print(f"Serial number: {device.unique_id}") print(f"Product type: {hex(device.product_id)}") board_num = board_index ul.create_daq_device(board_num, device) board_index = board_index + 1 if board_num == -1: print(f"Device {find_device} not found") return else: print("No devices detected") return # **********End of Discovery************ try: ul.d_config_port(board_num, DigitalPortType.AUXPORT, DigitalIODirection.OUT) ul.d_out(board_num, DigitalPortType.AUXPORT, 0) sleep(1.0) for i in range(0, 4): bit_value = 2 ** i ul.d_bit_out(board_num, DigitalPortType.FIRSTPORTA, i, bit_value) sleep(1.0) # example of delay print('Setting line', i, 'to', bit_value) except Exception as e: print('\n', e) finally: ul.release_daq_device(board_num) if __name__ == '__main__': run_example() Link to comment Share on other sites More sharing options...
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