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

📄 frmmain.frm

📁 850运动控制卡的详细开发资料
💻 FRM
📖 第 1 页 / 共 4 页
字号:

      Loop
      

'最后一段
    If m_bEqualityVelocity Then inp_dec_enable 0, no
    DemoInpMove
 
    
    Do While True
    
     get_stopdata cardno, ch, nstate1
     If nstate1 <> 0 Then GoTo err
     get_inp_status cardno, no, nstate2
     If nstate2 = 0 Then Exit Do
     DoEvents
    
    Loop


  Exit Sub
    
err:
    
     
   MsgBox "error"
   
      
   
   
End Sub

Private Sub btnDetailSetting_Click()
   frmSetting.Show vbModal, frmMain
   
   btnPMove.Enabled = True
   btnContinueMove.Enabled = True
End Sub

Private Sub btnExit_Click()


    sudden_stop cardno, 1
    sudden_stop cardno, 2
    sudden_stop cardno, 3
    sudden_stop cardno, 4

   End

End Sub

Private Sub btnPMove_Click()
If Not m_bEnableDemo_x And Not m_bEnableDemo_z And m_bIsTwoAxisInp Then
  MsgBox "请选择插补轴!"
  Exit Sub
End If
If Timer1.Enabled = False Then Timer1.Enabled = True
  
m_bIsContinueInp = False  '单个插补
'范围设定数据更新
set_range cardno, 1, 8000000 / m_nRatio_x
set_range cardno, 2, 8000000 / m_nRatio_y
set_range cardno, 3, 8000000 / m_nRatio_z
set_range cardno, 4, 8000000 / m_nRatio_w

'三轴插补和四轴插补时Z的倍率应设置成与X轴一样
If Not m_bIsTwoAxisInp Then set_range cardno, 3, 8000000 / m_nRatio_x



SetSpeed
If Not m_bEqualityVelocity Then SetAddSpeed
DemoInpMove

End Sub

Private Sub btnStop_Click()

    sudden_stop cardno, 1
    sudden_stop cardno, 2
    sudden_stop cardno, 3
    sudden_stop cardno, 4

 
End Sub

Private Sub chkCurve_S_Click()
If chkCurve_S.value = vbChecked Then
   m_bEnableCurve_S_Move = True
Else
   m_bEnableCurve_S_Move = False
End If

End Sub

Private Sub chkDemo_w_Click()
Dim i As Integer
   If chkDemo_w.value = vbChecked Then
       m_bEnableDemo_w = True
       txtPulseCount_w.BackColor = &H80000005
      
   Else
       m_bEnableDemo_w = False
       txtPulseCount_w.BackColor = &H8000000B
      
           sudden_stop cardno, 4
      
   End If
    txtPulseCount_w.Locked = Not m_bEnableDemo_w
End Sub

Private Sub chkDemo_x_Click()
Dim i As Integer
    If chkDemo_x.value = vbChecked Then
       m_bEnableDemo_x = True
       txtPulseCount_x.BackColor = &H80000005
  
    Else
       m_bEnableDemo_x = False
       txtPulseCount_x.BackColor = &H8000000B
       

           sudden_stop cardno, 1

   End If
       If m_bIsTwoAxisInp And m_bEnableDemo_x Then
         
          m_bEnableDemo_y = True
          txtPulseCount_y.BackColor = &H80000005
          
          
          chkDemo_z.Enabled = False
          chkDemo_w.Enabled = True
          chkDemo_w.value = False
          chkDemo_w.Enabled = False

        End If
        
        
       If m_bIsTwoAxisInp And Not m_bEnableDemo_x Then optnTwoAxisInp_Click
       
       
       
   
   
    txtPulseCount_x.Locked = Not m_bEnableDemo_x
End Sub

Private Sub chkDemo_y_Click()
    Dim i As Integer
    If chkDemo_y.value = vbChecked Then
       m_bEnableDemo_y = True
       txtPulseCount_y.BackColor = &H80000005
       
      
   Else
       m_bEnableDemo_y = False
       txtPulseCount_y.BackColor = &H8000000B
           sudden_stop cardno, 2
     
   End If
    txtPulseCount_y.Locked = Not m_bEnableDemo_y
End Sub

Private Sub chkDemo_z_Click()
Dim i As Integer

    If chkDemo_z.value = vbChecked Then
       m_bEnableDemo_z = True
       txtPulseCount_z.BackColor = &H80000005
         
        
        
      
   Else
       m_bEnableDemo_z = False
       txtPulseCount_z.BackColor = &H8000000B

           sudden_stop cardno, 3
       
   End If
   
   If m_bIsTwoAxisInp And m_bEnableDemo_z Then
         
          m_bEnableDemo_w = True
          txtPulseCount_w.BackColor = &H80000005
          
          
          chkDemo_x.Enabled = False
          chkDemo_y.Enabled = True
          chkDemo_y.value = False
          chkDemo_y.Enabled = False

        End If
        
        
       If m_bIsTwoAxisInp And Not m_bEnableDemo_z Then optnTwoAxisInp_Click
   txtPulseCount_z.Locked = Not m_bEnableDemo_z
End Sub

Private Sub chkSymmetryAcc_w_Click()
   If chkSymmetryAcc_w.value = vbChecked Then
       m_bEnableSymmetry_Acc_w = True
   Else
       m_bEnableSymmetry_Acc_w = False
   End If
End Sub

Private Sub chkSymmetryAcc_x_Click()
   If chkSymmetryAcc_x.value = vbChecked Then
       m_bEnableSymmetry_Acc_x = True
   Else
       m_bEnableSymmetry_Acc_x = False
   End If
End Sub

Private Sub chkSymmetryAcc_y_Click()
   If chkSymmetryAcc_y.value = vbChecked Then
       m_bEnableSymmetry_Acc_y = True
   Else
       m_bEnableSymmetry_Acc_y = False
   End If
End Sub

Private Sub chkSymmetryAcc_z_Click()
   If chkSymmetryAcc_z.value = vbChecked Then
       m_bEnableSymmetry_Acc_z = True
   Else
       m_bEnableSymmetry_Acc_z = False
   End If
End Sub

Private Sub Form_Load()
'   public variable is initialed here
   m_bEqualityVelocity = False
   m_bIsInpLine = True
   m_bEnableCurve_S_Move = False
   m_bIsContinueInp = False
   m_bIsTwoAxisInp = True
   m_bIsThreeAxisInp = False
   m_bIsFourAxisInp = False


   
   
   
   m_nStartV_x = 500
   m_nStartV_y = 500
   m_nStartV_z = 500
   m_nStartV_w = 500

   m_nDriveSpeed_x = 2000
   m_nDriveSpeed_y = 2000
   m_nDriveSpeed_z = 2000
   m_nDriveSpeed_w = 2000
   
   m_nVelocityAcc_x = 200
   m_nVelocityAcc_y = 200
   m_nVelocityAcc_z = 200
   m_nVelocityAcc_w = 200
   
   m_nVelocityDec_x = 200
   m_nVelocityDec_y = 200
   m_nVelocityDec_z = 200
   m_nVelocityDec_w = 200
   
   m_nRatio_x = 5
   m_nRatio_y = 5
   m_nRatio_z = 5
   m_nRatio_w = 5

   m_fAccTime_w = (m_nDriveSpeed_w - m_nStartV_w) / m_nVelocityAcc_w
   m_fAccTime_x = (m_nDriveSpeed_x - m_nStartV_x) / m_nVelocityAcc_x
   m_fAccTime_y = (m_nDriveSpeed_y - m_nStartV_y) / m_nVelocityAcc_y
   m_fAccTime_z = (m_nDriveSpeed_z - m_nStartV_z) / m_nVelocityAcc_z
' the variable of form level is initialed here
   m_bEnableDemo_w = False
   m_bEnableDemo_x = False
   m_bEnableDemo_y = False
   m_bEnableDemo_z = False
   
   m_bEnableSymmetry_Acc_w = False
   m_bEnableSymmetry_Acc_x = False
   m_bEnableSymmetry_Acc_y = False
   m_bEnableSymmetry_Acc_z = False
   
   m_bEnableCurve_S_Move = False
   
   cardno = 0
   Init850Card
   btnPMove.Enabled = True
   btnContinueMove.Enabled = True
   optnTwoAxisInp.value = True
   Timer1.Enabled = True
   
   
   
   
End Sub

Private Sub Init850Card()
   Const nCoefficient = 8000000
   
  Dim count As Integer
  
  count = adt850_initial
  
  
 
  
   

   
   If count < 1 Then
   
      MsgBox "850控制卡未安装"
      
   '   End
      
   End If

   
   Dim nValue As Long
 
   
           set_command_pos cardno, 1, 0
           set_command_pos cardno, 2, 0
           set_command_pos cardno, 3, 0
           set_command_pos cardno, 4, 0
'------------------倍率=8000000/R-----------------------------------------
'函数set_range()中的最后一个参数 由R=8000000/倍率来确定.
'------------------设置倍率参数-------------------------------------------
           
           nValue = nCoefficient / m_nRatio_x
           set_range cardno, 1, nValue

           nValue = nCoefficient / m_nRatio_y
           set_range cardno, 2, nValue

           nValue = nCoefficient / m_nRatio_z
           set_range cardno, 3, nValue

           nValue = nCoefficient / m_nRatio_w
           set_range cardno, 4, nValue


'------------------设置起始速度-------------------------------------------
           nValue = m_nStartV_x / m_nRatio_x
           set_startv cardno, 1, nValue
           
           nValue = m_nStartV_y / m_nRatio_y
           set_startv cardno, 2, nValue

           nValue = m_nStartV_z / m_nRatio_z
           set_startv cardno, 3, nValue

           nValue = m_nStartV_w / m_nRatio_w
           set_startv cardno, 4, nValue

'------------------设置驱动速度-------------------------------------------
           nValue = m_nDriveSpeed_x / m_nRatio_x
           set_speed cardno, 1, nValue
           
           nValue = m_nDriveSpeed_y / m_nRatio_y
           set_speed cardno, 2, nValue

           nValue = m_nDriveSpeed_z / m_nRatio_z
           set_speed cardno, 3, nValue

           nValue = m_nDriveSpeed_w / m_nRatio_w
           set_speed cardno, 4, nValue



End Sub
Private Function EnableWindow(ByVal bEnable As Boolean)
   chkCurve_S.Enabled = bEnable
   chkSymmetryAcc_x.Enabled = bEnable
   chkSymmetryAcc_y.Enabled = bEnable
   chkSymmetryAcc_z.Enabled = bEnable
   chkSymmetryAcc_w.Enabled = bEnable
   frmeMoveType.Enabled = bEnable
       
End Function
Private Sub chkAccInpMove_Click()



 m_bEqualityVelocity = Not m_bEqualityVelocity

 EnableWindow m_bEqualityVelocity
End Sub




Private Sub optnCircleInpMove_Click()
   m_bIsInpLine = False
   labLine.Visible = False

   labCircle.Visible = True
   optnTwoAxisInp.value = True
   
 optnTwoAxisInp.Enabled = False
   optnThreeAxisInp.Enabled = False
   optnFourAxisInp.Enabled = False
   
     
   
End Sub

Private Sub optnFourAxisInp_Click()
   m_bIsTwoAxisInp = False
   m_bIsThreeAxisInp = False
   m_bIsFourAxisInp = True
   
   chkDemo_x.value = vbChecked
   m_bEnableDemo_x = True
   chkDemo_x.Enabled = False
   txtPulseCount_x.BackColor = &H80000005
   
   chkDemo_y.value = vbChecked
   m_bEnableDemo_y = True
   chkDemo_y.Enabled = False
   txtPulseCount_y.BackColor = &H80000005
   
   chkDemo_z.value = vbChecked
   m_bEnableDemo_z = True
   chkDemo_z.Enabled = False
   txtPulseCount_z.BackColor = &H80000005
   
   chkDemo_w.value = vbChecked
   m_bEnableDemo_w = True
   chkDemo_w.Enabled = False
   txtPulseCount_w.BackColor = &H80000005
   
End Sub

Private Sub optnLineInpMove_Click()

Dim bEnable As Boolean


   labLine.Visible = True

   labCircle.Visible = False
   
   m_bIsInpLine = True

   bEnable = False
  optnTwoAxisInp.Enabled = True
     optnThreeAxisInp.Enabled = True
     optnFourAxisInp.Enabled = True
     

   EnableWindow bEnable

End Sub

Private Sub StopAllAxis()

               If m_bEnableDemo_x = True Then sudden_stop cardno, 1
               If m_bEnableDemo_y = True Then sudden_stop cardno, 2
               If m_bEnableDemo_z = True Then sudden_stop cardno, 3
               If m_bEnableDemo_w = True Then sudden_stop cardno, 4
  
End Sub

Private Sub SetAllAxisLogicPos()

               If m_bEnableDemo_x = True Then set_command_pos cardno, 1, 0
               If m_bEnableDemo_y = True Then set_command_pos cardno, 2, 0
               If m_bEnableDemo_z = True Then set_command_pos cardno, 3, 0

⌨️ 快捷键说明

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