11-09-2010 12:21 AM
Hi
This is a simple program which repeatedly adds a number once you define the step size of the number. Shift register is also being used. suppose if the no. is 9 and the step size is 1 then the result should be 10, but it is not so. what is wrong with the program?
11-09-2010 12:41 AM
If you are changing the "number" control after the program starts, you wont see any result. Also, your loop is spinning out of control. But a "wait" in there somewhere. Other than that I don't see any flawed logic, but it's late. What results are you getting. If we don't know what's wrong, we can't help you. All we know is you aren't getting the result you want.
11-09-2010 03:55 AM
Just add the wait function, try setting it to 1000ms so you can clearly see the transition. Apart from that it works correctly, what else do you want to do with this app?
Regards,
11-09-2010 04:25 AM
Hi jkfhdskh,
May be this vi will make you understand the concept.
Regards,
Nitz..
11-09-2010 04:50 AM
Hi Nitzy,
When you run your vi please monitor your cpu usage in your windows task manager, it is pulling a lot of processing power. To rectify this, try putting a 'Wait(ms)' timing function inside your while loop and wire a constant to this, it will solve this.
Just a tip as your application might crash your computer when you use more complex functions in the future.
Regards,
11-09-2010 05:06 AM
Hi John,
This was of great use for me. I never noticed such a big flaw in this way of using while loop. Just checked after reading your message. May be this is the reason why some of the VIs in my previous projects were getting slow while running.
anyway thanks a lot...:)
Regards,
Nitz..
11-09-2010 05:14 AM
Hi Nitzy,
I'm glad I could point that out, it's a necessity when using while loops!
Always here to help 🙂
11-09-2010 08:04 AM
Your VI does work as intended. Put a wait 1 second and you will see the answer is 10 given the start numeric of 9 and and a step of 1.
Alan
11-09-2010 10:35 AM
@Nitzy wrote:
Hi John,
This was of great use for me. I never noticed such a big flaw in this way of using while loop. Just checked after reading your message. May be this is the reason why some of the VIs in my previous projects were getting slow while running.
It really depends on what you're doing. For a loop that is intended to run for a long time you do not want to have the loop steal all of the CPU processing time. Otherwise the user interface and the OS will become unresponsive. There are times, however, when you would not need to put in a delay, such as using a while loop to create a Functional Global Variable, a.k.a. Action Engine. Or, if the loop is intended to only run for a few iterations (and there's a guarantee that it will break out and not become an infinite loop).
11-13-2010 01:43 PM
@smercurio_fc wrote:
It really depends on what you're doing. For a loop that is intended to run for a long time you do not want to have the loop steal all of the CPU processing time. Otherwise the user interface and the OS will become unresponsive. There are times, however, when you would not need to put in a delay, such as using a while loop to create a Functional Global Variable, a.k.a. Action Engine. Or, if the loop is intended to only run for a few iterations (and there's a guarantee that it will break out and not become an infinite loop).
These use cases have now better workarounds in newer LabVIEW versions.