PWM, Sigma_Delta reference clocks

tekguy49
Posts: 4
Joined: Thu Jul 14, 2016 1:35 am

PWM, Sigma_Delta reference clocks

Postby tekguy49 » Thu Jul 14, 2016 1:44 am

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.

User avatar
pratik
Posts: 467
Joined: Wed Jun 29, 2016 7:17 pm
Location: India
Contact:

Re: PWM, Sigma_Delta reference clocks

Postby pratik » Thu Jul 14, 2016 1:41 pm

Hello,

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.
Regards,
Pratik Panda
Website: http://www.PratikPanda.com

Custom firmware, Knowledge base and freelancing (ESP8266/ESP32):
http://www.iot-bits.com

eriksl
Posts: 157
Joined: Fri May 22, 2015 6:22 pm

Re: PWM, Sigma_Delta reference clocks

Postby eriksl » Mon Sep 12, 2016 9:58 pm

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.

Who is online

Users browsing this forum: No registered users and 6 guests