07-02-2026 09:24 AM
I have inherited a test program that uses VISA to read values. This program has a engineering screen that uses a producer / consumer architecture, with buttons which trigger reading and writing of the VISA values. The program is very slow to read and write values (I wonder if this is because the lack of waits in the while loops).
Ideally all of the values would read and write continuously, but I am not going to change the program that much.
The issue is the program will allow the switch tank value (see snippet below) to be switched when it is not safe. This value should only be switched when two other values are at or close to zero.
I want to disable and grey out the control for this value, but the values need to read numerous times until they are stable to determine if it is safe to enable the control.
This is only active when relay 1-5 or switch tank is pressed:
I am offsite right now, but I am going to insert this while loop with both read values, as shown below. Will this work? Any comments are welcome.
07-02-2026 10:45 AM - edited 07-02-2026 12:05 PM
@Mark1349 wrote:
It is impossible to debug truncated code pictures.
Some questions:
07-02-2026 01:15 PM
Altenbach,
Thank you for your response. Those are good questions.
#1 The shift registers will read the starting value of the analog inputs. I could start them at some value, but since I am looking for zero, I would need to start them higher than zero, but would not want to delay the slow VI any more than it already is.
#2 The local variable is located inside the consumer loop with the Ai_0 button. As I said, I don’t like the fact none of these indicator values are actually updated until their button is pressed.
#3. The subVIs are not reentrant. The intent is to prevent the operation of the Switch Tank control if either the Ai_0 r Ai_1 value is above 0.2. Once below 0.2, the loop would exit and allow the switch tank control to be enabled. Not sure how this could be done with a For loop.
#4. You are likely correct, probably need 100ms or more, won’t know until I actually put it in the code.
#5. The intent is to disable and grey out the Switch Tank control shown above, whenever either value is above 0.2. I think this can be accomplished by inserting this into part of the existing block diagram that is always running when this screen is active, then adding write commands to drop Ai_1 to zero (Ai_0 will follow as it discharges) if any of the switch controls are activated.
07-02-2026 03:35 PM
@Mark1349 wrote:
#5. The intent is to disable and grey out the Switch Tank control shown above, whenever either value is above 0.2.
Your code is not doing that at all! What you are checking is if the difference of the current value compare to the 10 previous values is less than 0.2. So if your reading is 1000 and stays there, the condition is already met.
We really have no idea how your various code fragments are assembled.
07-05-2026 10:33 AM
I understand that you don't want to share your (actual, mal-functioning) LabVIEW code as it might have proprietary information (possibly based on the names you chose for the variables or the values you placed in the Front Panel entries), but it is extremely difficult to understand what you are trying to do based on the limited information we can glean from the "pictures" of some fraction of your LabVIEW code that you choose to share with us (with Front Panel indicators heavily redacted).
There are several "curiosities" in the latest set of "pictures" of your LabVIEW code.
Note that the above (over-simplified) model has three parallel loops: an Event Loop that is largely monitoring changes to Front Panel controls, the Main Loop which gets inputs from the Event Loop to change the parameters of what it is the Main Loop does, and a "Data-Consumer" loop that handles the data that is generated by the code in the Main loop. All three loops will have a coordinated "Stop" routine -- pressing the Stop button fires off the Event Loop which switches the Main Loop to "Handle Close Program", which in turn sends a message fo the Data-Saving Loop to exit.
I know this may be a lot of "new stuff" that you might not be ready to tackle at this point. But if you can create a simple "one-channel" version of your actual LabVIEW Project, with "made-up names" where you have redacted information, bundle it in its own Project (in its own Project Folder), and pass us a compressed version of this Folder, we'll be much more able to provide more specific help. Right now, I'd say cleaning up your Event Structure may take top priority.
Please help us to help you.
Bob Schor