VERSION 5.00 Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX" Begin VB.Form Form1 Caption = "SOF8" ClientHeight = 7455 ClientLeft = 1215 ClientTop = 1275 ClientWidth = 11880 BeginProperty Font Name = "Courier" Size = 12 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty LinkTopic = "Form1" ScaleHeight = 7455 ScaleWidth = 11880 StartUpPosition = 2 'CenterScreen Begin VB.FileListBox FileCom Height = 330 Left = 2880 Pattern = "DDS8mCom.txt" TabIndex = 49 Top = 1080 Visible = 0 'False Width = 3015 End Begin VB.TextBox txtWait BackColor = &H00C0C0FF& Height = 360 Left = 10200 TabIndex = 48 Top = 1080 Width = 975 End Begin VB.Timer Timer1 Left = 6840 Top = 4560 End Begin VB.TextBox txtRRClock Alignment = 1 'Right Justify BeginProperty Font Name = "Arial" Size = 9.75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 375 Left = 2520 TabIndex = 44 TabStop = 0 'False Top = 3120 Width = 1335 End Begin VB.TextBox txtClockFrequency BeginProperty Font Name = "Arial" Size = 9.75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 360 Left = 8520 Locked = -1 'True TabIndex = 42 TabStop = 0 'False Top = 6615 Width = 2415 End Begin VB.TextBox txtClockSource BeginProperty Font Name = "Arial" Size = 9.75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 360 Left = 3720 Locked = -1 'True TabIndex = 41 TabStop = 0 'False Top = 6630 Width = 2415 End Begin VB.TextBox txtComPortNumber Height = 360 Left = 1320 Locked = -1 'True TabIndex = 37 TabStop = 0 'False Top = 6630 Width = 495 End Begin VB.CommandButton cmdEnter Caption = "Enter" Height = 315 Left = 600 TabIndex = 1 Top = 1080 Width = 1335 End Begin VB.TextBox txtMisc4 Alignment = 1 'Right Justify BeginProperty Font Name = "Arial" Size = 9.75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 360 Left = 9600 Locked = -1 'True TabIndex = 27 TabStop = 0 'False Top = 3120 Width = 975 End Begin VB.TextBox txtQdac Alignment = 1 'Right Justify BeginProperty Font Name = "Arial" Size = 9.75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 360 Left = 5040 Locked = -1 'True TabIndex = 23 TabStop = 0 'False Top = 4440 Width = 975 End Begin VB.CommandButton cmdReadRegisters Caption = "Read Registers" Height = 435 Left = 8280 TabIndex = 22 Top = 4440 Width = 2535 End Begin VB.TextBox txtOutputShape2 Alignment = 1 'Right Justify BeginProperty Font Name = "Arial" Size = 9.75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 360 Left = 2160 Locked = -1 'True TabIndex = 17 TabStop = 0 'False Top = 4440 Width = 975 End Begin VB.TextBox txtOutputShape1 Alignment = 1 'Right Justify BeginProperty Font Name = "Arial" Size = 9.75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 360 Left = 720 Locked = -1 'True TabIndex = 16 TabStop = 0 'False Top = 4440 Width = 975 End Begin VB.TextBox txtMisc3 Alignment = 1 'Right Justify BeginProperty Font Name = "Arial" Size = 9.75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 360 Left = 8640 Locked = -1 'True TabIndex = 15 TabStop = 0 'False Top = 3120 Width = 495 End Begin VB.TextBox txtMisc1 Alignment = 1 'Right Justify BeginProperty Font Name = "Arial" Size = 9.75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 360 Left = 6240 Locked = -1 'True TabIndex = 14 TabStop = 0 'False Top = 3120 Width = 975 End Begin VB.TextBox txtCM Alignment = 1 'Right Justify BeginProperty Font Name = "Arial" Size = 9.75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 360 Left = 7680 Locked = -1 'True TabIndex = 13 TabStop = 0 'False Top = 3120 Width = 495 End Begin VB.TextBox txtDwellTime Alignment = 1 'Right Justify BeginProperty Font Name = "Arial" Size = 9.75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 360 Left = 4320 Locked = -1 'True TabIndex = 12 TabStop = 0 'False Top = 3120 Width = 1455 End Begin VB.TextBox txtUpdateClock Alignment = 1 'Right Justify BeginProperty Font Name = "Arial" Size = 9.75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 360 Left = 720 Locked = -1 'True TabIndex = 11 TabStop = 0 'False Top = 3120 Width = 1335 End Begin VB.TextBox txtOutputShapeRR Alignment = 1 'Right Justify BeginProperty Font Name = "Arial" Size = 9.75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 360 Left = 3600 Locked = -1 'True TabIndex = 10 TabStop = 0 'False Top = 4440 Width = 975 End Begin VB.TextBox txtDeltaFreq Alignment = 1 'Right Justify BeginProperty Font Name = "Arial" Size = 9.75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 360 Left = 8640 Locked = -1 'True TabIndex = 9 TabStop = 0 'False Top = 2040 Width = 2100 End Begin VB.TextBox txtFreq1 Alignment = 1 'Right Justify BeginProperty Font Name = "Arial" Size = 9.75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 360 Left = 3600 Locked = -1 'True TabIndex = 8 TabStop = 0 'False Top = 2040 Width = 1900 End Begin VB.TextBox txtPhase2 Alignment = 1 'Right Justify BeginProperty Font Name = "Arial" Size = 9.75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 360 Left = 2160 Locked = -1 'True TabIndex = 7 TabStop = 0 'False Top = 2040 Width = 945 End Begin VB.TextBox txtFreq2 Alignment = 1 'Right Justify BeginProperty Font Name = "Arial" Size = 9.75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 360 Left = 6000 Locked = -1 'True TabIndex = 6 TabStop = 0 'False Top = 2040 Width = 2100 End Begin VB.TextBox txtPhase1 Alignment = 1 'Right Justify BeginProperty Font Name = "Arial" Size = 9.75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 360 Left = 720 Locked = -1 'True TabIndex = 5 TabStop = 0 'False Top = 2040 Width = 945 End Begin VB.TextBox txtReceive Alignment = 1 'Right Justify BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 315 Left = 3120 Locked = -1 'True MaxLength = 100 TabIndex = 2 TabStop = 0 'False Top = 600 Width = 8025 End Begin MSCommLib.MSComm MSComm1 Left = 11280 Top = 4680 _ExtentX = 1005 _ExtentY = 1005 _Version = 393216 DTREnable = 0 'False OutBufferSize = 1024 RThreshold = 1 BaudRate = 19200 End Begin VB.TextBox txtSend Alignment = 1 'Right Justify BeginProperty Font Name = "Arial" Size = 11.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 315 Left = 240 TabIndex = 0 Top = 600 Width = 2625 End Begin VB.Label lblWait BackColor = &H00C0C0FF& Caption = "Wait" Height = 255 Left = 9480 TabIndex = 47 Top = 1200 Width = 615 End Begin VB.Label lblProcessingCommands BackColor = &H00C0C0FF& Caption = "Processing Sequence Commands" BeginProperty Font Name = "Courier" Size = 9.75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Left = 7800 TabIndex = 46 Top = 120 Width = 3375 End Begin VB.Label Label19 Caption = "Td (1a)" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Left = 2880 TabIndex = 45 Top = 3600 Width = 1215 End Begin VB.Label Label17 Alignment = 2 'Center Caption = "Configuration Settings" BeginProperty Font Name = "MS Sans Serif" Size = 12 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 375 Left = 4080 TabIndex = 43 Top = 6000 Width = 3135 End Begin VB.Line Line8 X1 = 11160 X2 = 11160 Y1 = 6120 Y2 = 7080 End Begin VB.Line Line7 X1 = 240 X2 = 11160 Y1 = 7080 Y2 = 7080 End Begin VB.Line Line6 X1 = 240 X2 = 240 Y1 = 6120 Y2 = 7080 End Begin VB.Line Line5 X1 = 240 X2 = 11160 Y1 = 6120 Y2 = 6120 End Begin VB.Label Label18 Alignment = 1 'Right Justify Caption = "Clock Frequency (MHz)" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Left = 6600 TabIndex = 40 Top = 6720 Width = 1815 End Begin VB.Label Label16 Alignment = 1 'Right Justify Caption = "Clock Source" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Left = 2520 TabIndex = 39 Top = 6720 Width = 1095 End Begin VB.Label Label15 Caption = "COM Port " BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Left = 480 TabIndex = 38 Top = 6720 Width = 735 End Begin VB.Label Label14 Alignment = 2 'Center Caption = "Register Settings" BeginProperty Font Name = "MS Sans Serif" Size = 12 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 375 Left = 4440 TabIndex = 36 Top = 1440 Width = 2415 End Begin VB.Line Line4 X1 = 11160 X2 = 11160 Y1 = 5400 Y2 = 1560 End Begin VB.Line Line3 X1 = 240 X2 = 11160 Y1 = 1560 Y2 = 1560 End Begin VB.Line Line2 X1 = 240 X2 = 240 Y1 = 1560 Y2 = 5400 End Begin VB.Line Line1 X1 = 240 X2 = 11160 Y1 = 5400 Y2 = 5400 End Begin VB.Label Label13 Alignment = 2 'Center Caption = "(26)" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 375 Left = 5400 TabIndex = 35 Top = 5040 Width = 495 End Begin VB.Label Label12 Alignment = 2 'Center Caption = "(25)" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 375 Left = 3720 TabIndex = 34 Top = 5040 Width = 855 End Begin VB.Label Label11 Alignment = 2 'Center Caption = "% Cosine Amplitude (23)" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 375 Left = 2040 TabIndex = 33 Top = 4920 Width = 1095 End Begin VB.Label Label10 Alignment = 2 'Center Caption = "% Sine Amplitude (21)" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 375 Index = 1 Left = 600 TabIndex = 32 Top = 4920 Width = 1095 End Begin VB.Label Label9 Alignment = 2 'Center Caption = "(20)" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 375 Index = 0 Left = 9840 TabIndex = 31 Top = 3600 Width = 495 End Begin VB.Label Label8 Alignment = 2 'Center Caption = "Mode (1f)" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 495 Index = 2 Left = 8640 TabIndex = 30 Top = 3600 Width = 495 End Begin VB.Label Label7 Alignment = 2 'Center Caption = "Clock Multiplier (1e)" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 375 Left = 7440 TabIndex = 29 Top = 3600 Width = 1095 End Begin VB.Label Label6 Alignment = 2 'Center Caption = "(1d)" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Left = 6480 TabIndex = 28 Top = 3600 Width = 495 End Begin VB.Label Label5 Alignment = 2 'Center Caption = "Tr (16)" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Left = 960 TabIndex = 26 Top = 3600 Width = 975 End Begin VB.Label Label4 Alignment = 2 'Center Caption = "Dwell Time (DT) Microseconds" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 375 Left = 4320 TabIndex = 25 Top = 3600 Width = 1455 End Begin VB.Label cmdFrequency2 Alignment = 2 'Center Caption = "Delta Frequency (Fd) MHz (10)" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 375 Index = 0 Left = 8880 TabIndex = 24 Top = 2520 Width = 1575 End Begin VB.Label cmdFrequency2 Alignment = 2 'Center Caption = "Frequency 2 MHz (0a)" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 375 Index = 3 Left = 6480 TabIndex = 21 Top = 2520 Width = 1095 End Begin VB.Label cmdFrequency1 Alignment = 2 'Center Caption = "Frequency 1 MHz (04)" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 495 Index = 2 Left = 3960 TabIndex = 20 Top = 2520 Width = 1215 End Begin VB.Label cmdPhase2 Caption = "Phase 2 Degrees (02)" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 495 Index = 1 Left = 2280 TabIndex = 19 Top = 2520 Width = 1095 End Begin VB.Label cmdPhase1 Caption = "Phase 1 Degrees (00)" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 495 Index = 0 Left = 840 TabIndex = 18 Top = 2520 Width = 975 End Begin VB.Label Label2 Alignment = 2 'Center Caption = "RESPONSE" BeginProperty Font Name = "Arial" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 165 Left = 6240 TabIndex = 4 Top = 360 Width = 1695 End Begin VB.Label Label1 Alignment = 2 'Center Caption = "COMMAND" BeginProperty Font Name = "Arial" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 165 Left = 360 TabIndex = 3 Top = 360 Width = 1935 WordWrap = -1 'True End Begin VB.Menu mnuFile Caption = "&File" Begin VB.Menu mnuFileCopy Caption = "&Copy Registers to Clipboard" End Begin VB.Menu mnuFileSave Caption = "&Save Registers to EEPROM" End Begin VB.Menu mnuFileExit Caption = "&Exit" End End Begin VB.Menu mnuFrequency Caption = "&Frequency" Begin VB.Menu mnuFrequencySingleTone Caption = "&Single Tone (Mode 0)" End Begin VB.Menu mnuFrequencyFSK Caption = "FS&K (Mode 1)" End Begin VB.Menu mnuFrequencyTriangle Caption = "&Triangle (Mode 2)" End Begin VB.Menu mnuFrequencySawtooth Caption = "Sa&wtooth (Mode 3)" End Begin VB.Menu mnuFrequencyBPSK Caption = "&BPSK (Mode 4)" End End Begin VB.Menu mnuAmplitude Caption = "&Amplitude" Begin VB.Menu mnuAmplitudeIChannel Caption = "&Sine Amplitude" End Begin VB.Menu mnuAmplitudeQChannel Caption = "&Cosine Amplitude" End End Begin VB.Menu mnuPhase Caption = "&Phase" Begin VB.Menu mnuPhaseF1 Caption = "P&1 Output Phase" End Begin VB.Menu mnuPhaseF2 Caption = "P&2 Output Phase" End End Begin VB.Menu mnuBatchFile Caption = "&Batch File" End Begin VB.Menu mnuClock Caption = "Cloc&k" Begin VB.Menu mnuClockInternal Caption = "&Internal Crystal Oscillator" Checked = -1 'True End Begin VB.Menu mnuClockExternal Caption = "&External" End Begin VB.Menu mnuClockMultiplier Caption = "&Clock Multiplier" End End Begin VB.Menu mnuCom Caption = "C&OM" Begin VB.Menu mnuComPortNumber Caption = "&Set COM Port Number" End End Begin VB.Menu mnuRegister Caption = "&Register" Begin VB.Menu mnuRegisterHex Caption = "Display Register Settings in &HEX" End Begin VB.Menu mnuRegisterEU Caption = "Display Register Settings in &Engineering Units" End End Begin VB.Menu mnuClear Caption = "Cl&ear" Begin VB.Menu mnuClearDisplay Caption = "Clear &Display" End Begin VB.Menu mnuClearReset Caption = "&Reset to Last Saved Settings" End Begin VB.Menu mnuClearClear Caption = "&Clear Saved Settings and Restore Factory Defaults" End End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim ComEventSource As Integer Dim RegisterReceive As Variant Dim TimerTimeout As Boolean Dim TimeX As Double Dim TimerTimes As Double 'ENTER BUTTON CLICK EVENT Private Sub cmdEnter_Click() '(Index As Integer) txtReceive = "" ComEventSource = 1 If MSComm1.PortOpen = False Then MSComm1.PortOpen = True MSComm1.output = txtSend.Text & Chr$(13) Call Timeout txtSend.Text = "" End Sub 'READ REGISTERS BUTTON CLICK EVENT Private Sub cmdReadRegisters_Click() ComEventSource = 2 RegisterReceive = "" If MSComm1.PortOpen = False Then MSComm1.PortOpen = True MSComm1.output = "que" & Chr$(13) Call Timeout txtSend = "" End Sub 'FORM 1 LOAD EVENT Private Sub Form_Load() txtComPortNumber = MSComm1.CommPort txtClockSource = "Internal Crystal Oscillator" txtClockFrequency = 28.1474976710656 gClockMultiplier = 10 MsgBox ("The DDS8m is shipped with a jumper set to INTERNAL crystal oscillator. If you have changed this jumper to EXTERNAL then you must go to the Clock menu, select External and enter the external clock frequency.") 'MsgBox ("This program defaults to COM port 1. If this is not the COM port you are using then you must go to the COM menu and enter the correct COM port number") lblProcessingCommands.Visible = False mnuRegisterEU.Checked = True TimerTimes = 0 txtWait.Visible = False lblWait.Visible = False 'The LoadComPortNumber function returns True if the COM Port number 'is saved on disk and reads the com port number from the DDS3Com.txt file If LoadComPortNumber = False Then Call mnuComPortNumber_Click End Sub 'THIS FUNCTION RECEIVES A HEX NUMBER AND RETURNS IT'S DECIMAL VALUE. YOU PASS IT 'THE HEX NUMBER (HexNum) AND THE NUMBER OF HEX DIGITS (x) Private Function HexToDecimal(HexNum As Variant, x As Integer) Dim L As Double 'TOTAL ACCUMULATED DECIMAL VALUE Dim i As Integer 'COUNTDOWN INTEGER Dim j As Variant 'HEX VALUE OF INDIVIDUAL HEX DIGITS Dim k As Double 'DECIMAL VALUE FOR EACH DIGIT k = 79 L = 0 'Debug.Print "HexNum = ", Mid(HexNum, 2, 1) For i = x To 1 Step -1 j = Mid(HexNum, i, 1) Select Case j Case 0 k = 0 Case 1 k = 16 ^ (x - i) Case 2 k = 2 * 16 ^ (x - i) Case 3 k = 3 * 16 ^ (x - i) Case 4 k = 4 * 16 ^ (x - i) Case 5 k = 5 * 16 ^ (x - i) Case 6 k = 6 * 16 ^ (x - i) Case 7 k = 7 * 16 ^ (x - i) Case 8 k = 8 * 16 ^ (x - i) Case 9 k = 9 * 16 ^ (x - i) Case "A" k = 10 * 16 ^ (x - i) Case "B" k = 11 * 16 ^ (x - i) Case "C" k = 12 * 16 ^ (x - i) Case "D" k = 13 * 16 ^ (x - i) Case "E" k = 14 * 16 ^ (x - i) Case "F" k = 15 * 16 ^ (x - i) End Select 'Debug.Print k L = L + k Next i HexToDecimal = L End Function Private Sub mnuAmplitudeQChannel_Click() Dim a As Variant ComEventSource = 1 'Used in MSComm1_OnComm()subroutine txtSend.Text = "" a = 0 a = InputBox("Enter your desired amplitude. It should be a number from 0(off) to 4096.", "Q Channel Amplitude") If a = "" Then Exit Sub If a >= 0 And a < 4097 Then Else MsgBox ("You did not enter a valid amplitude") Exit Sub End If txtReceive = "" txtSend.Text = "vq " & Format(a, "####") 'Send text in gOut variables to DDS8m If MSComm1.PortOpen = False Then MSComm1.PortOpen = True MSComm1.output = txtSend.Text & Chr$(13) Do DoEvents If Timeout() = True Then Exit Sub If InStr(txtReceive, "?") Then Exit Sub 'Check to see if the DDS8m returned an error code Loop Until InStr(txtReceive, "OK" & vbCrLf) <> 0 End Sub Private Sub mnuClearClear_Click() ComEventSource = 1 'Used in MSComm1_OnComm()subroutine txtSend.Text = "" txtReceive = "" txtSend.Text = "clr" 'Send text in gOut variables to DDS8m If MSComm1.PortOpen = False Then MSComm1.PortOpen = True MSComm1.output = txtSend.Text & Chr$(13) Do DoEvents If Timeout() = True Then Exit Sub If InStr(txtReceive, "?") Then Exit Sub 'Check to see if the DDS8m returned an error code Loop Until InStr(txtReceive, "OK" & vbCrLf) <> 0 End Sub Private Sub mnuClearReset_Click() ComEventSource = 1 'Used in MSComm1_OnComm()subroutine txtSend.Text = "" txtReceive = "" txtSend.Text = "r" 'Send text in gOut variables to DDS8m If MSComm1.PortOpen = False Then MSComm1.PortOpen = True MSComm1.output = txtSend.Text & Chr$(13) Do DoEvents If Timeout() = True Then Exit Sub If InStr(txtReceive, "?") Then Exit Sub 'Check to see if the DDS8m returned an error code Loop Until InStr(txtReceive, "OK" & vbCrLf) <> 0 End Sub 'CLOCK/EXTERNAL MENU CLICK Private Sub mnuClockExternal_Click() Dim ExternalClock As Variant ExternalClock = InputBox("Enter the external clock frequency in MHz", "EXTERNAL CLOCK") If ExternalClock = "" Then Exit Sub End If mnuClockInternal.Checked = False mnuClockExternal.Checked = True txtClockSource = "External" txtClockFrequency = ExternalClock End Sub 'CLOCK/INTERNAL MENU CLICK Private Sub mnuClockInternal_Click() mnuClockInternal.Checked = True mnuClockExternal.Checked = False txtClockSource = "Internal Crystal Oscillator" txtClockFrequency = 28.1474976710656 End Sub Private Sub mnuClockMultiplier_Click() Dim a As Variant Dim b As Variant a = InputBox("Enter your desired clock multiplier") b = a Select Case a Case 1, 4, 5, 6, 7, 8, 9 a = "0" & a Case 10 a = "0a" Case 11 a = "0b" Case 12 a = "0c" Case 13 a = "0d" Case 14 a = "0e" Case 15 a = "0f" Case 16 a = "10" Case 17 a = "11" Case 18 a = "12" Case 19 a = "13" Case 20 a = "14" Case Else MsgBox ("You have not entered a valid clock multiplier") Exit Sub End Select txtSend = "Kp " & a txtReceive = "" ComEventSource = 1 If MSComm1.PortOpen = False Then MSComm1.PortOpen = True MSComm1.output = txtSend.Text & Chr$(13) Call Timeout Wait (1) Call SendQue ' This insures gClockMultiplier is updated End Sub Private Sub ComPortSave() Dim buffer As String Dim FileNum As Variant buffer = txtComPortNumber.Text FileNum = FreeFile Open "DDS8mCom.txt" For Output As FileNum Print #FileNum, buffer Close FileNum MsgBox ("You have saved the COM Port Number that is shown in the Configuraton Settings display area") End Sub Private Sub mnuFileCopy_Click() Dim CopySequence As Variant Dim a As Variant Call SendQue If mnuRegisterHex.Checked = True Then a = "HEX" Else a = "ENGINEERING UNITS" End If CopySequence = "REGISTER SETTINGS IN " & a & vbCrLf CopySequence = CopySequence & "Phase 1 (hex address 00) = " & txtPhase1 & vbCrLf CopySequence = CopySequence & "Phase 2 (hex address 02) = " & txtPhase2 & vbCrLf CopySequence = CopySequence & "Frequency 1 (hex address 04) = " & txtFreq1 & vbCrLf CopySequence = CopySequence & "Frequency 2 (hex address 0a) = " & txtFreq2 & vbCrLf CopySequence = CopySequence & "Delta Frequency Fd (hex address 10) = " & txtDeltaFreq & vbCrLf CopySequence = CopySequence & "Tr (hex address 16) = " & txtUpdateClock & vbCrLf CopySequence = CopySequence & "Td (hex address 1a) = " & txtRRClock & vbCrLf CopySequence = CopySequence & "Dwell Time DT (computed, no hex address) = " & txtDwellTime & vbCrLf CopySequence = CopySequence & "(hex address 1d) = " & txtMisc1 & vbCrLf CopySequence = CopySequence & "Clock Multiplier Kp (hex address 1e) = " & txtCM & vbCrLf CopySequence = CopySequence & "Mode (hex address 1f) = " & txtMisc3 & vbCrLf CopySequence = CopySequence & "(hex address 20) = " & txtMisc4 & vbCrLf CopySequence = CopySequence & "% Sine Amplitude (hex address 21) = " & txtOutputShape1 & vbCrLf CopySequence = CopySequence & "% Cosine Amplitude (hex address 23) = " & txtOutputShape2 & vbCrLf CopySequence = CopySequence & "(hex address 25) = " & txtOutputShapeRR & vbCrLf CopySequence = CopySequence & "(hex address 26) = " & txtQdac & vbCrLf Clipboard.SetText (CopySequence) End Sub Private Sub mnuFileSave_Click() ComEventSource = 1 'Used in MSComm1_OnComm()subroutine txtSend.Text = "" txtReceive = "" txtSend.Text = "s" 'Send text in gOut variables to DDS8m If MSComm1.PortOpen = False Then MSComm1.PortOpen = True MSComm1.output = txtSend.Text & Chr$(13) Do DoEvents If Timeout() = True Then Exit Sub If InStr(txtReceive, "?") Then Exit Sub 'Check to see if the DDS8m returned an error code Loop Until InStr(txtReceive, "OK" & vbCrLf) <> 0 End Sub Private Sub mnuFrequencyBPSK_Click() Dim i As Integer Dim a As Variant Dim b As Variant Dim c As Variant Dim receive As Variant txtReceive = "" ComEventSource = 2 gQueUpdate = False 'Flag set true at end of StatusUpdate function RegisterReceive = "" If MSComm1.PortOpen = False Then MSComm1.PortOpen = True MSComm1.output = "que" & Chr$(13) 'This is to insure the ClockMultiplier is correct a = Timer Do 'This Do loop checks for communication timeout and DDS8m error response DoEvents If InStr(txtReceive, "?") Then Exit Sub If a - Timer > 1000# Then a = Timer If a + 3 < Timer Then MsgBox ("Communication Timeout Error. Please verify that you have the correct COM port selected and that all cabling is ok and power is on to the DDS8m") Exit Sub End If Loop Until gQueUpdate = True ' Causes loop to end when que command is successful gQueUpdate = False txtReceive = "" receive = "" For i = 0 To 2 gOut(i) = "" 'gOut() holds the DDS8m commands to be sent to the DDS8m Next i ComEventSource = 1 'Used in MSComm1_OnComm()subroutine txtSend.Text = "" a = 0 a = InputBox("Enter your desired frequency F1 in megahertz.", "BPSK") If a = "" Then Exit Sub If a > 0.00001 And a < 100 Then a = (28.1474976710656 * 10) / (txtClockFrequency * gClockMultiplier) * a Else MsgBox ("You did not enter a valid frequency") Exit Sub End If b = 0 b = InputBox("Enter your desired value for Phase One (P1). This should be an integer between 1 and 16384.", "BPSK") If b = "" Then Exit Sub If b >= 0 And b < 16385 Then Else MsgBox ("You did not enter a valid frequency") Exit Sub End If c = 0 c = InputBox("Enter your desired value for Phase Two (P2). This should be an integer between 1 and 16384.", "BPSK") If c = "" Then Exit Sub If c >= 0 And c < 16385 Then Else MsgBox ("You did not enter a valid frequency") Exit Sub End If gOut(0) = "m 0" & vbCrLf gOut(1) = "f1 " & Format(a, "#0.0###########") & vbCrLf gOut(2) = "p1 " & Format(b, "######") & vbCrLf gOut(3) = "p2 " & Format(c, "######") & vbCrLf gOut(4) = "m 4" & vbCrLf 'Send text in gOut variables to DDS8m If MSComm1.PortOpen = False Then MSComm1.PortOpen = True For i = 0 To 4 MSComm1.output = gOut(i) Do DoEvents If Timeout() = True Then Exit Sub If InStr(txtReceive, "?") Then Exit Sub 'Check to see if the DDS8m returned an error code Loop Until InStr(txtReceive, "OK" & vbCrLf) <> 0 receive = receive & txtReceive 'receive used to accumulate commands and display them after next i txtReceive = "" Next i txtReceive = receive End Sub Private Sub mnuFrequencyFSK_Click() Dim i As Integer Dim a As Variant Dim b As Variant Dim receive As Variant txtReceive = "" ComEventSource = 2 gQueUpdate = False 'Flag set true at end of StatusUpdate function RegisterReceive = "" If MSComm1.PortOpen = False Then MSComm1.PortOpen = True MSComm1.output = "que" & Chr$(13) 'This is to insure the ClockMultiplier is correct a = Timer Do 'This Do loop checks for communication timeout and DDS8m error response DoEvents If InStr(txtReceive, "?") Then Exit Sub If a - Timer > 1000# Then a = Timer If a + 3 < Timer Then MsgBox ("Communication Timeout Error. Please verify that you have the correct COM port selected and that all cabling is ok and power is on to the DDS8m") Exit Sub End If Loop Until gQueUpdate = True ' Causes loop to end when que command is successful gQueUpdate = False txtReceive = "" receive = "" For i = 0 To 2 gOut(i) = "" 'gOut() holds the DDS8m commands to be sent to the DDS8m Next i ComEventSource = 1 'Used in MSComm1_OnComm()subroutine txtSend.Text = "" a = 0 a = InputBox("Enter your desired frequency F1 in megahertz.", "FSK") If a = "" Then Exit Sub If a > 0.00001 And a < 100 Then a = (28.1474976710656 * 10) / (txtClockFrequency * gClockMultiplier) * a Else MsgBox ("You did not enter a valid frequency") Exit Sub End If b = 0 b = InputBox("Enter your desired frequency F2 in megahertz.", "FSK") If b = "" Then Exit Sub If b > 0.00001 And a < 100 Then b = (28.1474976710656 * 10) / (txtClockFrequency * gClockMultiplier) * b Else MsgBox ("You did not enter a valid frequency") Exit Sub End If gOut(0) = "m 0" & vbCrLf gOut(1) = "f1 " & Format(a, "#0.0###########") & vbCrLf gOut(2) = "f2 " & Format(b, "#0.0###########") & vbCrLf gOut(3) = "m 1" & vbCrLf 'Send text in gOut variables to DDS8m If MSComm1.PortOpen = False Then MSComm1.PortOpen = True For i = 0 To 3 MSComm1.output = gOut(i) Do DoEvents If Timeout() = True Then Exit Sub If InStr(txtReceive, "?") Then Exit Sub 'Check to see if the DDS8m returned an error code Loop Until InStr(txtReceive, "OK" & vbCrLf) <> 0 receive = receive & txtReceive 'receive used to accumulate commands and display them after next i txtReceive = "" Next i txtReceive = receive End Sub 'COMMANDS/SINGLE TONE MENU CLICK Private Sub mnuFrequencySingleTone_Click() Dim i As Integer Dim a As Variant Dim receive As Variant txtReceive = "" ComEventSource = 2 gQueUpdate = False 'Flag set true at end of StatusUpdate function RegisterReceive = "" If MSComm1.PortOpen = False Then MSComm1.PortOpen = True MSComm1.output = "que" & Chr$(13) 'This is to insure the ClockMultiplier is correct a = Timer Do 'This Do loop checks for communication timeout and DDS8m error response DoEvents If InStr(txtReceive, "?") Then Exit Sub If a - Timer > 1000# Then a = Timer If a + 3 < Timer Then MsgBox ("Communication Timeout Error. Please verify that you have the correct COM port selected and that all cabling is ok and power is on to the DDS8m") Exit Sub End If Loop Until gQueUpdate = True ' Causes loop to end when que command is successful gQueUpdate = False txtReceive = "" receive = "" For i = 0 To 1 gOut(i) = "" 'gOut() holds the DDS8m commands to be sent to the DDS8m Next i ComEventSource = 1 'Used in MSComm1_OnComm()subroutine txtSend.Text = "" a = 0 a = InputBox("Enter your desired frequency in megahertz.", "SINGLE TONE") If a = "" Then Exit Sub If a > 0.00001 And a < 100 Then a = (28.1474976710656 * 10) / (txtClockFrequency * gClockMultiplier) * a Else MsgBox ("You did not enter a valid frequency") Exit Sub End If gOut(0) = "m 0" & vbCrLf gOut(1) = "f0 " & Format(a, "#0.0###########") & vbCrLf 'Send text in gOut variables to DDS8m For i = 0 To 1 MSComm1.output = gOut(i) Do DoEvents If Timeout() = True Then Exit Sub If InStr(txtReceive, "?") Then Exit Sub 'Check to see if the DDS8m returned an error code Loop Until InStr(txtReceive, "OK" & vbCrLf) <> 0 receive = receive & txtReceive 'receive used to accumulate commands and display them after next i txtReceive = "" Next i txtReceive = receive End Sub 'COMMANDS/TRIANGLE MENU CLICK EVENT Private Sub mnuFrequencyTriangle_Click() Dim i As Integer Dim a As Variant Dim receive As Variant txtSend = "" txtReceive = "" ComEventSource = 2 gQueUpdate = False 'Flag set true at end of StatusUpdate function RegisterReceive = "" ' Form level variable needed by MSComm1_OnComm() If MSComm1.PortOpen = False Then MSComm1.PortOpen = True MSComm1.output = "que" & Chr$(13) 'This is to insure the ClockMultiplier is correct a = Timer Do 'This Do loop checks for communication timeout and DDS8m error response DoEvents If InStr(txtReceive, "?") Then Exit Sub If a - Timer > 1000# Then a = Timer If a + 3 < Timer Then MsgBox ("Communication Timeout Error. Please verify that you have the correct COM port selected and that all cabling is ok and power is on to the DDS8m") Exit Sub End If Loop Until gQueUpdate = True ' Causes loop to end when que command is successful gQueUpdate = False txtReceive = "" receive = "" For i = 0 To 6 gOut(i) = "" 'gOut() holds the DDS8m commands to be sent to the DDS8m Next i ComEventSource = 1 'Used in MSComm1_OnComm()subroutine Form2.Caption = "Triangle Frequency Sweep" Form2.Show 'Send text in gOut variables to DDS8m For i = 0 To 6 Do DoEvents Loop Until gOut(i) <> "" If gOut(i) = "Tr to big" Then GoTo TrToBig 'Debug.Print "gOut(i) = "; gOut(i) MSComm1.output = gOut(i) Do DoEvents If InStr(txtReceive, "?") Then Exit Sub 'Check to see if the DDS8m returned an error code Loop Until InStr(txtReceive, "OK" & vbCrLf) <> 0 receive = receive & txtReceive txtReceive = "" Wait (1) TrToBig: Next i txtReceive = receive End Sub 'COM/SET COM PORT NUMBER MENU CLICK Private Sub mnuComPortNumber_Click() On Error GoTo ErrorHandler: Dim e As Integer Dim a As Variant a = 9999 e = MSComm1.CommPort If MSComm1.PortOpen = True Then MSComm1.PortOpen = False a = InputBox("Enter the COM port number", "COM Port Number") Debug.Print a If a > 9998 Then Exit Sub Else MSComm1.CommPort = a End If 'MSComm1.CommPort = InputBox("Enter the COM port number", "COM Port Number") MSComm1.PortOpen = True txtComPortNumber = MSComm1.CommPort Call ComPortSave Exit Sub ErrorHandler: MsgBox ("Error. You probably entered an invalid COM port number. Try again.") MSComm1.CommPort = e 'MSComm1.PortOpen = True 'txtComPortNumber = MSComm1.CommPort End Sub 'EXIT MENU Private Sub mnuFileExit_Click() If MSComm1.PortOpen = True Then MSComm1.PortOpen = False End End Sub Private Sub mnuFrequencySawtooth_Click() Dim i As Integer Dim a As Variant Dim receive As Variant txtReceive = "" ComEventSource = 2 gQueUpdate = False 'Flag set true at end of StatusUpdate function RegisterReceive = "" ' Form level variable needed by MSComm1_OnComm() If MSComm1.PortOpen = False Then MSComm1.PortOpen = True MSComm1.output = "que" & Chr$(13) 'This is to insure the ClockMultiplier is correct a = Timer Do 'This Do loop checks for communication timeout and DDS8m error response DoEvents If InStr(txtReceive, "?") Then Exit Sub If a - Timer > 1000# Then a = Timer If a + 3 < Timer Then MsgBox ("Communication Timeout Error. Please verify that you have the correct COM port selected and that all cabling is ok and power is on to the DDS8m") Exit Sub End If Loop Until gQueUpdate = True ' Causes loop to end when que command is successful gQueUpdate = False txtReceive = "" receive = "" For i = 0 To 6 gOut(i) = "" 'gOut() holds the DDS8m commands to be sent to the DDS8m Next i ComEventSource = 1 'Used in MSComm1_OnComm()subroutine Form3.Show 'Send text in gOut variables to DDS8m If MSComm1.PortOpen = False Then MSComm1.PortOpen = True For i = 0 To 5 Do DoEvents Loop Until gOut(i) <> "" If gOut(i) = "Tr to big" Then GoTo TrToBig 'Debug.Print "gOut(i) = "; gOut(i) MSComm1.output = gOut(i) Do DoEvents If Timeout() = True Then Exit Sub If InStr(txtReceive, "?") Then Exit Sub 'Check to see if the DDS8m returned an error code Loop Until InStr(txtReceive, "OK" & vbCrLf) <> 0 receive = receive & txtReceive 'receive used to accumulate commands and display them after next i txtReceive = "" Wait (1) TrToBig: Next i txtReceive = receive End Sub Private Sub mnuBatchFile_Click() Dim character As Variant Dim output As Variant Dim receive As Variant Dim b As Boolean Dim i As Integer Dim x As Double lblProcessingCommands.Visible = False output = "" character = "" b = False gOut(0) = "" Form4.Show Do DoEvents Loop Until gOut(0) <> "" If MSComm1.PortOpen = False Then MSComm1.PortOpen = True 'Parse sequence commands from form 4 lblProcessingCommands.Visible = True For i = 1 To Len(gOut(0)) If character = Chr(10) Then b = False character = Mid(gOut(0), i, 1) If character = "#" Then b = True If b = False Then output = output & character If character = Chr(10) And Len(output) = 2 Then character = "" output = "" End If If character = Chr(10) Then Select Case InStr(1, output, "dwell") Case 0 'dwell is not found in the variable output b = True ComEventSource = 1 txtReceive = "" MSComm1.output = output output = "" Do DoEvents If Timeout() = True Then Exit Sub If InStr(txtReceive, "?") Then Exit Sub 'Check to see if the DDS8m returned an error code Loop Until InStr(txtReceive, "OK" & vbCrLf) <> 0 Debug.Print "inside Case 0"; i Case 1 'dwell is found in the variable output If InStr(1, output, vbCrLf) <> 0 Then If Mid(output, 6, 1) <> Chr(32) Then MsgBox ("There is no space after dwell. Please fix this and try again") Exit Sub End If x = CDbl(Mid(output, 7, Len(output) - 8)) Call Wait(x) output = "" End If End Select End If End If Debug.Print "i = "; i; " output = "; output Next i lblProcessingCommands.Visible = False End Sub Private Sub mnuAmplitudeIChannel_Click() Dim a As Variant ComEventSource = 1 'Used in MSComm1_OnComm()subroutine txtSend.Text = "" a = 0 a = InputBox("Enter your desired amplitude. It should be a number from 0(off) to 4096.", "I Channel Amplitude") If a = "" Then Exit Sub If a >= 0 And a < 4097 Then Else MsgBox ("You did not enter a valid amplitude") Exit Sub End If txtReceive = "" txtSend.Text = "vi " & Format(a, "####") 'Send text in gOut variables to DDS8m If MSComm1.PortOpen = False Then MSComm1.PortOpen = True MSComm1.output = txtSend.Text & Chr$(13) Do DoEvents If Timeout() = True Then Exit Sub If InStr(txtReceive, "?") Then Exit Sub 'Check to see if the DDS8m returned an error code Loop Until InStr(txtReceive, "OK" & vbCrLf) <> 0 End Sub Private Sub mnuPhaseF1_Click() Dim a As Variant ComEventSource = 1 'Used in MSComm1_OnComm()subroutine txtSend.Text = "" a = 0 a = InputBox("Enter your desired phase. It should be a number from 0 to 16383.", "F1 Output Phase") If a = "" Then Exit Sub If a >= 0 And a < 16384 Then Else MsgBox ("You did not enter a valid phase") Exit Sub End If txtReceive = "" txtSend.Text = "p1 " & Format(a, "####0") 'Send text in gOut variables to DDS8m If MSComm1.PortOpen = False Then MSComm1.PortOpen = True MSComm1.output = txtSend.Text & Chr$(13) Do DoEvents If Timeout() = True Then Exit Sub If InStr(txtReceive, "?") Then Exit Sub 'Check to see if the DDS8m returned an error code Loop Until InStr(txtReceive, "OK" & vbCrLf) <> 0 End Sub Private Sub mnuPhaseF2_Click() Dim a As Variant ComEventSource = 1 'Used in MSComm1_OnComm()subroutine txtSend.Text = "" a = 0 a = InputBox("Enter your desired phase. It should be a number from 0 to 16383.", "F2 Output Phase") If a = "" Then Exit Sub If a >= 0 And a < 16384 Then Else MsgBox ("You did not enter a valid phase") Exit Sub End If txtReceive = "" txtSend.Text = "p2 " & Format(a, "####0") 'Send text in gOut variables to DDS8m If MSComm1.PortOpen = False Then MSComm1.PortOpen = True MSComm1.output = txtSend.Text & Chr$(13) Do DoEvents If Timeout() = True Then Exit Sub If InStr(txtReceive, "?") Then Exit Sub 'Check to see if the DDS8m returned an error code Loop Until InStr(txtReceive, "OK" & vbCrLf) <> 0 End Sub Private Sub mnuRegisterEU_Click() mnuRegisterHex.Checked = False mnuRegisterEU.Checked = True End Sub Private Sub mnuRegisterHex_Click() mnuRegisterHex.Checked = True mnuRegisterEU.Checked = False End Sub Private Sub mnuClearDisplay_Click() lblProcessingCommands.Visible = False TimerTimes = 0 txtWait.Visible = False lblWait.Visible = False txtReceive = "" txtSend = "" End Sub 'THIS FUNCTION DETECTS COMMUNICATION EVENTS AND THEN TAKES APPROPRIATE ACTION Private Sub MSComm1_OnComm() 'DETECTS A COMMUNICATION EVENT Dim a As Variant Dim P1 As Variant MSComm1.InputLen = 0 'READ ALL COMMUNICATION INPUTS WITH 0 OR MORE CHARACTERS Select Case ComEventSource 'ComEventSource IS A VARIABLE USED TO DETECT IF 'THE LAST BUTTON CLICKED WAS THE ENTER (CASE 1) 'OR READ REGISTER (CASE 2)BUTTON Case 1 Select Case MSComm1.CommEvent Case comEvReceive 'IF CommEvent DETECTS RECEIVED DATA THEN THE DATA 'IS SAVED IN "a" AND THEN ACCUMULATED IN "textReceive" a = MSComm1.Input txtReceive = txtReceive + a DDS8mErrorCodes (txtReceive) 'Debug.Print "CommEvent fired "; txtReceive End Select Case 2 Select Case MSComm1.CommEvent Case comEvReceive 'IF CommEvent DETECTS RECEIVED DATA THEN THE 'DATA IS SAVED IN "a" AND THEN ACCUMULATED 'UNTIL ALL BITS HAVE ARRIVED. THIS IS 82 BITS WHEN 'ECHO IS DISABLED AND 87 BITS WHEN ECHO IS ENABLED 'IF/THEN STATEMENTS QUALIFY THE EVENT AS ECHO ON OR OFF 'THIS CODE IS USED AFTER A "que" COMMAND IS SENT a = MSComm1.Input RegisterReceive = RegisterReceive + a DDS8mErrorCodes (RegisterReceive) If Left(RegisterReceive, 1) <> "q" Then 'IF TRUE THEN ECHO IS DISABLED If Len(RegisterReceive) = 82 Then txtReceive = RegisterReceive StatusUpdate (RegisterReceive) 'CALL StatusUpdate SUBROUTINE TO 'PARSE STATUS BYTESEnd If End If End If If Left(RegisterReceive, 1) = "q" Then 'IF TRUE THEN ECHO IS ENABLED If Len(RegisterReceive) = 87 Then txtReceive = RegisterReceive RegisterReceive = Right(RegisterReceive, 82) StatusUpdate (RegisterReceive) 'CALL StatusUpdate SUBROUTINE TO 'PARSE STATUS BYTES 'Debug.Print "yes q"; RegisterReceive End If End If End Select End Select End Sub 'THIS SUBROUTINE PARSES AN 80 BIT DDS8M HEX STATUS WORD AND DISPLAYS RESULTS AS DECIMAL VALUES. 'IT FIRST PARSES AND THEN CALLS THE FUNCTION HexToDecimal TO PERFORM THE CONVERSION 'CALLED FROM MSComm1_OnComm() Private Sub StatusUpdate(x As Variant) Dim P1, P2, F1, F2, Fd, UC, RRC, Misc1, CM, Misc3, Misc4, OSK1, OSK2, OSKRR, QDAC As Variant Dim Td As Variant Dim DT As Variant Dim Tr As Variant If mnuRegisterHex.Checked = False Then 'Debug.Print "StatusUpdate Fired" 'PARSE PHASE 1 P1 = Mid(x, 1, 4) P1 = HexToDecimal(P1, 4) txtPhase1 = Round(P1 * 360 / 16384, 2) 'PARSE PHASE 2 P2 = Mid(x, 5, 4) P2 = HexToDecimal(P2, 4) txtPhase2 = Round(P2 * 360 / 16384, 2) 'PARSE FREQUENCY 1. THE FREQUENCY IS COMPUTED CORRECTLY IF THE JUMPER 'IS SET TO INTERNAL CLOCK AND THE CLOCK MULTIPLIER IS SET TO 10 F1 = Mid(x, 9, 12) F1 = HexToDecimal(F1, 12) txtFreq1 = F1 * 10 ^ -12 'PARSE FREQUENCY 2 F2 = Mid(x, 21, 12) F2 = HexToDecimal(F2, 12) txtFreq2 = F2 * 10 ^ -12 'PARSE DELTA FREQUENCY (Fd) Fd = Mid(x, 33, 12) Fd = HexToDecimal(Fd, 12) txtDeltaFreq = Fd * 10 ^ -12 'PARSE UPDATE CLOCK (Tr) UC = Mid(x, 45, 8) UC = HexToDecimal(UC, 8) txtUpdateClock = UC 'PARSE RAMP RATE CLOCK (Td) Td = Mid(x, 53, 6) Td = HexToDecimal(Td, 6) txtRRClock = Td 'PARSE MISC1 (TTL) Misc1 = Mid(x, 59, 2) txtMisc1 = Misc1 'PARSE CLOCK MULTIPLIER CM = Mid(x, 61, 2) CM = HexToDecimal(CM, 2) CM = CM - 64 txtCM = CM gClockMultiplier = CM 'PARSE MISC3(mode) Misc3 = Mid(x, 63, 2) txtMisc3 = Misc3 If Misc3 = "00" Then txtMisc3 = 0 If Misc3 = "02" Then txtMisc3 = 1 If Misc3 = "A5" Then txtMisc3 = 2 If Misc3 = "87" Then txtMisc3 = 3 If Misc3 = "89" Then txtMisc3 = 4 'PARSE MISC4 Misc4 = Mid(x, 65, 2) txtMisc4 = Misc4 'PARSE OUTPUT SHAPE KEY #1 OSK1 = Mid(x, 67, 4) OSK1 = HexToDecimal(OSK1, 4) OSK1 = (OSK1 / 4095) * 100 OSK1 = Format(OSK1, "###.##") txtOutputShape1 = OSK1 'PARSE OUTPUT SHAPE KEY #2 OSK2 = Mid(x, 71, 4) OSK2 = HexToDecimal(OSK2, 4) OSK2 = (OSK2 / 4095) * 100 OSK2 = Format(OSK2, "###.##") txtOutputShape2 = OSK2 'PARSE OUTPUT SHAPE KEY RAMP RATE OSKRR = Mid(x, 75, 2) txtOutputShapeRR = OSKRR 'PARSE QDAC QDAC = Mid(x, 77, 4) txtQdac = QDAC 'COMPUTE FREQUENCY 1 & 2 BASED ON THE CONFIGURATION SETTING FOR 'CLOCK FREQUENCY AND THE ACTUAL CLOCK MULTIPLIER (CM) txtFreq1 = (txtClockFrequency * (CM / 10) / 28.1474976710656) * txtFreq1 txtFreq2 = (txtClockFrequency * (CM / 10) / 28.1474976710656) * txtFreq2 txtDeltaFreq = (txtClockFrequency * (CM / 10) / 28.1474976710656) * txtDeltaFreq txtFreq1 = Format(txtFreq1, "##0.############") txtFreq2 = Format(txtFreq2, "##0.############") txtDeltaFreq = Format(txtDeltaFreq, "##0.############") 'CONVERT txtRRClock INTO DT IN MICROSECONDS DT = ((Td + 1) / (txtClockFrequency * CM)) 'Td is in microseconds txtDwellTime = Format(DT, "##0.#####") 'INCREMENT gQueUpdate FOR USE IN que COMMAND VERIFICATION ROUTINE gQueUpdate = True Else 'Debug.Print "StatusUpdate Fired" 'PARSE PHASE 1 P1 = Mid(x, 1, 4) txtPhase1 = P1 'PARSE PHASE 2 P2 = Mid(x, 5, 4) txtPhase2 = P2 'PARSE FREQUENCY 1. F1 = Mid(x, 9, 12) txtFreq1 = F1 'PARSE FREQUENCY 2 F2 = Mid(x, 21, 12) txtFreq2 = F2 'PARSE DELTA FREQUENCY (Fd) Fd = Mid(x, 33, 12) txtDeltaFreq = Fd 'PARSE UPDATE CLOCK (Tr) UC = Mid(x, 45, 8) txtUpdateClock = UC 'PARSE RAMP RATE CLOCK (Td) Td = Mid(x, 53, 6) txtRRClock = Td 'PARSE MISC1 (TTL) Misc1 = Mid(x, 59, 2) txtMisc1 = Misc1 'PARSE CLOCK MULTIPLIER CM = Mid(x, 61, 2) txtCM = CM CM = HexToDecimal(CM, 2) CM = CM - 64 gClockMultiplier = CM 'PARSE MISC3(mode) Misc3 = Mid(x, 63, 2) txtMisc3 = Misc3 'PARSE MISC4 Misc4 = Mid(x, 65, 2) txtMisc4 = Misc4 'PARSE OUTPUT SHAPE KEY #1 OSK1 = Mid(x, 67, 4) txtOutputShape1 = OSK1 'PARSE OUTPUT SHAPE KEY #2 OSK2 = Mid(x, 71, 4) txtOutputShape2 = OSK2 'PARSE OUTPUT SHAPE KEY RAMP RATE OSKRR = Mid(x, 75, 2) txtOutputShapeRR = OSKRR 'PARSE QDAC QDAC = Mid(x, 77, 4) txtQdac = QDAC txtDwellTime = "" 'INCREMENT gQueUpdate FOR USE IN que COMMAND VERIFICATION ROUTINE gQueUpdate = True End If End Sub 'DDS8M ERROR CODE SUBROUTINE Private Sub DDS8mErrorCodes(x As Variant) If InStr(1, x, "?0") <> 0 Then MsgBox "Error, the DDS8m did not recognize the command" If InStr(1, x, "?1") <> 0 Then MsgBox "Error, bad DDS8m Frequency Command" If InStr(1, x, "?2") <> 0 Then MsgBox "Error, bad DDS8m AM command" If InStr(1, x, "?3") <> 0 Then MsgBox "Error, DDS8m input line too long" If InStr(1, x, "?4") <> 0 Then MsgBox "Error, bad DDS8m Phase Command" If InStr(1, x, "?5") <> 0 Then MsgBox "Error, bad DDS8m Time Command" If InStr(1, x, "?6") <> 0 Then MsgBox "Error, bad DDS8m Mode Command" If InStr(1, x, "?7") <> 0 Then MsgBox "Error, bad DDS8m Amp command" If InStr(1, x, "?8") <> 0 Then MsgBox "Error, bad DDS8m constant" If InStr(1, x, "?f") <> 0 Then MsgBox "Error, bad byte in DDS8m command" End Sub Private Sub txtSend_KeyDown(KeyCode As Integer, Shift As Integer) If MSComm1.PortOpen = False Then MSComm1.PortOpen = True If KeyCode = Asc(vbCr) Then txtReceive = "" ComEventSource = 1 MSComm1.output = txtSend.Text & Chr$(13) Call Timeout txtSend.Text = "" End If End Sub 'Looks for a character in txtReceive. If it does not see one in three seconds it displays a timeout message Public Function Timeout() As Boolean Dim a As Variant Timeout = False a = Timer 'Timer is a vb function that returns the number of seconds past midnight Do 'This Do loop checks for communication timeout and DDS8m error code DoEvents If a - Timer > 1000# Then a = Timer 'needed in case time goes through midnight If a + 3# <= Timer Then If txtReceive <> "" Then Exit Function MsgBox ("Communication Timeout Error. Please verify that you have the correct COM port selected and that all cabling is ok and power is on to the DDS8m") Timeout = True Exit Function End If Loop Until txtReceive <> "" ' Causes loop to end when que command is successful End Function Private Sub Wait(x As Double) Dim a As Boolean a = False lblWait.Visible = True txtWait.Visible = True TimeX = x TimerTimeout = False Timer1.Interval = 1000 Timer1.Enabled = True Do DoEvents If TimerTimeout = True Then Timer1.Enabled = False lblWait.Visible = False txtWait.Visible = False Exit Sub End If Loop Until a = True End Sub Public Sub Timer1_Timer() TimerTimes = TimerTimes + 1 txtWait = TimeX - TimerTimes If TimerTimes = TimeX Then TimerTimes = 0 TimerTimeout = True End If End Sub Public Sub SendQue() Dim a As Variant txtReceive = "" ComEventSource = 2 gQueUpdate = False 'Flag set true at end of StatusUpdate function RegisterReceive = "" ' Form level variable needed by MSComm1_OnComm() If MSComm1.PortOpen = False Then MSComm1.PortOpen = True MSComm1.output = "que" & Chr$(13) 'This is to insure the ClockMultiplier is correct a = Timer Do 'This Do loop checks for communication timeout and DDS8m error response DoEvents If InStr(txtReceive, "?") Then Exit Sub If a - Timer > 1000# Then a = Timer If a + 3 < Timer Then MsgBox ("Communication Timeout Error. Please verify that you have the correct COM port selected and that all cabling is ok and power is on to the DDS8m") Exit Sub End If Loop Until gQueUpdate = True ' Causes loop to end when que command is successful gQueUpdate = False End Sub 'Reads the COM port number from the DDS8Com.txt file 'This file must be in the same directory as the SOF8 program Public Function LoadComPortNumber() As Boolean Dim buffer As String Dim FileNum As Variant txtReceive = "" buffer = "" FileNum = FreeFile 'The FileListBox control (named File1) on the form only lists files with the name '"CommandSequence.txt" since this is the only file in the FileListBox Pattern 'property. If this file does not exist then File1.ListCount will be 0 If FileCom.ListCount < 1 Then MsgBox ("No COM Port number has been saved") LoadComPortNumber = False Exit Function End If Open "DDS8mCom.txt" For Input As FileNum Line Input #FileNum, buffer Close FileNum txtComPortNumber = buffer MSComm1.CommPort = buffer LoadComPortNumber = True End Function