Encoder block in Simulink not resetting properly

26 vues (au cours des 30 derniers jours)
Richard Balogh
Richard Balogh le 15 Juin 2023
Commenté : Osama Ahmad le 21 Fév 2024
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?

Réponse acceptée

Swathi
Swathi le 21 Juin 2023
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 commentaires
Richard Balogh
Richard Balogh le 23 Juin 2023
Confirming, after patching everything works as expected. Thanks!
Osama Ahmad
Osama Ahmad le 21 Fév 2024
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?

Connectez-vous pour commenter.

Plus de réponses (1)

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

Produits


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by