📄 frmmain.frm
字号:
If m_bEnableDemo_w = True Then set_command_pos cardno, 4, 0
End Sub
Private Sub CheckAxisStatus()
Dim state As Long
Dim value As Long
state = -1
If m_bEnableDemo_x = True Then
While (state <> 0)
value = get_status(cardno, 1, state)
Wend
state = -1
End If
If m_bEnableDemo_y = True Then
While (state <> 0)
value = get_status(cardno, 2, state)
Wend
state = -1
End If
If m_bEnableDemo_z = True Then
While (state <> 0)
value = get_status(cardno, 3, state)
Wend
state = -1
End If
If m_bEnableDemo_w = True Then
While (state <> 0)
value = get_status(cardno, 4, state)
Wend
state = -1
End If
End Sub
Private Sub optnThreeAxisInp_Click()
m_bIsTwoAxisInp = False
m_bIsThreeAxisInp = True
m_bIsFourAxisInp = False
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 = False
m_bEnableDemo_w = False
chkDemo_w.Enabled = False
txtPulseCount_w.BackColor = &H8000000B
End Sub
Private Sub optnTwoAxisInp_Click()
m_bIsTwoAxisInp = True
m_bIsThreeAxisInp = False
m_bIsFourAxisInp = False
chkDemo_x.Enabled = True
chkDemo_x.value = False
chkDemo_y.value = vbChecked
chkDemo_y.Enabled = False
txtPulseCount_y.BackColor = &H8000000B
chkDemo_z.Enabled = True
chkDemo_z.value = False
chkDemo_w.value = vbChecked
chkDemo_w.Enabled = False
txtPulseCount_w.BackColor = &H8000000B
End Sub
Private Sub Timer1_Timer()
Dim value As Long
If m_bEnableDemo_x Then
value = get_command_pos(cardno, 1, m_nLogicPos_x)
End If
If m_bEnableDemo_y Then
value = get_command_pos(cardno, 2, m_nLogicPos_y)
End If
If m_bEnableDemo_z Then
value = get_command_pos(cardno, 3, m_nLogicPos_z)
End If
If m_bEnableDemo_w Then
value = get_command_pos(cardno, 4, m_nLogicPos_w)
End If
If (m_bIsInpLine) Then
If (m_bIsTwoAxisInp) Then
If m_bEnableDemo_x Then get_speed cardno, 1, m_nCurrentSpeed_x
If m_bEnableDemo_z Then get_speed cardno, 3, m_nCurrentSpeed_z
End If
If m_bIsThreeAxisInp Then
If m_bEnableDemo_x Then get_speed cardno, 1, m_nCurrentSpeed_x
End If
If m_bIsFourAxisInp Then
If m_bEnableDemo_x Then get_speed cardno, 1, m_nCurrentSpeed_x
End If
Else
If m_bIsTwoAxisInp Then
If m_bEnableDemo_x Then get_speed cardno, 1, m_nCurrentSpeed_x
If m_bEnableDemo_z Then get_speed cardno, 3, m_nCurrentSpeed_z
Else
End If
End If
txtLogicPos_x.Text = CStr(m_nLogicPos_x)
txtCurrentSpeed_x.Text = CStr(m_nCurrentSpeed_x * m_nRatio_x)
txtLogicPos_y.Text = CStr(m_nLogicPos_y)
txtCurrentSpeed_y.Text = CStr(m_nCurrentSpeed_y * m_nRatio_y)
txtLogicPos_z.Text = CStr(m_nLogicPos_z)
txtCurrentSpeed_z.Text = CStr(m_nCurrentSpeed_z * m_nRatio_z)
txtLogicPos_w.Text = CStr(m_nLogicPos_w)
txtCurrentSpeed_w.Text = CStr(m_nCurrentSpeed_w * m_nRatio_w)
Dim state As Long
state = -1
If m_bIsTwoAxisInp And m_bEnableDemo_z Then
get_inp_status cardno, 2, state
Else
get_inp_status cardno, 1, state
End If
If state = 1 Then
btnPMove.Enabled = False
btnContinueMove.Enabled = False
btnExit.Enabled = False
btnDetailSetting.Enabled = False
btnClear.Enabled = False
optnLineInpMove.Enabled = False
optnCircleInpMove.Enabled = False
chkAccInpMove.Enabled = False
optnTwoAxisInp.Enabled = False
optnThreeAxisInp.Enabled = False
optnFourAxisInp.Enabled = False
chkDemo_x.Enabled = False
chkDemo_y.Enabled = False
chkDemo_z.Enabled = False
chkDemo_w.Enabled = False
txtPulseCount_x.Enabled = False
txtPulseCount_y.Enabled = False
txtPulseCount_z.Enabled = False
txtPulseCount_w.Enabled = False
EnableWindow False
End If
If state = 0 Then
btnPMove.Enabled = True
btnContinueMove.Enabled = True
btnExit.Enabled = True
btnDetailSetting.Enabled = True
btnClear.Enabled = True
optnLineInpMove.Enabled = True
optnCircleInpMove.Enabled = True
chkAccInpMove.Enabled = True
If m_bIsInpLine Then
optnTwoAxisInp.Enabled = True
optnThreeAxisInp.Enabled = True
optnFourAxisInp.Enabled = True
Else
optnTwoAxisInp.Enabled = False
optnThreeAxisInp.Enabled = False
optnFourAxisInp.Enabled = False
End If
If m_bIsTwoAxisInp Then
If m_bEnableDemo_x Then chkDemo_x.Enabled = True
If m_bEnableDemo_z Then chkDemo_z.Enabled = True
End If
EnableWindow m_bEqualityVelocity
If m_bEnableDemo_x Then txtPulseCount_x.Enabled = True
If m_bEnableDemo_y Then txtPulseCount_y.Enabled = True
If m_bEnableDemo_z Then txtPulseCount_z.Enabled = True
If m_bEnableDemo_w Then txtPulseCount_w.Enabled = True
End If
End Sub
Private Sub DemoInpMove()
m_nPulseCount_x = CLng(txtPulseCount_x.Text)
m_nPulseCount_y = CLng(txtPulseCount_y.Text)
m_nPulseCount_z = CLng(txtPulseCount_z.Text)
m_nPulseCount_w = CLng(txtPulseCount_w.Text)
If (m_bIsInpLine) Then '//直线插补
If (m_bIsTwoAxisInp) Then
If (m_bEnableDemo_x) Then inp_move2 cardno, 1, m_nPulseCount_x, m_nPulseCount_y
If (m_bEnableDemo_z) Then inp_move2 cardno, 2, m_nPulseCount_z, m_nPulseCount_w
End If
If (m_bIsThreeAxisInp) Then
If (m_bEnableDemo_x) Then inp_move3 cardno, m_nPulseCount_x, m_nPulseCount_y, m_nPulseCount_z
End If
If (m_bIsFourAxisInp) Then
If (m_bEnableDemo_x) Then inp_move4 cardno, m_nPulseCount_x, m_nPulseCount_y, m_nPulseCount_z, m_nPulseCount_w
End If
Else '//圆弧插补
If (m_bIsTwoAxisInp) Then
If (m_bEnableDemo_x) Then inp_cw_arc cardno, 1, m_nPulseCount_x, m_nPulseCount_y, 0, 10000 ' //圆心(0,10000) 半径R=10000
If (m_bEnableDemo_z) Then inp_ccw_arc cardno, 2, m_nPulseCount_z, m_nPulseCount_w, 10000, 0 '//圆心(10000,0) 半径R=10000
Else '目前演示程序,不支持圆弧的三轴插补
End If
End If
End Sub
Private Sub SetAddSpeed()
Dim nValue As Long
m_nPulseCount_x = CLng(txtPulseCount_x.Text)
m_nPulseCount_y = CLng(txtPulseCount_y.Text)
m_nPulseCount_z = CLng(txtPulseCount_z.Text)
m_nPulseCount_w = CLng(txtPulseCount_w.Text)
If Not m_bEqualityVelocity Then '加/减速运动
Dim bMode_Acc As Byte
bMode_Acc = IIf(m_bEnableCurve_S_Move, 1, 0)
'---------------设为梯形/S形加减速.0为梯形,1为S形----------------------
set_ad_mode cardno, 1, bMode_Acc
set_ad_mode cardno, 2, bMode_Acc
set_ad_mode cardno, 3, bMode_Acc
set_ad_mode cardno, 4, bMode_Acc
'---------------对每轴设置,对称加减速/非对称加减速,0为对称,1为非对称----------------
bMode_Acc = IIf(m_bEnableSymmetry_Acc_x, 1, 0)
set_dec1_mode cardno, 1, bMode_Acc
bMode_Acc = IIf(m_bEnableSymmetry_Acc_y, 1, 0)
set_dec1_mode cardno, 2, bMode_Acc
bMode_Acc = IIf(m_bEnableSymmetry_Acc_z, 1, 0)
set_dec1_mode cardno, 3, bMode_Acc
bMode_Acc = IIf(m_bEnableSymmetry_Acc_w, 1, 0)
set_dec1_mode cardno, 4, bMode_Acc
'-----------------------采用自动减速方式-------------------------------------------------
Dim j As Integer
For j = 1 To 4
set_dec2_mode cardno, j, 0
Next j
'---------------------------采用手动减速方式-------------------
Dim nDecPos As Long
If m_bIsInpLine Then
If m_bIsContinueInp Then
set_dec2_mode cardno, 1, 1
'nDecPos = 1500 - (m_nDriveSpeed_x + m_nStartV_x) * (m_fAccTime_x / 2)
nDecPos = m_nPulseCount_x - (m_nDriveSpeed_x + m_nStartV_x) * (m_fAccTime_x / 2)
set_dec_pos cardno, 1, nDecPos
If m_bEnableDemo_z And m_bIsTwoAxisInp Then
set_dec2_mode cardno, 3, 1
' nDecPos = 1500 - (m_nDriveSpeed_z + m_nStartV_z) * (m_fAccTime_z / 2)
nDecPos = m_nPulseCount_z - (m_nDriveSpeed_z + m_nStartV_z) * (m_fAccTime_z / 2)
set_dec_pos cardno, 3, nDecPos
End If
Else
set_dec2_mode cardno, 1, 0
If m_bEnableDemo_z And m_bIsTwoAxisInp Then set_dec2_mode cardno, 3, 0
End If
Else
Dim nPulseCount As Long
nPulseCount = (10000 / 1.414) * 8
set_dec2_mode cardno, 1, 1
nDecPos = nPulseCount - (m_nDriveSpeed_x + m_nStartV_x) * (m_fAccTime_x / 2)
set_dec_pos cardno, 1, nDecPos
If m_bEnableDemo_z And m_bIsTwoAxisInp Then
set_dec2_mode cardno, 3, 1
nDecPos = nPulseCount - (m_nDriveSpeed_z + m_nStartV_z) * (m_fAccTime_z / 2)
set_dec_pos cardno, 3, nDecPos
End If
End If
'-----------------------设置每轴的加速度-----------------------------------------------
'------------加速度的实际值为nValue=m_nVelocityAcc_x*125*m_nRatio_x--------------------
set_acc cardno, 1, m_nVelocityAcc_x
'------------加速度的实际值为nValue=m_nVelocityAcc_y*125*m_nRatio_y--------------------
set_acc cardno, 2, m_nVelocityAcc_y
'------------加速度的实际值为nValue=m_nVelocityAcc_z*125*m_nRatio_z--------------------
set_acc cardno, 3, m_nVelocityAcc_z
'------------加速度的实际值为nValue=m_nVelocityAcc_w*125*m_nRatio_w--------------------
set_acc cardno, 4, m_nVelocityAcc_w
'-----------------------设置每轴的减速度-----------------------------------------------
'------------减速度的实际值为nValue=m_nVelocityDec_x*125*m_nRatio_x--------------------
set_dec cardno, 1, m_nVelocityDec_x
'------------减速度的实际值为nValue=m_nVelocityDec_y*125*m_nRatio_y--------------------
set_dec cardno, 2, m_nVelocityDec_y
'------------减速度的实际值为nValue=m_nVelocityDec_z*125*m_nRatio_z--------------------
set_dec cardno, 3, m_nVelocityDec_z
'------------减速度的实际值为nValue=m_nVelocityDec_w*125*m_nRatio_w--------------------
set_dec cardno, 4, m_nVelocityDec_w
'-----------------------如果是S形加速运动,设置速度增加率.-----------------------------
If m_bEnableCurve_S_Move Then
Dim nAccValue As Long
If m_bEnableDemo_x Then
If m_fAccTime_x = 0 Then Exit Sub
nValue = m_nVelocityAcc_x / m_fAccTime_x
nAccValue = 62500000 * m_nRatio_x / nValue
set_acac cardno, 1, nAccValue
End If
If m_bEnableDemo_z And m_bIsTwoAxisInp Then
If m_fAccTime_z = 0 Then Exit Sub
nValue = m_nVelocityAcc_z / m_fAccTime_z
nAccValue = 62500000 * m_nRatio_z / nValue
set_acac cardno, 3, nAccValue
End If
End If
End If
End Sub
Private Sub SetSpeed()
If Not m_bEqualityVelocity Then
If m_bIsTwoAxisInp Then
If m_bEnableDemo_x Then
set_startv cardno, 1, m_nDriveSpeed_x / m_nRatio_x
set_speed cardno, 1, m_nDriveSpeed_x / m_nRatio_x
End If
If m_bEnableDemo_z Then
set_startv cardno, 3, m_nDriveSpeed_z / m_nRatio_z
set_speed cardno, 3, m_nDriveSpeed_z / m_nRatio_z
End If
Else
If m_bEnableDemo_x Then
set_startv cardno, 1, m_nDriveSpeed_x / m_nRatio_x
set_speed cardno, 1, m_nDriveSpeed_x / m_nRatio_x
set_startv cardno, 3, m_nDriveSpeed_x / m_nRatio_x
set_speed cardno, 3, m_nDriveSpeed_x / m_nRatio_x
End If
End If
Else
If m_bIsTwoAxisInp Then
If m_bEnableDemo_x Then
set_startv cardno, 1, m_nStartV_x / m_nRatio_x
set_speed cardno, 1, m_nDriveSpeed_x / m_nRatio_x
End If
If m_bEnableDemo_z Then
set_startv cardno, 3, m_nStartV_z / m_nRatio_z
set_speed cardno, 3, m_nDriveSpeed_z / m_nRatio_z
End If
Else
If m_bEnableDemo_x Then
set_startv cardno, 1, m_nStartV_x / m_nRatio_x
set_speed cardno, 1, m_nDriveSpeed_x / m_nRatio_x
set_startv cardno, 3, m_nStartV_x / m_nRatio_x
set_speed cardno, 3, m_nDriveSpeed_x / m_nRatio_x
End If
End If
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -