unreliable calculations


DaveP

Recommended Posts

I am using a number of pressure transducers to measure the pressure drop accross an orrifice and hence calculate the flow rate.

I have done some calibration trials and graphed mV against flow rate, but the characteristic is such that the curve does not pass through zero (as you might expect on this kind of device) so I have a polynomial like

y = -0.0391x2 + 1.1072x + 1.8403 this means that at 0 mV I will my variable will have a value of 1.8403.

To allow for this I wrote in a sequence

while(1)
   if (Mean(Master_Hot_Flow[0,9])< 2.5)
	  MHflow=0
   else
	  MHflow=(-0.0391*(Mean(Master_Hot_Flow [0,9])+zero8))^2+1.1072*(Mean(Master_Hot_Flow[0,9])+zero8)+1.8403
   endif 
   delay(1)
endwhile

The idea being to force the variable to 0 if the raw data is less than 2.5mV

The problem I have is that a display of the variable MHflow, when there is no flow, will keep jumping between 0 and 1.8

I cannot understand why this happens as the sequence should never go to the 'else' instruction.

can anyone point out my error or a workaround, I cannot put a continue before the endif because I need to similarly process 3 more flow meters within the loop.

Link to comment
Share on other sites

Perhaps you are changing that variable elsewhere? Try stepping through the script using the debugger.

Also, you really should precalc the mean:

while(1)
   private mhf_mean = Mean(Master_Hot_Flow[0,9])
   if (mhf_mean < 2.5)
	  MHflow=0
   else
	  MHflow=(-0.0391*(mhf_mean+zero8))^2+1.1072*(mhf_mean+zero8)+1.8403
   endif
   delay(1)
endwhile

Link to comment
Share on other sites

I believe I have a similar problem as this.

I've also noticed our pressure transducer is never really "zero".

I've made some sliders for zero and span, a "fake zero" variable, a manual begin/end button if the loop finishes early or needs re-starting in my attempts to have a smooth running pressure tranduscer sequence...

Sometimes I set my fake zero to something like 0.0009.

Kinda hard to find accurate calculations when zero can never be found. :)

Link to comment
Share on other sites

That is likely hardware related. You can do global x = 0 and I can assure you x will equal 0.0000000. If you want to apply a deadband to a channel so any value below, say, 0.001 results in 0.0000000, just use this conversion:

Value * (value >= 0.001)

For +/-, use abs:

Value * (abs(value) >= 0.001)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.