LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why won't my shift register work?!

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.

0 Kudos
Message 1 of 11
(4,563 Views)

@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?

-----

The best solution is the one you find it by yourself
0 Kudos
Message 2 of 11
(4,562 Views)

I have it outputted onto an excel sheet and it's clearly not adding the previous volume.

0 Kudos
Message 3 of 11
(4,560 Views)

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.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 4 of 11
(4,545 Views)

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

0 Kudos
Message 5 of 11
(4,536 Views)

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"...

 

0 Kudos
Message 6 of 11
(4,521 Views)

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.

0 Kudos
Message 7 of 11
(4,501 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 8 of 11
(4,449 Views)

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

0 Kudos
Message 9 of 11
(4,438 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 10 of 11
(4,427 Views)