Im trying to use a switch ( I named "BOOLEAN SWITCH") to switch in between placing datapoints into arrays, and using those arrays to run a stepper motor. Right now, Im using a case structure to send a "10" signal (motor stop) when the switch is set to false (measuring) and it sets the signal to the approriate direction based on the first values of the array when the switch is changed to true (running).
Unfortunately the switch is always outputting flase all the time. I have a property node to default it to false at the beginning of the program, and when I remove that, the switch will just be locked into whichever the last value was when it starts running. Any suggestions on what might be causing this?
Im sorry about the code, its probably a bit bloated and ugly, but im learning.
The problem is with your Event structures. First of all, you should only have one event structure and handle all of the events in that same structure. You won't miss events because the event structure queues them up. This, though, isn't the cause of your problem. Your problem is that the loop does not iterate until your event structures have completed. You either need to put the event structure in a separate loop or add a timeout event to the event structure.
Also, there are no guarantees that your boolean will be set to true at the beginning of your code. Just because the property node is to the left of the main loop does not mean that it will execute first. LabVIEW executes code as soon as all of its inputs are available. In order to assure proper operation you should wire the error out from the property node to your main loop, forcing the main loop to wait for this node to execute.
I also recommend that you try to compact your code so that you do not have to scroll to see the entire diagram. This makes it much easier to follow the flow of the program. One way to do this is to put some of the code into subvis.
You've got a decoration on top of the switch so you're unable to set it. Select the decoration and then move that to the back by selecting the Reorder button (top right of tool bar) and choosing Move to Back.
Ok, Ive merged the events together and tried adding a timeout but the boolean is still just giving the same value.
Would it make more sense to put this in a sequence and running the measurement part in the first frame and using a boolean to jump to the next frame and run the rest?
I forgot to mention the point that Dennis brought up that your decoration needs to be moved to the back. This should solve the remainder of your problem.
I still suggest that you clean up your code a bit. You have wires running the wrong way (LabVIEW style guidelines are left to right data flow) and the block diagram covers a large amount of area. I think that you could consolidate considerable portions of your code to subvis to save room on the screen.
Yes, thanks for the suggestion. I was working to bring a whole bunch of parts together before going through and cleaning it up. I can shrink it up quite a bit though now using a couple sub VI's.