Page 1 of 1

PWM, Sigma_Delta reference clocks

Posted: Thu Jul 14, 2016 1:44 am
by tekguy49
Documents for ESP8266EX indicate maximum PWM frequency is 1Khz. I need 20Khz to 100Khz. Can be PWM clock pre-scaler be modified?

I have the same question for the Delta_Sigma hardware.

Re: PWM, Sigma_Delta reference clocks

Posted: Thu Jul 14, 2016 1:41 pm
by pratik

The timer interrupts are used to generate PWM. Therefore, a frequency of over 1kHz is not really practical as it takes up a lo of CPU.
What are you using it for? Lights or motors or something else?
Sometimes it may be possible to modulate the PWM output at 100kHz again using a simple 555 timer circuit. That would work well with lights and motors.

Re: PWM, Sigma_Delta reference clocks

Posted: Mon Sep 12, 2016 9:58 pm
by eriksl
The frequency of PWM is directly and linearly related to the period of the PWM. The ESP8266 runs at 80 MHz normally, it can run on 160 MHz if you want to. The timer clock always runs at 80 MHz though and the practical lowest divisor is 16, which makes a raw rate of 5 MHz or a period of 200 nanoseconds. It's up to you how to use these 200 nanosecond slots. If you want 16 bits resolution, you will need 5000000 / 65536 slots, which makes a period time of only 76 Hz. But on the other hand, if you go to 8 bits resolution, you only need 256 slots which will make the period almost 20 kHz. So that's really the consideration.

Besides, above explanation deals with theory. The PWM code inside the SDK can't achieve this, it cannot distinguish between the 1/2/3/4/5/6/7/8/9/10/11/12/13/14/15 duty values. All others are fine. Making it, afaic make it a lot less useful. You may consider using one of alternative, open, implementations that actually CAN achieve all of this.

And BTW, if you didn't already understood, the ESP8266 doesn't have a hardware PWM implementation. It's not that bad actually, because one can make a pretty decent implementation in software, it's fast enough for that.

There IS a SigmaDelta implemention in hardware, though, which, afaik, can run at pretty high speeds. It's limited to 8 bits though, so it may or may not suit your needs.