LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I use 3 buttons to control the transitions of my case structure?

Solved!
Go to solution

Hi everyone,

 

Hopefully this will be an easy fix... Although I cannot seem to work it out??

 

I am building a state machine inside a while-loop with the following states:

1. System idle.

2. Self-cal pci card.

3. Run DAQ and do my processing.

4. Stop the vi.

 

I can do this using a enum no problems (with state 1. System idle as the initialising state for the while-loop)... But I really want to have is 4 buttons on the front panel, one for each of the 4 states, so that all the user needs to do is press the button corresponding to the state they want and the appropriate transition ocurrs... For example, when the vi first runs, the idle state is operating... When the user is ready can then hit button 2 for a self-cal... Is self-cal is ok, they hit button 3 for DAQ... Once the DAQ is finished the user can hit button 4 to stop the vi..

 

My problem is that I need the current button to unlatch when another button is hit...

 

Any suggestions?... This is killing me!

 

Thanks,

Jack

0 Kudos
Message 1 of 14
(3,186 Views)

Attached is some reall simple code but I think it does what you want.  Converted to LV 8.0.

 

 

Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
0 Kudos
Message 2 of 14
(3,176 Views)

Does the sequence always run in the same order?  If so, how about just using one boolean ("next') button to step through each part of the sequence?

 

Otherwise, you can use four buttons.  Just add an event structure to your idle case and handle each button, with the next enum state based on which button was pressed.  You will need to go back to the idle case after each step.

 

 

>

"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
0 Kudos
Message 3 of 14
(3,174 Views)

Hi Matthew,

 

Thanks for your help... This works well... I will need to remove the 1000ms timeout from the event structure otherwise the DAQ code I place in inside will stop after 1 sec..(I tried it with a LED and it turned off after the 1000ms timeout)... Is that ok...? It won't cause an problems?

 

Are you able to problem a quick description of why the idex array and locals variables are needed?... I don't quite get the programming here...?

 

Regards,

Jack

0 Kudos
Message 4 of 14
(3,168 Views)

You can remove the timeout BUT it will not resample the buttons (event loop) until DAQ code is done.

 

Buttons set to "Switch Mode" and local variables are used to reset state of buttons.  Made into arry just to reduce wires.

 

IF buttons were set to "Latch Mode" then event structure would reset buttons automatically without having to use local variables.

 

Simple code but does what you were asking for...

 

Matt

 

Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
0 Kudos
Message 5 of 14
(3,165 Views)

I would recommend a radiobutton control with four buttons inside.

0 Kudos
Message 6 of 14
(3,153 Views)

Ok... This makes sense... But my DAQ duration is variable and is stopped using the user.... So if I leave the timeout as is the DAQ might stop prematurely... If I remove the timeout the user will not be able to exit by hitting the exit button (as the DAQ code is continous)...? It his right?

 

Thanks,

Jack

0 Kudos
Message 7 of 14
(3,150 Views)
Solution
Accepted by topic author jcannon

Here's what I had in mind. You can easily add conditions so code only executes once after a control change, for example.

 

 

Message 8 of 14
(3,145 Views)

Hi altenbach,

 

Brillant!.... Thanks heaps....!!

 

Regards,

Jack 

0 Kudos
Message 9 of 14
(3,138 Views)

Hello! I have same sort of problem. But I have 3 inputs and the code applied on them is same. The problem has been illustrated in the diagram attached.

 

 When I will press button 1, source 1 data will pass through black box and the code in vi will apply on it. Same when button 2 is pressed ,source 2 data passes through black box and same vi code applies on it.same thing with button 3.

How can I do this? Help me to do this.

Thank you

0 Kudos
Message 10 of 14
(3,011 Views)