read digital pin pulses
古いコメントを表示
how could I read digital pin pulses from arduino in matlab?
I mean by writing readDigitalPin(a,'D4')
it shows just 0 or 1
but I want to read pulses from this pin which connected with the phase of increamental encoder
回答 (1 件)
Asad Mirza
2019 年 2 月 24 日
0 投票
Digital pins only return values of 0 or 1. If you want to read voltage information from an incremental encoder it would have to be connected to an analog in pin and then you would have to use readVoltage.
7 件のコメント
john white
2019 年 2 月 24 日
Asad Mirza
2019 年 2 月 24 日
I believe MATLAB has an example code that reports the position of an encoder. Granted they use pin's D2 and D3 but you can easily change it to be D4 and D5 for ChannelA and B and then have say D2 be for the pushbutton.
john white
2019 年 2 月 25 日
Asad Mirza
2019 年 2 月 25 日
Ah that might be because only D2 and D3 on a classic Arduino Uno have what are called interrupt pins which are needed for rotary encoder information. Arduino Interrupts explains a bit about this. As far as I know you cannot change the interrupt pins in MATLAB but using the Arduino ide you can program the Atmel chip to make any of the other digital pins interrupts like so.
john white
2019 年 2 月 25 日
Asad Mirza
2019 年 2 月 25 日
Yeah, as far as I know MATLAB can't natively change the interrupt pins.
Welid Benchouche
2022 年 9 月 15 日
but can matlab call an interrupt in matlab code ?not the external interrupt or detect increase in simulink, in matlab code.
カテゴリ
ヘルプ センター および File Exchange で Arduino Hardware についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!