What should be the sample time of the input pin to read the PWM signals?
44 ビュー (過去 30 日間)
古いコメントを表示
I used a Arduino Mega to generate PWM pulses with varying duty cycles and frequency 100Hz.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1746361/image.png)
This is the following output on a external logic analyzer connected to the 3, 5 pins. It shows a duty cycle of 20%
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1746366/image.png)
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1746371/image.png)
What frequency should I configure such that I get the same input PWM as in the external logic analyzer?
0 件のコメント
採用された回答
Finn
2024 年 8 月 21 日 6:49
Hi @Vallabh
I think the best way to go would be to configure your ESP32 with external interrupts on your digital Pins
その他の回答 (1 件)
Umar
2024 年 8 月 5 日 9:55
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.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Modeling についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!