From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you handle linear calibration?

I have a few sensors (Dexcom G4 glucose sensor) that have fairly linear response curves, but I'm having trouble calibrating them. I'm calibrating using a device (YSI 2300 stat plus) that's within +/-1% of the true value. My current scheme:

 

  1. Least squares fit
  2. Calibrations older than 4 hours get dropped
  3. No weighting of values in time

I'm seeing that with this current setup, if we get a "bad" calibration value, the entire calibration can be off for a long time. Ideally, I wouldn't need to calibrate more than once every 4 hours, and new calibrations would greatly outweigh the old ones.

 

Here's a snippet of a weighted/nonweighted calibration scheme with geometric precedence of newer values. How would you handle this?calibration.png

0 Kudos
Message 1 of 4
(3,194 Views)

Hi ijustlovemath,

I am a little confused on what your VI is supposed to do… you are trying to create a Linear Fit by only running the code once? Also what are the for loops for? The way this is programmed they only run once.

0 Kudos
Message 2 of 4
(3,130 Views)

Assuming that your calibration procedure/process is correct, why don't you just use the latest values as those are the most up-to-date calibration values? I would put in a check to detect a 'bad' calibration value (e.g. if something fails...the calibration values are within some tolerance) but just use the latest calibration value.

 

If you're averaging/combining multiple calibrations then this 'bad' calibration will always impact your other results and instead should just be discarded. You could also record the calibration values used and/or log the raw data so you can correct them if necessary.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 3 of 4
(3,099 Views)

This code is within a subVI thats part of a larger application. I have a need to be able to interpolate incoming raw values using my current calibration, which is where this code would run.

 

The inputs X and Y come from a functional global variable that holds calibration values, and appends new ones. The two for loops are for generating a "Weight" array, using exponential smoothing for the weights, eg array element i gets weight a*(1-a)^i. The innermost for loop is for that exponentiation, as I couldn't quite figure out how else to do it. Here's a snippet showing what I mean: 

 

calibration method.png

 

It's all on one diagram, but in the application it's two separate subVIs. I see what you're saying Sam, maybe my bounds check needs to be a little more complex. Something like computing the distance of a new calibration point from the current calibration line, which tosses the point if it's too far away. Would using the bisquare method of the linear fit VI do this for me?

0 Kudos
Message 4 of 4
(3,079 Views)