07-31-2024 09:37 PM
I don't want the while loop to have a delay (wait (ms)). I already know this code is flawed. How can I make it better?
Solved! Go to Solution.
07-31-2024 09:42 PM
What are you trying to achieve?
What do you exactly mean by "no delay"?
08-01-2024 01:01 AM
@GRCK5000 wrote:
I don't want the while loop to have a delay (wait (ms)). I already know this code is flawed. How can I make it better?
08-01-2024 01:04 AM - edited 08-01-2024 01:09 AM
Hi GRCK,
@GRCK5000 wrote:
How can I make it better?
Elapsed time is defined as difference between two timestamps: why don't you calculate the difference between two timestamps???
One option:
(Still no need to calculate "elapsed time" millions of times per second…)
@GRCK5000 wrote:
I already know this code is flawed.
Most of your code was "flawed" until now… 😄
One item in your VI: why is there an arbitrary constant used in your calculation and WHY is there NO comment/information about the meaning of that value???
08-01-2024 05:48 AM - edited 08-01-2024 05:50 AM
Maybe you mean that the wait may executes before your code in highlight execution. This is not what happens in reality. Highlight execution puts everything in some sequential order.
08-01-2024 07:22 AM
Thanks Gerd! This is what I was trying to achieve. smh.
To answer your questions, I was just trying stuff. I like trying different things.
08-01-2024 08:24 AM
A Timer without a "clock" makes no sense! You persist on worrying about the "How" (do I do such-and-such) instead of considering the "What" (is it that I ultimately want to do?).
You have a While loop that "does something". What do you want to know about this loop? If it is doing "repetitive things", it may make sense to replace the While with a For, wiring N = 1000, and see how long it takes to loop 1000 times (so that the "cost" in time of timing the loop might be small compared to the time executing the contents of the Loop).
Remember IBM's Company Motto!
Bob Schor
P.S. -- I'm prepared to be "wrong" about the Motto.
08-01-2024 11:03 AM - edited 08-01-2024 11:07 AM
How about this?
I mean I get it we all hate Express VIs but sometime the easiest solution works.
08-01-2024 11:23 AM - edited 08-01-2024 11:24 AM
We could even wrap the following into a reentrant subVI.
Still, the express VI has some additional baggage that can be useful, such as reset, auto-reset, alarms, formatted time output, start time setting, etc, etc.. Here's the converted block diagram of it: I prefer not to carry all that along.