MATLAB Answers

Pulsewidth detection SIMULINK with a rounding issue

3 ビュー (過去 30 日間)
Robin Henne
Robin Henne 2019 年 12 月 19 日
回答済み: Fangjun Jiang 2019 年 12 月 19 日
Hi all, i want do detect the Pulsewidth of the Pulsegenerator. Therefore i check if the Signal i want to detect and my Clock is both on high.If they are then i increment the counter. The value of the counter is read every 100us. After that i substract the old counter value from the new one. I dont get, why the Scope shows 7 instead of 6.5 ( the Pulsegenerator is set to 65%).
Does anyone know why i get a 7 instead of a 6.5 although the counter is set to 2^16-1? I hope someone has an idea or an remark to fix my problem? As soon as i set the Generator to 1 Mhz i get the correct value.
Thank you a lot and merry christmas

  0 件のコメント

サインイン to comment.

採用された回答

Fangjun Jiang
Fangjun Jiang 2019 年 12 月 19 日
Your pulse cycle is 100us. Your clock cycle is 10us. So you can count 10 times during a pulse cycle. It is like counting by 10 so you got 70 or 60 when the pulse width is 65%.
When you increase your clock to 1Mhz which is 1us clock cycle, you are counting by 1 so you are able to get 65.

  0 件のコメント

サインイン to comment.

その他の回答 (0 件)

サインイン してこの質問に回答します。

製品


リリース

R2018a

Translated by