You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • It's frustrating - I'm not really sure why it's so bad when the F1 was fine. It's interesting that it is bad enough to warrant ST writing that document on it. I wonder whether if the whole CPU was clocked down it might be better.

    The other thing is Espruino reads an analog value giving the ADC the longest time period possible - which is supposed to mean the highest accuracy. However it's possible that if the problem is to do with voltage fluctuations, maybe getting the conversion done as soon as possible is the best bet!

    It strikes me that some of the glitchiness could actually be from USB... I'd be interested to know what happens if you power Espruino from a battery and log the error rates, then see how bad it is with and without USB connected.

    At least doing the N-X averaging is a lot easier in Espruino! Something like:

    function nxavr(pin) {
      var a = new Uint16Array(100);
      for (var i=0;i<a.length;i++) a[i] = analogRead(pin)*4096;
      a.sort();
      var middle = new Uint16Array(a.buffer,25*2,50);
      return E.sum(middle)/middle.length;
    }
    

    So that's 100 samples, dropping the 25 smallest and 25 largest.

About

Avatar for Gordon @Gordon started