What should be the sample time of the input pin to read the PWM signals?

조회 수: 3 (최근 30일)
Vallabh
Vallabh 2024년 8월 3일
댓글: Vallabh 2024년 8월 21일
I used a Arduino Mega to generate PWM pulses with varying duty cycles and frequency 100Hz.
This is the following output on a external logic analyzer connected to the 3, 5 pins. It shows a duty cycle of 20%
I configured an ESP32 WROOM(30 pin) to read the same PWM input using the digital pins with sample time = 0.005. I'm not getting the same input as expected.
Also the PWM inputs appear discontinuous in the simulink logic analyzer
What frequency should I configure such that I get the same input PWM as in the external logic analyzer?

채택된 답변

Finn
Finn 2024년 8월 21일
I think the best way to go would be to configure your ESP32 with external interrupts on your digital Pins
  댓글 수: 1
Vallabh
Vallabh 2024년 8월 21일
Yes, this is the best possible way for any board.
I have used interrupts for every rising and falling edge and sample the signal at that interrupt.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Umar
Umar 2024년 8월 5일
Hi @ Vallabh,
You should configure the frequency of the PWM signal on the ESP32 WROOM to match that of the Arduino Mega, which is 100Hz in this case. By setting the frequency to 100Hz on the ESP32 WROOM, you should be able to synchronize the duty cycle readings between the two devices effectively. Remember to adjust the sample time in your ESP32 WROOM code to match the desired frequency for capturing the PWM input. By aligning the frequency settings, you can achieve a consistent and accurate representation of the PWM signals across different devices.

카테고리

Help CenterFile Exchange에서 Arduino Hardware에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by