• No analog output without it, right?

    Could be limiting for the project I have in mind... I have a dozen raw 12E boards I bought for $1.99 ea from China for this particular (lightstrip) project. Since each strip -- and there are many -- needs its own MCU, it simply isn't financially practical to do this with the official boards :-(

  • I think the problem is there isn't any PWM at all afaik. It's all software - which Espruino can do, but it's a bit janky. You can buy external PWM chips though.

  • Well, what what got me curious was this text from this page:

    1. Programmable PWM Frequency
      While building an RGB PWM controller with my Uno, I found the Uno’s PWM created a buzzing noise. Running close to 600Hz, that is not a surprise. My decoupling capacitors were singing due to piezoelectric effects. One option is to change the PWM frequency, but that would mean digging in the Arduino libraries. Possible, but more work than I wanted to put in at the moment.

    The ESP8266 core of the Arduino library, however, has a built-in PWM frequency call. Changing the PWM frequency is easy.

    AnalogWriteFreq(1000);
    Another bonus is the PWM resolution. The ESP8266 core has 1024 (0-1023) levels of pulse-width instead of Arduino’s 256 (0-255). This resolution means smoother LED fading and more precise motor speed control.

    Lastly, any of the GPIO pins can be used for PWM. With clever software, you can make any pin on an Arduino do PWM using Software PWM. Being able to use hardware PWM on any pin makes the ESP8266 very flexible.

    It sure seems to imply there is hardware support for PWM -- after all, why would there be the odd 10-bit PW setting. I doubt when porting the Arduino code to the ESP8266 someone decided to expand the software PWM pulse width resolution to 10 bits. I didn't look any further, but will dig a bit more.

    In any case it works on the competition -- we need to get it working for Espruino. After all, Javascript is soooooo much better a platform...

  • Here's their implementation of it:

    https://github.com/esp8266/Arduino/blob/­master/cores/esp8266/core_esp8266_wiring­_pwm.c

    They use one of the hardware timers, but twiddle the pin in the ISR.

  • Software PWM (pins not directly hardware gate connected to timer hardware) has always glitches... You may not notice as long as the PWM 'frequencies' are low (on/off pulse widths are wide) compared to processor speed and to processor hogging code sequences.

    I experienced similar issues with stepper motor(s) driven by Espruino, where timing is essential and irregularities can be heard easily: the sound/humming has a stuttering once in a while when running over a decent time at a constant frequency. With dimming this is not really an issue.

    Electrical issues - instable rails - are a different story.

  • Potentially someone could make the UtilTimer in jsharware.c do this using the hardware timer and interrupt - that's what it was originally meant for. It's like 3 functions to implement and then you can have proper soft PWM.

    Since each strip -- and there are many -- needs its own MCU, it simply isn't financially practical to do this with the official boards

    You know the price goes down a lot if you order directly, and in bulk? If you buy 100 it's £12 each for the Pico - so I guess it depends how many strips you're doing and how much you think your time is worth ;)

  • Any update on this? Would love pwm on esp8266

  • Is there any progress?

    Thanks
    Navas

  • Yes, there is a possible substitution for the existing code.

    Welcome to jump in and take over the implementation named in issue 914

  • Yes, would be great to have flicker-free LED dimming.

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

PWM? Anyone ever get it working? Even via peek/poke directly at control registers?

Posted by Avatar for dwallersv @dwallersv

Actions