01-31-2019 08:25 AM
Hi, this is a really interesting problem that I am facing. I created a flat sequence structure and it works fine with a New VI. But it does not work after integrating it with another While loop. I will attach both of the VIs to the topic.
To make it clear, please run "Works.vi" file to see the Flat sequence structure that works fine. Then run "Does not works.vi" with an Arduino Mega. Then you will see that it does not work for the time I set for it and it only works like blinking.
Best
01-31-2019 08:40 AM
I can't run your code because I don't have an Arduino. But I think the problem has nothing to do with the Arduino.
You need to rearchitect your entire program. Even the "Works" VI has issues with it being really long running code. It is not scalable.
The Not Works code is worse because you've make is less scalable by having multiple while loops all doing the same things for different items.
What I see is an abuse of local variables. You are writing to local variables of indicators at the bottom, while you are simultaneously writing to them in each of those loops. That is called a race condition. The different parts of code are battling each other as to what to display in the indicators.
01-31-2019 08:42 AM
I didn't quite understand what your definition of works vs. worksn't is, but I'd guess it has to do with you putting many different while loops, with wildly different stop conditions in a larger while loop. the larger while loop will only complete an iteration, once all the loops inside have stopped. What's more is, that the flat sequence takes 45+ seconds (that's when I stopped adding those delays up) seconds to complete a single iteration.
I suggest you look into bundling some functionality:
You might think, you need to execute them in parallel for some requirement you have, but the N chan VI will do that. If it doesn't exist, the For loop iterating through, will probably still be as fast as your solution.
These are your two main problems. You can learn the concepts I mentioned in the many free tutorials online.
01-31-2019 08:50 AM
Hi PeterFoerster, thank you for kind answer,
First, without stop buttons inside each loop does not respond anything. I thought it is necessary. Surely, there is a better way to do that. Secondly, I could not create a timed duty series without Flat sequence structure.
I am still new in Labview. Can you please show me a better way to do that? I will be really appreciated if you fix it and attach it to the issue 🙂
Best
01-31-2019 09:01 AM
Sure I can!
So for the flat sequence, what you want to do is learn about auto indexing for loops. What it does is, when you wire an array of values to a for loop, it will go through them one by one with each iteration. So you'd just have to put the content of a single sequence frame into the for loop and wire the auto-indexing tunnel to the variable.
E.g.: Create an array with values [0 1 2 3 4], which will result in the for loop executing 5 times giving you 0 on the first iteration, 1 on the second and so on... Replace 0 to 4 with the values you need for that variable (or timing value for that matter)
Here's a video tutorial on the concept: https://www.youtube.com/watch?v=LpmG6b4uzmg
Feel free to post, when you're stuck with the implementation.
As for solving it for you: I think it'd be a terrible waste of a learning opportunity.
01-31-2019 09:30 AM
Hi again,
Thank you for your advance answers. But the problem is I really have no time. I see that the LabView is a great program to learn. I only want someone "feels free to be that one 🙂 " to show me the solution. Then I can understand the solution. I have to implement it and at least run it. The "Works.vi" actually fine but it is not working with the main vi that I have to run.
To be honest, I want to learn this program advance. But now, I have to find a solution to this issue.
Best
01-31-2019 11:04 AM
@H1636 wrote:
Thank you for your advance answers. But the problem is I really have no time. I see that the LabView is a great program to learn.
Both programs are highly flawed and it seems you already wasted a lot of time creating a gigantic diagram with tons of duplicate code. If you had spend 50% of that time on LabVIEW tutorials, you would already have a perfectly working scalable program. Both of your current programs are highly flawed and full of race conditions so the "works/not work" distinction could be just that the race conditions are exposed more in one version. Both are bad!
(For example, for all progress bars you are writing to the terminal and reading from a local variable of that same terminal in parallel and the outcome critically depends on the order of operations, but that order is random. In addition, you also write to another local variable in parallel elsewhere. All you get is a cacophony of race conditions.)
As I said, you could have written functional code (after some tutorials) using 5% of the current code and in 5% of the time. Use arrays of clusters for the bottom part and a 2D array of gauges, etc. and write scalable code. The entire diagram would probably be the size of a postcard!
It is not clear why you were asked to write this code, because obviously you are not qualified. If you need a turnkey solution, you might want to hire someone to do it for you.
02-01-2019 03:48 PM
Hi everyone,
I have a problem with my VI. I attached the program. I have a time sequence structure and it works well alone without connecting anything. But after connecting it to an Arduino, Arduino stops the connection.
How to solve this problem?
Best
02-01-2019 04:05 PM
This seems to be a continuation of your original thread. You still haven't addressed the flaws brought up in that thread. I suspect what you are talking about here is the same or a similar symptom as you were having before.
This message has been merged into that thread, so that people who might reply to this one will have benefit of seeing the history of your messages.
02-02-2019
02:50 PM
- last edited on
12-16-2024
12:06 PM
by
Content Cleaner
I tried it many times. I watched many tutorials and solved some of the problems. At the end, I have still the same problem.. If I run the test of the program connection lost. This is the main problem. Please sent me a tutorial or a page that explain this issue. Here is the last version of my VI. I asked it many professors here in my country. They are not good at it and they even do not know the basics of it.
Please help me. Sent me a tutorial, a page.. a thing that shows the problem.
http://www.ni.com/newsletter/51735/en/