Read rotary encoder from Arduino Uno in Simulink

201 ビュー (過去 30 日間)
Apostolos Vrontos
Apostolos Vrontos 2020 年 3 月 20 日
コメント済み: Omer Faruk 2022 年 5 月 19 日
Hello,
I can easily read the counts in Matlab (like this: https://de.mathworks.com/help/supportpkg/arduinoio/ug/control-rotary-encoder-knob.html), but not in Sumulink! Can someone tell me how it is the correct way to read the counts in real-time in Simulink?
Thanks

採用された回答

Pranav Murali
Pranav Murali 2020 年 3 月 23 日
I understand that you are trying to read the counts from a rotary encoder using Simulink. Although Simulink doesn't have a block to interface a rotary encoder at present, it can possibly be achieved in two ways:
  1. Write your code on MATLAB and import the function as a Simulink block. See how that is done here.
  2. Attach External Interrupt block to pins 2 and 3 to call an Interrupt Service Routine (ISR) function. The ISR will then perform bitwise comparison of the two inputs to increment/decrement the counts.
The idea behind the second approach is to implement the rotaryEncoder function through existing Simulink blocks.
  9 件のコメント
Azlin Afiqah
Azlin Afiqah 2021 年 8 月 9 日
@Phan Du Thank you so much. I really really appreciate that. Thank you so much <3
Ghani Lawal
Ghani Lawal 2022 年 2 月 18 日
If one doesn't care about the direction of the motor, can one just attach the External Interrupt to call the ISR when the signal at PIN 2 goes from LOW o HIGH?

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

その他の回答 (3 件)

Hasan Falah
Hasan Falah 2020 年 6 月 30 日
Hello friends,
I’m using arduino Due to read incremental rotary encoder by simulink, there is no block in sinulink to do that.
I tried with external interrupt example in matlab 2020a but it is reading only in one direction and just increasing, so it should be readings in clockwise and counterclockwise.
Aslo I tried with encoder S-Function in Device Driver examples but also does not work.
Your help please .....
Thanks
  4 件のコメント
Harshil Jani
Harshil Jani 2021 年 3 月 29 日
Hi Yago menezes, If you are able to use it using simulink please send me to harshiljani008@gmail.com
Anass Dkheila
Anass Dkheila 2021 年 9 月 21 日
Hello Hasan did you solve this problem? if you did can you send it to me at againstmarz@gmail.com

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


Daniel Velazquez
Daniel Velazquez 2021 年 7 月 5 日
Hi, thanks for the encoder part.
Attached is a preliminary implementation of a PID Speed Controller for a DC motor with encoder.
The circuit is a low side FET to the pin 5 of the ATMEGA (PWM output) and pins 2 and 3 go to the encoders as input.
The PID parameters and scopes are tuneable.
Saludos
Daniel Velazquez
  1 件のコメント
Azlin Afiqah
Azlin Afiqah 2021 年 8 月 4 日
Hi, can you give me the block diagram in version R2014a. Thank you. I'm helpless doing this project. I really really appreciate your support. Thank you again

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


Daniel Velazquez
Daniel Velazquez 2021 年 8 月 6 日
Hello Azlin, unfortunately I do not have R2014a but you can easily redraw it in your version from the image attached of the Simulink diagram.
Have fun
Daniel
  3 件のコメント
mechali omar
mechali omar 2021 年 10 月 21 日
編集済み: mechali omar 2021 年 10 月 21 日
Hola, Hello Daniel Velazquez
Thank you for providing these useful files.
May I kindly ask you to provide a small clirification about some blocs in the encoder function.
1- for the gain 60/485. Why we exactly need to choose these values. Are thery related to the encoder type, or they remain valid for any other encoder.
2- for the bloc with gain of 0.1. What is the role of this bloc with exactly 0.1 gain.
3- How to change the sampling time of the S-Function block "Ts".It remains always 0.1 even we have changed it in the workspace.
GRACIAS
Omer Faruk
Omer Faruk 2022 年 5 月 19 日
Daniel could you explain how we obtain response curve?

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

カテゴリ

Help Center および File ExchangeArduino Hardware についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by