Optical encoder read with Arduino Due in Simulink

10 ビュー (過去 30 日間)
Frank Schmidt43
Frank Schmidt43 2016 年 9 月 7 日
コメント済み: redouane elalami 2017 年 11 月 19 日
I have to create a dc motor control test bench. One important part is the reading of the optical encoder for the speed. It's a simple 2 channel encoder (500 counts) which is connected to an Arduino Due board. I'm using Simulink 8.5 (MATLAB 2015a) with the Arduino support package. The whole control should run in external mode in Simulink to read out the values like rpm and current in real time. First I tried to use the Simulink trigger block, but it's too slow for 25kHz (500 counts and 3000rpm).
Now I'm using the s-function Builder block (encoder_slsp.mdl) from Device Drivers to read out the counts of the encoder. The pins (22, 24) are connected to the encoder (CH A, CH B). I had to change the code a litte bit in the libraries tab in "includes" for compiling the s-function from:
void debounce(int del) {
for (int k=0;k<del;k++) {
to
void debounce(int del) {
int k;
for (k=0;k<del;k++) {
It runs in external mode without errors, but the output of the encoder-read block is always 0 (I tried many posibilities with function generators to simulate different encoder signals.). The optical encoder itself works fine (with 3.3V). Any suggestions what I can do? Thank you for your help.
  2 件のコメント
daniel hernandez
daniel hernandez 2017 年 4 月 3 日
Hello, could you solve the problem ?, I have a similar problem and I could not find the answer.
redouane elalami
redouane elalami 2017 年 11 月 19 日
The same problem ! if you find a solution i'd be glad if you share it with me

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

回答 (0 件)

カテゴリ

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