08-13-2012 02:56 PM
I am trying to calculate the volume by multiplying the rate by the time plus the previous volume. The previous volume is the part that I can't figure out. I used a shift register and it's not working.
08-13-2012 03:01 PM
@Mike227 wrote:
I am trying to calculate the volume by multiplying the rate by the time plus the previous volume. The previous volume is the part that I can't figure out. I used a shift register and it's not working.
What do you mean by not working?. What is the output you are getting at the summation output?
08-13-2012 03:06 PM
I have it outputted onto an excel sheet and it's clearly not adding the previous volume.
08-13-2012 03:20 PM
You have to probe the output an dcheck. What happens when any one of the multiplication input is zero?. So you have to check everything since there is nothing wrong in the usage of shift register.
08-13-2012 03:26 PM
Mike227,
That seems like a strange loop. It runs as fast as possible adding a constant to the previous value until some off-the-image boolean stops the loop. Since there is no wait or delay in the loop, it probably runs very fast, thus generating very large numbers (unless one of the inputs is 0, in which case it generates zero many times). A calculation loop typically runs until some condition is met on the calculation being performed and the condition is tested inside the loop. Try temporarily putting an indicator on the output of the Add inside the loop and watch to see if it changes. Also put an indicator on the iteration terminal to see how many times the loop runs.
Lynn
08-13-2012 03:45 PM
Troubleshoot your vi by "Set Breakpoint" on one of your Integer "Data Wire" and "Probe" the multiple data lines, including your shift register and "Step to next Iteration"...
08-13-2012 05:34 PM
As others have already said, you code is somewhat of a mess. Without seing the entire VI we cannot really tell what is going on. Too much is clipped. Too much is hidden in other cases. That entire while loop seem completely useless. Where is the "loopdone" value set? There does not seem to be any reliable way to tell the number of iterations, and they will strongly depend on the computer speed. Since the result is critically dependent on the number of iterations, the results are thus random and useless.
Can you tell us what the program is supposed to do? can you attach the actual VI?
If you want to start with the Previous volume (whatever that is, but maybe it is the orange wire entering from the left), you need to wire that to the shift register instead of a zero diagram constant. Just wildely guessing! Many more things are definitely broken at the moment.
08-14-2012 07:08 AM
I'll throw in a guess. I have seen this before. It is likely that the 0 constant is wired via a tunnel to the add instead of the shift register. Easy way to check this is to move the shift register. If a tunnel magically appears (because it's durrently hiding behind the shift register), there's your problem.
08-14-2012 08:14 AM
Hello everybody,
Thanks for all of your replys so far. I know that I have a tendency for messy code. I try to improve my skills as I inherit more tips and knowledge within LabView.
Attached is my entire VI. Do you think that I need the while loop inside? Maybe that's what is causing this mess.
Mike
08-14-2012 08:40 AM
The first thing I notice is that the loop will never exit since the "Loop Done" is never being written to inside the loop. I'm not seeing what the point of the while loop is. Are you trying to wait so long until a certain volume is reached and then report it?
From a general programming view, you should breakup your code into subVIs. It'll make it a lot simpler to understand.
I'm also noticing several "multiply by 1" in there. Those do nothing, get rid of them.
I also don't see the point in having separate code for the positive and negative flow rates. The math works the same (V1 = V0 + rate). The negative will subtract on its own.
I would convert to a single flow rate. For instance, if the rate is in ml/h, convert to ml/min inside a case structure and then do the volume calculation after the case structure. If the rate is in ml/min, just pass the flow rate through the case structure and do the calculation. This will eliminate duplicate code.