Sunteți pe pagina 1din 7

A CHILDS GUIDE TO DIRECT DATALOGGING WITH EXCEL

version 4

(All brickbats and bouquets gladly received - on the Arduino forum)

This is an aide memoire for the PLX-DAQ macro for Excel. Parallax do not address the use
of their freebie with Arduino.
The objective is to use this macro in order to feed data direct from Arduino to Excel.
Essentially, the macro enables Excel to work just like any other terminal programme but
has the advantage of producing direct input into where you really want it, and it can give
you live graphs as well as a data file. Im sure you can get pretty sophisticated with the
Excel commands, but this start might be all you need.
1. WHAT IS PLX?
It has taken me about two years to work out that PLX_DAQ is just a terminal interface for
Excel. All the things you do with the data are what you do with Excel. I got PLX-DAQ
because of the ability to make graphs on the fly but this is not some mystical ability of PLXDAQ, all that is happening is that PLX-DAQ expedites normal Excel procedures. There is
no difference between the making of my old Excel graph and PLX-DAQ except that
manually entering one line of data each day is not nearly as spectacular as PLX-DAQ
receiving a line of data each second automatically from Arduino.
2. MINIMUM REQUIREMENTS
Hardware: Any Arduino capable of serial output
Software: Microsoft Office 2000, Windows XP
The PLX-DAQ macro for Excel. This available for free from
http://www.parallax.com/downloads/plx-daq
3. AREAS OF OPERATION
There are two separate things to do:
1. Format the output from Arduino so that it is properly interpreted by Excel
2. Understand the use of the macro within Excel.
4. ARDUINO
The following code example is lifted from a current project. Activities include
1. read three temperature sensors at one second intervals.
2. record those readings along with time on an SD card
3. derive the difference between first two readings
4. send the appropriately formatted data to serial to be received by Excel
The vital feature to note is that the material sent from Arduino is a mixture of data and Excel
commands. The Excel commands do not preclude the use of other terminal programmes.

Only three Excel commands are used in this exercise LABEL, DATA, and TIME
LABEL signifies that the following material is just a label
DATA signifies that the following is DATA
TIME is the command to get the PC time and write it in the first cell. Note that this is a local
call, the time does not come from Arduino.
The sheet header, if required, is written when the reset is pressed. The line is in the setup
section.
Serial.println("LABEL,Time,InTemp,OutTemp,diff,DrainTemp");
Which labels the first five columns.
At the appropriate position in the loop, are the following commands:
Serial.print("DATA,TIME,"); // Excel commands
Serial.print(InTemp);
Serial.print(" , ");
Serial.print(OutTemp);
Serial.print(" , ");
Serial.print(diff);
Serial.print(" , ");
Serial.println(DrainTemp);
This tells Excel to put the PC time in the first column and fill the next four with numeric data.
This data is the same floats the were sent to any other terminal programme, and a
maximum of 26 items will be accepted. Note that the section in the PLX help file is called
Control Directives, as are the commands. There is a lot of extra stuff but you can ignore
their admonishions about carriage returns, it clearly does not apply to Arduino, just use
Serial.println for the last in the normal manner. If you are a bit short of confidence, you can
do a test run using the serial monitor. It is quite readable.
5. EXCEL
Download and install the macro in the normal manner. The installation includes a desktop
folder with two shortcuts inside. Note that the help file is pretty comprehensive, even though
it does not refer to Arduino. The objective is to get the right material into Excel, regardless
of where it originated. Your job is simply get Arduino to talk the same language..
The vital bit is that Excel is not started by the usual procedure, it is started from the macro.
This may be common practice but it is the only Excel macro I use.
Once Installed, Excel is started through through the shortcut in the desktop folder. You
need to allow the macro to run and then you should see this window over an Excel sheet.

This is used to make the connection and start Excel. The connection is made via the USB
cable in the normal manner, and the port is the same as that used by the Arduino IDE. The
baud rate must match that in the Serial,begin command in the Arduino programme.
By having the Reset on Connect box ticked, serial commands in the setup section of the
Arduino programme will be implemented i.e. the title. At the start Excel opens with a dummy
sheet. Ignore this, it will dump it when Arduino starts.
Run Arduino and click the connect button in the PLX window. You shouldnt be left in any
doubt about what is going on there is quite a lot After Arduino goes through its
startup procedure, your titles should go up, the C status goes green, R flashes red on
receipt, the message line at the bottom will advise of each line of data being accepted, and
yes, the numbers come into the cells.
6. LIVE GRAPHS
The live graph facility works but you need to get used to it. It is normal Excel, PLX-DAQ
just feeds the data into the cells. The latest version of Excel may be better at this. Some
familiarity with Excel graph-making wont go astray.
I think there are a couple of secrets with graphs though. If you want a live graph, it is
usually one where data is measured against time and the regular dispatches from Arduino
are a sufficient time-cycle in themselves. In short, while the timestamp is included in the
data lines on the work sheet, Excel doesnt need them on the graph and I think it gets
along better without them.
If you want to start at a specific point, the Clear Columns button in the PLX-DAQ window is
ideal. No need to reset Arduino or reconnect.
The procedure below is for a four-line graph with two y-axes. It was originally planned to
use four lines. The main problem with graphs is that default is soul-destroying and the
configuration equally so, but each aspect is configurable and it is quite versatile.
So the objective is to get it right and hang onto it for dear life as a template. The Excel
chart wizard suffices
1.
Run your Arduino programme so that the data is being entered.

2.
Highlight the relevant data column and select Chart from the Insert menu. This is the
standard chart wizard. Select the plain-vanilla chart called Line and click Next. Donr be
tempted to try anything fancy. If you use the press-to-view button, you will probably get a
fair idez of what is going on.

3.
This is a vital bit. The data range. The graph is about time and the duration needs to be
determined. Here, Arduino is looping at about 1Hz and we want a graph for half an hour
1800 seconds.
The range offered in the wizard is simply the wipe over columns B to E and down to the last
data line written at the time of the click. This is edited as follows
='Simple Data'!$D$1:$D$1800
You have already done the series, so click next.

4.
Give it some titles as you see fit. Note particularly that the labels for the lines, InTemp,
OutTemp etc., cannot be edited with the graph tools and, in this case, is data from Arduino.

And go through the tabs. I made no change to the axes. I called for major and minor
gridlines. The picture goes black, dont panic. This is a time graph, so the X-axis is
important, and the legend is moved to the top.

Click Finish and see godawful mess.


5.
Left click on the graph and stretch it to something useful but probably discouraging, and
possibly meaningless as well.
6.
Here comes the cavalry Each item on the graph is individually configurable.

In the above example, the titles and legend have defaulted quite nicely. This is not normal
but you can attend to them by right clicking on them to change the font and colour.
The first item for attention is likely to be the Y-axis, so right click on a figure to get to the
format dialogue. Nearly everything has been changed.

I just blunder with the X-axis, the objective is to get some sensible grid-lines, and get rid of
what looks like a black background.
Now comes the magic bit run one of the lines on a different Y axis. Right-click on any data
point on the Line, select Format Data Series, select the Axis tab and select Secondary Axis.
Note that there appears to be nothing that can be done about the way the X-axis counts.
You can specify the interval but you are stuck with starting at 1, not 0.
7.
Note that, once the graph is going, you can right click on the line and change the weight or
colour. Note also that Excel is not above changing the graph type while you are configuring
something. Picture shows graph in progress at about 650 seconds.

S-ar putea să vă placă și