12-24-2014 03:52 AM
Hey all,
Im just starting out in Labview and am currently messing around with state machines.
I am trying to find a way to do the following:
The state machine should stay in the "waiting" state untill one of two buttons is pressed, then it needs to hop to the state that belongs with the button pressed.
But I do not know how to hook this up to the final shift register since it can only have one signal going in.
Here is an image to give you a bit of an idea to what I am trying to accomplish.
Is there anyone who wants to help a noobie out on this one? I know that it might be a stupid question to ask around here but I can't seem to find anything on the subject and don't know where to go..
12-24-2014 04:19 AM
A wire can only have one source. Try to wire the output of the first select node to one of the inputs of the second select node. You'll figure it out.
12-24-2014 08:13 AM
You could do the same thing with a Event Structure within that "Wait" case. Look that up too.
12-24-2014 08:22 AM - edited 12-24-2014 08:23 AM
12-24-2014 09:44 AM - edited 12-24-2014 09:46 AM
@altenbach Yeah I get that now, was really confused at first because they were of the same type and I thought it didn't matter!
12-24-2014 09:47 AM
@Eric1977 only just heard of that, figuring it out now! And @GerdW Thanks! Don't know why I didn't think of that option, good call!
12-24-2014 12:12 PM
@TheAlPaca wrote:
@altenbach Yeah I get that now, was really confused at first because they were of the same type and I thought it didn't matter!
Think about it from a conceptual standpoint rather than specifically in your code.
If the case has only one output, but two things feeding that output, how could you know which one is actually being sent as the output? The best way I can think to describe this is to think of two people, Harry and Jim. Harry and Jim both have the phone number (123) 456-7890. You pick up your phone and dial that number. Who will you get? Each time you dial, you won't know. That is something that will break your code. As such, the environment SHOULD throw an error.
Let's look at your code. Let's say the first button always manages to win, just for ease in understanding. If the first button always wins, it will look like your program is working when you push that button because it will behave as expected. If you push the second button, it will never respond. It will just go back to wait.
As it stands, we really don't know which would reach. If LabVIEW allowed you to wire things like that, you could potentially lose one button if both were pressed at the same time. Beyond that, are you wanting the response to one cup to repeat until the button is pressed again or do you want it to happen once? Is the button set up as a switch or a latch? If you're looking for a state machine to respond to user input, you probably want to spend time with the event structure as it is meant to watch for user input.
12-24-2014 12:52 PM
@TheAlPaca wrote:
Here is an image to give you a bit of an idea to what I am trying to accomplish.
A few more comments to your code draft shown in the image.
Depending on the rest of the code, there is a nonzero chance that both booleans are true when this case is encountered. Do you need to deal with that case? I also assume that you have a small wait somewhere to prevent 100% CPU use when the program is not doing anything important.