LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Case Structure with Three Cases Controlled Manually

Solved!
Go to solution

Hi!

I'm new to LabVIEW and I am not totally familiar with it's basics. I have been searching for a while but can't seem to find what I am looking for, which, I reckon, should be pretty simple to execute:

 

I have a case structure with three different cases and I would like to be able to switch between the three different cases manually by pushing a button. Right now, I'm doing it with an "Enum constant", but I would much rather have three separate control buttons which I could push in order to switch states instead. 

 

Thank you for your support,

Manuel

0 Kudos
Message 1 of 10
(4,045 Views)
Solution
Accepted by topic author manuelrp

If we could see the code you have written, we could probably suggest how you might modify it.  I'm not entirely sure what it is you want to do.  Could you possibly be thinking of using a Radio Button Boolean, where you can have three buttons, only one of which can be pressed at a time, that control your Case?

 

Bob Schor 

0 Kudos
Message 2 of 10
(4,010 Views)
Solution
Accepted by topic author manuelrp

Sounds like a simple Radio Button setup to me.


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
0 Kudos
Message 3 of 10
(3,974 Views)

@crossrulz wrote:

Sounds like a simple Radio Button setup to me.


Which... when it all comes down to it... is an enum.  😄

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 4 of 10
(3,946 Views)

Thank you for your answer!

I'm currently at college and I'm using LabVIEW to create a project. We removed the tire from a bicycle wheel and placed neodymium magnets around the wheel's frame at equal distance from each other. My LabVIEW program is meant control a relay which would change the polarization of an electromagnet that would either accelerate or decelerate the wheel's spin, or keep it at a constant speed, depending on what I want. This is pretty much where the three buttons come in action: I would like to press a button named "Accelerate" in order to accelerate the wheel, "Decelerate" to decelerate it and "Constant speed" to keep it in it's current state. 

 

I've tried using the radio Boolean, but it does not seem to be what I am looking for.. I would prefer having separate buttons instead.

 

Thank you!

 

 

0 Kudos
Message 5 of 10
(3,929 Views)

Please do not attach pictures of your code (how helpful would it be to post a picture of a listing of a large Matlab file?).  Instead, attach your VI.  Among other things, it would tell us (a) what Version of LabVIEW you are using (so we could post compatible suggestions), (b) show us all your code (including "behind" any Case statement), and (c) let us test your code (by running it).

 

It would also give us a clue how familiar you are with LabVIEW.  Since I've seen no code, I can't judge, so this may go right over your head (sorry ...).

 

A Producer/Consumer Design Pattern with Events would certainly do this for you.  You could have three Boolean Latched Buttons (Accel, Decel, Maintain), each with its own Case, with a State Machine as the Consumer handling the Accelerate, Decelerate, or Maintain situations, depending on the button pressed.

 

You can find a Template for this Design Pattern in the New ... (the dots are important) option in the File Menu.

 

Bob Schor

 

Bob Schor

0 Kudos
Message 6 of 10
(3,914 Views)

I understand. Here is a copy of my VI. However, I do not think that you will be able to test it since the ELVISmx Digital Reader and Writer require an ELVIS prototyping board USB wired to your computer in order to run the program. The reader is used to give a T/F signal when the magnets block a beam of infrared light and the writer is used to power the relay. They are not really necessary to test the function I'm wishing to add to the program, so you could just remove them to test it.

 

I just checked the template, but I do not understand how it would be useful since I'm not that experienced with LabVIEW, sadly.. 

 

Wouldn't it be possible to use three simple switch buttons and have them correspond to one of the three case in the case structure? I've tried linking them into a boolean array and convert it into a number which is sent to the case structure, but it hasn't been working since I wasn't able to change the case numbers for them to match with the binary numbers..

0 Kudos
Message 7 of 10
(3,909 Views)

I'm sorry for posting twice in a row, I just realised that the VI I send was not quite the right one and I haven't been able to delete the post, so here is the right VI.

 

Manuel

0 Kudos
Message 8 of 10
(3,900 Views)
Solution
Accepted by topic author manuelrp

manuelrp wrote:

I've tried using the radio Boolean, but it does not seem to be what I am looking for.. I would prefer having separate buttons instead.


Little trick here: put the buttons you want inside of the Radio Button frame and delete the default ones.  Now you will have 3 buttons, only one of which can be active at a time and it has the same data type as an enum.


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 9 of 10
(3,860 Views)

Thank you crossrulz for this clear, simple explanation!

I've tried it and it works how I want it to.

 

Have a nice day!

0 Kudos
Message 10 of 10
(3,838 Views)