Hello guys ,
I’m using simple ledcsetup call to generate 1000hz pwm on a pin .
It looks to work ok but I’m getting minimum variation on signal .
Signal continue cycling (Every 5 sec ) between exactly 1000hz and 996/998 hz .
Do you think This is normal behavior or there’s way to achieve a stable 1000hz ?
Pwm not super stable
-
- Posts: 9711
- Joined: Thu Nov 26, 2015 4:08 am
Re: Pwm not super stable
How are you measuring this? Are you sure it's not a glitch in your measuring method?
Re: Pwm not super stable
I’m using a simple cheap oscilloscope .
About Being sure it’s not the oscilloscope I can’t obviously be sure , do you think it can be the problem ? Seems btw , that with another non esp32 device I’m using per comparison , I can got the stable 1000hz
About Being sure it’s not the oscilloscope I can’t obviously be sure , do you think it can be the problem ? Seems btw , that with another non esp32 device I’m using per comparison , I can got the stable 1000hz
-
- Posts: 9711
- Joined: Thu Nov 26, 2015 4:08 am
Re: Pwm not super stable
It could be, scopes without a hardware pulse counter can be unreliable as it depends on either how well they can sample the edges or how many samples can fit in sample memory... Given the fact that the LEDC is a hardware device, I'd have a hard time explaining how it would go off every x seconds, to be honest.
Edit: Any chance we can see your code? Chance is that somehow the LEDC isn't set for *exactly* 1KHz, and your scope shows that as frequency jitter.
Edit: Any chance we can see your code? Chance is that somehow the LEDC isn't set for *exactly* 1KHz, and your scope shows that as frequency jitter.
- jgustavoam
- Posts: 164
- Joined: Thu Feb 01, 2018 2:43 pm
- Location: Belo Horizonte , Brazil
- Contact:
Re: Pwm not super stable
Hi,
The LED PWM on ESP32 is incredible stable and has high accuracy! The best I've ever seen!
But you must know how to use correctly.
Example to 1000 Hz.
Setup frequency : 1000 Hz
Select channel : 0 to 15
Setup resolution : 15 (more accuracy) maximum available frequency is 2441 Hz ( 80MHz / 32768)
Setup Duty : 16383 (50%) ===> 0 to (2 ** duty_resolution) - 1
Reference:
https://docs.espressif.com/projects/esp ... /ledc.html
The LED PWM on ESP32 is incredible stable and has high accuracy! The best I've ever seen!
But you must know how to use correctly.
Example to 1000 Hz.
Setup frequency : 1000 Hz
Select channel : 0 to 15
Setup resolution : 15 (more accuracy) maximum available frequency is 2441 Hz ( 80MHz / 32768)
Setup Duty : 16383 (50%) ===> 0 to (2 ** duty_resolution) - 1
Reference:
https://docs.espressif.com/projects/esp ... /ledc.html
Retired IBM Brasil
Electronic hobbyist since 1976.
Electronic hobbyist since 1976.
Who is online
Users browsing this forum: Majestic-12 [Bot] and 61 guests