Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Dim g_eng As CaoEngine
Dim g_ctrl As CaoController
Dim g_robot As CaoRobot
Dim g_robotVar As CaoVariable
Dim g_haltFlag As Boolean
Private Sub Command1_Click()
' Start motor if arm is stationary
If g_robotVar.Value = False Then
g_robot.Execute "Motor", Array(1, 0)
End If
End Sub
Private Sub Command2_Click()
' Stop motor if arm is stationary
If g_robotVar.Value = False Then
g_robot.Execute "Motor", Array(0, 0)
End If
End Sub
Private Sub Command3_Click()
' Stop robot
g_robot.Halt
' Record robot stop
g_haltFlag = True
End Sub
Private Sub Command4_Click()
' Do not run new operation instruction if arm is running
If g_robotVar.Value = True Then
Exit Sub
End If
g_haltFlag = False
' Run robot
g_robot.Move 1, "@P P10", "NEXT"
' Do not start next motion until previous motion is completed
Do Until g_robotVar.Value = False
DoEvents
Loop
' Do not start next motion if robot has stopped
If g_haltFlag = True Then
Exit Sub
End If
' Run robot
g_robot.Move 1, "@P P11", "NEXT"
End Sub
Private Sub Form_Load()
Set g_eng = New CaoEngine
' Connect RC: IP setting depends on your RC setting.
Set g_ctrl = g_eng.Workspaces(0).AddController("RC8", "caoProv.DENSO.RC8", "", "Server=192.168.0.1")
' Create CaoRobot object
Set g_robot = g_ctrl.AddRobot("Arm")
' Argument used to check arm running status
Set g_robotVar = g_robot.AddVariable("@BUSY_STATUS")
' Get arm control authority
g_robot.Execute "Takearm"
' Start motor
Command1_Click
End Sub
Private Sub Form_Unload(Cancel As Integer)
' Stop motor
Command2_Click
' Release arm control authority
g_robot.Execute "Givearm"
g_robot.Variables.Clear
Set g_robotVar = Nothing
g_ctrl.Robots.Clear
Set g_robot = Nothing
g_eng.Workspaces(0).Controllers.Remove g_ctrl.Index
Set g_ctrl = Nothing
Set g_eng = Nothing
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.