You are reading a single comment by @allObjects and its replies. Click here to read the full conversation.
  • Update:

    I modified hardware and software to provide more details:

    1. Added a sense/shunt resistor on the high side and the load circuit (in series with the GPS).
    2. Measure/plot voltage v0 across sense resistor AND load (GPS)
    3. Measure/plot voltage v1 across the load only (GPS)
    4. Calculate/plot current from delta v0 and v1 and kown resistor value

      // ePoweredGPS.js
      var eps = // espruino power supply
      //                               green LED2
      { _pwrPins: [ B7,  B6,  B5,  B4, B12 ]  
      , _pwr:        1 +  2 +  4 +  8 + 16
      , _volt0Pin: A4, _volt1Pin: A1
      , _v0: 0, _v1: 0, _a: 0
      , _isOn: false
      , init: function() { this.isOn = false;
      this._pwrPins.forEach(function(p){
        p.reset(); pinMode(p,"output"); });
      pinMode(this._volt0Pin,"analog");
      pinMode(this._volt1Pin,"analog"); }
      , switch: function(b) { digitalWrite(this._pwrPins,
        (this._isOn = !!b) ? this._pwr: 0); }
      , getAmps: function() {
      var s0=0.0,s1=0.0,i,iMx=10;
      for (i = 0; i < iMx; i++) {
        s0 += analogRead(this._volt0Pin) * 3.3;
        s1 += analogRead(this._volt1Pin) * 3.3; }
      this._v0 = Math.round(s0 / iMx * 1000) / 1000;
      this._v1 = Math.round(s1 / iMx * 1000) / 1000;
      this._a = (this._v1 - this._v0) / 0.47;
      return this._a; }
      };
      var gps =
      { _eps: null
      , _serial: Serial2
      , _gpsMod: require("GPS")
      , _isOn: false
      , _fix: 0, _sats: 0, _lat: 0, _lon: 0, _pos: ""
      , _gps: null
      , init: function() { var _t = this;
      this._serial.setup(9600,{tx:A2,rx:A3});
      this._gps = this._gpsMod.connect(this._serial,
        function(d){
          _t._fix = d.fix;
          _t._sats = d.satellites;
          _t._lat = d.lat + 10; _t._lon = d.lon - 10;
          _t._pos = "" + _t._lat + "|" + _t._lon;
      }); this._init(); }
      , _init: function() {
      this._fix = this._sats = 0;
      this._lat = this._lon = NaN; this._pos = ""; }
      , switch: function(b) { if (this._isOn !== (b=!!b)) {
      this._eps.switch(this._isOn = b);
      if (b) this.init(); else this._init(); } }
      };
      gps._eps = eps;
      eps.init();
      // setBusyIndicator(LED1);
      

    To get higher resolution in the plot, values are scaled and cut off where needed to fit into the y-range of 2..3.1 in the graph and show best resolution/most details:

    1. fix (light brown) 0 shows as 2, 1 shows as 2.5, and 2 shows as 3 (2 + .5 * fix)
    2. sats/satellites (light blue): 0 shows as 2, 1 as 2.1, 2 as 2.2, etc (2 + .1 * sats)
    3. position "lat|long" available (red): show as text on hover over red circles
    4. current (green): 0 shows as 2.5, then to scale (*)
    5. volts 0 and 1 (purple and brown): less than 2 show 2, >=2 show to scale
    6. on/off indicator (teal): off shows as 2.05, on shows as 3.05

    *) Calculated current - measured voltage difference over sense/shunt resistor of known value - feels weird: almost 180..250 mA = which it cannot be for sure, last but not least I was measuring the other day around 30 mA.

    The sense/shunt resistor is 5 band coded and shows 0.47 R... measured with the digital multi-meter it shows 1.0 R... and in series with a 3.6 R it contributes with 0.4 R. I assume in these low ranges the values are not especially accurate, even though the resistor is a precision (sense) resistor out of a digital power inverter. In other words - for what the (green) amps line is worth - the (green) amps line shows change/increase/decrease of power drawn, and not absolute value. The more noteworthy is the fluctuation of voltage due to power draw and light-weight implemented sourcing... Current has smooth phases and bumpy phases - don't know why. The 0.05 V above 2.7 min Vcc of GPS module is fine but a fine line.

    The graph shots include:

    1. Start-up to fix level 1 (light brown from 2 to 2.5 (0 to 1)
    2. Start-up all the way to fix level 2: from 2 to 2.5 to 3 (0 to 1 to 2)
    3. Shut-down.

    3 Attachments

    • StartUpFrom0to6_8_7satellitesFix1.png
    • StartUpAllTheWayToFix2.png
    • ShutDown.png
About

Avatar for allObjects @allObjects started