⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uhf_analysis.frm

📁 M8演示程序
💻 FRM
📖 第 1 页 / 共 5 页
字号:
        MsgBox "Failed to turn off Freq hoppping"
        Exit Function
    Else
        If Mid(Form1.Response$, 2, 2) <> comand$ Then
            'label_Status.Caption = "Waiting for Command"
            'textbox_ModDepth.Text = "<Write Fail>"
            MsgBox "Failed to turn off Freq hoppping"
            Exit Function
        End If
    End If

End Function

Private Function Write_All_Memory()
    Dim bytesWritten As Integer
    Dim numTries As Integer
    
    ' Perform 4 consecutive "Write System" commands, one for each
    ' of the 4 text boxes / system parameters:
    '
    ' WRITE SYS COMMAND:
    '
    '   <STX><FLAGS><COMMAND><STARTING_BLOCK><NUMBER_OF_BLOCKS><DATA><CRC>, where
    '
    '      <FLAGS>
    '      <COMMAND> = 0x42
    '      <STARTING_BLOCK> = paramBlock
    '      <NUMBER_OF_BLOCKS> = 0x01
    '      <DATA> = 4 bytes
    '      <CRC> = 2 bytes, calculated over <FLAGS> through <DATA>
       
    If Form1.MSComm1.PortOpen = False Then
        Exit Function
    End If
    
   ' flags$ = "20"   ' set the CRC_F
   ' If option_Sys.Value = True Then
   '     comand$ = "42" ' this is a Write_Sys command
   '     label_Status.Caption = "Writing to System"
   ' Else
   '     comand$ = "41" ' Assume this is a Write_Mem command
   '     label_Status.Caption = "Writing to Memory"
   ' End If
   
   flags$ = "20"   ' set the CRC_F
   comand$ = "42" ' Assume this is a Write_Sys command
    
    nbBlks$ = "01"


    If Write_Frequency() = True Then
    End If

    If Write_Max_Frequency() = True Then
    End If

    If Write_Min_Frequency() = True Then
    End If
        
    If Write_Step_Frequency() = True Then
    End If

    If Write_Power() = True Then
    End If
    
    If Write_Mod_Depth() = True Then
    End If

    

    
    

   '    '*********************************************************************
    '
    ' Write Rise Time
    '*********************************************************************
    'flags$ = "20"   ' set the CRC_F
    'freqData$ = textbox_Freq.Text ' has the form 869.525
    '' send the Write_Sys command "42" to write freqData$ into block "0D"
    'Form1.MSComm1.Output = vbCr & flags$ & "42" & "0D" & "01" & freqData$ & vbCr
    'If Form1.GetResponse() = True Then
    '    If Mid(Form1.Response$, 2, 2) <> "42" Then
    '        label_Status.Caption = "Waiting for Command"
    '        textbox_Freq.Text = "<Write Fail>"
    '        Exit Sub
    '    End If
    '    ' the write sys command passed.
    'End If
   '
   '
    
    'label_Status.Caption = "Waiting for Command"

End Function
Private Sub Read_All_Memory()
    Dim crc$
    Dim byteCount As Integer
    Dim strByteCount As String
    Dim bytesRead As Integer
    Dim numTries As Integer
    
    ' Four consecutive Read_Sys commands are sent to the M8.
    ' Error messages <command fail> and <illegal value> can appear
    ' in the corresponding text box, but typically the command will pass,
    ' and the M8 will respond with the value stored in that system parameter.
    ' The corresponding function will format and display the system parameter value.
    
    flags$ = "20"   ' set the CRC_F
    
    'If option_Sys.Value = True Then
        'comand$ = "22" ' this is a Read_Sys command
        'label_Status.Caption = "Reading from System"
    'Else
        'comand$ = "21" ' Assume this is a Read_Mem command
        'label_Status.Caption = "Reading from Memory"
    'End If
    
    nbBlks$ = "01"
    
    '******************************************************************************
    ' FREQUENCY - param 0E
    '
    '  This will read 4 bytes from the M8 and reconstruct something like 915.875
    '
    '******************************************************************************
    strtBlk$ = "0E"
    crc$ = Form1.calculateCRC(flags$ & comand$ & strtBlk$ & nbBlks$)
    Form1.MSComm1.Output = vbCr & flags$ & comand$ & strtBlk$ & nbBlks$ & crc$ & vbCr
    ' wait .1 second to give the reader time to process the command before it responds
    Start = Timer
    Do
    Loop Until (Timer - Start) > 0.1
    If Form1.GetResponse() = False Then
        'label_Status.Caption = "Waiting for Command"
        textbox_Freq.Text = "<Read Fail>"
        Exit Sub
    Else
        If Mid(Form1.Response$, 2, 2) <> comand$ Then
            'label_Status.Caption = "Waiting for Command"
            textbox_Freq.Text = "<Read Fail>"
            Exit Sub
        End If
    End If
    ' the read mem (read sys) command passed.
    ' now format and display the data in the text box
    
    ' build the text box
    hexByte0$ = Mid$(Form1.Response$, 10, 2)
    hexByte1$ = Mid$(Form1.Response$, 8, 2)
    hexByte2$ = Mid$(Form1.Response$, 6, 2)
    hexByte3$ = Mid$(Form1.Response$, 4, 2)
    
    freqData$ = "&H" & hexByte0$ & hexByte1$ & hexByte2$ & hexByte3$
    'Dim abc As Double
    
    abc = CLng(Val(freqData$))
    longFreeq$ = Str$(abc)
    hex1$ = Mid$(longFreeq$, 2, 3)
    hex2$ = Mid$(longFreeq$, 5, 3)
    textbox_Freq.Text = hex1$ & "." & hex2$
    
    
    '******************************************************************************
    ' MIN FREQUENCY - param 10
    '
    '  This will read 4 bytes from the M8 and reconstruct something like 915.875
    '
    '******************************************************************************
    strtBlk$ = "10"
    nbBlks$ = "01"
    crc$ = Form1.calculateCRC(flags$ & comand$ & strtBlk$ & nbBlks$)
    Form1.MSComm1.Output = vbCr & flags$ & comand$ & strtBlk$ & nbBlks$ & crc$ & vbCr
    ' wait .1 second to give the reader time to process the command before it responds
    Start = Timer
    Do
    Loop Until (Timer - Start) > 0.1
    If Form1.GetResponse() = False Then
        'label_Status.Caption = "Waiting for Command"
        textbox_MinFreq.Text = "<Read Fail>"
        Exit Sub
    Else
        If Mid(Form1.Response$, 2, 2) <> comand$ Then
            'label_Status.Caption = "Waiting for Command"
            textbox_MinFreq.Text = "<Read Fail>"
            Exit Sub
        End If
    End If
    ' the read mem (read sys) command passed.
    ' now format and display the data in the text box
    
    ' build the text box
    hexByte0$ = Mid$(Form1.Response$, 10, 2)
    hexByte1$ = Mid$(Form1.Response$, 8, 2)
    hexByte2$ = Mid$(Form1.Response$, 6, 2)
    hexByte3$ = Mid$(Form1.Response$, 4, 2)
    
    freqData$ = "&H" & hexByte0$ & hexByte1$ & hexByte2$ & hexByte3$
    'Dim abc As Double
    
    abc = CLng(Val(freqData$))
    longFreeq$ = Str$(abc)
    hex1$ = Mid$(longFreeq$, 2, 3)
    hex2$ = Mid$(longFreeq$, 5, 3)
    textbox_MinFreq.Text = hex1$ & "." & hex2$
    
    '******************************************************************************
    ' MAX FREQUENCY - param 0F
    '
    '  This will read 4 bytes from the M8 and reconstruct something like 915.875
    '
    '******************************************************************************
    strtBlk$ = "0F"
    nbBlks$ = "01"
    crc$ = Form1.calculateCRC(flags$ & comand$ & strtBlk$ & nbBlks$)
    Form1.MSComm1.Output = vbCr & flags$ & comand$ & strtBlk$ & nbBlks$ & crc$ & vbCr
    ' wait .1 second to give the reader time to process the command before it responds
    Start = Timer
    Do
    Loop Until (Timer - Start) > 0.1
    If Form1.GetResponse() = False Then
        'label_Status.Caption = "Waiting for Command"
        textbox_MaxFreq.Text = "<Read Fail>"
        Exit Sub
    Else
        If Mid(Form1.Response$, 2, 2) <> comand$ Then
            'label_Status.Caption = "Waiting for Command"
            textbox_MaxFreq.Text = "<Read Fail>"
            Exit Sub
        End If
    End If
    ' the read mem (read sys) command passed.
    ' now format and display the data in the text box
    
    ' build the text box
    hexByte0$ = Mid$(Form1.Response$, 10, 2)
    hexByte1$ = Mid$(Form1.Response$, 8, 2)
    hexByte2$ = Mid$(Form1.Response$, 6, 2)
    hexByte3$ = Mid$(Form1.Response$, 4, 2)
    
    freqData$ = "&H" & hexByte0$ & hexByte1$ & hexByte2$ & hexByte3$
    'Dim abc As Double
    
    abc = CLng(Val(freqData$))
    longFreeq$ = Str$(abc)
    hex1$ = Mid$(longFreeq$, 2, 3)
    hex2$ = Mid$(longFreeq$, 5, 3)
    textbox_MaxFreq.Text = hex1$ & "." & hex2$
    
    '******************************************************************************
    ' FREQUENCY STEP SIZE - param 11
    '
    '  This will read 2 bytes from the M8 and reconstruct something like 915.875
    '
    '******************************************************************************
    strtBlk$ = "11"
    nbBlks$ = "01"
    crc$ = Form1.calculateCRC(flags$ & comand$ & strtBlk$ & nbBlks$)
    Form1.MSComm1.Output = vbCr & flags$ & comand$ & strtBlk$ & nbBlks$ & crc$ & vbCr
    ' wait .1 second to give the reader time to process the command before it responds
    Start = Timer
    Do
    Loop Until (Timer - Start) > 0.1
    If Form1.GetResponse() = False Then
        'label_Status.Caption = "Waiting for Command"
        textbox_StepSize.Text = "<Read Fail>"
        Exit Sub
    Else
        If Mid(Form1.Response$, 2, 2) <> comand$ Then
            'label_Status.Caption = "Waiting for Command"
            textbox_StepSize.Text = "<Write Fail>"
            Exit Sub
        End If
    End If
    ' the read mem (read sys) command passed.
    ' now format and display the data in the text box

    ' build the text box
    If Mid$(Form1.Response$, 4, 2) = "00" Then
        textbox_StepSize.Text = "10"
    ElseIf Mid$(Form1.Response$, 4, 2) = "01" Then
        textbox_StepSize.Text = "25"
    ElseIf Mid$(Form1.Response$, 4, 2) = "02" Then
        textbox_StepSize.Text = "50"
    ElseIf Mid$(Form1.Response$, 4, 2) = "03" Then
        textbox_StepSize.Text = "100"
    Else
        textbox_StepSize.Text = "200"
    End If
    
    

    '******************************************************************************
    ' POWER - param 16
    '******************************************************************************
    strtBlk$ = "16"
    
    crc$ = Form1.calculateCRC(flags$ & comand$ & strtBlk$ & nbBlks$)
    Form1.MSComm1.Output = vbCr & flags$ & comand$ & strtBlk$ & nbBlks$ & crc$ & vbCr
    ' wait .1 second to give the reader time to process the command before it responds
    Start = Timer
    Do
    Loop Until (Timer - Start) > 0.2
    If Form1.GetResponse() = False Then
        'label_Status.Caption = "Waiting for Command"
        textbox_Pwr.Text = "<Read Fail>"
        Exit Sub
    Else
        If Mid(Form1.Response$, 2, 2) <> comand$ Then
            'label_Status.Caption = "Waiting for Command"
            textbox_Pwr.Text = "<Read Fail>"
            Exit Sub
        End If
    End If
    ' the read mem (read sys) command passed.
    ' now format and display the data in the text box

    ' update the text box for Pwr
    retPwrData = Val("&H" & (Mid$(Form1.Response, 4, 2)))
    
    newPwrData = Int(retPwrData)
    ' Need to convert from Hex to 12-27dBm values
    newPwrData = ((CDec(newPwrData) / 10) + 12)
    
    textbox_Pwr.Text = newPwrData
    ' This will display text for the format 12.1 (limits 12-27dBm)
    

    
    
    '******************************************************************************
    ' MODULATION DEPTH - param addr 17
    '******************************************************************************
    
    strtBlk$ = "17"
    
    crc$ = Form1.calculateCRC(flags$ & comand$ & strtBlk$ & nbBlks$)
    Form1.MSComm1.Output = vbCr & flags$ & comand$ & strtBlk$ & nbBlks$ & crc$ & vbCr
    '' wait .1 second to give the reader time to process the command before it responds
    Start = Timer
    Do
    Loop Until (Timer - Start) > 0.2
    If Form1.GetResponse() = False Then
        'label_Status.Caption = "Waiting for Command"
        textbox_ModDepth.Text = "<Read Fail>"
        Exit Sub
    Else
        If Mid(Form1.Response$, 2, 2) <> comand$ Then
            'label_Status.Caption = "Waiting for Command"
            textbox_ModDepth.Text = "<Read Fail>"
            Exit Sub
        End If
    End If
    '' the read mem (read sys) command passed.
    '' now format and display the data in the text box'
    newModVal = Val("&H" & Mid$(Form1.Response, 4, 2))
   
    newModVal = Int(newModVal)
    
    textbox_ModDepth.Text = newModVal
    ' This will display text in the format 10 (10-100)%
    
    
    
    '******************************************************************************
    ' RISE AND FALL TIMES
    '******************************************************************************
    
    ' not yet supported
    
    'label_Status.Caption = "Waiting For Command"

End Sub


'Private Function setStatus(inputString)
'    label_Status.Caption = inputString
'    DoEvents
'    Start = Timer
'    Do
'    Loop Until (Timer - Start) > 0.5
'End Function

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -