v1.0 CALIBRATION: Leaf Thickness Quick


Calibration macro for clamp to open and close
// pop out those first and last elements, then save this particular output to the white device.  
// fix open-close-start
// check white device versus black devices in terms of calibration...


// update soon to generate the max value correctly, also need to update the actual protocol to reflect an actual process
// once we have actual flush devices


//============================================
// Macro for calibrating leaf thickness in the MultispeQ v1.0
// created: 09/06/2016
//============================================

// utilizes polynomial fit, using the MathPOLYREG(array,degrees)
// note that all values are converted to um for storage (since they are stored as floats, this helps reduce the number of very very small saved values which could be less than 6 numbers into the decimal place

//Define the output object here
var output = {};

// To be used if we have standard calibration values in the future
//var calibration_thickness = [.05,.125,.19,.6,1.016,2.74]

// distances measured and replicates for each distance measured for this protocol
distancesMeasured = 2;
reps = 5;

// Create the arrays and initialize to zero to use in the model for calculating leaf thickness coefficients to convert from Hall effect sensor to actual thickness in mm

var calibrationHall = [];
for (var i=0;i<distancesMeasured;i++) {
  calibrationHall[i] = 0;
}

// Populate the Hall effect sensor data (there are 8 distances measured, and 5 reps at each distance)
for (var i=0;i<distancesMeasured;i++) {
  for (var j=0;j<reps;j++) {
    calibrationHall[i] += parseFloat(json.thickness_raw[i*reps+j]);
  }
  calibrationHall[i] = calibrationHall[i] / reps;  // now average all values into a single value for that distance
}

// set thickness_min and thickness_max (the first and last thickness measured)
var thickness_min = calibrationHall[0];
var thickness_max = calibrationHall[distancesMeasured-1];

// add error checking + warnings

// Output those fits and save them to the device
output ["toDevice"] = "set_thickness_quick+"+thickness_min+"+"+thickness_max+"+";

output ["thickness_max"] = thickness_max;
output ["thickness_min"] = thickness_min;

//Check if the key time exists in json
if (json.time !== undefined){

	//Add key time and value to output
	output["time"] = json.time;
}

//Return data
return output;
{
  "time_offset": 240,
  "time": 1473176351826,
  "device_version": "1",
  "device_id": "d4:f5:00:00:00:00",
  "device_battery": -18,
  "device_firmware": "1.06",
  "firmware_version": "1.06",
  "device_time": 1471522138,
  "sample": [
    [
      {
        "time": 1473176351840,
        "protocol_id": 1,
        "message": [
          [
            "alert",
            "thickness fully closed",
            "ok"
          ],
          [
            "alert",
            "thickness fully open",
            "ok"
          ]
        ],
        "thickness": [
          "0.967000",
          "0.969906",
          "0.971281",
          "0.973437",
          "0.973437",
          "10.886344",
          "10.859282",
          "10.870093",
          "10.870093",
          "10.856531"
        ],
        "thickness_raw": [
          "47639.000000",
          "47643.000000",
          "47645.000000",
          "47648.000000",
          "47648.000000",
          "37747.000000",
          "37757.000000",
          "37753.000000",
          "37753.000000",
          "37758.000000"
        ],
        "data_raw": [
          19,
          17,
          19,
          18,
          19,
          18,
          18,
          18,
          19,
          17
        ]
      }
    ]
  ],
  "app_os": "linux",
  "app_name": "PhotosynQ",
  "app_version": "0.3.5",
  "app_device": "x86-64",
  "location": [
    "42.7226084",
    "-84.4746675"
  ],
  "ConsoleMacro": "179"
}
012409 pbi 160 low low res headshot
Created by

Greg Austic


Protocol connections:
2
Latest Update:
Sep 2016