-->
Page 1 of 2

Difference between sigma_delta and PWM

PostPosted: Mon Sep 11, 2017 3:23 am
by Solomon Candy
I hear that esp8266 doesn't have hardware PWM and the PWM library uses internal timer to drive outputs like PWM. But I recently discovered esp8266's delta_sigma pin driver compatibility and was happy because I could finally dim LED's through it. But then I thought - Wait a minute!! ... isn't this sigma_delta thing what a PWM is?? What is the difference between these two?

Re: Difference between sigma_delta and PWM

PostPosted: Thu Sep 28, 2017 9:04 am
by eriksl
There are a number of differences between PWM and delta-sigma (implementations on ESP8266).

The main difference is that delta-sigma won't keep the modulation frequency constant. So if you change the duty cycle, the frequency also changes. If you don't want that, you will have to compensate for it.

Secondly, there is only one sigma-delta generator. Although it may drive multiple outputs, it has only one set of configuration registers.

Third, sigma-delta is implemented in hardware, the ESP8266 does not have any hardware support for PWM, so one will need to implement it using software. The function in the native SDK supplies something like that, but it's far from optimal. I know at least two alternative implementations (one of them by myself) that quite closely approach a real hardware PWM, which allows for different duty cycles on all attached pins.

Fourth, the sigma-delta function only allow for 8 bit resolution, which is really quite small. A software PWM can achieve full 16 bit resolution at 122 Hz, if the cpu is set to 160 MHz.

Re: Difference between sigma_delta and PWM

PostPosted: Sun Aug 19, 2018 6:48 pm
by malachi
eriksl wrote:There are a number of differences between PWM and delta-sigma (implementations on ESP8266).

The main difference is that delta-sigma won't keep the modulation frequency constant. So if you change the duty cycle, the frequency also changes. If you don't want that, you will have to compensate for it.

Secondly, there is only one sigma-delta generator. Although it may drive multiple outputs, it has only one set of configuration registers.

Third, sigma-delta is implemented in hardware, the ESP8266 does not have any hardware support for PWM, so one will need to implement it using software. The function in the native SDK supplies something like that, but it's far from optimal. I know at least two alternative implementations (one of them by myself) that quite closely approach a real hardware PWM, which allows for different duty cycles on all attached pins.

Fourth, the sigma-delta function only allow for 8 bit resolution, which is really quite small. A software PWM can achieve full 16 bit resolution at 122 Hz, if the cpu is set to 160 MHz.


I found this a very helpful response, thank you!
Just curious, did you mean 122 Hz, or 122 KHz?

Re: Difference between sigma_delta and PWM

PostPosted: Mon Aug 20, 2018 11:03 am
by eriksl
122 Hz, really, at 16 bits. A hardware implementation, like on the ATmega, can't reach very much higher than that.

What are you trying to achieve with a PWM at 121 KHz? It will probably fry your mosfets if they need to switch a significant amount of current.