Skip to main content
Suppose you had a group of devices connected via a multi-drop RS422 or RS485 line such that each device responded to a prompt by sending back a record of data. Suppose also that you wanted to set up the Wedge and Excel to poll each device in sequence and retrieve the data stacking up the readings from each device in separate columns in your spreadsheet. In a multi-drop situation you typically have to wait for each device to respond to its prompt before you can send the next prompt to the next device. The following instructions and macro examples show how to handle a situation like this. Note: The following example can also be used to send multiple prompts to a single device over an RS232 connection and thus retrieve multiple data elements from the device.

Setting up the polling sequence

WinWedge setup

  1. Select “DDE Server” from WinWedge “Mode” menu. When the dialog box appears asking for a “DDE Command Destination Application”, clear out both text boxes prompting for an Application Name and a DDE topic.
Note: in this example we will not be configuring the Wedge to send a DDE Command to Excel therefore these two items are not necessary and can be left blank. 2. Select “Input Data Record Structure” in the “Define” menu and define the structure of the input data record(s) to WinWedge. When you get to the final Window with the caption “Input Record Definition Editor”, make sure that you do not have any Field Postamble DDE Commands defined. 3. Set up the Wedge to transmit the first prompt for the first device that you want to poll using either a timer controlled output string or a button controlled output string – Select “Output Strings” from the DEFINE menu. If you use a timer controlled output string, set the timer interval to a value that is high enough to guarantee that all devices will be polled before the first prompt gets sent again. Also, do not check the option “Enable Timer on Activation” – we will activate the timer later, after we are finished setting up Excel. 4. Set up the rest of WinWedge parameters and then activate it.

Creating the Excel polling macro

Excel instructions

Create or edit a macro module in Excel and enter the following code in the module: (To create a new module click on Insert > Module from the Menus in the Visual Basic Editor Window.)
After entering the two subroutines above, run the subroutine “SetUpDDE” to establish a DDE link between Excel and the RecordNumber DDE item in the Wedge.

How the polling process works

After Excel is set up and you are ready to start prompting for data you can enable the timer in the Wedge. What is going on here is that the Wedge will send the first prompt to the first device causing it to send back a response. When each response comes back, the Wedge updates the RecordNumber DDE item in Excel forcing it to run the macro above (because we used the SetLinkOnData method in the SetUpDDE subroutine to cause this to happen). The first thing the macro does is pull in the data from the Wedge and place it in a column using the “PNum” variable as the column selector. For example, if PNum is equal to one, the data is written to column A. If PNum is equal to two then the data is written to column B, etc. Next, the macro increments a “PNum” variable and checks its value. If PNum is greater than the maximum number of prompts (i.e. devices) then it simply resets to 1 and quits; otherwise it transmits the next prompt in the sequence. When the response to this prompt comes in, the process repeats itself until we receive the data from the last device and PNum is incremented past the number of devices. The timer controlled output string in the Wedge starts the whole process over again by prompting for data from the first device. Note: You do not have to use a timer controlled output string. To kick off the sequence, simply transmit the prompt for the first device. You can do this from Excel by writing a macro that sends a DDE command to the Wedge telling it to send the first prompt or you can define a hot key or a button controlled output string in the Wedge that would transmit the first prompt.
Last modified on November 3, 2026