From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Are sequence structures the right approach here?

Question for Dennis-

By adding one event structure, does this necessitate a change in the entire program's approach?  In other words, now that I want one event structure (for the toggle trap button), do I have to add event functionality for every part of the program?  I thought that the quit button could still attach to the terminal condition outside of the event structure if the event structure were set up for only the toggle trap button.

Thanks,
Brad
0 Kudos
Message 11 of 23
(927 Views)
The shift register stores the value of the boolean array and passes it to the next iteration of the while loop.  There is a little bug in my example.  The array to cluster element and the cluster indicator should have been wired before the event structure.  The event structure was waiting for either the Toggle Trap or Quit buttons to be pressed before displaying the initial condition.Robot Sad  I suggest moving them.  Each time the Toggle Trap button is pressed (changes value), the event structure flips all the booleans.  The event structure passes this NOT'ed array to the shift register, which uses it on the next iteration of the while loop.  The while loop checks that Quit is still false, and restarts.  The new values are displayed in the cluster.  And we are back at the event structure, waiting for a button press.


In answer to your other question, most of the mathematical and logical functions can be applied to either a single value or an array of values.  I noticed in your program that one case was the exact opposite of the other.  By applying a NOT to an array of booleans automajically applies to each element without having to pull the array apart in a for loop and apply the NOT to each element.
0 Kudos
Message 12 of 23
(922 Views)
Now that the event structure seems to be working properly, I want to return to the original question of sequence structures and, more specifically, timed sequence structures.

In the original message of this post, I laid out a plan of what I wanted the VI to do.  I have half of that plan implemented, and now I am trying to get a timed sequence structure to work.  The help files are a bit over my head, there are no examples for this, and I keep recieving the error that I have no kHz clock available to use for the timed tasks.  I have attached the VI in 8.0, and I have tried to save it in 7.1 but there are issues with the timed sequence.

Maybe I am jumping a little too far - I haven't used sequences before.  The goal is for the bank of booleans to move from one state to another by changing the state of the boolean "Toggle Trap."  Each step has a 2 second delay. 

Thanks,
Brad

(I will cross post this in case it is too buried)


Download All
0 Kudos
Message 13 of 23
(909 Views)
Here is an attempt at the same with a flat sequence structure that is told to wait 2 seconds.  Still a property node problem here...


0 Kudos
Message 14 of 23
(905 Views)
Using a timed structure for a 2 second delay is a bit like trying to kill a fly with an anvil.  Timing structures are intended for very close control of when things happen.  Plus, you are having to dance around with the property nodes to update your display.  If it were me, I would use a state machine.  It makes program maintenance a snap.  Want to reorder the sequence?  No problem.  Want to add steps?  Easy Remove steps?  Still easy.

For timing, I used a Wait.  Flip bits, wait 2 seconds (2000 milliseconds), update display, move to next step.  The wait function is not quite as exact as the timed structure, but do you really need >.01s precision?

As a bonus, I added a cursor busy.  Any UI response that takes more than about a half a second will frustrate the user.  The cursor busy tells them something is happening and they just need to wait it out.



A final aside: looking at your latest attachements, I am not entirely certain what sequence the valves are supposed to be opening and closing.  V4 and V6 never change.  Thankfully, it is pretty easy to change things around with a state machine.


Message Edited by jasonhill on 06-20-2006 09:25 AM

Message 15 of 23
(895 Views)
Thank you for the note, Jason.  I had started to arrive at the anvil-fly conclusion and changed directions.  It still doesn't work with my new implementation using timed while loops.  Here is that example.  I will play with your example.

Thanks,

Brad
Download All
0 Kudos
Message 16 of 23
(888 Views)
Jason,

I like the compactness of your VI.  If my attempt shows anything, though, it is that the VI has to be a little more complex by using a few more sequences.  I will try to add them to your state machine and post that.

Thanks,
Brad
0 Kudos
Message 17 of 23
(878 Views)
one second, I think I've got it...

Message Edited by CFAMS Brad on 06-20-2006 11:10 AM

0 Kudos
Message 18 of 23
(868 Views)
I found a problem with the state machine approach -

It doesn't initiate the shift registers until the event that starts the state machine triggers it.  I would like to have the machine initialized as per the array control when the program is started.  Is there a way to do this?

Thanks, Brad
Download All
0 Kudos
Message 19 of 23
(846 Views)
This is a good place to use a Value Property Node.



Although if we are actually switching real physical valves, I would want some way of programatically verifying the current orientation of each valve (through a sub-vi, perhaps).  Then pass those values into the loop.

Message Edited by jasonhill on 06-20-2006 01:03 PM

Message 20 of 23
(844 Views)