Version 1.00 BEGIN Form Dds3main AutoRedraw = 0 BackColor = QBColor(7) BorderStyle = 1 Caption = "DDS3 PC Driven Synthesiser: CW and Sweep" ControlBox = 0 Enabled = -1 ForeColor = QBColor(0) Height = Char(23) Left = Char(5) MaxButton = 0 MinButton = 0 MousePointer = 0 Tag = "" Top = Char(2) Visible = -1 Width = Char(75) WindowState = 0 BEGIN TextBox OutFreqDisplay BackColor = QBColor(0) BorderStyle = 1 DragMode = 0 Enabled = -1 ForeColor = QBColor(12) Height = Char(3) Left = Char(8) MousePointer = 0 MultiLine = 0 ScrollBars = 0 TabIndex = 12 TabStop = -1 Tag = "" Text = " 0 Hz" Top = Char(5) Visible = -1 Width = Char(25) END BEGIN Label Label1 Alignment = 0 AutoSize = 0 BackColor = QBColor(7) BorderStyle = 0 Caption = "Output Frequency" DragMode = 0 Enabled = -1 ForeColor = QBColor(0) Height = Char(1) Left = Char(12) MousePointer = 0 TabIndex = 13 Tag = "" Top = Char(4) Visible = -1 Width = Char(20) END BEGIN TextBox AttenDisplay BackColor = QBColor(0) BorderStyle = 1 DragMode = 0 Enabled = -1 ForeColor = QBColor(10) Height = Char(3) Left = Char(52) MousePointer = 0 MultiLine = 0 ScrollBars = 0 TabIndex = 14 TabStop = -1 Tag = "AttenDisplay" Text = " 70 dB" Top = Char(5) Visible = -1 Width = Char(19) END BEGIN Label Label2 Alignment = 0 AutoSize = 0 BackColor = QBColor(7) BorderStyle = 0 Caption = "Attenuation" DragMode = 0 Enabled = -1 ForeColor = QBColor(0) Height = Char(1) Left = Char(56) MousePointer = 0 TabIndex = 15 Tag = "" Top = Char(4) Visible = -1 Width = Char(15) END BEGIN CommandButton SetLowFreq BackColor = QBColor(7) Cancel = 0 Caption = "Set &Low Fr" Default = 0 DragMode = 0 Enabled = -1 Height = Char(3) Left = Char(8) MousePointer = 0 TabIndex = 6 TabStop = -1 Tag = "" Top = Char(16) Visible = -1 Width = Char(13) END BEGIN CommandButton StopDDS BackColor = QBColor(7) Cancel = 0 Caption = "S&Top" Default = 0 DragMode = 0 Enabled = -1 Height = Char(3) Left = Char(34) MousePointer = 0 TabIndex = 10 TabStop = -1 Tag = "" Top = Char(16) Visible = -1 Width = Char(11) END BEGIN CommandButton SetSweepStep BackColor = QBColor(7) Cancel = 0 Caption = "Sw St&Ep" Default = 0 DragMode = 0 Enabled = -1 Height = Char(3) Left = Char(34) MousePointer = 0 TabIndex = 8 TabStop = -1 Tag = "" Top = Char(13) Visible = -1 Width = Char(11) END BEGIN CommandButton CWSelect BackColor = QBColor(7) Cancel = 0 Caption = "&CW" Default = 0 DragMode = 0 Enabled = -1 Height = Char(3) Left = Char(22) MousePointer = 0 TabIndex = 2 TabStop = -1 Tag = "" Top = Char(10) Visible = -1 Width = Char(11) END BEGIN CommandButton StartDDS BackColor = QBColor(7) Cancel = 0 Caption = "&Start" Default = 0 DragMode = 0 Enabled = -1 Height = Char(3) Left = Char(22) MousePointer = 0 TabIndex = 9 TabStop = -1 Tag = "" Top = Char(16) Visible = -1 Width = Char(11) END BEGIN CommandButton SetIOAddress BackColor = QBColor(7) Cancel = 0 Caption = "Set &I/O Adr" Default = 0 DragMode = 0 Enabled = -1 Height = Char(3) Left = Char(58) MousePointer = 0 TabIndex = 1 TabStop = -1 Tag = "" Top = Char(10) Visible = -1 Width = Char(13) END BEGIN CommandButton SetFreq BackColor = QBColor(7) Cancel = 0 Caption = "Set &Freq" Default = 0 DragMode = 0 Enabled = -1 Height = Char(3) Left = Char(8) MousePointer = 0 TabIndex = 3 TabStop = -1 Tag = "" Top = Char(10) Visible = -1 Width = Char(13) END BEGIN CommandButton SetAtten BackColor = QBColor(7) Cancel = 0 Caption = "Set &Atten" Default = 0 DragMode = 0 Enabled = -1 Height = Char(3) Left = Char(46) MousePointer = 0 TabIndex = 4 TabStop = -1 Tag = "" Top = Char(10) Visible = -1 Width = Char(11) END BEGIN CommandButton SweepSelect BackColor = QBColor(7) Cancel = 0 Caption = "S&Weep" Default = 0 DragMode = 0 Enabled = -1 Height = Char(3) Left = Char(34) MousePointer = 0 TabIndex = 5 TabStop = -1 Tag = "" Top = Char(10) Visible = -1 Width = Char(11) END BEGIN CommandButton SetHighFreq BackColor = QBColor(7) Cancel = 0 Caption = "Set &High Fr" Default = 0 DragMode = 0 Enabled = -1 Height = Char(3) Left = Char(8) MousePointer = 0 TabIndex = 7 TabStop = -1 Tag = "" Top = Char(13) Visible = -1 Width = Char(13) END BEGIN CommandButton Quit BackColor = QBColor(7) Cancel = 0 Caption = "&Quit" Default = 0 DragMode = 0 Enabled = -1 Height = Char(3) Left = Char(58) MousePointer = 0 TabIndex = 11 TabStop = -1 Tag = "" Top = Char(16) Visible = -1 Width = Char(13) END BEGIN CommandButton Help BackColor = QBColor(7) Cancel = 0 Caption = "Hel&P" Default = 0 DragMode = 0 Enabled = -1 Height = Char(3) Left = Char(58) MousePointer = 0 TabIndex = 0 TabStop = -1 Tag = "" Top = Char(13) Visible = -1 Width = Char(13) END END 'Module level code for DDS3main module ' ' $INCLUDE: 'CONSTANT.BI' 'Include control panel definitions DIM SHARED OutByte(5) AS INTEGER 'Bytes sent to DDS card DIM SHARED BaseAddr AS INTEGER 'Card base address in decimal DIM SHARED BaseByte AS INTEGER 'Template for bits 0-4 of lowest data byte DIM SHARED FreqHigh AS LONG 'Upper limit for sweeping DIM SHARED FreqLow AS LONG 'Lower limit for sweeping DIM SHARED OutFreq AS LONG 'Current output frequency DIM SHARED OutAtten AS INTEGER 'Current output attenuation DIM SHARED SweepStep AS LONG 'Sweeping increment DIM SHARED RunFlag AS INTEGER 'Sweep run flag DECLARE FUNCTION HexStringToDecimal (HexInput$) AS INTEGER DECLARE SUB SendFreq (BYVAL Freq&) DECLARE SUB SendAtten (BYVAL Atten%) SUB CWSelect_Click () IF BaseAddr = 0 THEN MSGBOX "Please set DDS card base address!": EXIT SUB SetHighFreq.VISIBLE = 0 'Hide & disable unwanted controls SetHighFreq.ENABLED = 0 SetLowFreq.VISIBLE = 0 SetLowFreq.ENABLED = 0 SetSweepStep.VISIBLE = 0 SetSweepStep.ENABLED = 0 StartDDS.VISIBLE = 0 StartDDS.ENABLED = 0 SetFreq.VISIBLE = -1 'Show & enabled wanted controls SetFreq.ENABLED = -1 END SUB SUB Form_Load () SCREEN.ControlPanel(ACTIVE_BORDER_BACKCOLOR) = 7 SCREEN.ControlPanel(ACTIVE_BORDER_FORECOLOR) = 0 SCREEN.ControlPanel(TITLEBAR_BACKCOLOR) = 5 SCREEN.ControlPanel(TITLEBAR_FORECOLOR) = 15 WindowState = 2 BaseByte = 0 'Make sure base byte is set up SweepStep = 0 '& Sweep step too... SetFreq.VISIBLE = 0 'Hide & disable some controls to guide setup SetFreq.ENABLED = 0 SetHighFreq.VISIBLE = 0 SetHighFreq.ENABLED = 0 SetLowFreq.VISIBLE = 0 SetLowFreq.ENABLED = 0 SetSweepStep.VISIBLE = 0 SetSweepStep.ENABLED = 0 StartDDS.VISIBLE = 0 StartDDS.ENABLED = 0 END SUB SUB Help_Click () CR$ = CHR$(13) + CHR$(10) Msg$ = "This program is designed to allow easy control of the" + CR$ Msg$ = Msg$ + "Novatech DDS3 PC synthesiser card for both fixed" + CR$ Msg$ = Msg$ + "frequency operation and sweeping." + CR$ Msg$ = Msg$ + "It can be controlled using either the keyboard or a" + CR$ Msg$ = Msg$ + "Microsoft-compatible mouse. With a keyboard, hold" + CR$ Msg$ = Msg$ + "the key down and press a button's access key" + CR$ Msg$ = Msg$ + "(highlighted letter). closes dialog boxes." + CR$ Msg$ = Msg$ + "To begin, use the [Set I/O] button to set the program" + CR$ Msg$ = Msg$ + "for the I/O address your card is located at." + CR$ Msg$ = Msg$ + "Then click either the [CW] or [Sweep] buttons" + CR$ Msg$ = Msg$ + "as desired. For CW, use [Set Freq] and [Set Atten]" + CR$ Msg$ = Msg$ + "keys; for sweeping, [Set Low Fr], [Set High Fr] and" + CR$ Msg$ = Msg$ + "[Sw Step] keys (in that order) -- plus [Set Atten]." + CR$ Msg$ = Msg$ + "Note that the [Stop] key stops and resets DDS in both" + CR$ Msg$ = Msg$ + "CW and sweep modes, but [Start] restarts in sweep only." + CR$ Msg$ = Msg$ + "Written by Jim Rowe, Electronics Australia January 1994" MSGBOX Msg$, 0, "DDS3 PC CW & Sweeping Program -- Help Text" END SUB FUNCTION HexStringToDecimal (HexInput$) AS INTEGER DIM StrLen AS INTEGER, Hexvalue AS INTEGER DIM N AS INTEGER, Char AS STRING Hexvalue = 0 StrLen = LEN(HexInput$) FOR N = 1 TO StrLen Hexvalue = Hexvalue * 16 Char = MID$(HexInput$, N, 1) SELECT CASE Char CASE "1" TO "9" Hexvalue = Hexvalue + VAL(Char) CASE "A", "a" Hexvalue = Hexvalue + 10 CASE "B", "b" Hexvalue = Hexvalue + 11 CASE "C", "c" Hexvalue = Hexvalue + 12 CASE "D", "d" Hexvalue = Hexvalue + 13 CASE "E", "e" Hexvalue = Hexvalue + 14 CASE "F", "f" Hexvalue = Hexvalue + 15 CASE "H", "h" Hexvalue = Hexvalue / 16 END SELECT NEXT N HexStringToDecimal = Hexvalue END FUNCTION SUB Quit_Click () END END SUB SUB SendAtten (BYVAL Atten%) DIM SendByte AS INTEGER Atten$ = STR$(Atten%) AttenDisplay.TEXT = SPACE$(8 - LEN(Atten$)) + Atten$ + " dB" SendByte = BaseByte 'Fetch template for base address data byte IF Atten% >= 40 THEN SendByte = SendByte + 32: Atten% = Atten% - 40 IF Atten% >= 20 THEN SendByte = SendByte + 64: Atten% = Atten% - 20 IF Atten% >= 10 THEN SendByte = SendByte + 128: Atten% = Atten% - 10 OUT BaseAddr, SendByte END SUB SUB SendFreq (BYVAL Freq&) DIM N AS INTEGER, M AS INTEGER DIM RefBinWeight AS LONG Freqdisp$ = FORMAT$(Freq&, "#,#") 'Display output freq OutFreqDisplay.TEXT = SPACE$(15 - LEN(Freqdisp$)) + Freqdisp$ + " Hz" Freq& = Freq& / 2 'Allow for 2Hz incrementing of DDS FOR N = 5 TO 3 STEP -1 OutByte(N) = 0 'Clear byte first FOR M = 7 TO 0 STEP -1 'Now do binary conversion RefBinWeight = 2 ^ (8 * (N - 3) + M) IF Freq& >= RefBinWeight THEN OutByte(N) = OutByte(N) + 2 ^ M Freq& = Freq& - RefBinWeight END IF NEXT M OUT BaseAddr + N, OutByte(N) 'Byte now assembled, so send NEXT N 'Loop until all three freq bytes assembled & sent OUT BaseAddr + 1, 0 'And finally send HOPCLK to load into DDS END SUB SUB SetAtten_Click () DIM AttenInput AS INTEGER IF BaseAddr = 0 THEN MSGBOX "Please set DDS card address": EXIT SUB DO WantedAtten$ = INPUTBOX$("Give desired output attenuation in dB:") AttenInput = VAL(WantedAtten$) IF AttenInput >= 0 AND AttenInput <= 70 THEN EXIT DO MSGBOX "Sorry -- Outside range (0-70dB)" LOOP OutAtten = 10 * INT(AttenInput / 10) 'Convert to multiple of 10 CALL SendAtten(OutAtten) END SUB SUB SetFreq_Click () DIM FreqInput AS LONG DO WantedFreq$ = INPUTBOX$("Give desired frequency in Hz") FreqInput = VAL(WantedFreq$) IF FreqInput >= 0 AND FreqInput <= 1.5E+07 THEN EXIT DO MSGBOX "Sorry -- Outside range (0 - 15MHz)" LOOP OutFreq = FreqInput CALL SendFreq(OutFreq) END SUB SUB SetHighFreq_Click () DIM FreqInput AS LONG IF FreqLow = 0 THEN MSGBOX "Please set Low Limit Frequency first!": EXIT SUB DO WantedFreq$ = INPUTBOX$("Give desired sweep upper limit in Hz:") FreqInput = VAL(WantedFreq$) IF FreqInput >= 4 AND FreqInput <= 1.5E+07 THEN EXIT DO MSGBOX "Sorry -- Outside range (4Hz - 15MHz)" LOOP IF FreqInput <= FreqLow THEN MSGBOX "Not above lower limit!": EXIT SUB FreqHigh = FreqInput END SUB SUB SetIOAddress_Click () DIM BaseInput AS INTEGER CR$ = CHR$(13) + CHR$(10) Prompt$ = "Give DDS3 card's I/O base" + CR$ Prompt$ = Prompt$ + "address in hex. (Click on" + CR$ Prompt$ = Prompt$ + "[OK] or press to" + CR$ Prompt$ = Prompt$ + "accept default value):" DO HexInput$ = INPUTBOX$(Prompt$, "Enter DDS Address", "0338") BaseInput = HexStringToDecimal(HexInput$) IF BaseInput >= &H200 AND BaseInput <= &H3F8 THEN EXIT DO MSGBOX "Sorry -- Outside range (200 - 3F8)" LOOP BaseAddr = BaseInput OUT BaseAddr + 2, 0 'Reset DDS card before proceeding further END SUB SUB SetLowFreq_Click () DIM FreqInput AS LONG DO WantedFreq$ = INPUTBOX$("Give desired Low Sweep Limit in Hz:") FreqInput = VAL(WantedFreq$) IF FreqInput >= 2 AND FreqInput <= 1.49E+07 THEN EXIT DO MSGBOX "Sorry -- Outside range (0 - 14.9MHz)" LOOP FreqLow = FreqInput END SUB SUB SetSweepStep_Click () DIM FreqInput AS LONG DO WantedFreq$ = INPUTBOX$("Give desired frequency step in Hz:") FreqInput = VAL(WantedFreq$) IF FreqInput >= 0 AND FreqInput < (1.5E+07 - FreqLow) THEN EXIT DO MSGBOX "Sorry -- Outside Range!" LOOP SweepStep = FreqInput END SUB SUB StartDDS_Click () IF FreqLow = 0 THEN MSGBOX "Please set Sweep Low Limit": EXIT SUB IF FreqHigh = 0 THEN MSGBOX "Please set Sweep High Limit": EXIT SUB IF SweepStep = 0 THEN MSGBOX "Please set Sweep Step": EXIT SUB StartDDS.ENABLED = 0 'Disable button to prevent recursion StopDDS.SETFOCUS 'Set focus on stop button CALL SendAtten(OutAtten) 'Restore user's set attenuation if necessary RunFlag = -1 'Set DDS run flag for loop control OutFreq = FreqLow DO CALL SendFreq(OutFreq) 'Send current freq to DDS, display OutFreq = OutFreq + SweepStep IF OutFreq > FreqHigh THEN OutFreq = FreqLow DummyVar% = DOEVENTS() 'Go check for stop button press LOOP WHILE RunFlag StartDDS.ENABLED = -1 'Re-enable button on exit END SUB SUB StopDDS_Click () RunFlag = 0 'Reset run flag... OutFreqDisplay.TEXT = " 0 Hz" 'Update frequency display AttenDisplay.TEXT = " 70 dB" 'And atten display also OUT BaseAddr + 2, 0 'And finally reset DDS card END SUB SUB SweepSelect_Click () IF BaseAddr = 0 THEN MSGBOX "Please set DDS card base address!": EXIT SUB SetFreq.VISIBLE = 0 'Hide & disable unwanted control SetFreq.ENABLED = 0 SetHighFreq.VISIBLE = -1 '& show/enable wanted controls SetHighFreq.ENABLED = -1 SetLowFreq.VISIBLE = -1 SetLowFreq.ENABLED = -1 SetSweepStep.VISIBLE = -1 SetSweepStep.ENABLED = -1 StartDDS.VISIBLE = -1 StartDDS.ENABLED = -1 END SUB