You are reading a single comment by @lshk and its replies. Click here to read the full conversation.
  • I also checked the ratio of 40kHz impulses. It does not in any way affect the result. I changed it from 1: 1 to 1: 4. At any ratio, camera control works.

    I assumed that the problem might be that I have several arrays with timings. And I combined everything into one array. This eliminated multiple digitalPulse calls and loops. But that didn't help either ...

    const IR_ANODE = D17;
    const IR_CATHODE = D16;
    const IR_FREQ = 40000;
    const pulse_ratio = 0.25;
    //....
    var run = function () {
    //....
        digitalWrite(IR_CATHODE,0);
    
        let pulses = [2.4, 0.6, 1.2, 0.6, 0.6, 0.6, 1.2, 0.6, 1.2, 0.6, 0.6, 0.6, 1.2, 0.6, 0.6, 0.6, 0.6, 0.6, 1.2, 0.6, 0.6, 0.6, 1.2, 0.6, 1.2, 0.6, 1.2, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 1.2, 0.6, 1.2, 0.6, 1.2, 0.6, 1.2, 11.6, 2.4, 0.6, 1.2, 0.6, 0.6, 0.6, 1.2, 0.6, 1.2, 0.6, 0.6, 0.6, 1.2, 0.6, 0.6, 0.6, 0.6, 0.6, 1.2, 0.6, 0.6, 0.6, 1.2, 0.6, 1.2, 0.6, 1.2, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 1.2, 0.6, 1.2, 0.6, 1.2, 0.6, 1.2, 11.6, 2.4, 0.6, 1.2, 0.6, 0.6, 0.6, 1.2, 0.6, 1.2, 0.6, 0.6, 0.6, 1.2, 0.6, 0.6, 0.6, 0.6, 0.6, 1.2, 0.6, 0.6, 0.6, 1.2, 0.6, 1.2, 0.6, 1.2, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 1.2, 0.6, 1.2, 0.6, 1.2, 0.6, 1.2, 0.6];
      
        function shot(){
            analogWrite(IR_ANODE, pulse_ratio, {freq:IR_FREQ});
            digitalPulse(IR_CATHODE,1,pulses);
            digitalPulse(IR_CATHODE,1,0);
            digitalWrite(IR_CATHODE,0);
            digitalRead(IR_ANODE);
        }
    //....
        function some_function(){
            //....
            console.log('shot');
            shot();
            //....
        }
    //....
    };
    

    Wifi can be the cause of such problems (the module cannot cope with such a load)? The module is connected to a router and is controlled by wifi

    Is it possible to somehow disable all other processes during the transmission of the IR signal, or change their priority?

    Maybe the problem is low JS speed and I need to use C?

    I have no more ideas yet. Can you suggest anything?

About

Avatar for lshk @lshk started