From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

USB-6501 Drive Type configuration with Python nidaqmx and NI MAX

Hi NI team,

 

We're having difficulty with USB-6501 and the software and hoping you can help. Our system has:

    1.  DELL Windows 10 Enterprise x64 computer

    2.  2 NI USB-6501 in our test fixture hooked up to the Win10 computer via the included USB cables, and a relay driver IC on the DIOs

    3.  NI MAX Version 2022 Q3 with NI DAQmx

    4.  Python 3.10 and nidaqmx 0.6.5 from https://pypi.org/project/nidaqmx/

 

This page, https://www.ni.com/docs/en-US/bundle/usb-6501-feature/page/digital-output.html, says two things:

    1.  "The default configuration of the NI USB-6501 DIO ports is open collector, allowing 5 V operation, with an onboard 4.7 kΩ pull-up resistor."

    2.  "Additionally, you can configure the DIO ports as active drive. When configured as active drive, the total current sourced by all DO lines simultaneously should not exceed 65 mA."

 

This page, https://www.ni.com/docs/en-US/bundle/usb-6501-specs/page/specs.html, says:

 

Output driver type

Active drive (push-pull) or open collector (open-drain), software selectable

 

Since Active Drive is configurable and software selectable, how does one toggle between both (we want to know how to change to either mode any time we need) Active Drive and Open Collector in:

    1.  NI MAX

             a. So we can always do it manually, as needed. We don't see any option in the Test Panel. Right-clicking in the Device Tree has no Configure option.

    2.  Python nidadmx package

             a.  We're confused by the API. It doesn't tell you what the full line(s) of code should look like https://nidaqmx-python.readthedocs.io/en/latest/do_channel.html#nidaqmx._task_modules.channels.do_ch...

             b. Can you provide a full code example to configure the DAQs' drive type? We tried this and it doesn't work (and we'll need all Ports and Lines later):

 

    import nidaqmx
    from nidaqmx.constants import DigitalDriveType

 

    with nidaqmx.Task() as task_dev1_all, nidaqmx.Task() as task_dev2_all:
        task_dev1_all.do_channels.add_do_chan("Dev1/port0/line0:7")
        task_dev1_all.do_channels.do_output_drive_type(DigitalDriveType.ACTIVE_DRIVE)
        task_dev2_all.do_channels.add_do_chan("Dev2/port0/line0:7")
        task_dev2_all.do_channels.do_output_drive_type(DigitalDriveType.ACTIVE_DRIVE)
0 Kudos
Message 1 of 13
(1,925 Views)

The mistake is that you're treating a 'property' as a 'method'

 

 
import nidaqmx
from nidaqmx.constants import DigitalDriveType

with nidaqmx.Task() as task_dev1_all, nidaqmx.Task() as task_dev2_all:
    task_dev1_all.do_channels.add_do_chan("Dev1/port0/line0:7")
    task_dev1_all.do_channels.do_output_drive_type = DigitalDriveType.ACTIVE_DRIVE
    task_dev2_all.do_channels.add_do_chan("Dev2/port0/line0:7")
    task_dev2_all.do_channels.do_output_drive_type = DigitalDriveType.ACTIVE_DRIVE
Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 2 of 13
(1,901 Views)

Thanks, santo_13. The code executes without crashing, but no change occurs to the DAQ. We put a voltmeter on the DAQ pins, which still show high output above 3.3 V (so still Open Collector pulled to 5 V) when we toggle them high via NI MAX (which doesn't show any option to configure drive type). Is there something missing?

0 Kudos
Message 3 of 13
(1,874 Views)

With a fresh-out-of-the-box USB-6501 we tried this (stepping through to observe the changes on a voltmeter) and it only changed one port0 line 0 to high open collector. The same thing happens with our original 2 DAQs.

 

    with nidaqmx.Task() as task_dev3:
        task_dev3.do_channels.add_do_chan("Dev3/port0/line0:7")
        task_dev3.do_channels.do_output_drive_type = DigitalDriveType.ACTIVE_DRIVE
        task_dev3.write([False, False, False, False, False, False, False, False], auto_start=True)
        task_dev3.wait_until_done(1.0)
        task_dev3.write([True, True, True, True, True, True, True, True], auto_start=True)
        task_dev3.wait_until_done(1.0)
        task_dev3.close()
 
0 Kudos
Message 4 of 13
(1,864 Views)

It is weird that the settings reflect on only one line. Do you have the means to try the same on .NET or LabVIEW?

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 5 of 13
(1,843 Views)

Hi santo_13,

 

.NET or LabVIEW? Not at this time, and our project requires things to run in Python.

 

    import nidaqmx
    from nidaqmx.constants import DigitalDriveType

    NUM_DAQ_DEV = 2
    NUM_DAQ_PORT = 3
    NUM_DAQ_LINE = 8

 

    # This executed without error 1.19.2023, but the actual DAQ voltages are not >= 2 V as per the USB-6501 spec, and, the drive type doesn't seem changed.
    i = 1
    j = k = 0
    for i in range(1, NUM_DAQ_DEV + 1):
        for j in range(0, NUM_DAQ_PORT):
            for k in range(0, NUM_DAQ_LINE):
                with nidaqmx.Task() as task:
                    task.do_channels.add_do_chan(f"Dev{i}/port{j}/line{k}")
                    task.do_channels.do_output_drive_type = DigitalDriveType.ACTIVE_DRIVE
                    task.write([True], auto_start=True)
                    task.wait_until_done(1.0)
    task.close()
0 Kudos
Message 6 of 13
(1,759 Views)

What was your load current?

 

Spec guarantees 2V with up to 7.5/8.5mA load.

santo_13_0-1674620904156.png

 

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 7 of 13
(1,750 Views)

Hi santo_13,

 

This occurred even with no load on the "fresh" DAQ after having run that code above. The actual voltages vary wildly across different lines & ports. Have you been able to run the Python code and observe proper drive & voltage performance with the same model of DAQ?

0 Kudos
Message 8 of 13
(1,733 Views)

Unfortunately, I don't have the hardware to try it out. I am guiding you based on my experience with several other DAQ devices.

 

If you believe your device is not performing to its specifications, you could raise a support ticket with NI to get it repaired/replaced.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 9 of 13
(1,727 Views)

Hi RoboPuppy,

 

I was running into the exact same issue - after monitoring the driver calls behind the scenes, I can see that your current code is not actually setting the output drive type.

 

The code below worked for me instead (of course, change the device name/task name accordingly for your script):

 

import nidaqmx
from nidaqmx.constants import DigitalDriveType

with nidaqmx.Task() as task:
	do_channel = task.do_channels.add_do_chan("Dev1/port0/line7")
	print("Mode before: ", do_channel.do_output_drive_type)
	do_channel.do_output_drive_type = DigitalDriveType.ACTIVE_DRIVE
	print("Mode after: ", do_channel.do_output_drive_type)

 

0 Kudos
Message 10 of 13
(1,322 Views)