02-20-2012 04:07 PM
Hello everyone. I'm looking for some help with a timing issue I am running in to in one of my larger VIs. The situation is essentially this: the VI has 3 simultaneously excecuting loops at any one time.
One of these loops handles the user interface, updating things like the text in a text box, the fill level of a fill bar etc based on things the user is doing. It also controls the display for a countdown clock I've built into my program (it turns a text box green and displays a numeric variable controlled by my third loop as its text value). There is a wait function in this loop that ensures it excecutes no more than once every 20 milliseconds.
The second loop maintains some properties of the front panel and changes them as needed. This has lower priority and has a wait function for 750 milliseconds to prevent it from running too frequently and slowing excecution.
The third is by far the most important. It is the main piece of the program and the problem occurs in this third loop. It goes through its excecution well for its first trial (a 50 second run collecting mouse location and a few other variables) it then enters what is supposed to be a 10 second break. The break is divided into 2 sections, one lasting 5 seconds in which most of the values on the screen are locked into place and not much can change, and another, also 5 seconds, that writes a value to another computer through a LAN i have set up and then starts the countdown clock in the first loop to countdown from 5.
The problem occurs in the interim between saving on the LAN and starting the countdown. For some reason rather than simultaneously excecuting as they do at all other points the program seems to focus on the first two loops and waits 6 to seven seconds before starting the countdown. I know its not the LAN connection as its only saving a 8 character text file and several other times in the program it saves these files within 1/10th of a second, and I've set probes and seen that the other two loops continue to excecute continuously the entire time the program is breaking.
Does anyone have any idea why this might occur? If needed I can post pictures or a sample of the program but id prefer not to as i dont believe my lab wants many people knowing what we're studying until we publish. Any help would be appreciated! Thank you!
Solved! Go to Solution.
02-21-2012 06:44 AM
Yes it would be better if you post a snippet of your 3rd loop.
02-21-2012 12:10 PM - edited 02-21-2012 12:11 PM
Fair enough. I'm including 4 pieces, one for each of the loops, and a version of the final program that should make it slightly harder to see what the programs actual intent is. I've also included a few of the variables and SubVIs that should allow the program to run.
EDIT: I should clarify that the actual full program has been named "sendable program"
02-21-2012 12:36 PM
I do not see anything in the VI you posted which looks like the problem you described. Where is the write to LAN and the timing countdown?
Lynn
02-21-2012 02:47 PM - edited 02-21-2012 02:48 PM
The timing countdown is occuring in the 3rd loop in a for loop, should look like this:
The Numeric Variable that its changing is being written to a text box on the front panel and during the countdown the background color of that text box turns green so it can show up.
The write to LAN function looks like this:
The file path is written to change a text file on the other computer in my LAN.
But the problem is occuring in this section:
The program will wait the five seconds instructed in the first box, then write the text file in the second, then spend several seconds doing nothing but excecuting the other loops before moving on the the final two boxes.
02-21-2012 03:38 PM
The worst part about it is that it doesnt always happen. I cant reproduce it so I have trouble at times knowing if I've really fixed it or if im just having a string of good luck. Will reward with Kudos for any one that can even get a me a place to start looking.
02-21-2012 09:00 PM - edited 02-21-2012 09:01 PM
@Nproach wrote:
Will reward with Kudos for any one that can even get a me a place to start looking.
Don't expect anyone to help for "Kudos" .Kudos silently tells "It really helped me..." "I support your point..." "I like your answer.." thats all. Do not put these kind of offers to attract the user as they really don't do.
02-22-2012 12:22 AM
So I some how did something wrong by saying that if someone can help me, I'll use the tool used to show that someone helped me? I fail to see the issue. Either way though I could really use some help, and I would be incredibly grateful to anyone that could give me a place to start looking.
02-22-2012 02:20 PM
Quick update: I've added a loop in my program that allowed me to guarentee that the first loop of the program continues to operate over and over and over. I think I might have found the issue. I think that my program may be attempting to save the files on the other computer, is encountering interference, and cannot continue with its excecution in the loop until the file on the other computer saves due to my sequence structures. Is this plausible? I know I thought that this couldnt be the answer but as I look at the data more and more this is the only logical conclusion that I can draw.
02-22-2012 04:57 PM
One of the characteristics of the sequence structure is that everything inside one frame must complete execution before the next frame can start. So if your write to file hangs up due to OS or communications issues, your program will be stuck there until the file write is complete.
Parallel loops can minimize this type of problem by allowing the file operations to take as much time as they need without limiting the timing of the other loop (within limits of how much data you can buffer in one or both loops).
Sequence structures severely constrain your flexibility. Best practices in LV generally avoid their use. A state machine is often a better choice.
Lynn