Controlling WiNRADiO 1500 series receivers using the DDE interface.
Under Windows, WiNRADiO can be controlled from another program, including a word processor or a spreadsheet, using WiNRADiO's DDE (Dynamic Data Exchange) interface.
SetFrequency(freq) freq is the receiving frequency in Hz.
SetMode(mode) mode can be: `SSB', `AM', `FMN' or `FMW'.
SetVolume(volume) volume is in between 0 and 31 (quietest to loudest)
SetBFOOffset(offset) offset is the BFO offset between -3000 and +3000 in Hz.
SetSquelch(squelch) squelch is between 0 and 100
AttenOn select local
AttenOff select DX
PowerOn switch power on
PowerOff switch power off
MuteOn switch mute on
MuteOff switch mute off
GetFrequency returns frequency in Hz
GetMode returns the mode: `SSB', `AM', `FMN' or `FMW'.
GetSignalStrength returns between 0 and 100
GetVolume returns between 0 and 31
GetBFOOffset returns between -3000 and 3000
GetSquelch returns between 0 and 100
GetAtten returns either `DX' or `L' (local)
GetPower returns either `on' or `off'
GetMute returns either `on' or `off'
Each command must be enclosed in square brackets, and multiple commands may be sent at the one time.
The following example shows how to control WiNRADiO using Word for Windows' macro language. Suppose we wish to tune to a broadcast FM station on 101.5 MHz, with medium volume, sensitivity set to 'Local', and have the signal strength inserted into the current document:
The above example works well for MS Word version 6. For version 7, use the following instead:Sub MAIN channel = DDEInitiate("WinRadio", "WinRadio") DDEExecute channel, "[PowerOn][SetFrequency(101500000)]" DDEExecute channel, "[SetMode(FMW)][SetVolume(10)]" DDEExecute channel, "[AttenOn]" ss$ = DDERequest$(channel, "GetSignalStrength") Insert ss$ DDETerminate channel End Sub
Sub MAIN channel = DDEInitiate("WinRadio", "WinRadio") DDEExecute channel, "[PowerOn][SetFrequency(101500000)]" DDEExecute channel, "[SetMode(FMW)][SetVolume(10)]" DDEExecute channel, "[AttenOn]" ss$ = DDERequest(channel, "GetSignalStrength") Selection.Text=ss$ DDETerminate channel End Sub
Using the DDE interface, you can also write WiNRADiO-based programs in high-level languages such as C, C++, Delphi, Visual Basic and any other language that supports Windows programming.
The following example is part of a small Delphi program (supplied with the WiNRADiO software) that controls WiNRADiO through DDE:
unit WRDDEEx; { WiNRADiO DDE example for Delphi } interface ... implementation ... procedure TWinRadioDDEForm.FreqEditChange(Sender: TObject); var s: array [0..31] of Char; begin DDEClient.SetLink('WinRadio', 'WinRadio'); if DDEClient.OpenLink then begin StrPCopy(s, '[SetFrequency(' + IntToStr(FreqEdit.Value * 1000) + ')]'); DDEClient.ExecuteMacro(s, False); DDEClient.CloseLink; end; end; ... procedure TWinRadioDDEForm.FormCreate(Sender: TObject); var s: String; fr, vo, bf, sq, mo, at, pr, mu, po: PChar; begin DDEClient.SetLink('WinRadio', 'WinRadio'); if DDEClient.OpenLink then begin fr := DDEClient.RequestData('GetFrequency'); vo := DDEClient.RequestData('GetVolume'); bf := DDEClient.RequestData('GetBFOOffset'); sq := DDEClient.RequestData('GetSquelch'); mo := DDEClient.RequestData('GetMode'); at := DDEClient.RequestData('GetAtten'); mu := DDEClient.RequestData('GetMute'); po := DDEClient.RequestData('GetPower'); DDEClient.CloseLink; ... ... end; end; end.
The following Delphi code was provided courtesy James Brown (W6KYP, www.seti.net), whose application of WiNRADiO receivers for SETI (Search for Extraterrestrial Intelligence) research is one of the most interesting we have seen:
unit SETIWiNRADiO; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, DdeMan, ShellAPI, FMXUtils; type TfrmWiNRADiO = class(TForm) DdeClientItem: TDdeClientItem; DdeClientConv: TDdeClientConv; btnSetFreq: TButton; btnGetFreq: TButton; btnStartRadio: TButton; edFreq: TEdit; btnClose: TButton; btnPowerOff: TButton; btnPowerOn: TButton; procedure btnSetFreqClick(Sender: TObject); procedure btnGetFreqClick(Sender: TObject); procedure btnStartRadioClick(Sender: TObject); procedure btnCloseClick(Sender: TObject); procedure btnPowerOffClick(Sender: TObject); procedure btnPowerOnClick(Sender: TObject); private { Private declarations } public { Public declarations } end; var frmWiNRADiO: TfrmWiNRADiO; implementation {$R *.DFM} procedure TfrmWiNRADiO.btnSetFreqClick(Sender: TObject); var strFreq: string; PCHARFreq: array[0..31] of Char; begin if DDEClientConv.SetLink('WinRadio', 'WinRadio') then begin DDEClientConv.ExecuteMacro('[PowerOn]', False); DDEClientConv.ExecuteMacro('[SetMode(LSB)]', False); strFreq := '[SetFrequency(' + edFreq.Text + ')]'; StrPCopy(PCHARFreq, strFreq); DDEClientConv.ExecuteMacro(PCHARFreq, False); DDEClientConv.closeLink; end else ShowMessage('Error connecting to radio'); end; procedure TfrmWiNRADiO.btnGetFreqClick(Sender: TObject); var fr: PChar; begin if DDEClientConv.SetLink('WinRadio', 'WinRadio') then begin ShowMessage('Connected.'); fr := DDEClientConv.RequestData('GetFrequency'); ShowMessage('fr is:' + fr); DDEClientConv.closeLink; end else ShowMessage('Error') end; procedure TfrmWiNRADiO.btnStartRadioClick(Sender: TObject); var results: integer; begin results := ShellExecute(Handle, 'open', 'c:\Program Files\WiNRADiO\WINRADIO.EXE', nil, 'c:\Program Files\WiNRADiO', SW_SHOWNORMAL); ShowMessage('results are: ' + inttostr(results)); if DDEClientConv.SetLink('WinRadio', 'WinRadio') then begin DDEClientConv.ExecuteMacro('[AttenOff]', False); // Select DX position of attenuator DDEClientConv.ExecuteMacro('[SetMode(LSB)]', False); DDEClientConv.closeLink; end else ShowMessage('Error connecting to radio'); end; procedure TfrmWiNRADiO.btnCloseClick(Sender: TObject); begin Close; end; procedure TfrmWiNRADiO.btnPowerOffClick(Sender: TObject); begin if DDEClientConv.SetLink('WinRadio', 'WinRadio') then begin DDEClientConv.ExecuteMacro('[PowerOff]', False); DDEClientConv.closeLink; end else ShowMessage('Error connecting to radio'); end; procedure TfrmWiNRADiO.btnPowerOnClick(Sender: TObject); begin if DDEClientConv.SetLink('WinRadio', 'WinRadio') then begin DDEClientConv.ExecuteMacro('[PowerOn]', False); DDEClientConv.closeLink; end else ShowMessage('Error connecting to radio'); end; end. =================================================== James Brown Jim@SETI.Net Argus Station DM12jw W6KYP www.seti.net