LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Given up on State MAchines please help...

Ok Ray.R ,... thanks a lot for the help.... I am pretty new to LV.. i dnt understand who is doing what...

 

so get confused... 😞

Now on LabVIEW 10.0 on Win7
0 Kudos
Message 11 of 19
(890 Views)

No problem.

 

An experience is to learn that it is important to architecture the code before actually writing (wiring) it.

 

You should not feel bad about it 😉

 

Start by stating how you'd like the application to behave.  At least try to find out what is the best architecture for your application.  Maybe it is the state machine..

0 Kudos
Message 12 of 19
(878 Views)

@CrackJack wrote:

ohhh... okayyy.... didnt know that.... but arnt event structures time based, I mean if the operator decides not to press the button, then will the

timeout occur and the loop come out of its execution/?? please correct me if I am wrong...


Only the Timeout event is time based.  You can have an event structure without a timeout case.  So the event structure itself is not time based.  Any event, whether it is a timeout or other, will cause the event structure code to be finished.  Then the loop will simply go to the next iteration and wait for another event.  It is what is wired to the stop sign that stops the loop, not that an event has fired.  The reason an event structure is commonly placed inside a while loop is so that when one event happens, the loop iterates again and the program waits for another event.  Commonly, timeout events will occur over and over again until some other event stops the loop.  The way to end the loop is to have some event send a True to the stop sign.  That is usually done by a stop button with a Stop button value change event.Try making a small vi with an event structure inside a while loop with a timeout event set to time out every 1 second.  Wire an indicator to the while loop's i terminal.  Put a stop button and a stop value change event.  in the stop value change event, wire a true constant to the stop sign.  Now run the vi.  Notice that the indicator will update every second, showing that the timeout event has fired, the loop has not stopped, and the time between is spent waiting for the next event.  When you press the stop button, that event will cause the loop to stop because you programmed it to do so.

I hope this helps you understand events better.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 13 of 19
(872 Views)

Yes sir definately...  Now I am really up to go ahead and try the event structure... sounds fun 🙂

Now on LabVIEW 10.0 on Win7
0 Kudos
Message 14 of 19
(864 Views)

Hello Everyone

                   I was doing a simple code... an operator presses start button, waveform chart displays the waveform, he presses stop, VI stops....

however, I found a better code... this one.. can anyone please explain me what is the purpose of the CASE structure/? how and why are the values

being passed to a shift register????

Now on LabVIEW 10.0 on Win7
0 Kudos
Message 15 of 19
(853 Views)

 


@CrackJack wrote:

Hello Everyone

                   I was doing a simple code... an operator presses start button, waveform chart displays the waveform, he presses stop, VI stops....

however, I found a better code... this one.. can anyone please explain me what is the purpose of the CASE structure/? how and why are the values

being passed to a shift register????


It looks like to me that the case structure is there simply to keep the state of the button. This is really unnecessary. It could have been for something the orginal developer had in mind for something that he was doing. You can get rid of it with no fear of breaking something.

 

Tim
GHSP
0 Kudos
Message 16 of 19
(848 Views)

That's an interesting implementation.

I have not seen a solution implemented that way before.. 

 

Well, the case structure appears to change the timeout value from "never time out (-1)" to 100ms.

So as soon as the operator clicks on Start/Stop, and once the waveform (data) has been obtained from the DAQ board, it will obtain new data 100ms later because the shift register passed a 100 value to the timeout input of the event structure.  After getting that 2nd sample, since the button (Start/Stop) has reset to false, -1 is sent to the timeout and the event structure will wait until the button is pressed again.

 

Now the problem with this approach is that it takes a sample, then another 100ms later.  I do not know if this is what they intended to do. 

 

Is this the type of behavior that you wanted to obtain for your code?

0 Kudos
Message 17 of 19
(845 Views)

nope...i was just on my learning curve... thought of developing this start/stop from a single button using EVENT stucture....

 

came up with this... 😛

 

 

I actually coded a while loop inside an EVENT structure, but everyone says never ever have a while loop inside an event....

 

sooo thinking wat else can be done...

Now on LabVIEW 10.0 on Win7
0 Kudos
Message 18 of 19
(830 Views)

yep..

 

I have to agree.  A While Loop inside an Event Structure is not a good idea because it defeats the purpose of having an Event Structure 😄

The Event Structure should be able to handle events as they happen, so if there is a busy while loop running, the Event Structure may (will) loose unhandled (or rather events that were not captured) events as a result, so it diminishes the reason for implementing an Event Structure in the first place.  The better alternative would have been a simple State Machine.

 

The above paragraph is related to code that has a While Loop within an Eent Structure, not "Event Structures" in general.  I just wanted to make sure that distinction was clear.. 😉

0 Kudos
Message 19 of 19
(810 Views)