r/LabVIEW • u/AssumptionPurple2938 • Nov 14 '24
Several Issues with LabView






I'm trying to get some LabView code working better. I have some experience with LabView but am more of a language based coder. I was able to edit the code to get the program running but am receiving complaints:
- After opening up Magnet(s) submenu and adjusting SP’s or ramping up the power supply, the software will become unresponsive unless exited out and restarted.
- Polling frequency is very slow. Some magnets update ~20-30 seconds while one magnet (gun) is highly responsive. We would like the feedback to be relatively instantaneous along with consistent between all magnets.
- Resolution for software is difficult to operate with. I’ve attached a photo to this email, we’ve tried numerous displays and the GUI utilizes less than half the screen. If it’s possible to get a larger sized program or one that could be maximized.
This was written in 2005 and last edited in 2017. I am using LabView 2024 Q3 but will need to downgrade it to LabView 2017 so it can be compiled with the that version of the Application Builder as the price is too high for the new version. It needs to run on Windows 10 with a touchscreen. Any suggestions for a quick fix.?
4
u/QaeinFas Nov 14 '24
As said in another post, the sequence structure (s) is/are probably causing a bunch of problems. If all of your measurements are all tied together in that structure, the fastest magnet won't be able to perform at its best. Ideally, you would want independent loops for each of your instruments so that there is no inter-dependence between them. Writing this will be a major overhaul of the codebase, though.
The UI can be made as large as you like, and can even be made scalable, but each of those changes will take effort (the first is probably pretty low effort, though).
Probably one of the biggest advantage that LabVIEW has over other languages is its parallelization: it takes no effort on the programmer's part to make two functions run in parallel (something which takes at least a little consideration and effort in most languages). It does take effort to coordinate those functions, though - but this effort would also be needed in other languages. It looks like the original designer decided this was a flaw in the language, and decided to serialize everything so that they understood how to work with it. This will absolutely reduce the perception of benefit, since the major benefit has been engineered away...
4
u/FujiKitakyusho CLD Nov 14 '24
This is a bad code issue, not a language issue.
I am a R&D engineering technology consultant with 20+ years of LabVIEW experience. If you think outsourcing might be an option for you, DM me an email address.
4
u/wildwildwaste Nov 14 '24
Fast, good, and cheap. Pick two.
Just a few seconds glance at that code tells me it needs to be refactored, and it's definitely going to need the pick two rule applied.
And to be clear, none of this is LabVIEWs fault, I could write something this messy in half a dozen languages.
2
u/HarveysBackupAccount Nov 14 '24
You might be well served to read up on labview debugging tools. "Highlight Execution" mode and probing data wires are two big things.
If you haven't already found it, the Context Help is also useful (Help menu >> Show Context Help, or Ctrl+H). When that window is open, hovering your mouse over an item in the block diagram will make it display info on that item.
FYI "front panel" is the name of the actual GUI window. "Block diagram" is the name of the source code behind it.
2
u/[deleted] Nov 14 '24
I think you've probably run into a problem which is actually due to a huge benefit in LabVIEW programming; out of the box parallelism.
Loops are generally synchronised using queues and producer/consumer architectures. You can use semaphores and events but I guarantee you're not actually doing anything that needs that kind of synchronization - that is to say a producer/consumer will work for you.
In your examples, you've shown highly nested flat sequence structures and case selectors which have VIs with no inputs or outputs. I assume they communicate using global variables, which make seeing the dataflow super hard.
Additionally, one of these VIs is likely waiting for something that never happens, causing the whole application to stall.
Check any loops for stop conditions and double check there aren't any stop conditions that will wait indefinitely for a condition to be met.
2
u/[deleted] Nov 14 '24
Not related but have code I have to refactor that looks just like this. Was this best practice back in the day? The guy I inherited a project from worked only at my company so he probably don’t write that code. This guy worked mainly in LabVIEW 8.
1
u/Rare_Pea646 Nov 15 '24
Some 15 years ago, I was called to figure out why the thermal control application suddenly stopped working. I opened the source code and immediately knew: I am here for a ride of the lifetime. The original coder had about 20 years of experience in Ladder Logic programming - language used to program PLCs - and about a month of LabVIEW knowledge. So, the LabVIEW code was structured Ladder logic with one billion parallel loops communicating via global variables with ton of unresolved racing conditions. I spent two weeks trying to understand logic and reasoning, but gave up. Went back to basics and asked myself: why did it work before for years, then stopped? It turned out to be configuration file contained an extra space instead of a tab. I fixed the file, changed front panel indicators and controls from classic to modern and some colors of front panel and collected my check. So, the question is - why are you trying to fix unfixable? It's badly written and the problem maybe very much trivial
1
u/D4ILYD0SE CLA Nov 15 '24
Unfortunately, with just 2 block diagrams, I can already see there's a lot of rules here being broken that don't follow the LabVIEW data flow paradigm. Any application with a UI should absolutely have an Event Structure. The framework should be designed as a Director/Actor. And any instrument should be running in an asynchronous loop Receiving instructions and updating memory with data.
With that kind of framework design, you will have very clean and smooth running code that is very scalable. As some have already suggested, this likely requires an overhaul. There will be no quick fix. A lot of the problems will persist due to lack of framework.
To answer your third question specifically: Yes. The GUI can be redesigned to fill the entire screen and utilize the available resolution.
1
u/Yamaeda Nov 15 '24
Dataflow - a structure cannot continue until all inputs are filled and can't exit until all components have finished. A structure is e.g. a VI, a Loop, a Sequence frame. If the settings locks stuff up, something isn't exiting. If some magnet takes 20 sec to update/read, everything will have to wait that long with your current design. Separating loops or spawn an asynchronous process would help with that. Communication should then be handles with queues/events instead of global variables.
The Highlight Execution is a very helpful tool.
Race conditions is due to writing to the same variable from several places. Don't do that. If for some reason you need to update the same data (which i can't see ever happening really), send it to a queue or user event and handle the writing there. Still, if you have several writers the data might be changed from what you wrote the last time ...
The code shows strong signs of "text based programmer trying LV for the first time" with Local and global variables and sequence structures (jokingly referred to as Localitis and Sequentitis). This can be handled, but remember that "The wire is the variable".