You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Hi - there's actually another post just today on interfacing the HX711 - it might be some help: http://forum.espruino.com/conversations/­287032/#comment12991616

    Have you tried it? I'd be a little surprised if the timeout was such that it didn't work.

    If it does need pulsing that quick, you have a few options:

    • Use SPI SCK + MISO (but then you'll only be able to send 24 bits)
    • Use SPI MOSI + MISO - send 0b10101010 as the SPI data - then you'll just have to pick out every other bit from the returned result. Even software SPI should be fast enough for this. You can just make sure the final byte is only 0b10100000 or whatever is needed to set the gain
    • Use minified, unrolled JS - it should be just about fast enough. Something like:

      function get() {
      var s = CLK.set.bind(CLK);  
      var r = CLK.reset.bind(CLK);
      var b = DATA.read.bind(DATA);
      var v = 0;
      s();r();v=(v<<1)|b();s();r();v=(v<<1)|b(­);s();r();v=(v<<1)|b();s();r();v=(v<<1)|­b();
      s();r();v=(v<<1)|b();s();r();v=(v<<1)|b(­);s();r();v=(v<<1)|b();s();r();v=(v<<1)|­b();
      s();r();v=(v<<1)|b();s();r();v=(v<<1)|b(­);s();r();v=(v<<1)|b();s();r();v=(v<<1)|­b();
      s();r();v=(v<<1)|b();s();r();v=(v<<1)|b(­);s();r();v=(v<<1)|b();s();r();v=(v<<1)|­b();
      s();r();v=(v<<1)|b();s();r();v=(v<<1)|b(­);s();r();v=(v<<1)|b();s();r();v=(v<<1)|­b();
      s();r();v=(v<<1)|b();s();r();v=(v<<1)|b(­);s();r();v=(v<<1)|b();s();r();v=(v<<1)|­b();
      s();r(); // gain
      return v;
      }
      
    • Use 'compiled' JS - http://www.espruino.com/Compilation - this would definitely be fast enough, but maybe isn't as portable as it needs the online web service to compile the JS into native code each time you upload.

    Hope that helps!

About

Avatar for Gordon @Gordon started