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

📄 frmfindsenseresistor.frm

📁 利用VB开发的针对Maxim-Dallas DS2770电量检测芯片
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmFindSenseResistor 
   Caption         =   "Find Sense Resistor"
   ClientHeight    =   2355
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4725
   Icon            =   "frmFindSenseResistor.frx":0000
   LinkTopic       =   "Form1"
   Picture         =   "frmFindSenseResistor.frx":030A
   ScaleHeight     =   2355
   ScaleWidth      =   4725
   StartUpPosition =   1  'CenterOwner
   Begin VB.CommandButton cmdCancel 
      Caption         =   "Cancel"
      Height          =   375
      Left            =   1440
      TabIndex        =   11
      Top             =   1920
      Width           =   1575
   End
   Begin VB.CommandButton cmdOK 
      Caption         =   "OK"
      Height          =   375
      Left            =   3120
      TabIndex        =   10
      Top             =   1920
      Width           =   1575
   End
   Begin VB.Frame Frame1 
      Height          =   1815
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   4695
      Begin VB.CommandButton cmdCalculateResistor 
         Caption         =   "Calculate Resistor"
         Height          =   375
         Left            =   120
         TabIndex        =   9
         Top             =   1240
         Width           =   1575
      End
      Begin VB.TextBox txtForcedCurrent 
         Height          =   285
         Left            =   2040
         TabIndex        =   1
         Text            =   "1000"
         Top             =   320
         Width           =   855
      End
      Begin VB.Label Label1 
         BackStyle       =   0  'Transparent
         Caption         =   "mAmps"
         Height          =   255
         Left            =   3240
         TabIndex        =   8
         Top             =   360
         Width           =   1095
      End
      Begin VB.Label Label2 
         BackStyle       =   0  'Transparent
         Caption         =   "Current Forced"
         Height          =   255
         Left            =   240
         TabIndex        =   7
         Top             =   360
         Width           =   1215
      End
      Begin VB.Label lblCurrentRegister 
         BackStyle       =   0  'Transparent
         Caption         =   "0.00"
         Height          =   255
         Left            =   2160
         TabIndex        =   6
         Top             =   840
         Width           =   735
      End
      Begin VB.Label Label3 
         BackStyle       =   0  'Transparent
         Caption         =   "mVolts"
         Height          =   255
         Left            =   3240
         TabIndex        =   5
         Top             =   840
         Width           =   975
      End
      Begin VB.Label Label4 
         BackStyle       =   0  'Transparent
         Caption         =   "Volts Measured"
         Height          =   255
         Left            =   240
         TabIndex        =   4
         Top             =   840
         Width           =   1335
      End
      Begin VB.Label lblResistor 
         BackStyle       =   0  'Transparent
         Caption         =   "0.00"
         Height          =   255
         Left            =   2160
         TabIndex        =   3
         Top             =   1320
         Width           =   735
      End
      Begin VB.Label Label6 
         BackStyle       =   0  'Transparent
         Caption         =   "mOhms"
         Height          =   255
         Left            =   3240
         TabIndex        =   2
         Top             =   1320
         Width           =   975
      End
   End
End
Attribute VB_Name = "frmFindSenseResistor"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim VRegister As Single
Dim ACurrent As Single
Public OResistor As Single
Public Updated As Boolean

Private Sub cmdCalculateResistor_Click()

    ReadCurrent
    ACurrent = Val(txtForcedCurrent.Text) / 1000
    If ACurrent = 0 Then
        MsgBox "Current cannot be 0"
        ACurrent = 100
        txtForcedCurrent.Text = ACurrent
    ElseIf (VRegister < 0.0001) And (VRegister > -0.0001) Then
        MsgBox "No current is detected."
    Else
        OResistor = VRegister / ACurrent
        lblResistor.Caption = Format(OResistor * 1000, "#0.00")
    End If
End Sub

Private Sub cmdCancel_Click()
    Updated = False
    Unload Me
End Sub

Private Sub cmdOK_Click()
    Updated = True
    Unload Me
End Sub

Private Sub Form_Load()
    OResistor = SenseResistor
    lblResistor.Caption = Format(OResistor * 1000, "#0.00")
End Sub

Private Sub ReadCurrent()
Dim temp As Long
    ReadRealTime
    temp = gCurrentMSB
    If gCurrentMSB > 127 Then
        VRegister = (((temp * 256) + gCurrentLSB - 65536) And &HFFFF) * 0.0000015625
    Else
        VRegister = (((temp * 256) + gCurrentLSB) And &HFFFF) * 0.0000015625
    
    End If
    
    lblCurrentRegister.Caption = Format(VRegister, "0.00000")
End Sub

⌨️ 快捷键说明

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