Hi guys, I wonder how to use Matlab to get data from a incremental encoder through an Arduino mega2560 board. I have to do this to control a motor by using Matlab software.
Hi guys, I wonder how to use Matlab to get data from a incremental encoder through an Arduino mega2560 board.
I don't think you can. The encoder should be using interrupts to trigger the Arduino to increment or decrement a value. You can have the Arduino send that value each time it changes. Or, you could have the Matlab ask the Arduino for the current value.
First, thank you very much for helping!
In my project I want to get feedback values of motors in real to compare with values that I've got by using simulation in Simulink. So, you think I have to code my Arduino to communicate with Matlab, get encoder's signal by using arduino and code Matlab to ask data from Arduino ? I want to get data in real-time, what can i do ?
Its possible to use a serial port object in matlab to transfer the data. If you set up a Serial.event() function on the arduino side to see if matlab has asked for anything then everytime it does, you just send whatever data needs to be sent.