Hi! We have this project for our senior's research regarding the optimization of multiple sensors which incorporates DS Theory. I would like to know if any of you knows how to import data from a microcontroller into MATlab program?:-D
Hi! We have this project for our senior's research regarding the optimization of multiple sensors which incorporates DS Theory. I would like to know if any of you knows how to import data from a microcontroller into MATlab program?:-D
MATLAB has a direct interface for the most commonly used boards (Uno, Mega, Due, Leonardo) at Arduino Support from MATLAB - Hardware Support
This is much easier than trying to do your own bit-banging. The interface is just an ordinary USB cable from the PC to port on the Arduino.
MATLAB has a direct interface for the most commonly used boards (Uno, Mega, Due, Leonardo) at Arduino Support from MATLAB - Hardware Support
This is much easier than trying to do your own bit-banging. The interface is just an ordinary USB cable from the PC to port on the Arduino.
There is a MATLAB package that you use to abstract the serial connection to both transmit instructions to, and receive data from the Arduino. The link I included in my post gives you "how-to" videos, code examples, and a documentation package. Only caveat is you need to have MATLAB R2014a or higher. There is more than one way to do it, but; for instance say I wanted to connect to an Arduino Uno on the USB port COM4, and use a TMP102 I2C temp sensor.
1. Start the connection: a = arduino ( 'com4', 'uno', 'Libraries', 'I2C')
2. Scan the I2C bus: addrs = scanI2CBus(a)
3. We'll say the only I2C address this returns is 0x298
4. You create the I2C object: tmp102 = i2cdev(a, '0x298')
5. And write the code to retrieve the Celsius temp using I2C:
write(tmp102, 0, 'uint8');
data = read(tmp102, 2, 'uint8');
temperature = (double(bitshift(int16(data(1)), 4)) + double(bitshift(int16(data(2)), -4))) * 0.0625
This is a screenshot of a demo on the MathWorks website using MATLAB R2015a. They've tried to make the API's close to Arduino syntax.