I am controlling two solenoid valves using an NI 9482 relay. The first valve will open 500 ms after beginning the program, and the second needs to open anywhere from 15-50 ms after the first valve. There is also a pressure check which will terminate the while loop and close the valves if the pressure does not reach 50 psig within a specified amount of time. When I write to the file to determine when the valves opened, the difference between the x-values are about 100 ms, when I need the while loop to iterate at most every 5-10 ms. What are some suggestions for timing this while loop to run every 5 ms OR just run faster so that the x-values have a deltax of less than 5 ms? Thanks.
While loop execution time is generally determined by the code that is present in the while loop. Since you are using express VI's you may have trouble getting the loop time down to 5-10 ms. One way you could improve the execution timing of your code is by using the DAQmx Control Task VI instead of the DAQmx Start Task VI. By doing this you can set the state of your DAQ device to commit. This programs your hardware according to the task you have configured. I would also suggest moving some express VI's outside the while loop if possible as this will increase loop execution speed.
You could also look into implementing Timed Loops to get more precise timing control. Information on how to do this is linked in the Knowledge Base Article below.
Link: Timed Loop
I hope this information helps!
Thank you for your reply. Last week I improved the while loop iteration time to 3 ms by removing the pressure check which utilized the DAQ Assistant. I also created a producer/consumer loop to write the data in a separate while loop, but that change did not improve the speed of the loop, so I reverted back to one while loop. Today, however, the fastest this loop will run is 10 ms with several loops running at 0 ms so I'm getting duplicate data points. Do you have any clue why I have this huge timing change after altering nothing over the weekend (I attached my current VI)? Thanks.
I was able to take a look at your VI, and when I ran it for a duration of 3-8 seconds it seemed that the loop iteration time was about 3 ms which coincides with the time you were getting when you first made changes to the loop. One reason you might be seeing a slow down is because you may have other programs running that could be utilizing the resources of your computer. I would also suggest closing other LabVIEW programs that you may have running and see if that changes the iteration speed of the loop.