09-16-2010 10:52 AM
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... 😞
09-16-2010 11:59 AM
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..
09-16-2010 12:13 PM
@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.
09-16-2010 01:04 PM
Yes sir definately... Now I am really up to go ahead and try the event structure... sounds fun 🙂
09-16-2010 03:00 PM
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????
09-16-2010 03:04 PM
@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.
09-16-2010 03:15 PM
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?
09-16-2010 04:05 PM - edited 09-16-2010 04:09 PM
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...
09-17-2010 06:47 AM
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.. 😉