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!