I have two (2) "latch until release switches" inside an event structure. The structure is set for 500 mS. How can I control these swiches with a global value? Is it even possible? Should I and try and put the two VI together?
Solved! Go to Solution.
"How can I control these swiches with a global value?"
You can not. Change the action to a no latch. Then you can add a local variable, to the end of the switch action,
so you can simulate the latch action.
"The structure is set for 500 mS", "Should I and try and put the two VI together?"
That makes no sense to me. You must discride a little better, what you want to do.
What exactly are you trying to do? Could you post an example VI? Thanks!
I have two (2) "latch until release switches" inside an event structure.
Why did you decide on this relatively exotic mechanical action?
The structure is set for 500 mS.
Are you talking about a timeout (ms) or a conductance (mS)? Why would the timeout matter is you have an event for the switch?
How can I control these swiches with a global value?
What is a "global value"? If you man "global variable", You have things backwards. Global variables don't "control" events.
Is it even possible?
What is "it"? In LabVIEW everything is possible if you do it right and don't impose narrowminded restrictions on the code.
Should I and try and put the two VI together?
This is the first time you are talking about two VIs. Does this have anything to do with the rest of the post?
Can you explain what the program should do from a user perspective?
That code looks very confusing. So you basically wait for a "value change" of the control and then write watever value is in the global to the control just pressed, ignoring watever the user just tried to set. THe code fights the user!
If you really want it to work that way, make it an indicator, wait for a "mouse down" event on it, and wire the global directly to the indicator. No need for a value property.
In any case, it seems weird to wait for a user interaction. Shouldn't it update automatically whenever the global changes?
I wrote the VI with switches. The switches would allow me to test the modbus out.
Later I needed to automate the VI.
So I needed to delete the swithes.
I created a True or False global from my GUI VI.
My GUI has 5 variables that I pass or read. Read Register, Write Register, Address, Quanity, Read Temperature address and Pass a 1 or 0.
I have a data array that is 4 by 30.
I have enclosed a jpg file of the front panel. I tested the MB interface by filling in the Write/Read and all the rest of the data required. Then I pressed the querry button and all data was written or read. I used the open button and query button to test the MB. The MB interface at the present time works in latched postion only. This is with no globals passed. That is my problem.
It would have been more helpful if you attached a picture of the block diagram, or better yet, a copy of the actual VI.
I am going to assume what you have now is a VI that has a while loop and a stop button. And the real heart of the code is in a case structure that your switch is wired to.
Now you want to make this a subVI a part of a larger program. ????
If so, you need to change out the program runs. It won't need a while loop or a stop button, it won't need a switch to call the heart of your code. You will want to take the heart of your code and wire the important things into your connector panel. Things like the modbus cluster and the output array. Also, things like slave address and com port.
To really do it right, take a look at action engines where you will have 3 major actions: open, write, close. That way you can open the port one time before your while loop in your main program. Write/Read within your while loop as needed, then Close the port as a final cleanup step after your while loop before your main program ends.