Questions? Search our site or call us at 1-800-722-6004

Origin 5.0: Launching the WinWedge and Collecting Data to a Column

WinWedge DDE Server Settings

Remember to set WinWedge up in DDE Server Mode! Click here.

DDE Application Name: Origin
DDE Topic: ORG
DDE Command: Get_Wedge_Data

Example#1 – Launching and Starting a Conversation with WinWedge

Launch Origin and open the Script Window by selecting Window:Script Window from the Origin menu bar. Enter the following lines of script to launch WinWedge and Start a conversation. This example assumes that WinWedge.Exe and the configuration file "MyConfig.SW3" exists and both are located in a directory named "WinWedge" and that the config file "MyConfig.SW3", saved from above, will configure WinWedge for serial port COM1.

//Launch WinWedge with configuration file
run -e c:\Winwedge\winwedge.exe c:\WinWedge\MyConfig.SW3;
dde -c WinWedge|Com1 id; //Initiate conversation

Note: There are two ways to execute a script from the Script Window. One way is to type text into the Script Window and press ENTER. The text from the beginning of the line to the current cursor point is sent to the interpreter as a single script. After pressing ENTER, Origin appends a semicolon to the end of the line to indicate the script was executed. Another option for executing script from the Script Window is to Highlight multiple lines of text (including a semicolon at the end of each line) to be executed and press ENTER.

Example #2: Collecting Data to a Column in a Spreadsheet

Origin 5.0 does not have a "Get_Wedge_Data" DDE command so the first step is to create one. When you create a macro in Origin 5.0, the name of the macro automatically becomes a valid Origin 5.0 DDE command (or script command) for as long as the project is open. This example assumes that WinWedge.EXE and the configuration file "MyConfig.SW3" both exist and are located in a directory named "WinWedge" and that the config file "MyConfig.SW3", saved from above, will configure WinWedge for serial port COM1. Each time data is sent to the wedge the data is entered in a new row.

//Create Get_Wedge_Data Macro
def Get_Wedge_Data {
//Launch WinWedge with configuration file:
run -e c:\Winwedge\winwedge.exe c:\WinWedge\MyConfig.SW3;
dde -c WinWedge|Com1 id; //Initiate conversation
dde -r id field(1); //Request information
plot -a %H 1 "%Z "; //Enter data into column 1 of the active worksheet
dde -d id; //terminate dde link
};

Note: To define the above macro, highlight the entire block of text and hit ENTER.

If you have defined 2 fields in WinWedge and would like to collect the data into two columns, then modify the macro above to include a line that collects data from field 2:

//Create Get_Wedge_Data Macro
def Get_Wedge_Data {
//Launch WinWedge with configuration file:
run -e c:\Winwedge\winwedge.exe c:\WinWedge\MyConfig.SW3;
dde -c WinWedge|Com1 id; //Initiate conversation
dde -r id field(1); //Request information from field 1
plot -a %H 1 "%Z "; //Enter data into column 1 of the active worksheet
dde -r id field(2); //Request information from field 2
plot -a %H 2 "%Z "; //Enter data into column 2 of the active worksheet
dde -d id; //terminate dde link
};

 


Categories: Macro / Code Sample, Other Applications, WinWedge

Last Updated: 2011.07.12

Need more help?

Don't hesitate to call or email us with your questions

Our office is open 9AM - 5PM Monday Through Friday (E.S.T.)

Technical Support: 215-496-0202

Toll-Free: 1 (800) 722-6004
Skype: taltech1 (Voice only)
Email: support@TALtech.com