BallardHill Posted May 9 Share Posted May 9 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! Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted May 10 Share Posted May 10 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? Quote Link to comment Share on other sites More sharing options...
BallardHill Posted May 10 Author Share Posted May 10 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 Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted May 13 Share Posted May 13 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. Quote Link to comment Share on other sites More sharing options...
BallardHill Posted June 13 Author Share Posted June 13 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) Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted June 13 Share Posted June 13 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. Quote Link to comment Share on other sites More sharing options...
BallardHill Posted June 13 Author Share Posted June 13 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 ... Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted June 13 Share Posted June 13 That might be a time stamp thing. You might add insertTime(): insertTime(InterpolatePoly(CalMVOfs0, CalPctg, CH0[0]), ch0.time[0],0) Quote Link to comment Share on other sites More sharing options...
BallardHill Posted June 14 Author Share Posted June 14 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. Any advice? Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted June 14 Share Posted June 14 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) Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted June 14 Share Posted June 14 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) Quote Link to comment Share on other sites More sharing options...
BallardHill Posted June 15 Author Share Posted June 15 I hesitate to mention this (because it makes me look REALLLY stupid), but perhaps the LJTick-InAmp gain of 201 we have applied on all Load Cell Channels should be inserted somewhere, perhaps: 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! Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted June 15 Share Posted June 15 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.