generate nonpar led test values


generate nonpar led test values
/**
 * Macro for data evaluation on PhotosynQ.org
 * by: David M. Kramer
 * created: January 4, 2019 9:02 PM
 */

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

// Check if the key time exists in json
if (json.time !== undefined){
    // Add key time and value to output
    output.time = json.time;
} 

//10000+3000+-200
var satV=15000;
var vals =[]; 

var tauV = [500,1000, 1500, 2000, 3000];
var offsetV = [200,300,400,500,600];
 
var _par=5000;

var max_adc=30000;
output.toDevice="";

var dac_values=[];
var tau_vals=[];
var offsetV_vals=[];
for (var ii=0; ii<offsetV.length; ii++){
for (var i=0; i<tauV.length; i++){
    
	dac_values.push(-1*MathROUND(tauV[i]/(satV/(_par-offsetV[ii]) - 1),0));
    tau_vals.push(tauV[i]);
    offsetV_vals.push(offsetV[ii]); //, satV]);
}
}
output.dac_values=dac_values.join();
output.tau_vals=tau_vals.join();
output.offsetV_vals=offsetV_vals.join();
 
var leds=json.v_arrays[0];
output.leds=leds;

test_data=[]
for (var ledi=0; ledi<leds.length;ledi++){
  output["r" + leds[ledi]]=[];
  var testvals=GetProtocolByLabel( leds[ledi], json );
  test_datum=[]
  for (ledii=0;ledii<testvals.length;ledii++){
     //output["testvals" + leds[ledi] +"-"+ ledii]=testvals[ledii].data_raw[0];;
    test_datum.push(testvals[ledii].data_raw[0]);
  }
  	test_data.push(test_datum);
    output["r" + leds[ledi]]+=test_datum

  
  
    var index_to_optimum=0;
    var curr_best=0; 

    for (var i=0; i<test_datum.length; i++){
      if ((test_datum[i]<max_adc) && (test_datum[i]>curr_best)){
        curr_best=test_datum[i];
            index_to_optimum=i;
      }
    }
 
    output["index_to_optimum " + leds[ledi]]=index_to_optimum;
    output["curr_best " + leds[ledi]] = curr_best;
    opt_tau_val=tau_vals[index_to_optimum];
    output["opt_tau_val " + leds[ledi]]=tau_vals[index_to_optimum];
    opt_offsetV_val=offsetV_vals[index_to_optimum];
    output["opt_offsetV_val "+ leds[ledi]]=opt_offsetV_val;

    // Return data
    output.toDevice += "s+set_par_to_dac_calibration+";
    output.toDevice += + leds[ledi] + "+";
    output.toDevice += satV + "+";
    output.toDevice += opt_tau_val + "+";
    output.toDevice += opt_offsetV_val + "+-1+";
  
  
  
  
}

return output;
//find the settings with the ADC values that are highest, but 
//not above mac_adc
var index_to_optimum=0;
var curr_best=0;

for (var i=0; i<testvals.data_raw.length; i++){
  if ((testvals.data_raw[i]<max_adc) && (testvals.data_raw[i]>curr_best)){
	curr_best=testvals.data_raw[i];
    	index_to_optimum=i;
  }
}

output.index_to_optimum=index_to_optimum;
output.curr_best=curr_best;
opt_tau_val=tau_vals[index_to_optimum];
output.opt_tau_val=tau_vals[index_to_optimum];
opt_offsetV_val=offsetV_vals[index_to_optimum];
output.opt_offsetV_val=opt_offsetV_val;

// Return data
output.toDevice += "s+set_par_to_dac_calibration+";
output.toDevice += "10+";
output.toDevice += satV + "+";
output.toDevice += opt_tau_val + "+";
output.toDevice += opt_offsetV_val + "+-1+";
  
// set_par_to_dac_calibration+10+10000+2000+-700+-1+
return output;
{
  "time": 1546715494103,
  "device_name": "MultispeQ",
  "device_version": "2",
  "device_id": "32:31:36:b3",
  "device_battery": 98,
  "device_firmware": 2.006,
  "sample": [
    [
      {
        "time": 1546715494103,
        "v_arrays": [
          [
            "6",
            "7",
            "8",
            "10",
            "5"
          ],
          [
            "1",
            "1",
            "1",
            "1",
            "1"
          ],
          [
            "-471",
            "-706",
            "-941",
            "-1412",
            "-3294",
            "-456",
            "-684",
            "-913",
            "-1369",
            "-3194",
            "-442",
            "-663",
            "-885",
            "-1327",
            "-3096",
            "-429",
            "-643",
            "-857",
            "-1286",
            "-3000",
            "-415",
            "-623",
            "-830",
            "-1245",
            "-2906"
          ]
        ],
        "set_repeats": 5,
        "protocol_id": 1,
        "set": [
          {
            "time": 1546715494103,
            "label": "6",
            "data_raw": [
              1595
            ]
          },
          {
            "time": 1546715494103,
            "label": "6",
            "data_raw": [
              3630
            ]
          },
          {
            "time": 1546715494107,
            "label": "6",
            "data_raw": [
              5757
            ]
          },
          {
            "time": 1546715494112,
            "label": "6",
            "data_raw": [
              10518
            ]
          },
          {
            "time": 1546715494133,
            "label": "6",
            "data_raw": [
              35829
            ]
          },
          {
            "time": 1546715494133,
            "label": "6",
            "data_raw": [
              1489
            ]
          },
          {
            "time": 1546715494134,
            "label": "6",
            "data_raw": [
              3417
            ]
          },
          {
            "time": 1546715494142,
            "label": "6",
            "data_raw": [
              5491
            ]
          },
          {
            "time": 1546715494145,
            "label": "6",
            "data_raw": [
              10069
            ]
          },
          {
            "time": 1546715494151,
            "label": "6",
            "data_raw": [
              34177
            ]
          },
          {
            "time": 1546715494158,
            "label": "6",
            "data_raw": [
              1384
            ]
          },
          {
            "time": 1546715494164,
            "label": "6",
            "data_raw": [
              3234
            ]
          },
          {
            "time": 1546715494172,
            "label": "6",
            "data_raw": [
              5238
            ]
          },
          {
            "time": 1546715494177,
            "label": "6",
            "data_raw": [
              9617
            ]
          },
          {
            "time": 1546715494184,
            "label": "6",
            "data_raw": [
              32552
            ]
          },
          {
            "time": 1546715494190,
            "label": "6",
            "data_raw": [
              1280
            ]
          },
          {
            "time": 1546715494197,
            "label": "6",
            "data_raw": [
              3088
            ]
          },
          {
            "time": 1546715494206,
            "label": "6",
            "data_raw": [
              4974
            ]
          },
          {
            "time": 1546715494210,
            "label": "6",
            "data_raw": [
              9207
            ]
          },
          {
            "time": 1546715494219,
            "label": "6",
            "data_raw": [
              31013
            ]
          },
          {
            "time": 1546715494223,
            "label": "6",
            "data_raw": [
              1179
            ]
          },
          {
            "time": 1546715494230,
            "label": "6",
            "data_raw": [
              2904
            ]
          },
          {
            "time": 1546715494240,
            "label": "6",
            "data_raw": [
              4722
            ]
          },
          {
            "time": 1546715494243,
            "label": "6",
            "data_raw": [
              8758
            ]
          },
          {
            "time": 1546715494249,
            "label": "6",
            "data_raw": [
              29557
            ]
          },
          {
            "time": 1546715494256,
            "label": "7",
            "data_raw": [
              13
            ]
          },
          {
            "time": 1546715494262,
            "label": "7",
            "data_raw": [
              27
            ]
          },
          {
            "time": 1546715494273,
            "label": "7",
            "data_raw": [
              32
            ]
          },
          {
            "time": 1546715494276,
            "label": "7",
            "data_raw": [
              45
            ]
          },
          {
            "time": 1546715494282,
            "label": "7",
            "data_raw": [
              125
            ]
          },
          {
            "time": 1546715494289,
            "label": "7",
            "data_raw": [
              18
            ]
          },
          {
            "time": 1546715494295,
            "label": "7",
            "data_raw": [
              25
            ]
          },
          {
            "time": 1546715494305,
            "label": "7",
            "data_raw": [
              34
            ]
          },
          {
            "time": 1546715494308,
            "label": "7",
            "data_raw": [
              47
            ]
          },
          {
            "time": 1546715494315,
            "label": "7",
            "data_raw": [
              121
            ]
          },
          {
            "time": 1546715494321,
            "label": "7",
            "data_raw": [
              15
            ]
          },
          {
            "time": 1546715494328,
            "label": "7",
            "data_raw": [
              25
            ]
          },
          {
            "time": 1546715494334,
            "label": "7",
            "data_raw": [
              32
            ]
          },
          {
            "time": 1546715494341,
            "label": "7",
            "data_raw": [
              49
            ]
          },
          {
            "time": 1546715494347,
            "label": "7",
            "data_raw": [
              117
            ]
          },
          {
            "time": 1546715494354,
            "label": "7",
            "data_raw": [
              12
            ]
          },
          {
            "time": 1546715494361,
            "label": "7",
            "data_raw": [
              25
            ]
          },
          {
            "time": 1546715494367,
            "label": "7",
            "data_raw": [
              29
            ]
          },
          {
            "time": 1546715494374,
            "label": "7",
            "data_raw": [
              46
            ]
          },
          {
            "time": 1546715494380,
            "label": "7",
            "data_raw": [
              111
            ]
          },
          {
            "time": 1546715494387,
            "label": "7",
            "data_raw": [
              12
            ]
          },
          {
            "time": 1546715494393,
            "label": "7",
            "data_raw": [
              23
            ]
          },
          {
            "time": 1546715494400,
            "label": "7",
            "data_raw": [
              31
            ]
          },
          {
            "time": 1546715494407,
            "label": "7",
            "data_raw": [
              42
            ]
          },
          {
            "time": 1546715494413,
            "label": "7",
            "data_raw": [
              107
            ]
          },
          {
            "time": 1546715494419,
            "label": "8",
            "data_raw": [
              1085
            ]
          },
          {
            "time": 1546715494426,
            "label": "8",
            "data_raw": [
              3149
            ]
          },
          {
            "time": 1546715494433,
            "label": "8",
            "data_raw": [
              5489
            ]
          },
          {
            "time": 1546715494440,
            "label": "8",
            "data_raw": [
              10580
            ]
          },
          {
            "time": 1546715494446,
            "label": "8",
            "data_raw": [
              37619
            ]
          },
          {
            "time": 1546715494453,
            "label": "8",
            "data_raw": [
              973
            ]
          },
          {
            "time": 1546715494459,
            "label": "8",
            "data_raw": [
              2911
            ]
          },
          {
            "time": 1546715494465,
            "label": "8",
            "data_raw": [
              5201
            ]
          },
          {
            "time": 1546715494473,
            "label": "8",
            "data_raw": [
              10102
            ]
          },
          {
            "time": 1546715494478,
            "label": "8",
            "data_raw": [
              35855
            ]
          },
          {
            "time": 1546715494487,
            "label": "8",
            "data_raw": [
              881
            ]
          },
          {
            "time": 1546715494492,
            "label": "8",
            "data_raw": [
              2724
            ]
          },
          {
            "time": 1546715494498,
            "label": "8",
            "data_raw": [
              4913
            ]
          },
          {
            "time": 1546715494516,
            "label": "8",
            "data_raw": [
              9623
            ]
          },
          {
            "time": 1546715494516,
            "label": "8",
            "data_raw": [
              34117
            ]
          },
          {
            "time": 1546715494520,
            "label": "8",
            "data_raw": [
              784
            ]
          },
          {
            "time": 1546715494524,
            "label": "8",
            "data_raw": [
              2567
            ]
          },
          {
            "time": 1546715494531,
            "label": "8",
            "data_raw": [
              4628
            ]
          },
          {
            "time": 1546715494540,
            "label": "8",
            "data_raw": [
              9180
            ]
          },
          {
            "time": 1546715494544,
            "label": "8",
            "data_raw": [
              32479
            ]
          },
          {
            "time": 1546715494550,
            "label": "8",
            "data_raw": [
              688
            ]
          },
          {
            "time": 1546715494557,
            "label": "8",
            "data_raw": [
              2378
            ]
          },
          {
            "time": 1546715494564,
            "label": "8",
            "data_raw": [
              4345
            ]
          },
          {
            "time": 1546715494570,
            "label": "8",
            "data_raw": [
              8703
            ]
          },
          {
            "time": 1546715494577,
            "label": "8",
            "data_raw": [
              30945
            ]
          },
          {
            "time": 1546715494583,
            "label": "10",
            "data_raw": [
              564
            ]
          },
          {
            "time": 1546715494591,
            "label": "10",
            "data_raw": [
              2901
            ]
          },
          {
            "time": 1546715494596,
            "label": "10",
            "data_raw": [
              6078
            ]
          },
          {
            "time": 1546715494607,
            "label": "10",
            "data_raw": [
              13853
            ]
          },
          {
            "time": 1546715494610,
            "label": "10",
            "data_raw": [
              59715
            ]
          },
          {
            "time": 1546715494617,
            "label": "10",
            "data_raw": [
              463
            ]
          },
          {
            "time": 1546715494635,
            "label": "10",
            "data_raw": [
              2629
            ]
          },
          {
            "time": 1546715494635,
            "label": "10",
            "data_raw": [
              5679
            ]
          },
          {
            "time": 1546715494636,
            "label": "10",
            "data_raw": [
              13076
            ]
          },
          {
            "time": 1546715494642,
            "label": "10",
            "data_raw": [
              56485
            ]
          },
          {
            "time": 1546715494649,
            "label": "10",
            "data_raw": [
              373
            ]
          },
          {
            "time": 1546715494656,
            "label": "10",
            "data_raw": [
              2365
            ]
          },
          {
            "time": 1546715494662,
            "label": "10",
            "data_raw": [
              5273
            ]
          },
          {
            "time": 1546715494669,
            "label": "10",
            "data_raw": [
              12357
            ]
          },
          {
            "time": 1546715494676,
            "label": "10",
            "data_raw": [
              53489
            ]
          },
          {
            "time": 1546715494682,
            "label": "10",
            "data_raw": [
              314
            ]
          },
          {
            "time": 1546715494690,
            "label": "10",
            "data_raw": [
              2149
            ]
          },
          {
            "time": 1546715494695,
            "label": "10",
            "data_raw": [
              4869
            ]
          },
          {
            "time": 1546715494701,
            "label": "10",
            "data_raw": [
              11611
            ]
          },
          {
            "time": 1546715494708,
            "label": "10",
            "data_raw": [
              50657
            ]
          },
          {
            "time": 1546715494714,
            "label": "10",
            "data_raw": [
              241
            ]
          },
          {
            "time": 1546715494722,
            "label": "10",
            "data_raw": [
              1901
            ]
          },
          {
            "time": 1546715494727,
            "label": "10",
            "data_raw": [
              4521
            ]
          },
          {
            "time": 1546715494734,
            "label": "10",
            "data_raw": [
              10873
            ]
          },
          {
            "time": 1546715494741,
            "label": "10",
            "data_raw": [
              47949
            ]
          },
          {
            "time": 1546715494747,
            "label": "5",
            "data_raw": [
              21583
            ]
          },
          {
            "time": 1546715494755,
            "label": "5",
            "data_raw": [
              48189
            ]
          },
          {
            "time": 1546715494760,
            "label": "5",
            "data_raw": [
              65501
            ]
          },
          {
            "time": 1546715494767,
            "label": "5",
            "data_raw": [
              65501
            ]
          },
          {
            "time": 1546715494773,
            "label": "5",
            "data_raw": [
              63889
            ]
          },
          {
            "time": 1546715494780,
            "label": "5",
            "data_raw": [
              20165
            ]
          },
          {
            "time": 1546715494790,
            "label": "5",
            "data_raw": [
              45209
            ]
          },
          {
            "time": 1546715494793,
            "label": "5",
            "data_raw": [
              65501
            ]
          },
          {
            "time": 1546715494799,
            "label": "5",
            "data_raw": [
              65501
            ]
          },
          {
            "time": 1546715494807,
            "label": "5",
            "data_raw": [
              63897
            ]
          },
          {
            "time": 1546715494813,
            "label": "5",
            "data_raw": [
              18763
            ]
          },
          {
            "time": 1546715494821,
            "label": "5",
            "data_raw": [
              42737
            ]
          },
          {
            "time": 1546715494826,
            "label": "5",
            "data_raw": [
              65501
            ]
          },
          {
            "time": 1546715494832,
            "label": "5",
            "data_raw": [
              65501
            ]
          },
          {
            "time": 1546715494840,
            "label": "5",
            "data_raw": [
              63561
            ]
          },
          {
            "time": 1546715494845,
            "label": "5",
            "data_raw": [
              17393
            ]
          },
          {
            "time": 1546715494854,
            "label": "5",
            "data_raw": [
              40781
            ]
          },
          {
            "time": 1546715494858,
            "label": "5",
            "data_raw": [
              65501
            ]
          },
          {
            "time": 1546715494865,
            "label": "5",
            "data_raw": [
              65501
            ]
          },
          {
            "time": 1546715494871,
            "label": "5",
            "data_raw": [
              63633
            ]
          },
          {
            "time": 1546715494878,
            "label": "5",
            "data_raw": [
              16012
            ]
          },
          {
            "time": 1546715494887,
            "label": "5",
            "data_raw": [
              38401
            ]
          },
          {
            "time": 1546715494891,
            "label": "5",
            "data_raw": [
              62977
            ]
          },
          {
            "time": 1546715494898,
            "label": "5",
            "data_raw": [
              65501
            ]
          },
          {
            "time": 1546715494904,
            "label": "5",
            "data_raw": [
              63195
            ]
          }
        ],
        "data_raw": [

        ]
      }
    ]
  ],
  "app_os": "macOS 17.7.0",
  "app_name": "PhotosynQ",
  "app_version": "1.1.0",
  "app_device": "x64",
  "location": false,
  "time_offset": "America/New_York"
}
Dave in cap img 4615
Created by

David M. Kramer


Protocol connections:
0
Latest Update:
Jan 2019