02-06-2019 06:12 PM
Hi all,
I'm trying to run a small program where I open a Shutter and, after while, close it during 5 seconds. Then, open again. That's all.
However, after 5 or 10 minutes, the LabView shut down giving me this unknown error. Do you have any suggestions?
Thanks in advance
Solved! Go to Solution.
02-06-2019 06:35 PM - edited 02-06-2019 06:44 PM
I would put a small wait function in that loop. When your elapsed time has not passed, you have a CPU burning loop as it will run as fast as those .Net functions allow. I'd be worried they can't handle rapid repeated calls.
You can get rid of the flat sequence structure, data flow will control the order of operations. And you can save some wiring and constants if you wire the boolean that goes to the case structure directly to the shift register rather than having a True in the true case and a False in the false case each sending a value to the shift register.
If those things don't help, then I would suspect bugs in the .Net functions because you don't have that much pure LabVIEW code that would cause any problems.
It's also possible that you may need to close those .Net reference wires, but I'm not sure since I don't know what those .Net nodes are really doing and if they are generating new references on every call.
Oh, I see one more thing that might cause your VI to not work the way you want even if it wasn't crashing. When Elapsed time has passed, you have set the Operating state to Active, then the case structure runs the true case. Inside you have a wait function, but it is in parallel to the Active State node. No data dependency there means you'll immediately set the operating state back to Inactive.
EDIT:
The closer I look, I do believe the issue is with those .Net nodes. I see the one is called Create Device which makes me think, (wait for it), it is creating a device on every call. Run that every loop iteration infinitely fast, I do believe you'd run out of resources and crash the program.
(Oh, and the Set operating State reference wire in the case structure should come from the output reference of the one in your first frame,)
It seems some of those calls belong outside the loop. And setting the Operating state should probably only be done when it actually changes. You should re-architect you code into a state machine where you have perhaps 4 states.
1. Initialize (get the references and feed them into a shift register.)
2. Set operating state (either active or inactive)
3. Wait. For however long you need for elapsed time become true, or for the wait in the case structure to occur)
4. Close (close out references.)
02-11-2019 11:57 AM
Hello!
Thanks for your recommendations. I applied them and now my program works perfect! I have a huge program and, as I expected, the problem came from this part.
03-09-2020 04:20 AM
Thanks it's working because I faced the same problem with .net DLL. And when I add "Thread.Sleep(500);" between the two main functions. the problem is gone ~ happy~~~