I am using a USB DAQ to control the opening and closing of two micro-fluidic water nozzles. Basically the program works by using a while loop that iterates every milisecond (with the wait until next multiple ms set to 1), and every milisecond it should check to see if it should "open the nozzle".
For example:
frequency is set to 1 Hz and High Time is set to 500 ms (this means that the digital signal is 1 Hz with 50% duty cycle)
so everytime the while loop iterates, it checks to see if
the remainder of Current Time (ms since the execution of the program) / Period is less than High Time. if this returns true then it writes the boolean value "true" to the DAQ and it opens the nozzle. if the remainder of that equation is higher or equal to High Time, then it writes the boolean value "false" to the DAQ and the nozzle closes.
in other words, during the first 500 ms, the remainder of Current Time (<500) divided by Period (1000) is always less than High Time (500) so it is true and the nozzle opens; on the 501 ms, the remainder of Current Time (501) divided by Period (1000) is 501 which is greater than High Time (500), so it is false and the nozzle closes.
My code seems to work fine until the High Time is set to less than 10 ms. Sometimes the nozzle doesn't open when it is supposed to. It just gets worse and worse as the High Time goes down.
I made a few simple VIs to test various timing issues and i have noticed the following:
1. When I set Wait until next multiple ms to 1, it doens't actually force the while loop to run every millisecond. the iteration count is actually about half of the milisecond count.
2. When I set Wait until next multiple ms to 0, the iteration count way way exeeds the milisecond count, so this proves that the while loop is capable of running at a much higher speed than the milisecond timer.
since 1 is the lowest number i can set Wait until next multiple MS, i can't seem to make the loop iterate at exactly once every ms...
i believe this is the main problem with the program. Is there any way to fix this or alternative ways to force the while loop to go once per ms? I have read some of the posts and i have seen many suggesting that Windows is incapable of sub-two-digit ms timing. Is this true?
Thank you all for your help!!
Much appreciated