Avatar for lshk

lshk

Member since Sep 2021 • Last active Oct 2021
  • 1 conversations
  • 20 comments

Most recent activity

    • 37 comments
    • 1,379 views
  • in Projects
    Avatar for lshk

    Disabled everything except IR signal generation, now the minimal code. It didn't help either. The first code sequence consists of the required number of pulses (21). But they are all with the wrong duration and pauses. The second and third sequences are slightly better, but there are also offsets. And the duration of the impulses is longer than the specified one.

    Now I definitely can't change anything. There is a minimal code left.

    I don't understand how a module that is much more powerful than arduino nano is not able to solve this simple task ...
    What is it for then? Blinking chaotically with LEDs?

    [add]
    I flashed the code from arduino nano to esp32. It works just as perfectly as it does on the arduino board. It turns out this javascript is so slow...

  • in Projects
    Avatar for lshk

    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?

  • in Projects
    Avatar for lshk

    This is arduino nano board

  • in Projects
    Avatar for lshk

    The duration of the impulses is incorrect. It is about 1.4-1.5 times longer than it should be. For example, instead of 0.6ms, I see 0.96ms.
    Integers gives exactly the same problem. This is (floats) not the problem.

  • in Projects
    Avatar for lshk

    This is esp32

  • in Projects
    Avatar for lshk

    I bought a logic analyzer yesterday. Thanks for the advice, I did not know that they are so cheap. Now I've seen everything going on, it's super helpful.

    analogWrite is very stable with an ideal 40kHz output. But digitalPulse gives pulses of the wrong duration, and the duration of these pulses changes randomly. I will attach screenshots a little later.
    I also checked the work of the Arduino. This module is extremely stable and predictable. The signal is perfect.

  • in Projects
    Avatar for lshk

    Yes, only integer. I noticed this. But I hope this is just an example. I will try to find additional information.

Actions