From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
07-22-2019 10:34 AM
Sorry about the image. Here I attached VI which I drop the version to 2017 so maybe you can see the VI.
07-22-2019 10:37 AM
By the way, because it doesn't change anything if I just put the logic delay to the loop, so it would be same if I just connect the 'wait' to the inner for loop, you can just ignore the sequence structure. 😄
07-22-2019 12:06 PM
I'm trying to understand what you want to do. You want to delay the inner loop after the first iteration each time? If so then you need to put your delay in the inner loop. But you're already delaying (potentially) the inner loop with the Wait for next ms. Do you want an additional delay for the first iteration?
07-22-2019 01:34 PM
Yes, I'd like to have another delay in the inner loop but not only for the first iteration. As you can see what this program does now is that it will delay 1 more sec when the D indicator reaches 70, let's say 30,1sec,40,1sec,50,1sec,60,1sec,70,2sec until it goes to 30 in the next iteration. What I'd like to achieve is that delay 2sec in every iteration when it reaches 30 after the first iteration rather than 2sec when it's 70. So now it would be 30,1sec, 40,1sec, 50,1sec, 60,1sec, 70,1sec, 30,2sec, 40,1sec, 50,1sec, 60,1sec......
Sorry for the confusion and thanks a lot for your patience.
07-22-2019 01:55 PM - edited 07-22-2019 02:08 PM
Hi AIEXINUK,
So now it would be 30,1sec, 40,1sec, 50,1sec, 60,1sec, 70,1sec, 30,2sec, 40,1sec, 50,1sec, 60,1sec......
You really need to learn how to express simple logic dependencies!
You already learned about the Select function in previous posts.
So I guess a simple hint is enough for now:
IF i>0 AND x==30 THEN wait(2s) ELSE wait(1s) ENDIF
"i" is the iterator of the outer FOR loop…
07-22-2019 02:04 PM
Additional hint - this logic has to be in the inner loop.
07-22-2019 02:57 PM
@aputman wrote:
Wouldn't it be better to use a case structure with no wait function rather than a 0ms wait? You probably won't notice a difference but a wait of 0ms does force the thread to give up control of the CPU.
That is a good thing and allows other parallel processes to do their thing. Almost any loop short of a "crunch these number the rest of the code be damned" should at least included a "0 ms Wait" to allow other threads to update.
Ben
07-23-2019 06:25 AM
Thanks for your answers. It works.
However, If I type the values in the front panel, sometimes it will have a 2sec delay when it reaches the minimum, sometimes it doesn't. And when I click highlight execution, it shows that it has 2sec delay every time.
07-23-2019 06:35 AM - edited 07-23-2019 06:37 AM
Hi AIEXINUK,
If I type the values in the front panel, sometimes it will have a 2sec delay when it reaches the minimum,
Please define "sometimes"…
The code runs fine for me (you should have learned about the Ramp function until now):
The longer wait occurs not in the first iteration of the outer loop…
07-23-2019 06:37 AM - edited 07-23-2019 06:39 AM
Change your logic just a bit. You really want x==Dmin. This only occurs when i=0 on the inner loop. Also, you should be using the Wait (ms) function, not the Wait until next ms Multiple function. Finally, change the datatype for your wait times to U32 to match what is expected by the Wait function.
Edited to add: Looks like GerdW beat me to the punch.