Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

USB845x single DIO pulse with specific length

Solved!
Go to solution

Hi, I have integrated the USB845x using python ctypes to use the DIO. I want to output a single pulse with the length of 10 microsecond. However, I am able to do it with the minimum length of 250 microsecond using the C API. Maybe there is a overhead of using python to access the NI USB845x. Is there a specific code to make sure it pulse maximum of 10 microsecond?

Here is my code for the python DIO pulse:

portNum = 0
    lineNum = 0
    writeData = 1
    offData = 0
    check_error(ni845x_dll.ni845xDioWriteLine(dev_handle,portNum, lineNum, writeData))
    # time.sleep(0.00001)
    start = time.perf_counter()
    while (time.perf_counter() - start) < 10e-6:
        pass
    check_error(ni845x_dll.ni845xDioWriteLine(dev_handle,portNum, lineNum, offData))

I have tried time.sleep and even run it without both type of delay. The smallest will still be 200+ microsecond.
Thanks in advanced.
0 Kudos
Message 1 of 3
(208 Views)
Solution
Accepted by topic author RudyTS

You are hitting a limit of using Windows/software timing.  What you really need is a counter output (if using a DAQ) or Function Generator that can output a pulse.  If on a hardware budget, I would probably just get a Raspberry Pi Pico and program it to do my pulse.  Even a Pi5 might be able to do it (I have not played around with one yet, so I do not know what kind of timing is possible on it).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 3
(177 Views)

@RudyTS wrote:

Hi, I have integrated the USB845x using python ctypes to use the DIO. I want to output a single pulse with the length of 10 microsecond. However, I am able to do it with the minimum length of 250 microsecond using the C API. Maybe there is a overhead of using python to access the NI USB845x. Is there a specific code to make sure it pulse maximum of 10 microsecond?

Here is my code for the python DIO pulse:

portNum = 0
    lineNum = 0
    writeData = 1
    offData = 0
    check_error(ni845x_dll.ni845xDioWriteLine(dev_handle,portNum, lineNum, writeData))
    # time.sleep(0.00001)
    start = time.perf_counter()
    while (time.perf_counter() - start) < 10e-6:
        pass
    check_error(ni845x_dll.ni845xDioWriteLine(dev_handle,portNum, lineNum, offData))

I have tried time.sleep and even run it without both type of delay. The smallest will still be 200+ microsecond.
Thanks in advanced.

You're using the wrong hardware for the job. 845x DIO are supposed to be used for non-time restricted operations like setting some relays or mode signals on your DUT along with I2C/SPI communication. You need a M or X-series DAQ at least to generate the 10us pulse.

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 3 of 3
(173 Views)