Hello,
I would like to perform a task with very high precision (preferably to within at least a microsecond of precision) using Python and the NI-DAQmx API that involves performing several task.start() and task.stop() calls at very particular times for separate tasks. I am attempting to determine whether or not a signal I am reading has a duty cycle, and if it doesn't, whether or not it is High or Low, and need to perform this task within a very short amount of time (preferably less than 0.1 ms.) It appears that there is not an existing function in the NI DAQmx API that can handle both duty cycle measurement and a digital (high/low) input measurement. In this case, my plan is to measure the signal from a digital input task to determine if it is high or low. Then, to confirm that it does not have a duty cycle, I intend on using the add_ci_pulse_chan_freq, as the add_ci_duty_cycle_chan function does not appear to be supported on this device, to determine the duty cycle, if it exists. Given that calling the read() function on the add_ci_pulse_chan_freq task will result in a timeout if the signal is High or Low (i.e. does not have a duty cycle), I intend on calling the read() function for the add_ci_pulse_chan_freq task with a timeout time of either 0 or a very small (i.e. < 0.0001 s) amount of time, and catching the error as an exception so that my code continues to compile. Since these tasks (add_ci_pulse_chan_freq and add_di_chan) share the same pin/resource name, I'll need to be starting and stopping them very quickly, as they can't run using the same resource. I am concerned that Python is not inherently quick enough to precisely handle the starting and stopping of these tasks, as I believe that Python can often have delays of up to 20 ms between function calls (although I am not sure if this in fact the case, especially on a PXI.) Are there any resources available (preferably existing code in Python, if any exists) that provide methodology that can be used to 'schedule' task start/stop times ahead of time? Alternatively, if there is an existing function or other methodology that is capable of performing both duty cycle or digital input measurements at the same time (which I don't believe there is) on the same resource line, please let me know.
I believe that most functions inherently handle this problem by utilizing cfg_samp_clk_timing to set a sampling rate, however given that the two functions share resources, I believe that method unfortunately is not an option here.
Similarly, are there ways to access the precision clocking available on the PXI from Python? Given that time.sleep() is not very accurate for shorter time intervals, I was wondering if there is a way to ensure that a specified amount of time has passed/elapsed with a very high level of precision. I am using a PXI-6612 module on a PXI 1085 chassis.
↧
Determine if a signal has a duty cycle or if it is digital high/low on a PXIe-6612?
↧