Hello everyone, I'm a newbie using LabView for my project. So I'm developing a program that gathers data from sensors that attach in the DAQmx board and also a spectrometer from STS-VIS ocean optic. At the first developing, I combine both devices in one loop inside the same flat structure, but I got an error saying: "The application is not able to keep up with the hardware acquisition." I cannot get the data showing on the graph for both devices, but it was just fine if I run it separately. And I found the solution saying that I need to separate both devices in a different while loop process because it may have different buffer sizes (?). I did it and it worked that all the sensors are showing in each graph. But the weird thing is, I need to stop the program first in the first run, then run it again for the second time for getting the graph showing in the application. Can anyone tell me what I did wrong and give me a solution? Due to the project rule I cannot share my Vi here publicly, but if anyone interested to help, I'd like to share it personally. Thank you.
I did it and it worked that all the sensors are showing in each graph. But the weird thing is, I need to stop the program first in the first run, then run it again for the second time for getting the graph showing in the application. Can anyone tell me what I did wrong and give me a solution?
Simple answer: you made something wrong when programming! Software usually does what you programmed it for, but not what you imagined it could do for you!
So provide the code to get more help…
Due to the project rule I cannot share my Vi here publicly, but if anyone interested to help, I'd like to share it personally.
You could create an example VI without the "confidential stuff", that still explains/shows the buggy behaviour. Then you attach that example VI and you will get help to solve the bugs…
This isn't something that can be solved without a posted vi snippet.
Attempt to create the problem in a simplified version of the vi; either you'll recreate the issue and be able to post the snippet here for experts to debug, or you'll identify your issue.
The fact that you're getting separate behavior between two runs makes me think you're experiencing an error in synchronization between your acquisition and processing, but that's just a guess.
This is the Vi file. Can you help me and tell me what did I do wrong with the process?
Can you help me and tell me what did I do wrong with the process?
The VI does exactly what you have it programmed to do!
There's an init frame, then there is a frame where most of the work is done within loops, and then there is a cleanup stage.
There is NO WAY TO RESTART AUTOMATICALLY: you need to stop the VI, then press the RUN arrow in the menu…
You really should do the Basics training courses as has been mentioned before!
What about this huge overuse of local variables?
What's the point of this part of your code:
Why do you need a local variable when the terminal sits unused just next to it???
Why are there so many unsused terminals in the block diagram?
Cleanup your VI. Obey the StyleGuide! Use more subVIs and shift registers, and less local variables!
Following community best practices:
1. Make sure that you share all required vis to run your program when posting snippets. There were several vis missing.
2. You can use File->Save For Previous Version to downgrade your code to an older version, allowing others the ability to run your code.
Programming Best Practices
1. The use of flat sequence structures are not recommended. Your program would work better as an event-controlled state machine with an acquisition/processing loop.
2. Instead of querying the state of local variables unnecessarily in both loops, use an event-controlled loop to catch the UI interactions of your vi, such as saving your DAQ, starting/stopping acquisition, starting/stopping your program. You should only use one event handler in your vi, so you may need to use local variables in your processing loop.
3. All controls and indicators should be initialized in an initialization state, before entering your state machine/acquisition, etc.
What's most likely causing your problem:
You're initializing your boolean controls out in space, meaning that they can be initialized at any time during program execution. Initialized your controls in your initialization portion of your structure/program, ensuring that they are properly initialized BEFORE you begin acquisition. Otherwise your program may behave unexpectedly.
Overall, I would strongly recommend enrolling in a Labview basics course to ensure that you follow best practices, and ensure that your future code is easier to read and maintain.
Hi GerdW, thank you for your reply.
Yes, there are lots of things that I should learn about the basics of using LabView. It's actually my first time using LabView for (quite) complicated program, because my supervisor asked me to use it. Once again thank you, I'll try to clean up the mess inside my Vi.
Thank you for your reply. I checked your suggestions from the Vi and I will be looking forward to it. Besides, I will enroll the LabView basics first as everyone in this thread recommends me to do. Once again thank you for the help.
I would recommend the LabVIEW Style Book by Peter Bloom. It's old. It's expensive. It's still 99% relevant. That's because it talks about style and not features. Read it cover to cover and it will make you a better programmer. Use it as a starting point, then develop your own style from it.