0

The problem is that I'm expecting a low frequency (1.25khz) continuous square wave when writing to the PWM output of the ESP32 and what I get is regular/irregular pulsed PWM triangle wave with a 125hz pulse rate (enough for the human eye to see it as flickering.)

Is there any way around this?

I've tried the config below for it:

ledc_timer_config_t ledc_timer_D = {
    .duty_resolution = LEDC_TIMER_15_BIT,
    .freq_hz = 1250,                     
    .speed_mode = LEDC_HS_MODE,          
    .timer_num = LEDC_HS_TIMER_2,          
    .clk_cfg = LEDC_USE_APB_CLK,              
};

The output:

1250Hz signal from ESP32-mini-1

I've tried this with the low speed as well and got the same issue, if not an issue when compiling through VS Code IDE.

1 Answer 1

0

From the drawing you show in the graph, it seems you are not using a good sampling device and you are sampling at a low rate too. The poligonal shaped traces of the signal indicate that probably you are sampling at the same frequency of the pwm signal or even lower. I should recommend you to oversample (let's say 16 times faster) to see properly shaped square pulses.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for that, and give it a try. in the back of my mind I'm supprised that with a resolution of 15Bit that it still has too slow of a sampling rate for 1.25KHz
To get 16 samples on a square signal of 1.25khz you need to get 24ksps and you will still see the ramps between two differing samples in the signal, that will appear more as made of trapezoids than of rectangles. If yor pwm is 16bit resolution you have 65536 values to set it and to precise measuring yo need to sample abou 131,072 samples x 1.25khz ≈ 170Msps Only then you will have full resolution sampling.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.