Interacting with an Arduino Using the Matlab Serial Commands

Two sets of files demonstrate serial communications between Matlab and the Arduino.
9,6K téléchargements
Mise à jour 16 fév. 2010

Afficher la licence

Using information from Matlab central, Robot Grrl, and the Arduino forums, four files (two .m and two sketches) demonstrate two way communications between Matlab and the Arduino. The first set of files, serialTest1, demonstrates arduino input with Matlab tic/toc timing information added, and the second set of files, serialTest2, uses clock information from the arduino. I think you'll find the results interesting when the two approaches are compared.

Usage:
Load the sketch on your arduino. LED13 will light, indicating that the arduino is waiting for a response from Matlab to start. Load the m file, and change the com port to the port where the arduino USB is mapped on your PC (I use Linux, thus the /dev/ttyUSB1, it will be something like 'COM3' in windows). Run the .m file, and LED13 will turn off as Matlab signls the arduino, data is read, and a plot is created of time info versus counter data (simulating sensor data). Remember to reset the arduino before each m file run (LED13 must be on)! Used an arduino mega, but should work fine on most arduinos. Thanks to Tom Igoe and Robot Grrl (see sketch references to http addresses). Robot Grrl plots as she goes, and you can do that also, although it will slow things down slightly. But, note the key to these files, is the use of the proper TERMINATOR. The matlab set terminator statement using LF and the use of serial.println in arduino is the secret ingredient to success. If you don't use these, then you are relying on inserted timing delays, yuck.

Citation pour cette source

Lowell Toms (2024). Interacting with an Arduino Using the Matlab Serial Commands (https://www.mathworks.com/matlabcentral/fileexchange/26711-interacting-with-an-arduino-using-the-matlab-serial-commands), MATLAB Central File Exchange. Récupéré le .

Compatibilité avec les versions de MATLAB
Créé avec R2009a
Compatible avec toutes les versions
Plateformes compatibles
Windows macOS Linux
Catégories
En savoir plus sur Instrument Control Toolbox dans Help Center et MATLAB Answers
Remerciements

Inspiré par : Arduino meets MATLAB

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

arduino2matlab/

Version Publié le Notes de version
1.0.0.0