Hi, I'm using the Arduino Support Package for Simulink Toolbox. My goal is to make a counter that counts up when it rotates clockwise and counts down when it rotates counterclockwise by using KY-040 Encoder. I can read all values appropriately. (Encoder has 2 output pins, OutA and OutB, and they produce digital signals.) My problem is to take the values I read from the OutA pin and compare them with the new values. Which blocks should I use for this?

 採用された回答

J Chen
J Chen 2020 年 3 月 2 日

1 投票

You can use Simulink Delay block which store you last data. Type delay in the search box in the Simulink Library Browser to locate the block.

5 件のコメント

Berke Ogulcan Parlak
Berke Ogulcan Parlak 2020 年 3 月 2 日
Thanks, Chen! Could u give a little example for combination of summation and delay blocks?
J Chen
J Chen 2020 年 3 月 2 日
編集済み: J Chen 2020 年 3 月 2 日
See the attachment for an example.
BienPz10
BienPz10 2020 年 3 月 11 日
Chen, can you export that file in a previous version (2017b) ?. Please.
J Chen
J Chen 2020 年 3 月 11 日
2017b version is attached.
Berke Ogulcan Parlak
Berke Ogulcan Parlak 2020 年 3 月 11 日
Hi!, Chan. The block diagram works really well with this state. However, when I connect the encoder to the input, the count is delayed. I think this problem occurs because I don't use interrupt. But when I use the external interrupt block, although my encoder is 20 pulse / rev, I read values like 500-600 and it is not stable. Do you have any advice for counting pulses with interrupt? Thank u!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Arduino Hardware についてさらに検索

製品

リリース

R2019b

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by