Exporting data and charting in Excel in real-time
Download a Free Trial Version. It allows you to try all features! Plugins can be downloaded separately here
I want to connect an RS-2322 port to MS Excel. The port will provide a stream of ASCII numeric characters to Excel. I want Excel to automatically receive and graph the ASCII data, sort of like an oscilloscope. I can control the format of the incoming ASCII data.
It is assumed that:
You've prepared parser items for export.
You can work in Microsoft Excel, specifically create charts in an Excel file.
For this tutorial all items were prepared in the previous part.
Also you may read other examples:
All parser items are now ready for export to "Direct Excel Connection" plug-in. Please, open the configuration window of the "Direct Excel Connection" plug-in (fig.1) by selecting the module in a list and clicking the "Setup" button on the "Data export" page.
Fig.1. Charting in Excel. Excel connection.
Just select options in the field #1 and the field #2. These options will allow you to start Excel and display it on your desktop. Excel will be started automatically on program start.
Because we want to draw a chart in a real-time environment, then we should prepare an Excel file before the next step. In this example we've created a diagram with 3 plots. Each plot is based on a data from columns A, B or C. We'll place FLOW1, VOLW1 and TEMP1 to columns and the chart will use these values and automatically redraw every time. We'll use last 30 values on the diagram only.
Fig.2. Charting in Excel. Excel file.
The figure above contains following elements:
- Data source for plots in this example;
- Excel worksheet.
The Excel file, which we've created you can download
here and use it in your work.
In the next tab, you should specify your workbook options as per your requirements (real-time charting).
Fig.3. Charting in Excel. Workbook options.
You should select the "Use a workbook from a file" option (fig.3 pos.1) that allows you to use an existing file and write data to this file. The path and name of this file, which you created before (fig.2), you should specify in the field #2. The option at the pos. 3 allows you to save all the written data when the program exits.
Fig.4. Charting in Excel. Worksheet options.
In the next tab, with help of the option at the pos. 3, you should specify your worksheet number in the workbook. We've create the workbook, where the worksheet is first. Therefore we've specified this number on the ""Worksheet" page.
The last page "Binding" (fig.5) is very important. On this page the column description and column position that you require to be bound to the variables names are specified.
Fig.5. Charting in Excel. Binding.
Any new items may be added by clicking the "Add item" button (Fig.5, pos. 7). Before adding an item the program will ask you about an item description. You can type any characters here, which will help you to remember a variable's content. For this example 3 variables with their corresponding descriptions have been added.
Each data export item has a number of properties:
- Parser item name - is a
parser variable name, which you have created in the parser configuration.
You may select a variable name from a drop-down box or type this name manually;
- Filling mode - data is sent to Microsoft Excel in this mode in such a way that if the
number of cells for filling is exceeded, data is moved upwards (if it is filled
by columns) or to the left (if it is filled by rows) and new data is written to
the position that becomes unoccupied after data is moved. Thus, the FIFO filling
method is used. In this example we need last 30 values, therefore we've selected the "Move" method;
- Filling orientation - In this example we need to send data to Microsoft Excel, by columns. Therefore we've selected the "Vertically" method;
- Left top cell - here you should specify the coordinates of the upper-left cell starting from which data will be sent to Microsoft Excel. The format the coordinates are specified in should comply with the standard accepted in Microsoft Excel. For example, a record like A1 will mean the coordinates of the top left cell on the worksheet;
- Cells to fill count - here you can specify the maximum number of cells in a column or in a row that will be filled when data is sent to Microsoft Excel.
Click the "OK" button and close the Direct Excel Connection plug-in configuration
window and the "OK" button in the options window.
Okay, all settings have been completed and we are ready to capture data
to an Excel file.
If the data export module and the parser had been correctly set up, then you should see real-time drawing in Microsoft Excel (fig.6).
Fig.6. Charting in Excel. Drawing.
The figure above contains following elements:
- Last 30 values of the parsed data ;
- Diagram with plots.
The Excel file with all values and plots you can download here.