05-09-2023 09:36 AM
Hello all ,
I have VI , which has 3 while loop inside and some CAN send recive code inside these while loop.
I am facing issue when I run the VI 1st time inside code doesn't execute and if I stop and re-run ,try like this for 2 ,3 times, VI executes properly.
Why is it behaves like this, please give me some inputs to improve my code ..
Thanks
05-09-2023 09:40 AM
Maybe you should include the code in the post.
05-09-2023 09:45 AM
@AnilB953550 wrote:
I am facing issue when I run the VI 1st time inside code doesn't execute and if I stop and re-run ,try like this for 2 ,3 times, VI executes properly.
This typically points to a race condition and/or an error (hardware, file IO, etc). Impossible to give any other advice without seeing your code.
05-09-2023 10:19 AM
thanks for responding ,
attached my VI .
thank you .
05-09-2023 10:44 AM
You have a TON of race conditions due to all of the local variables you have everywhere. There are several things that do not need constantly done, so those should be moved to before the loops, such as reading the channel names from the configuration file. Then work on removing every since local variable from your VI, most of which can be replaced with simple wires. Wires ensure data flow.
For any more advice, I highly recommend you follow the getting started links at the top of the LabVIEW forum.
05-09-2023 12:53 PM
To iterate what has been said, I agree that your program shows a glaring misunderstanding of LabVIEW and basic dataflow principles. LabVIEW does not execute left to right. Execution order is solely determined by dataflow and any disconnected code island can execute in parallel.
You need to start with the basic tutorials before diving into the deep end and making every possible mistake.
Race conditions and blatant overuse of local variables have been mentioned. Here's just the tip of the iceberg!
For example (right part of picture) parsing the U8 array according to the rules does NOT need anything pink! Code for that would probably fit on a postage stamp!
05-09-2023 01:03 PM
@altenbach wrote:
For example (right part of picture) parsing the U8 array according to the rules does NOT need anything pink! Code for that would probably fit on a postage stamp!
This would basically do exactly the same. And if you would use an array or cluster indicator, one indicator terminal would replace all the green terminals.
05-10-2023 06:00 AM
Thanks for your reply.
Surely i will more learn.
Thanks for the tips I'll update my code.