LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to assign multiple functions to a single button

hi,

 

i wanted to switch between screens by using a single button.

 

the screens are nothing but a single string indicator with the string it displays varying. here is how i want it to function

 

i am in screen1. when i press the button more, it should display screen2. now when i press the button more it should display screen3 and the again when i press more it should display screen 4.now from screen 4 when i press more again screen1 should be displayed.

that is i have a single "more button" to switch or scroll through the 4 screens.

 

i have another button exit. when i press the exit button from any screen ( ie 1,2 or 3), it shoul return to screen 1.

 

i made a flow diagram of the explanation above. i am attaching the image for clarity.

 

please help.

 

thanks,

sunal.

0 Kudos
Message 1 of 14
(2,996 Views)

You'd need to use something to keep track of which screen you're on. I think the concept of a state machine will help you here: Application Design Patterns: State Machines

Message 2 of 14
(2,986 Views)

I think I would use a tab control and event structure. See the attached

Tim
GHSP
Message 3 of 14
(2,981 Views)

@aeastet wrote:

I think I would use a tab control and event structure. See the attached


Yep. To make it look more like "pages" rather than tabs, you could color the tab control transparent, after decorating each tab to look like a page. Set the tabs to invisible.

Richard






Message 4 of 14
(2,971 Views)

hey,

smercurio_fc thanks. i think it should solve my problem.

 

regards,

sunal

0 Kudos
Message 5 of 14
(2,925 Views)

hi,

 

tim, i use labview 2010. so i cudnt open ur vi. could u save it as a prev version and again attach it. please.

 

thanks.

 

sunal.

0 Kudos
Message 6 of 14
(2,924 Views)

Here you go.

 

Tim
GHSP
0 Kudos
Message 7 of 14
(2,911 Views)

hi,

 

smercurio_fc, i tried using state machine concept, my problem is how do i use a single button to switch between states. Also the flow diagram i gave above has only 4 states, which is only a small part of the code. i have a total of 21 states to work with, which might become a little cumbersome.

 

So i was thinking may be i make an xcontrol , that modifies the boolen button to have more funtions than just T/F.but how do i go about it?

 

please help.

 

thanks

sunal

0 Kudos
Message 8 of 14
(2,900 Views)

aeastet's example clearly shows how to do it with a shift register and increment/decrement. It's a simple concept, and making an X-Control just seems to complicate the situation, in my opinion.

 

Attached is an example that simplifies it a bit.

 

 

Richard






Message 9 of 14
(2,892 Views)

If the process is strictly linear then clearly a simple shift register with an increment/decrement will work just fine. A state machine provides a generalized solution so you can move around the states. Have you looked at the examples for a state machine? They're fairly self-explanatory. An extension of the state machine would be the producer-consumer architecture. The producer handles the button event and passes the "move to next state" message to the consumer. The consumer loop has the shift register which knows what state it's currently in, so it can pass out the required next state.

0 Kudos
Message 10 of 14
(2,887 Views)