04-02-2009 04:21 AM
I have made a subVI containing a loop which is supposed to syncronize some activities with a clock (Tick count). The SubVI also has in and outlets for errors. The error wire passes through two different case strucures inside the while loop.
As I run the program the clock seems to get stuck almost imediatly, but the loop keeps doing more and more iterations. Could this be a data flow problem, that the error wire sends the program of in the wrong direction when it's supposed to tick up the clock?
04-02-2009 04:31 AM
Seeing the block diagram the error cluster is routed into the case structure and should not affect the millisecond timer function. If the VI is struct within the VISA functions the timer will stop but are you sure that the VI is still running without hanging up in the subVI's. can you post the code so that we can probe into it.
Note:
1. As good programming practice introduce a delay in the while loop to avoid 100% CPU usage
2.Use appropriate data types to avoid coercion dots in the code that will make the code memory efficient.
04-02-2009 05:42 AM
Do you see a potential abuse of data types?
04-02-2009 05:44 AM
04-02-2009 06:05 AM
When the basic programming practices are followed without flaw the code will run without error and in your case i can see that very clearly. You have violated the programming law by not handling the errors within your loop.
When the visa read returns error the get string.vi gets struck in the while loop indefinitely since you have not handled the error case.
The programming practices and suggestions might be simple but following it you can avoid errors and debugging cycles. A developer might not anticipate many problems by not following these but in a bigger setup these will reflect and the performance of the code gets affected.
04-02-2009 06:17 AM
Hi Tzench,
I seen some of your posts, I think ur new to LabVIEW. For best programming practices go through LabVIEW basics manuals.Here i attached some usefull information for you regarding the while loop and error handling.
1) Ya as JK told your while loop got stucked in the getstrings vi without proper error handling.
2) your Vis consuming maximum CPU usage because of absence of delays inside the loops.
http://zone.ni.com/reference/en-XX/help/371361B-01/lvconcepts/error_checking_and_error_handling/
04-02-2009 06:22 AM
04-02-2009 06:42 AM
As you said:The error wire makes these loops know in which order they are supposed to be executed. As far as I knew this was a well established way of programming in LabVIEW
But you have not strictly follwed the well established way of programming .Find your mistakes in the attaached screen shots.
04-02-2009 07:38 AM
04-02-2009 09:06 AM