read digital pin pulses
Mostrar comentarios más antiguos
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
Respuestas (1)
Asad Mirza
el 24 de Feb. de 2019
0 votos
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 comentarios
john white
el 24 de Feb. de 2019
Asad Mirza
el 24 de Feb. de 2019
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
el 25 de Feb. de 2019
Asad Mirza
el 25 de Feb. de 2019
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
el 25 de Feb. de 2019
Asad Mirza
el 25 de Feb. de 2019
Yeah, as far as I know MATLAB can't natively change the interrupt pins.
Welid Benchouche
el 15 de Sept. de 2022
but can matlab call an interrupt in matlab code ?not the external interrupt or detect increase in simulink, in matlab code.
Categorías
Más información sobre Arduino Hardware en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!