Alternative to digitalPulse for remote control sockets?

Posted on
  • I started off using remote control sockets on an Espruino Pico, which worked great. I then switched to a Pixl.js, and suddenly things were not so great. Sometimes it works, and sometimes it doesn't.

    I've traced it to this issue, which explains that the NRF52 does not have the same accurate timing as the STM32.

    Now I'm wondering if there's another way to send the right pulse stream to the 433.92MHz transmitter, or at least get my new remote control sockets working reliably with the Pixl.js?

  • Is your Pixl.js firmware up to date? And you're using the code from that remote control sockets example?

    Did you actually see the waveforms it sends getting messed up?

    It shouldn't be that limited. After all we use exactly that code fine on nRF52 for sending IR control signals from Puck.js and it's fine. Even if it were only accurate to 1/32kHz, that should still be more than enough for the 0.3ms signal pulses that are send out.

  • I was on 2v06, so just updated to 2v07 to be sure. No difference.

    I'm using the code from the example, but found that I had a little bit more success on Pixl.js by changing

    digitalPulse(TX,1,0.9);
    digitalPulse(TX,0,0.3);
    

    to

    digitalPulse(TX, 1, [0.9, 0.3]);
    

    I was also able to increase the chances of success by sending 40 times instead of 10 times, and it works better for some pulse trains than others (in my case, using button 2 's pulses instead of button 1).

    All this led me to believe that it may be jitter due to the RTC. I will try to hook up my logic analyser to see if it is indeed the actual waveforms getting messed up.

    • Would the digitalPulse(TX,1,0.001) at the end of the pulse train be affected by the RTC?
    • Also, does it matter whether I use an analog pin vs a digital pin?
  • Using a logic analyser, the Pico pulse trains are 27.4ms long, pretty close to the 25 * 1.1ms = 27.5ms:

    Pico pulse train

    The Pixl.js pulse trains are 29.7ms long:

    Pixl.js pulse train

    I used the remote control example code for both, just changing from A6 on the Pico to D13 on the Pixl.js, and modifying the pulse train sequences for my sockets.

  • Please could you try:

    function sendCommand(command) {
      var bits = (CODE & ~0b11111) | command;
      var pulses = [];
      for (var i=24;i>=0;i--) {
        if ((bits>>i)&1) {
          pulses.push(0.9,0.3);
        } else {
          pulses.push(0.3,0.9);
        }
      }
      pulses.push(0.001);
      digitalPulse(TX,1,pulses);
    }
    

    That might fix it - it's possible that because the Pixl is a bit slower than STM32 boards it's actually struggling to go around the loop and call digitalPulse again before all the pulses have already gone out?

    Sending them all in one go might sort it.

  • Gave it a try, but the Pixl.js pulse train is still 29.7ms.

  • Ok, thanks - I'll take a look in the next few days. There are other solutions (like using SPI) but obviously fixing this properly would be ideal

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Alternative to digitalPulse for remote control sockets?

Posted by Avatar for gendor @gendor

Actions