LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Program won't start before stop the program frist.

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.

0 Kudos
Message 1 of 9
(2,291 Views)

Hi keyvdir,

 


@keyvdir wrote:

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…

 


@keyvdir wrote:

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…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 9
(2,249 Views)

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.

Using Labview 2022, Windows 10
0 Kudos
Message 3 of 9
(2,208 Views)

This is the Vi file. Can you help me and tell me what did I do wrong with the process?

0 Kudos
Message 4 of 9
(2,147 Views)

Hi keyvdir,

 


@keyvdir wrote:

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!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 9
(2,135 Views)

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.

 

Using Labview 2022, Windows 10
0 Kudos
Message 6 of 9
(2,112 Views)

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.

 

 

 

Best regards,

 

Kevin

0 Kudos
Message 7 of 9
(2,079 Views)

Hi Allison,

 

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.

 

 

Best regards,

 

Kevin

0 Kudos
Message 8 of 9
(2,078 Views)

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.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 9 of 9
(2,057 Views)