ESP32 PWM Max frequency output
-
- Posts: 11
- Joined: Thu Mar 25, 2021 5:44 am
ESP32 PWM Max frequency output
Can I know what's the Max ESP32 PWM frequency?
Need to drive 2.7MHz Piezoelectric transducer.
Need to drive 2.7MHz Piezoelectric transducer.
-
- Posts: 364
- Joined: Mon Jan 04, 2021 2:06 pm
Re: ESP32 PWM Max frequency output
Hi,
See the reference documentation in the LED Control section: supported range of frequency and duty resolutions.
Hope this could help you!
See the reference documentation in the LED Control section: supported range of frequency and duty resolutions.
Hope this could help you!
-
- Posts: 11
- Joined: Thu Mar 25, 2021 5:44 am
Re: ESP32 PWM Max frequency output
Hi,
Can't MCPWM be used?
Can't MCPWM be used?
-
- Posts: 364
- Joined: Mon Jan 04, 2021 2:06 pm
Re: ESP32 PWM Max frequency output
Hi,
If you're not going to use for motor control, I recommend you to try the LED Control.
You can try this code to test.
If you're not going to use for motor control, I recommend you to try the LED Control.
You can try this code to test.
Code: Select all
#include <stdio.h>
#include "driver/ledc.h"
#include "esp_err.h"
#define LEDC_OUTPUT_IO 15 // Output GPIO of a sample 1 Hz pulse generator
static void ledc_init(void)
{
// Prepare and then apply the LEDC PWM timer configuration
ledc_timer_config_t ledc_timer;
ledc_timer.speed_mode = LEDC_HIGH_SPEED_MODE;
ledc_timer.timer_num = LEDC_TIMER_1;
ledc_timer.duty_resolution = LEDC_TIMER_4_BIT;
ledc_timer.freq_hz = 2700000; // set output frequency at 2.7 MHz
ledc_timer.clk_cfg = LEDC_APB_CLK;
ledc_timer_config(&ledc_timer);
// Prepare and then apply the LEDC PWM channel configuration
ledc_channel_config_t ledc_channel;
ledc_channel.speed_mode = LEDC_HIGH_SPEED_MODE;
ledc_channel.channel = LEDC_CHANNEL_1;
ledc_channel.timer_sel = LEDC_TIMER_1;
ledc_channel.intr_type = LEDC_INTR_DISABLE;
ledc_channel.gpio_num = LEDC_OUTPUT_IO;
ledc_channel.duty = 8; // set duty at about 50%
ledc_channel.hpoint = 0;
ledc_channel_config(&ledc_channel);
}
void app_main(void)
{
ledc_init();
}
- Attachments
-
- DS1Z_QuickPrint4.png (39.35 KiB) Viewed 22357 times
-
- Posts: 11
- Joined: Thu Mar 25, 2021 5:44 am
Re: ESP32 PWM Max frequency output
Thank you.
-
- Posts: 11
- Joined: Thu Mar 25, 2021 5:44 am
Re: ESP32 PWM Max frequency output
Hi,
I checked with the above code, gives an error: " struct ledc_timer_config_t' has no member clk_cfg
I checked with the above code, gives an error: " struct ledc_timer_config_t' has no member clk_cfg
-
- Posts: 364
- Joined: Mon Jan 04, 2021 2:06 pm
Re: ESP32 PWM Max frequency output
Hi,
Can you confirm the ESP-IDF version that you are using?
Can you confirm the ESP-IDF version that you are using?
-
- Posts: 11
- Joined: Thu Mar 25, 2021 5:44 am
Re: ESP32 PWM Max frequency output
I was trying with Arduino IDE
-
- Posts: 364
- Joined: Mon Jan 04, 2021 2:06 pm
Re: ESP32 PWM Max frequency output
For Arduino, you can try this one:
Code: Select all
#define LEDC_CHANNEL_0 0
// use 4 bit precission for LEDC timer
#define LEDC_TIMER_4_BIT 4
// use 2.7MHz Hz as a LEDC base frequency
#define LEDC_BASE_FREQ 2700000
#define LED_PIN 5
void setup() {
// Setup timer and attach timer to a led pin
ledcSetup(LEDC_CHANNEL_0, LEDC_BASE_FREQ, LEDC_TIMER_4_BIT);
ledcAttachPin(LED_PIN, LEDC_CHANNEL_0);
ledcWrite(LEDC_CHANNEL_0, 7);
}
void loop() {
}
-
- Posts: 11
- Joined: Thu Mar 25, 2021 5:44 am
Re: ESP32 PWM Max frequency output
Thanks,
I've set the duty cycle to 9 for 110KHz(instead of 2.7MHz).
I don't see the transducer turning on.
Circuit of transducer circuit is:
https://www.electroschematics.com/wp-co ... eprint.png
Input Voltage 12V,113KHz Transducer.
I've set the duty cycle to 9 for 110KHz(instead of 2.7MHz).
I don't see the transducer turning on.
Circuit of transducer circuit is:
https://www.electroschematics.com/wp-co ... eprint.png
Input Voltage 12V,113KHz Transducer.
Who is online
Users browsing this forum: nguyennamdsn and 72 guests