Channel Conversion Calibration Expression

Recommended Posts

Does anyone have a working Channel Conversion expression using a 5-point array that they can share?

I've read that the Interpolate function has been or will be deprecated, so the obvious technique would seem to be inadvisable.

If no extant expression is available, can anyone offer advice on a workable approach?

We'd be willing to consider buying such a resource for a reasonable fee.

Thanks for your consideration!

Share on other sites

The interpolate function is not deprecated, just the menu items that do interpolation.  You can still use interpolate from script / expressions. Can you tell me where you read this so we can adjust the verbage to be clearer?

Share on other sites

I found it yesterday while searching my long-standing topic of calibration tables, but it does not show up now using "interpolation", "calibration", "interpolate" or "calibrate" as keywords".

Sigh ...  I apologize that I cannot be of greater assistance.

If I stumble on it again I'll be sure to revisit this message and report my findings.

Thanks for your consideration,

Malcolm

Share on other sites

Here is an explanation of doing an interpolation with 5 points.  First you need to create two global variables, call them say, "calPerc", "calVoltage".  CalPerc you can set to your steps:

global calPerc = {0,25,50,75,100}

CalVoltage you can initialize to some defaults:

global calVoltage = {0,1,2,3,4}

Then if you want, you can pull actual values from a file or the registry.

To then calculate a percentage based on a voltage reading ("Value" below) you just do:

interpolatePoly(calVoltage, calPerc, Value)

You can then change calVoltage all you want for new calibration values.  Just use array notation, so calVoltage[0] is the calibration reading at 0%, calVoltage[1] is the reading at 25%, etc.
Share on other sites

• 5 weeks later...

In Setup script Startup, which runs at startup, we have:

// BEGIN Calibration Section

// Load Max Percentage
Global        CalPctg = {0,25,50,75,100}

// Per Channel Calibration points
Global        CalMVOfs0 = {1.250019, 1.252121, 1.254183, 1.256247, 1.258308} // Calibration Service results for Load Cell #0 at 0%, 25%, 50%, 75%, and 100% Load

(We've added the 1.25 Volt offset applied by LabJack U3)

Then in Conversions field of Channel Table, for Channel 0 named CH0, we use:

InterpolatePoly(CalMVOfs0, CalPctg, Value)

Q:  Can we also use in Export:  InterpolatePoly(CalMVOfs0, CalPctg, CH0)

Share on other sites

Yes.  Export sets take expressions, so as long as the expression evaluates to a value, it will work.  But if you are already applying the conversion to CH0, then you already have the value.

Also, it would be better to use math to apply the 1.25 volt offset:

global calMVOfs0 = {0.0019, 0.002121, etc....}
calMVOfs0 += 1.25 // apply LabJack offset

This is cleaner, more obvious what you are doing, and allows you to change the cal points without adding 1.25 to every value.

Share on other sites

Applying InterpolatePoly in Channel Conversions results in wildly varying values (on our machines) - have not yet determined why, so I hoped to apply it at Export time.  Not getting output for those Export Expressions yet - columns are blank ...

Share on other sites

That might be a time stamp thing.  You might add insertTime():

insertTime(InterpolatePoly(CalMVOfs0, CalPctg, CH0[0]), ch0.time[0],0)

Share on other sites

Slight (but significant variable renaming and value changes, and the attempt to implement the Conversion shown results in NaNs displayed:

// Load Max Percentage
Global        CalPctg = {0,25,50,75,100}

// Per Channel Calibration points
// reflecting 1.25 volt offset to get above noise already removed
Global        CalMV0 = { 0.000019, 0.002121, 0.004183, 0.006247, 0.008308}

In Conversions Table:  InsertTime(InterpolatePoly(CalMV0, CalPctg, CH0[0] - 1.25), CH0.time[0], 0)

This Conversion is set in the Channel Table for CH0.

Strikes me as some stupid (well, mindless,) error on my part.

Share on other sites

If it is a conversion you really should use the keyword "Value" instead of the channel name:

InsertTime(InterpolatePoly(CalMV0, CalPctg, Value - 1.25), getTime(value), 0)

And you may not need the inserttime() part, just:

InterpolatePoly(CalMV0, CalPctg, Value - 1.25)

Share on other sites

Also, test it with static values.  Try setting the conversion to:

InterpolatePoly(CalMV0, CalPctg, 0.004)

Or better yet, test it at the command / alert window too:

? InterpolatePoly(CalMV0, CalPctg, 0.004)

Share on other sites

I hesitate to mention this (because it makes me look REALLLY stupid), but perhaps the InterpolatePoly(CalMV0, CalPctg, (Value - 1.25) / 201).

(Yes, I over-parenthesize to prevent possible confusion in orders of operator precedence ...)

I'll try this out and see what results arise.  Will advise.

Have a good weekend!

Share on other sites

The third parameter really needs to be between 0.000019 and 0.008308.  It maybe can go a little past the ends, but beyond that the interpolation is going to get a bit wild.  If you aren't doing the /201, then yeah, it will really swing bad.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.