필터 지우기
필터 지우기

Encoder block in Simulink not resetting properly

조회 수: 11 (최근 30일)
Richard Balogh
Richard Balogh 2023년 6월 15일
댓글: Osama Ahmad 2024년 2월 21일
Since the R2021b, Simulink hardware support for Arduino introduced also the rotary Encoder block: https://www.mathworks.com/help/supportpkg/arduino/ref/encodersensors.html
This block offers an ability to reset counter either regularly at sample time or using an external signal. Unfortunately, external signal reset simply doesn't work. It resets the counter in regular intervals, regardless of the reset input state. To me, it seems like a bug, but maybe I didn't catch something.
As you can see from the following image, Encoder is counting (blue line) regardless of the state at the Reset input (yellow), but then it's zeroing itself regularly.
I am using R2023a, Simulink Support Package for Arduino Hardware with Arduino UNO, and operating in Connected IO mode
Any advices, please?

채택된 답변

Swathi
Swathi 2023년 6월 21일
The issue of not being able to leverage the external signal to reset the Rotary Encoder block has now been fixed.
To resolve this issue follow the instructions given below:
  1. Download the files within the attached zip file and put them in the same folder.
  2. Navigate to the folder created in step 1 above in MATLAB.
  3. Run the 'applyPatch.m' file from MATLAB command prompt.
  4. Restart MATLAB.
  댓글 수: 2
Richard Balogh
Richard Balogh 2023년 6월 23일
Confirming, after patching everything works as expected. Thanks!
Osama Ahmad
Osama Ahmad 2024년 2월 21일
I am trying to get encoder values using the rotary Encoder block. The encoder is reading the ticks generated by a pendulum.It is working perfectly fine for Arduino Uno but for a Due board, it shows a drift in the aquired sensor value over time. the difference between the two results can be seen in the attached screenshots (1: Arduino Uno - 2: Arduino Due). Everything works fine if I use the Arduino IDE and the encoder library(therefore the Arduino Due hardware is working fine).
I am running the model in external mode with Arduino as target. Fixed time step of 0.001and solver selection is auto, no clash with pin map as i am using pin 2 and 3 for the signals A and B respectively.The simulation target and code generation languages are C. Using Matlab 2021b.
Is it a bug or am i doing soemthing wrong here?

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

추가 답변 (1개)

Cris LaPierre
Cris LaPierre 2023년 6월 16일
I get the same behavior when I test it. I would suggest reporting this here: https://www.mathworks.com/support/contact_us.html

카테고리

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

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by