Professional Documents
Culture Documents
Objective:
The objectives of this tutorial are to learn how ActiveRobot commands can be used from within
Visual Basic to control the CRS robot.
control the CRS robot using commands from the ActiveRobot Library
transfer files from the CRS controller to the PC using ActiveRobot Explorer
Preparation:
Review the “BASIC Programming Quick Reference” and the ActiveRobot manuals.
Read over the lab to gain an understanding of what the code will do
Note:
Before using an ActiveRobot application to control the CRS robot, control of the robot must be
passed from the pendant to the terminal.
2. In the New Project dialog box, click Standard EXE then click Open.
4. In the Available References list, check off CRS ActiveRobot Type Library then click OK.
In Visual Basic, you start by laying out the elements for the user interface.
5. On the Toolbox, double-click on the CommandButton to add a command button to the form.
Add 3 more command buttons and arrange them on the form.
Use a naming convention to keep track of controls and make the code easier to follow. A
standard convention is to use a 3 letter prefix that indicates the type of control. For example:
Notice the name of the subroutine. This subroutine will run whenever the control named
cmdOK receives a Click event.
6. Create the code for the grip open and grip close buttons.
Double-click on the Open Gripper button. This creates a new blank subroutine for the
default event of a control. In this case, the default event is the click event.
Robot.GripperOpen 40
Create a new subroutine for the Close Gripper button and add the code to close the
gripper.
7. Create an event handler subroutine for the Jog Axis 1 button and add the following code:
Robot.Joint 1,5 'jog joint 1 by 5 degrees
3. In the code window, change the code for the Jog Axis button event handler.
Note: The name of a text box refers to its value. CDbl converts the text from the text box
to a double (real) number.
4. Run the program again. Try entering different angles. Click OK when done.
3. Add code to display the coordinates in the label when the user clicks the Position button.
Private Sub cmdGetPosition_Click()
Dim loc As New CRSLocation
Set loc = Robot.WorldLocation(ptActual)
lblPosition = CStr(loc.x) & "," & CStr(loc.y) & "," & CStr(loc.z)
End Sub
Note: CStr converts a real number to a string so the numbers can be joined into a string
with commas between the coordinates. The & joins strings together. To format numbers
(control number of decimals, etc.), use Format instead of CStr e.g Format(loc.x, "#.00").
4. Run the program and test the function.
End Sub
Note: The v3 file must be in the same folder as the application (App.Path & "\points.v3").
Call EnableButtons
Exit Sub
Error_Handler:
MsgBox "Error occurred:" & Err.Description
End Sub
Problem
Write a VB program that will implement the following task using ActiveRobot:
1) wait for a block to be detected on the slide by the optical sensor (the block can be
placed manually))
2) activate the slide to move the block to the robot pickup location
3) pickup the block using the robot arm, and move to the ready position
4) drop the block
5) repeat the sequence, starting at step 1