• Thoughts on magnetometer calibrations.

    • Use a min/max program to find the minimum and maximum readings for each axis and then average the minimum and maximum to obtain the offset for each axis.
      Point both ends of each axis towards the magnetic pole. Remember the pole is actually below the horizontal by the dip angle.

      //Cal_idea.js
      //5 Jan 2017
      
      function minmax(){
      this.min=[0,0,0];
      this.max=[0,0,0];
      this.avg=[0,0,0];
      }
      
      minmax.prototype.process=function(A){
      var i;
      for(i=0;i<3;i++){
      if(A[i]>this.max[i])this.max[i]=A[i];
      if(A[i]<this.min[i])this.min[i]=A[i];
      this.avg[i]=(this.min[i]+this.max[i])/2;
      }
      console.log("max= ",this.max);
      console.log("min= ",this.min);
      console.log("avg= ",this.avg);
      };
      
      var i;
      var reading=[0,0,0];
      var T=new minmax();
      for(i=-4;i<4;i++){
      //take magnetometer readings here
      //fake some data for demo
      reading[0]=i;
      reading[1]=i*i;
      reading[2]=i*i*i;
      //process data while moving the magnetometer
      // until the max and min for each axis is at the limit
      //use the average as the offset value
      T.process(reading);
      }//next i
      
    • In the module MAG3110.js, does the Puck use this function?
      http://www.espruino.com/modules/MAG3110.js

      /**
      * Performs a manual magnetic sensor reset (One-Shot).
      * Initiates a magnetic sensor reset cycle that will restore correct operation after exposure to an excessive magnetic
      * field wich exceeds the Full Scale Range of +/-1000µT, e.g. near a speaker magnet.
      */
      MAG3110.prototype.magneticReset = function () {
      var value = this.read8(MAG3110.CTRL_REG2);
      value |= 0x10; // set Mag_RST
      this.write8(MAG3110.CTRL_REG2, value);
      };
      
    • Finding the best fit sphere regression using Solver in Excel

    http://forum.espruino.com/conversations/297875/


    1 Attachment

About