06-06-2024 01:59 AM
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:
Solved! Go to Solution.
06-06-2024 07:40 AM - edited 06-06-2024 07:42 AM
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).
06-06-2024 07:56 AM
@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 = 0lineNum = 0writeData = 1offData = 0check_error(ni845x_dll.ni845xDioWriteLine(dev_handle,portNum, lineNum, writeData))# time.sleep(0.00001)start = time.perf_counter()while (time.perf_counter() - start) < 10e-6:passcheck_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.