# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## Interpolation of 3 variables

Working on a project at the moment that dispenses fluid in user selectable amounts (gm).

Flow measurement of the fluid is carried out by a flowmeter with quadrature output so pulses are counted for a given quantity dispensed.

From this an array has been created for flow (pulses) versus quantity measured in gram from scales. This array was then interpolated (attached vi) so for a given request for mass (gm) the required pulses from flowmeter were indicated. This worked reasonably (except for delays in fluid transfer etc) but it was found that the table became inaccurate with change in pressure.

So at various pressures of 20Bar, 30Bar, 40Bar etc arrays have been created for flowmeter pulses versus mass. What I am attempting to do is for a given request for mass (gm) interpolation will take place between the current pressure and mass (gm) to indicate the flowmeter pulses required.

I have searched for interpolation 2D and also 3D, found quite a few examples but struggling to get my head around them.

Labview Version 8.5
Labview Version 8.6
Labview Version 2014
Message 1 of 9
(3,766 Views)

## Re: Interpolation of 3 variables

All you need is a 2D array and some bilinear interpolation using the pressure and volume. Use iterpolate array to get the corresponding fractional array indices for each dimension, then index (fractional) into the 2D using e.g. my bilinear code code posted here.

If the behavior is relatively smooth, you could just fit the 2D data to a low order 2D polynomial and apply the formula instead.

On a side note, your current 1D code could be simplified by indexing by column (eliminates the tranpose, note the 0 wire to the bottom index) and by replacing the FOR loop with "index & bundle cluster array".

Message 2 of 9
(3,746 Views)

## Re: Interpolation of 3 variables

Thanks for link and I will have a look at that now.

Your verson of my code is really neat and I was chuffed at my attempt, I will get there one day and know what to aim for!

Please find attached interpolation vi with data from 40 Bar and then 50 Bar 'sweep'.

The issue I have with the pressure is that it does not have a constant set point and can vary significantly when dispensing takes place due to the pump being used. Typically a 'drift' of 3 Bar can be seen as the pressure falls before pump operation which initially drops the pressure by up to 2 Bar and then recovers the pressure to its original set point (so + 5 Bar in this example).

The 'juggling point' from my perspective is do I try to determine the corrections in software with Labview or modify mechanical hardware to try and reduce the pressure variations with accumulators etc. Guess its the old chicken and egg situation..................

Labview Version 8.5
Labview Version 8.6
Labview Version 2014
Message 3 of 9
(3,725 Views)
Solution
Accepted by topic author jack1

## Re: Interpolation of 3 variables

Now you need two "data in", one for pressure and one for the desired grams.

Output would be a scalar "# of pulses" needed, right?

Message 4 of 9
(3,720 Views)

## Re: Interpolation of 3 variables

Yes,

Thanks,

Jack

Labview Version 8.5
Labview Version 8.6
Labview Version 2014
Message 5 of 9
(3,716 Views)

## Re: Interpolation of 3 variables

Sorry for delay in thanking you for your help on this and used some of your code from earlier posts.

Done a bit of 'mix & match', its not elegant but it works for now and have attached vi in case its of use to anyone.

Labview Version 8.5
Labview Version 8.6
Labview Version 2014
Message 6 of 9
(3,638 Views)
Solution
Accepted by topic author jack1

## Re: Interpolation of 3 variables

Ah, I forgot about that discussion. Here's what I came up with a long time ago. One problem is that the two calibration arrays have different g ranges, so you would need to some range checking. Right now you'll get edge values if out of range.

I still think fitting the data to a 2D polynomial would be better.

Message 7 of 9
(3,621 Views)

## Re: Interpolation of 3 variables

Thanks,

The method for dispensing uses several nozzle sizes which affects the flowmeter measurment and a major factor I have found is the delivery pressure due to viscosity. So to meet the clients dispense times it is a juggle between nozzle selection, time, qty and pressure.

From this I ran tests and came up with reduced data sets that fitted the clients spec before change of nozzle/pressure. These are typically limited to only 6 points so nozzle A might dispense in the required 4 seconds 0.4 gm up to 6 seconds for 0.7gm, nozzle B 5 seconds 0.6gm to 8 seconds 1gm etc.

Because the brief was wide from 0.1gm up to 10gm at the moment I have taken around 6 points for each of the nozzles in that range, then applied a polynomial to extend range either side of the 'value obtained from experiment' to the full range of say 0.1gm to 10gm.

Carried out some initial trials and mixed results so need to determine if its in the hardware or my software has an issue.

I take on board what you are saying and for flexiblity I have tried to 'fit' the data to 2nd and 3rd order polynomials but results were disappointing. This has led me to feel that the mechanical arrangement is not the best and so came up with thought that led me down where I am now.

I will let you know outcomes over the next few days,

Labview Version 8.5
Labview Version 8.6
Labview Version 2014
Message 8 of 9
(3,610 Views)

## Re: Interpolation of 3 variables & maths problem

After running trials with interpolation it was found limited (which I know was pointed out at the time, but tried anyway....).

Problems were found carrying out the computations in real time and also that unless the range to be used had previously had values obtained for dispense time versus quantity versus dispense pressure, then inaccurate results were obtained.

So a few plots were done again in this case with just 2 pressure settings of approximatly 29.5 Bar and 43.5 Bar over a 6.5 second period in increments of 0.5 seconds. The results for the quantity of material dispensed in each case had a very linear result of y=mx+c but different values for m, slope and slightly different for the intercept c. These being dependent upon the two pressures.

Therefore if the pressure could be held constant at say 43.5 Bar then the formula from Excel graph could be used directly in Labview for that plot.

But problem is that the pressure fluctuates significantly so I need to find the relationship between the 2 example plots so adjustments could be made to the slope and intercept values for the change in pressure. Also interim values for pressures not defined could be calculated in Labview.

In this example I took the pressures and found an approx factor of 170 to derive the slope value from the pressure but feel its a rubbish idea and total wrong................

My maths is quite rusty but I know there is a relationship that could be used and put into Labview, but I just cannot see it.............

Appreciate any help,

Thanks,

Jack

Labview Version 8.5
Labview Version 8.6
Labview Version 2014
Message 9 of 9
(3,363 Views)