02-23-2010 04:36 PM
I have not understand if it's good or no to pass error in and error out in shift register when it's set a instrumentation in loop. For example in this figure there is this, but many persons tell me that it's dangerous. Why? What is the better way for an exeper LabVIEW programmer?
02-23-2010 04:58 PM
Everyone has their own philosphy on this, but I do not typically use a shift register. My personal style is that each cycle of the loop should start "clean". If there is an error before the loop starts, I don't start the loop. At the end of each cylcle of the loop I place my Error Handler. This error handler decides if the error is fatal and should stop the VI, or in most cases just resets the instrument in question. After handling (and logging) the error, I reset the error out to no error and start the next cycle. Whether or not a shift register is used, the cycle starts with no error.
My error handler contains a feedback node and I usually consider two consecutive errors to be fatal (this often means time for a power cycle).
If you use a shift register and never handle or clear your errors you often wind up in an inifinite loop which spins as fast as the CPU allows. In short, whether or not you use a shift register you need to decide (as early as possible) what you want to do in the case of an error and how you intend to handle it.
02-23-2010 05:04 PM
02-23-2010 05:10 PM
For me, using the shift register is often very important for error trapping. Without the shift register, it is very easy to lose the error information. When you do use the shift register though, you need to make sure that all your subvi have a case structure that case the subvi to not execute but only to feed through the error information. By doing that, when an error occur, it is just going to feed through all the vi and loop iteration without being corrupted. If you trap the error, you will be able to trace back to where your bug is in your code.
Yik
02-23-2010 10:37 PM
Yik,
Why would you want to have a while loop continue to run if you aren't going to do nothing in later iterations of the while loop? You might as well just go ahead and stop the while loop as soon as you get the error.
What could be worse is that the while loop might never end because of the error which would happen if the while loop would normally end based on something that would occur in the loop in the No Error case of your while loop.
I'd say the only way a shift register on the error wire is a good idea is if you have the NoError/Error case structure inside your loop, and you explicitly do something with that Error in the Error case on the next iteration such as closing/reopening your resource, or logging the error to a file, or triggering off some other process, and the proceed to clear the error so that your while loop goes back to normal operation.
02-24-2010 12:50 AM
02-24-2010 12:53 AM
02-24-2010 01:01 AM
02-24-2010 01:20 AM - edited 02-24-2010 01:25 AM
Michelle...
Believe me "nobody gets paid here" for solving any problem...
Its their whole and soul interest whether to answer a question asked or to discard the same.Keeping this in mind if you can solve the problem on your own may be tomorrow you can help some one out and you wont end up repaeting the same mistake that you have done earlier.
Also it is up to you to take the suggestions given by other fellow buddies or not to take it.
Guru
02-24-2010 07:38 AM
Guruthilak wrote:Michelle...
Believe me "nobody gets paid here" for solving any problem...
Its their whole and soul interest whether to answer a question asked or to discard the same.Keeping this in mind if you can solve the problem on your own may be tomorrow you can help some one out and you wont end up repaeting the same mistake that you have done earlier.
Also it is up to you to take the suggestions given by other fellow buddies or not to take it.
Guru
Message Edited by Guruthilak on 02-24-2010 12:55 PM
Double dittos to that!
Years ago one of my old bosses caught me mubling something along the lines "well that's job security" when talking about something I knew but nobody else. So he say me down and explained what I had to do to succeed.
Ross Beadle to myself:
"
Ben, succesful people go through phases in the carrers.
They start not knowing what they should or could do and they need guidance from the more experienced.
Latter they learn to do the job with only occational asistance.
Then they move into phase where they can do it independently and can occationally help others.
If the keep working they can get to the point where they can do their job AND others depend on them to get things done.
Unfortunately many people stop at this point thinking they have job security. To truely be valuable they should take the next step and work to train all around them such that the peers can work without assistance thereby freeing themselves to move to the next level.
"
So just learning how to do something is just one step along the path. I have followed Ross's advise and it has served me well. I regularly remind my boss that I am trying to work myself into retirement such that my company will not miss me when I retire. My efforts here and elsewhere are for the same reason.
Sorry for the lecture. Sometimes I just have to get it out.
Ben