LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can someone please help me figure out this enum problem (My code is a lot simpler than the previous one I posted)?

Solved!
Go to solution

Here is the problem that I am having. Let's say for Enum I, I select 1 and for Enum II I select 1. If choose 2 for enum I or II while the program is running,  it goes to default 0 case. How do I prevent it from going to 0. I want when I input 2, case 2 to execute no matter what enum I am using to input the number. If you use highlight execution, you'll know what I mean. (see attached VI).

 

 

Note: Bear with me. I am just the baby in here trying to grow.

0 Kudos
Message 1 of 19
(1,911 Views)

@GRCK5000 wrote:

Here is the problem that I am having. Let's say for Enum I, I select 1 and for Enum II I select 1. If choose 2 for enum I or II while the program is running,  it goes to default 0 case. How do I prevent it from going to 0. I want when I input 2, case 2 to execute no matter what enum I am using to input the number. If you use highlight execution, you'll know what I mean. (see attached VI).

 

 

Note: Bear with me. I am just the baby in here trying to grow.


I think the forum didn't like your attachment because it never came through.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 19
(1,908 Views)

Thanks BillKo. I fixed it.

0 Kudos
Message 3 of 19
(1,893 Views)

Do you understand the concept of an Enum (a shortened form of "Enumerated Type")?  It is a process that lets you (the user/programmer) choose "Human-friendly" names that can be used in place of "counting numbers".

 

In your program, you have two Dbl variables called "Enum 1" and "Enum 2".  They are not "Enums" as LabVIEW (and C, and Pascal, and other programming languages) consider them.

 

There is an Enum entry on the Front Panel.  I'm sure if you learned about Enums (or paid attention in class, or read the Help files, or taken the LabVIEW Core 1 tutorials) you would understand how to use them.

 

You define an Enum by giving it a name (say, "Color") and specifying its Values on the Front Panel (for example, you can use the Resistor code "Black", "Brown", "Red", "Orange", "Yellow", "Green", "Blue", "Violet", "Gray", "White".  Common things to do with an Enum is to get the "Next" item (try the LabVIEW "Increment" function) or "Previous" item (try the LabVIEW "Decrement" function).  An interesting function of Enums is they only take their "defined" values -- the next "Color" after "White" is ... "Black".

 

I use them any time I have a small number of "choices" to make (as opposed to two choices, for which I usually use a Boolean, choices "True" or "False").

 

Bob Schor

Message 4 of 19
(1,872 Views)

@GRCK5000 wrote:

Here is the problem that I am having. Let's say for Enum I, I select 1 and for Enum II I select 1. If choose 2 for enum I or II while the program is running,  it goes to default 0 case.


It is actually using the "Default", which just happens to be the 0 case.  The reason is that the OR is a bit-wise OR.  To keep it simple, 1 is 0b01.  2 is 0b10 in binary.  OR those together and you get 0b11, which is 3.  So it is actually trying to call case 3.  But since you don't have a case 3, it calls the default case.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 5 of 19
(1,870 Views)

So my question is if there a way. I can call case 2 when I input 2 in either "enum I" or "enum II"?

0 Kudos
Message 6 of 19
(1,856 Views)

@GRCK5000 wrote:

So my question is if there a way. I can call case 2 when I input 2 in either "enum I" or "enum II"?


Change your case from "2" to "2, 3".  Then the case will be active if the input is 2 or 3.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 7 of 19
(1,825 Views)

Hi,

the Vi's purpose and functionality It is unclear, as @ crossrulz stated, that you should understand the functionality of (OR) in your VI, as an Example :

Emna20_0-1651674104239.png

Enum I : 1 => (ob0001)

Enum II : 2 = (ob0010)

 

Result (x.or.y ?) =  (ob0001) or (ob0010) = (ob0011) = 3 (decimal)

in your VI you don`t have a case for (3) , LabVIEW choose the default case which is (0).

you need to specify the range of the input, if it is between (0,1,2) max (2).

you could use the @ crossrulz solution by adding (3) to the case of (2) => "2, 3"

 

otherwise it doesn`t work, an Example if you want to choose 2 if it appear on Enum I or Enum II.

Enum I : 4 => (ob0100)

Enum II : 2 = (ob0010)

 

Result (x.or.y ?) =  (ob0100) or (ob0010) = (ob0110) = 6 (decimal)

there is no case for 6, abVIEW choose the default case which is (0).

Best Regards.

 

0 Kudos
Message 8 of 19
(1,801 Views)

Please bear with me.  I do not want case (3). I want to limit this to case 0, 1, 2 

Here is the scenario:

Imagine you are using my VI. You select for Enum 1 -->1 as shown below:

GRCK5000_0-1651675642613.png

Then you do the same for Enum II as shown below:

GRCK5000_2-1651675767448.png

Using highlight execution, press RUN. You'll notice the flow goes from 1 to level 2b, then back to 1 (a cycle).

Now, here is the problem: Let's say while it's running. I change Enum I or Enum II input to 2, it would go to 3 which corresponds to 0 (default case) mainly because I do not have case 3. My goal is to force it to go to 2 when I change Enum I or Enum II input to 2. I do not want this to go to 0 default.  

How do I do that? 

Note: I do not want to add case 3. 

 

 

 

0 Kudos
Message 9 of 19
(1,791 Views)

Hi crossrulz. I tried my best to re-explain what I want to do. Please can you scroll and let me know if that makes things clear and how do I go about doing what I want to do?

0 Kudos
Message 10 of 19
(1,790 Views)