|
|
Workbench for Windows: DDE Output from WorkBench PC for Windows into Microsoft Excel
An important feature of WorkBench PC for Windows is
its support of Dynamic Data Exchange (DDE). Utilizing the
DDE Output and DDE Input modules, users have the ability
to send and receive data between WorkBench and other
Windows applications. These modules can then be connected
to other modules to incorporate the data into the
worksheet.
|
AN EXCEL EXAMPLE
One of the most common uses of
DDE in WorkBench is to send collected data to a
spreadsheet for further analysis. As a simple example,
suppose you want to output the data from a Generator
module into a Microsoft Excel worksheet. The following
steps show how to do this:
- Load WorkBench. Create a Generator module and a
DDE Output module on a new worksheet.
- Click on the A/D button in the function bar, or
choose Experiment Setup from the Menu. Set the
Block Size to 8 and the Sampling Rate/Channel to
50Hz. Close the dialog box.
- Double-click on the DDE Output module to set its
parameters. For this Excel example, set the
parameters as follows:
- Application: Excel
- Topic: WBfWdde.xls (or your worksheet
name. Remember to include the
".xls" extension.)
- Item: DDECELL
- Output Format: Columns
- Separator: Tab
- Final Character: CR LF
- Decimal Format: Point
- Double-click on the Generator module. Check that
the defaults are set to Sine Wave "10
Hz" and Amplitude "4" then click
OK.
- Open Excel, creating a new worksheet. Select
cells A1 through A8. Note that the number of
columns matches the number of channels being
passed through DDE, one in this case. The number
of rows selected should always equal the Block
Size, 8 samples for our example.
- Use the Insert/Name/Define (or Formula/Define
Name in older versions) menu selection in Excel
to name the selected area. The name should be the
same as that entered in Item field of the DDE
Output module, "DDECELL" for our
example.
- Save the worksheet as "WBfWDDE.xls" (or
the name you specified as Topic in WorkBench).
- Return to WorkBench and start the experiment. The
Excel column should immediately begin to show the
acquired data in real-time.
NOTE: For a better display of this real-time
data, use cells A1 through A8 as the data series for a
chart in Excel. In this way, a graph of a moving sine
wave will be displayed. For better resolution of this
sine wave, increase the Block Size and Sample Rate in
WorkBench and make the associated changes in Excel.
|
TROUBLESHOOTING
If the Application or Topic is
incorrectly entered in WorkBench, then a "Cannot
Create DDE-Link" will be displayed. It is important
to make sure that the ".xls" ending is present
in Topic or this same error message will result. An
incorrect Item will not cause an error message but will
result in no information being transferred to Excel.
|
MULTIPLE CHANNEL DDE
To transfer multiple columns of data
to Excel, use one DDE Output module with multiple
channels. For example, if two columns of data are needed
in Excel, then the DDE module would have two channels
selected. The Application, Topic, and Item settings are
the same for all channels. All that needs to be changed
is the block selection in Excel - select two columns of 8
rows and define the name as DDECELL. When WorkBench is
started each channel on the DDE output icon will pass
data to one column in Excel.
|
A NOTE ON DDE
DDE transfer of data allows data to
be passed from one application to another in the Windows
environment. Typically, any new data passed to the
receiving application will write over any preceding data,
rather than append it. In this way, data sent to Excel
will overwrite the previous "blcok" of data to
have been sent from WorkBench. If it is required for all
data to be present in Excel at the end of an experiment,
it is necessary to log data to disk using the Write
module in WorkBench, and then to open that file into
Excel. This is a limitation with DDE, not WorkBench PC
for Windows.
|
|
|