LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

triangular select function to select case

Solved!
Go to solution

I have a triangular select function with its output wired to a shift register in a state machine.  The shift register is then used to set the case selector to determine the next case to flow to.  The inputs to the triangular select function are T: value of 10 and F: the value in the shift register after being incremented by 1 so it can go to the next case ?: a Boolean flag that lets me know if another parallel loop is running.  The question I have is when the flag is True how does it flow to case 10 when I only have 9 cases in that state machine?  Will I get an error or will the state machine just end?

0 Kudos
Message 1 of 35
(4,358 Views)
You need a case for each value or you will need to set a default case (which will execute when the value = 10).  The loop will stop based on how the condition terminal is wired.  You could wire your flag to the condition terminal with it set as "stop if True" )
Message Edited by vt92 on 03-13-2009 08:08 AM
>

"There is a God shaped vacuum in the heart of every man which cannot be filled by any created thing, but only by God, the Creator, made known through Jesus." - Blaise Pascal
Message 2 of 35
(4,349 Views)
Well here is the deal.  There are two other Boolean flags that are wired to And Function to set the conditional terminal. The Boolean flag I was talking about has no relationship to the conditional terminal.  All the triangular select function has is a value for a case that does not exist (True) and the value for the next case (False).  So then are you telling when this flag is True it is indeed flowing to case 10 or some case that was set as the default case?
0 Kudos
Message 3 of 35
(4,345 Views)

If you wire a selector to a case structure and no corresponding case for that selector exists, the case structure will execute the default case.

 

So:  if your flag comes back "T" and feeds a value of 10 to your case structure (for which no case exists), the default case in your case structure will execute.

 

The point of having a default case is to handle situations exactly like the one you describe, and LabVIEW forces you to either define a case for every possible value, or to designate a case as the default.

0 Kudos
Message 4 of 35
(4,311 Views)
Then the question how do I know what my default case is?  I am using Labview 5.1.1.
0 Kudos
Message 5 of 35
(4,284 Views)

Your default case is the one that is labeled 'Default'. You can select any case and right click and select "Make This the Default Case".

 

Message Edited by Dennis Knutson on 03-16-2009 08:20 AM
0 Kudos
Message 6 of 35
(4,279 Views)
Solution
Accepted by BME_genuis

BME genuis wrote:
I am using Labview 5.1.1.

That makes a big difference. Not sure, but I don't think default cases were supported in 5.1.1. If I remember correctly, if the case structure was driven by a numeric value, and you sent a value larger than the largest value, then the last case would be executed. 

0 Kudos
Message 7 of 35
(4,271 Views)
See, there is no default case like described by Dennis.  I am running 5.1.1 and need to verify what happens when you send a value to a case selector that has no case for that value.
0 Kudos
Message 8 of 35
(4,263 Views)

BME genuis wrote:
.. need to verify what happens when you send a value to a case selector that has no case for that value.

You can easily do this by running your code in highlight mode (the lightbulb in the toolbar). You will see the value of the wire and you will see which case gets executed. The LabVIEW manual explains how to do this. 

0 Kudos
Message 9 of 35
(4,251 Views)
I thought of this however this state machine is wrapped in such a big hunk of code that has no many other dependecies for this state machine to occur.  I don't know how to isolate it to get it to this point in the program.  Can you write a new piece of code in the same environment to emulate this?
0 Kudos
Message 10 of 35
(4,242 Views)