11-17-2009 01:05 PM
I apoligize for the ignorance but can someone give me an example of implementing a state machine that solves this problem.
I tried various things to get around the wait associated with the GPS data rates but have only solved the problem with the global. However, I welcome a little more knowledge surrounding a state machine. Have read a little about them but have not tried to build one and, in fact, am a little in the dark as to getting started.
11-17-2009 01:22 PM
irfocus wrote:I apoligize for the ignorance but can someone give me an example of implementing a state machine that solves this problem.
I tried various things to get around the wait associated with the GPS data rates but have only solved the problem with the global. However, I welcome a little more knowledge surrounding a state machine. Have read a little about them but have not tried to build one and, in fact, am a little in the dark as to getting started.
Well you have come to the right place but first a litle background about all of these people that have been helping out. Most of the contributors to this forum are NOT NI employees (they have bluish bars under thier names). They are all volunteers who (for the most part) have a real job which has nothing to do with answering Qs. So to get something out this forum you are going to have to carry the lions share of the so...
Post code and images of what you have tried and detail where you get stuck. Most of the frequent flyers can help you by giving hints or pointing at other threads.
So show us were you have trouble and let community show you the direction.
Ben
11-17-2009 01:52 PM
Ben (and others) has taught me a ton about event driven state machines...I have been working on a little example using a stopwatch as a design target. It uses a type definition for all the variables and controls...it uses a state machine for all the functions...and has a little error recovery thingy ... all the event>state conversion are done using a queue and there is an error queue too.
The project is attached...and is not in "final" form...just good enough to work.
The basic outline was created by using "file>New>" and then selecting the event driven state machine outline. I added the error handling queue so I could do all that in one place. I'm still struggeling with the windows interfaces for the instruments and any suggesions on how to update the instruments in a way other than using value signaling spread all over the place would be welcome.
Good luck.
Hummer1
11-17-2009 03:34 PM
Thank you Hummer.
I know, what a pain in the XXXX. Would it be possible to save this to an 8.5 file. I can't read your 9.0.
11-17-2009 04:31 PM
I'm not sure how to do that...but will attack it and see what happens.
Do you just make a copy of the vi...and then save as under a different format?
11-17-2009 04:36 PM
Hummer1 wrote:I'm not sure how to do that...but will attack it and see what happens.
Do you just make a copy of the vi...and then save as under a different format?
Do a File->Save for previous version.
11-17-2009 04:36 PM
11-17-2009 04:37 PM
11-17-2009 04:48 PM
I can't do it from here.
There is a known issue with LV 2009...you can save to version 8.6...but not to 8.5. The work around is to save to 8.6...open 8.6 and then save to 8.5. (per forum discussion.)
I don't have 8.6 on my machine any more but would welcome someone trying this flip for us...
Thanks in advance...
Hummer1
11-18-2009 09:40 AM
Hi irfocus,
Let me try to clarify things a little.
There are two suggestions being offered to make your code better while also offering ideas to help with your delay.
1) more than one of us mentioned the timeout for the VISA functions since once they are started they do not retun until the timeout is reached. To check this watch your code in executio highlighting mode to see if the read is active when the shutdown is intitiated and verify when the timeout compltes, the app shuts down. watching it in execution highlighting mode can alos give you a hint as to when your shutdown is detected by teh sub-VI.
2) Action Engines were mentioned to give you a way of sharing data between threads that is not subject to race conditions. If the whole probelm is the T.O then this is just an FYI. If that global you are using is part of race condition, then AE's are a good way to fix that.
3) State Machines are another good programming suggestion and are wonderful for any code construct that is more complicated than a simple loop. They are much prefered over a seq structure because there order can be easily changed and the can lopp back on themselves if warrented.
So...
Start with watching your code in execution highlighting mode and figure out...
A) Is the subVI failing to see the stop (maybe race condition, or not being checked in an inner loop)
B) Is the sub-VI stuck in a VISA function and therefore is not checking for the stop.
Trying my best to help (and still keep my day job),
Ben