mccdaq/mcculw

Configure DIO ports on ME-UBRE when connected to MiniLAB-1008

Opened this issue · 0 comments

Hello,

I am trying to configure and then set the DIO ports to hi on my setup. The setup being a minilab-1008 which is conned to ME-UBRE through the DB37 port. The end goal I want to achieve is to be able to set the DOI port to hi and then back to low after a certain time. Any help in this regard would be greatly appreciated.
The current code I have is doing this for the DIO ports on the board. but there too I get "ERROR 42: Digital port is not configured correctly for requested operation."

`
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()
`