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.