ESP8266 with 10Bit PWM?

Hi,

is it possible to generate a PWM with 16Bit resolution? Currently I’m only able to generate a 8Bit PWM.

Code looks like this.

output:
  - platform: esp8266_pwm
    pin: GPIO02
    frequency: 4000 Hz
    id: stpdn_pwm_out
    
light:
  - platform: monochromatic
    output: stpdn_pwm_out
    id: stpdn_pwm_pwm
    name: "stpdn_pwm_out"
    #default_transition_length: 5s
    gamma_correct: 1.0

Any help would be nice :slight_smile:

Thanks, Bernd

Esp8266 is 10 bit PWM only. https://randomnerdtutorials.com/esp8266-pinout-reference-gpios/

Sorry, my fault. I mean 10-Bit PWM. Is it possible to use 10-Bit PWM?

Perhaps you need a lower frequency

The frequency to run the PWM with. Lower frequencies have more visual artifacts, but can represent much more colors. Defaults to 1000 Hz .

If i understand correct than pwm on 8266 is only 10 bit, since it’s software one, not hardware. And it can be on any pin.
Maybe my observations: higher frequency reduces control at lower end - it can happen that light won’t go as low as it goes with lower frequency. But at one point flickering begin to show.

I control led’s via mosfet, so having higher frequency requires faster mosfet, since not any mosfet is capable to follow higher frequencies. As a result going down with dimm value at one point light won’t go lower anymore, because mosfet doesn’t switch off fast enough.
Example: with 1000 Hz i can go to 10% to have minimum light, while with 2000Hz i can’t go lower than 20%. 500Hz goes even lower, but at this frequency flickering is quite visual and too annoying. If you have oscilloscope it will show this clearly.

@nickrout, I do not control a light. I need a higher resolution from the PWM signal.

So, question: Is it possible to set the PWM resolution from 8-Bit to 10-Bit?

Can’t see it in the docs. How are you measuring the resolution?

@nickrout, You can enter values from 1 to 255 :slight_smile: Thats 8-Bit. If you can enter values from 1 to 1024 it is 10-Bit.

Alternative: hock up a osciloscope to the PWM pin and you see the PWM signal.

Ahhh so I guess you are seeing that in the light component in the gui?

Yes, I can set brightnes from 1 to 255 and the osciloscope shows also 255 steps from 0-signal to full-signal.

In the Arduino World it qould be the “AnalogWriteRange” command:

NOTE: The default analogWrite range was 1023 in releases before 3.0, but this lead to incompatibility with external libraries which depended on the Arduino core default of 256. Existing applications which rely on the prior 1023 value may add a call to analogWriteRange(1023) to their setup() routine to return to their old behavior. Applications which already were calling analogWriteRange need no change.

What is is you are trying to do? Why do you need a higher resolution? Are you using PWM to drive a speaker or something like that?

I generate a DC voltage with the PWM signa. Using a RC-Filter and a OP-Amp. With this DC-Signal, I control a Step-Down converter (Current Regulation).

Hi Bernd,

Did you ever find a solution to this problem?