LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VI to calculate slope and intercept from a table

New to LabVIEW, thanks for any help I receive.

 

I am trying to write a simple script that consists of tables of calibration values (slopes and offsets) for several families of sensors (temperature, pressure, and ADC channels).  I then want the user to be able to select which sensors they're using (either a pressure and ADC or temperature and ADC) and have a single calibration slope and intercept calculated for that sensor/ADC pair.  Any suggestions on how to go about this or existing examples to try?

Thank you.

0 Kudos
Message 1 of 6
(3,950 Views)

In the Mathematics -> Fitting pallette, there's a slew of VIs that return slope and intercept. Maybe Linear Fit.VI will be what you need.

0 Kudos
Message 2 of 6
(3,943 Views)

Not sure if I was clear.  I have a calibration slope and intercept for each sensor and/or ADC channel.  Each time we deploy the tool there will be either a pressure or temperature sensor aconnected to a particular ADC channel.  Rather than having to input two slopes/intercepts for each sensor/channel pair, I want the user to be able to select which sensor/ADC channel being used and calculate a single slope and intercept for the pair.  I already have creted a series of inputs for each slope/intercept and I need to create a front panel set-up where the user can select which sensor and ADC channel is being used and then have the script take those two slopes and intercepts, plug them into the equation, and kick out a single slope and intercept.  

 

Thanks for responding.

0 Kudos
Message 3 of 6
(3,939 Views)

Have you already written any code that would demonstrate what you're trying to do, even if that code does not yet work?  Perhaps you've put together a front panel showing the interface you want, and just need help filling in the block diagram?  It's hard to tell what you're asking here.  The math to merge two sets of scaling constants should not be difficult.

0 Kudos
Message 4 of 6
(3,927 Views)

It is an incomplete front panel but here you go.  You can see there is a place to input all the slopes and intercepts and then in the lower left I want the user to be able to select which CDAQ, tip snesor, shaft sensor, and thermistor  they're using and have a single slope/intercept calculated for the tip pressure, shaft pressure, and tip temperature.  I am not really concerned abou the math, I just don't know how to set up the portion where the user can select the sensor from a drop down menu and then pull the particular value into the equation.

Thanks for all your help.

0 Kudos
Message 5 of 6
(3,920 Views)

The first thing you'll want to do is look into enumerations, since that will be the best way to set up a drop-down menu.  Note that there is a difference between Rings and Enumerations.  My guess is that the latter will be more appropriate here, unless you expect to be changing the items in the list programmatically later.  Enumerations should be Type Definitions; see the help for this.  That way you only need to update the enumeration in a single location and all instances of it will be updated to match.  You'll want one enumeration for each category.

 

If this were my VI, I would use a table control instead of the separate string controls.  That way you can use the enumeration value to index out the appropriate row from the table.  Alternatively, you could replace all the string controls with numerics (they should be numeric since you're entering numbers).  If you put them into an array they'll be easier to manage.  You might make a cluster of two numeric values - slope, intercept - and then build an array of those clusters.

 

Once you get the front panel reformatted in a way that makes the data easier to manipulate, the rest should come together easily.

0 Kudos
Message 6 of 6
(3,910 Views)