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

📄 form1.frm

📁 使用51单片机定时器T0产生PWM的
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "51PWM控制常数"
   ClientHeight    =   3045
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   4005
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3045
   ScaleWidth      =   4005
   ShowInTaskbar   =   0   'False
   StartUpPosition =   1  '所有者中心
   Begin VB.ComboBox txtfc 
      Height          =   300
      ItemData        =   "Form1.frx":0000
      Left            =   1560
      List            =   "Form1.frx":000D
      TabIndex        =   7
      Text            =   "12000000"
      Top             =   900
      Width           =   1455
   End
   Begin VB.TextBox txtS 
      Height          =   1035
      Left            =   1020
      MultiLine       =   -1  'True
      TabIndex        =   6
      Top             =   1380
      Width           =   2235
   End
   Begin VB.TextBox txtD 
      Height          =   255
      Left            =   2460
      MaxLength       =   2
      TabIndex        =   2
      Text            =   "50"
      Top             =   540
      Width           =   975
   End
   Begin VB.TextBox txtFrq 
      Height          =   255
      Left            =   420
      TabIndex        =   1
      Text            =   "1000"
      Top             =   540
      Width           =   975
   End
   Begin VB.CommandButton Command1 
      Caption         =   "计算"
      Default         =   -1  'True
      Height          =   315
      Left            =   1320
      TabIndex        =   0
      Top             =   2580
      Width           =   1275
   End
   Begin VB.Label Label4 
      Caption         =   "晶体振荡器"
      Height          =   255
      Left            =   420
      TabIndex        =   8
      Top             =   960
      Width           =   1095
   End
   Begin VB.Label Label3 
      Caption         =   "结果"
      Height          =   255
      Left            =   420
      TabIndex        =   5
      Top             =   1440
      Width           =   555
   End
   Begin VB.Label Label2 
      Caption         =   "占空比"
      Height          =   195
      Left            =   2460
      TabIndex        =   4
      Top             =   300
      Width           =   975
   End
   Begin VB.Label Label1 
      Caption         =   "频率"
      Height          =   195
      Left            =   420
      TabIndex        =   3
      Top             =   300
      Width           =   1035
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub Command1_Click()
    Dim f0 As Double
    Dim f, d As Double
    Dim T1, T2 As Long
    Dim TIMEHH As Long
    Dim TIMEHL As Long
    Dim TIMELH As Long
    Dim TIMELL As Long
    Dim TIMEH As Long
    Dim TIMEL As Long
    f0 = Val(txtfc.Text)
    f = Val(txtFrq.Text)
    d = Val(txtD.Text)
    
    If f0 = 0 Then
        txtfc.Text = ""
        txtfc.SetFocus
        Exit Sub
    End If
    If f = 0 Then
        txtFrq.Text = ""
        txtFrq.SetFocus
        Exit Sub
    End If
    If d = 0 Then
        txtD.Text = ""
        txtD.SetFocus
        Exit Sub
    End If
    d = d / 100#
    TIMEH = 65536# - f0 * d / (12# * f)
    TIMEL = 65536# - f0 * (1# - d) / (12# * f)
    TIMEHH = TIMEH \ 256
    TIMEHL = TIMEH And 255
    TIMELH = TIMEL \ 256
    TIMELL = TIMEL And 255
    
    txtS.Text = Hex(TIMEHH) + " " + Hex(TIMEHL) + " " + Hex(TIMELH) + " " + Hex(TIMELL)
    txtS.Text = txtS.Text + vbCrLf + Hex(TIMEH) + " " + Hex(TIMEL)
End Sub

⌨️ 快捷键说明

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