Sei sulla pagina 1di 3

Arduino-Based Data Acquisition into Excel, LabVIEW, and MATLAB

Daniel Nichols

Citation: The Physics Teacher 55, 226 (2017);


View online: https://doi.org/10.1119/1.4978720
View Table of Contents: http://aapt.scitation.org/toc/pte/55/4
Published by the American Association of Physics Teachers

Articles you may be interested in


An Arduino-Based Magnetometer
The Physics Teacher 55, 274 (2017); 10.1119/1.4981032

Connecting Time and Frequency in the RC Circuit


The Physics Teacher 55, 228 (2017); 10.1119/1.4978721

The Polarization of Light and Malus’ Law Using Smartphones


The Physics Teacher 55, 264 (2017); 10.1119/1.4981030

Mobile Phone Radiation and Cancer


The Physics Teacher 55, 210 (2017); 10.1119/1.4978714

Two Types of Truth in the Physics Classroom


The Physics Teacher 55, 218 (2017); 10.1119/1.4978717

Know Your Bulbs!


The Physics Teacher 55, 231 (2017); 10.1119/1.4978722
Arduino-Based Data Acquisition into
Excel, LabVIEW, and MATLAB
Daniel Nichols, DeVry University, Chicago, IL

D
ata acquisition equipment for physics can be quite ex-
pensive. As an alternative, data can be acquired using
a low-cost Arduino microcontroller.1 The Arduino
has been used in physics labs where the data are acquired us-
ing the Arduino software.2-4 The Arduino software, however,
does not contain a suite of tools for data fitting and analysis.
The data are typically gathered first and then imported manu-
ally into an analysis program. There is a way, however, that
allows data gathered by the Arduino to be imported in real
time into a data analysis package. Illustrated in this article are
add-ins for Excel, MATLAB, and LabVIEW that import data
directly from the Arduino and allow for real-time plotting and
Fig. 3. View of Excel spreadsheet along with PLX-DAQ macro.
analysis.

The Arduino Uno Interfacing the Arduino to Excel


The Arduino Uno is a microcontroller with 14 digital in- Interfacing the Arduino to Excel can be done easily using a
puts and six analog inputs with 10-bit resolution.5 It can be Parallax Data Acquisition tool (PLX-DAQ) software free add-
purchased for as little as $6 on in for Microsoft Excel.8-11 To interface the Arduino to Excel,
eBay, programmed in C, and the Arduino would first have to be programmed with the Ar-
can be interfaced to a com- duino software (IDE) shown in Fig. 2. Once the Arduino code
puter through USB, and the is uploaded into the Arduino, click on the PLX-DAQ spread-
software is free.6 There exists a sheet icon. Choose the port the Arduino is connected to, check
lot of inexpensive sensors the the Download Data box, and then click Connect. A graph can
Arduino can interface to such be added to see real-time plotting, as shown in Fig. 3.
as the LM35 for temperature
sensor, the TSL2561 luminos- Interfacing the Arduino to MATLAB
Fig. 1. Arduino Uno connected
to an LM35 temperature sen- ity sensor, and the ADXL-335 Interfacing the Arduino to MATLAB can be done easily
sor. triple-axis accelerometer, all using a MATLAB free support package for the Arduino.12-14
under $15.7 As an example of There is no need to program the Arduino with the Arduino
this, an LM35 temperature sensor, which outputs 10 mV/oC is software; the support package takes care of that. MATLAB
monitored with an Arduino UNO, shown in Fig. 1. code for reading a sensor connected to the Arduino’s port A0,
//Arduino Code to send Data to Excel
as well as a real-time plot, is shown in Fig. 4.
void setup() {
Serial.begin(9600); // the bigger number the better
Serial.println(“CLEARDATA”); //clears up any data left
from previous projects
Serial.println(“LABEL,Clock,Time,Data”);
//Always write LABEL, so excel knows the next things
will be the names of the columns (instead of Acolumn
you could write Time for instance)
Serial.println(“RESETTIMER”); //resets timer to 0
}
void loop() {
Serial.print(“DATA,TIME,TIMER,”);
//Writes the time in the first column A, the elapsed
time in column B, and the data in C.
Serial.print(analogRead(A0));//Read channel A0
Serial.println(“”); //be sure to add println to the
last command so it knows to go into the next row on
the second run
delay(100); //Add a 100mS delay
}

Fig. 2. Arduino code for reading sensor connected to port A0. Fig. 4. MATLAB code and plot for reading sensor connected to
port A0.

226 THE PHYSICS TEACHER ◆ Vol. 55, April 2017 DOI: 10.1119/1.4978720
10. http://www.instructables.com/id/Sending-data-from-Ardui-
no-to-Excel-and-plotting-it/.
11. http://nutsvolts.texterity.com/nutsvolts/201506/?folio=34&pg
=34#pg34 .
12. https://www.youtube.com/watch?v=Tm3g1bZi7To .
13. https://www.mathworks.com/videos/using-matlab-and-
arduino-to-acquire-analog-signals-100739.html .
14. http://www.mathworks.com/hardware-support/arduino-
matlab.html .
15. http://sine.ni.com/nips/cds/view/p/lang/en/nid/212478 .
16. Marco Schwartz and Oliver Manickum, Programming Arduino
with LabVIEW (Packt Publishing), ISBN: 978-1-84969-822-1.
Fig. 5. Front panel of LabVIEW code to acquire data from 17. M. Jaskuła, M. Łazoryszczak, S. Peryt, “Fast MEMS application
Arduino. prototyping using Arduino/LabView pair measurement,” Auto-
mation Monitoring 61 (12), (Dec. 2015).
Interfacing the Arduino to LabVIEW 18. https://www.google.com/sheets/about/.
19. http://www.instructables.com/id/Visualize-data-from-sensors-
Interfacing the Arduino to LabVIEW can be done using using-Arduino-coolte/.
the LINX by LabVIEW Makerhub.15-17 This is a free interface
software to LabVIEW that easily allows LabVIEW to command Daniel Nichols is EIS faculty member at DeVry University in Chicago.
and acquire data from the Arduino. As with MATLAB, there His hobby is designing and building equipment to measure and control
is no need to program the Arduino with the Arduino software; systems.
dnichols2@devry.edu
the support package takes care of that. Simply run the program
in Fig. 5 and choose the correct com port the Arduino is con-
nected to and the data will be plotted.

Summary
gravitate
Students
The Arduino microcontroller and some inexpensive sensors
towards
can be used as a cheap alternative physics
to expensive with the
data acquisi- TEL-Atomic
tion equipment. The most Computerized cavendish
expensive component used in this Incorporated
Balance
article is the data analysis software. An alternative to these, free
spreadsheets such as Google Sheets18 can perform the analysis. Providing you with tools
to teach advanced Physics
There are also free serial port terminal applications, such as
CoolTerm,19 which would allow data from the Arduino to be
saved into a file. This data can then be imported into the analy-  Short oscillation periods of 2-4 minutes
sis program of your choice.  Complete experimental results in a single lab period
The software used in this article was arduino-1.6.4, Excel  No more optical lever jitters due to revolutionary
2013, MATLAB R2015b, and LabVIEW2013, and run on Win- sensor design
dows 7 Enterprise. To ensure compatibility on your computer,  24 bit resolution computerized cavendish
check the system requirements for these add-ins. balance
References
1. https://www.arduino.cc/.
2. Calin Galeriu, Cheryl Letson, and Geoffrey Esper, “An Arduino
investigation of the RC circuit,” Phys. Teach. 53, 285 (May 2015).
3. Calin Galeriu, Scott Edwards, and Geoffrey Esper, “An Arduino
investigation of simple harmonic motion,” Phys. Teach. 52, 157
(March 2014).
4. Calin Galeriu, “An Arduino-controlled photogate,” Phys. Teach.
51, 156 (March 2013). For product details >> www.telatomic.com
5. https://www.arduino.cc/en/Main/ArduinoBoardUno . 800.622.2866 sales@telatomic.com
6. www.arduino.cc/en/Main/Software .
7. https://www.adafruit.com .
8. https://www.youtube.com/watch?v=xzC4SDd6sJ0 . Tel-Atomic Cavendish AD.indd 1 12/7/2010 10:56:49 PM
9. https://www.parallax.com/downloads/plx-daq .

THE PHYSICS TEACHER ◆ Vol. 55, April 2017 227

Potrebbero piacerti anche