You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Do you think you could post up some example commands with what happens? It doesn't sound right but it might be something to do with the way you're using the options object...

    By default analogWrite on the MDBT42Q should use hardware PWM, and there shouldn't be flicker. For example:

    setInterval(function() {
      analogWrite(LED1,0.5+0.5*Math.sin(getTim­e()));
    },20);
    // pulsing LED - no flicker
    // calling pinMode(LED1,"output") stops PWM but the next call works fine
    

    And for software:

    // works fine:
    analogWrite(LED1,0.01,{freq:100,forceSof­t:true});
    // some flicker:
    analogWrite(LED1,0.01,{freq:1000,forceSo­ft:true});
    // stops output
    pinMode(LED1,"output")
    // works again
    analogWrite(LED1,0.01,{freq:100,forceSof­t:true});
    

    But I did encounter some issues when not specifying a frequency, so perhaps that could be the problem? If so it's something I can look at fixing in a firmware update

  • I think my issue might've been with doing too many PWMs at once - I'm doing a very slow fade by PWMing 10 LED strips through a bank of mosfets (MDBT42Q pins D22, D20, D19, D18, D17, D25, D26, D27, D28, D29), if I do more than 3 with:

    analogWrite(<PIN>, 0.1, {freq:100,soft:false} );
    

    I get an Uncaught Error: "No free Hardware PWMs. Try not specifying a frequency, or using analogWrite(pin, val, {soft:true}) for Software PWM"

    If I try forcing software PWM, if I try with more than 7 outputs like this:

    analogWrite(<PIN>, 0.1, {freq:100,forceSoft:true} );
    

    I get an Uncaught InternalError: Timeout on Utility Timer

    however, just doing an analog write without an options object for all of the pins allows me to write to all of them but with a bit of a flicker to it. I'm running the LED strips with a 24v supply & I'm doing low-side switching with a bank of mosfets, but I'm powering the MDBT42Q with a separate 5v power supply with a common ground reference, so I guess there's also chance that theres some noise between my supplies.

    I'm going to do a bit of digging and see if I can narrow down where the slight flicker is coming from, hopefully its just my code running a little inefficiently or a power supply thing :)

    Thanks for getting back to me so quick, apologies for being slower to reply!

About

Avatar for Gordon @Gordon started