Please read our Legal Disclaimer before executing any steps on this article.
Overview
In ORiN2 SDK, DCOM (Distributed Component Object Model) of Microsoft Corporation is adopted as a distributed object technology. The DCOM based CAO can be used from various program languages such as C++, JAVA, and Visual Basic.
This article is meant to help to gather information on resources that can help you get started with interfacing with the CAO Engine in Visual Basic. This article is not intended to aid you with programming in Visual Basic nor how to use VB6.
Tools and Parts needed
- ORiN 2 SDK Install
- PC running Windows OS
NOTE: The following sample code is provided "AS IS" under the MIT License. Programming support service of Visual Basic is out of warranty. Please note that we do not provide any programming support service beyond basic setup and troubleshooting.
Previous Steps...
Please make sure that you have reviewed the ORiN2 - Overview article and that your RC controller is properly setup. You can use the CAOTester to make sure that your PC is ready to communicate with the controller.
| Set up your controller to accept messages from your PC. | ORiN 2 - Robot Controller Setup (RC8 / RC8A / COBOTTA) |
| Test communication using CAO Tester application | ORiN 2 - Operation check using CAOTester (CAO Engine) |
| Configuring the Project to Point to the ORiN Library (CAO 1.0) Reference Section 2.2 of the ORiN2 Programmers User Guide. | ![]() |
Programming References
At this point, you should be ready to begin programming your application to interface with your robot controller. When connecting to the controller, you will need to specify the ORiN provider you are trying to use to establish communication. The provider differs based on the robot controller you are using. RC5, RC7, and RC7M controllers use the NetwoRC provider. RC8, RC8A, and COBOTTA controllers us the RC8 provider.
NetwoRC provider directory
C:\ORiN2\CAO\ProviderLib\DENSO\NetwoRC
RC8 provider directory
C:\ORiN2\CAO\ProviderLib\DENSO\RC8
NOTE: Please consult the Owner's manual for information on how to program your DENSO Robot or details on specific robot commands.
Programming using the Provider
The following samples are for performing various basic but essential operations. The samples are for connecting using the RC8 Provider.
For more information you can reference Section 4 RC8 Programming Using the Provider from the RC8 Provider User's Guide PDF document.
Variable Sample
The sample program uses the automatically created workspace and reads/writes the variable IO150 (the 150th I/O variable). IP should be set to the value for the target controller. This sample program uses the following value. IP:192.168.0.1
For more information, reference Section 4.1 RC8 controller variable access.
Dim g_eng As CaoEngine
Dim g_ctrl As CaoController
Dim g_val As CaoVariable
Private Sub Command1_Click()
' Read variable
Text1.Text = g_val.Value
End Sub
Private Sub Command2_Click()
' Write variable
g_val.Value = CBool(Text2.Text)
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")
' Variable name "IO150"
Set g_val = g_ctrl.AddVariable("IO150", "")
End Sub
Private Sub Form_Unload(Cancel As Integer)
' Delete variable object
g_ctrl.Variables.Clear
Set g_val = Nothing
' Delete controller object
g_eng.Workspaces(0).Controllers.Remove g_ctrl.Index
Set g_ctrl = Nothing
' Delete CaoEngine
Set g_eng = Nothing
End SubTask Sample
This sample code will start or stop a robot program (Pro1.pcs), also known as tasks.
Prerequisites:
- Controller must have a program named Pro1.pcs
- Controller must be set to Auto mode
For more information, reference Section 4.2 Task controller with RC8 controller.
Dim g_eng As CaoEngine
Dim g_ctrl As CaoController
Dim g_task As CaoTask
Private Sub Command1_Click()
' Start task
g_task.Start 2
End Sub
Private Sub Command2_Click()
' Stop task
g_task.Stop 3
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")
' Task name "PR01"
Set g_task = g_ctrl.AddTask("PRO1", "")
End Sub
Private Sub Form_Unload(Cancel As Integer)
g_ctrl.Tasks.Clear
Set g_task = Nothing
g_eng.Workspaces(0).Controllers.Remove g_ctrl.Index
Set g_ctrl = Nothing
Set g_eng = Nothing
End SubRobot Motion Sample
This sample code will turn the motor ON or OFF. When the Start Robot button is pressed, the robot will Move to position P10 and then to position P11.
Prerequisites:
- Global variables P10 and P11 must have valid coordinate data
- Robot state must be set to Auto mode
For more information, reference Section 4.3 Robot control with RC8 controller.
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 SubMore samples...
You can find Visual Basic samples in your install of the ORiN 2 SDK. Here are some recommendations:
RC8 Provider Samples
| Sample Name | Directory Path |
|---|---|
| Hand | C:\ORiN2\CAO\ProviderLib\DENSO\RC8\Samples\Hand\VB |
| Joystick | C:\ORiN2\CAO\ProviderLib\DENSO\RC8\Samples\Joystick\VB6 |
| Robot | C:\ORiN2\CAO\ProviderLib\DENSO\RC8\Samples\Robot\VB |
| Robot (VB6) | C:\ORiN2\CAO\ProviderLib\DENSO\RC8\Samples\Robot\VB6 |
| Robot (Simple) | C:\ORiN2\CAO\ProviderLib\DENSO\RC8\Samples\Simple\Robot\VB6 |
| Robot (Simple) (VBA) | C:\ORiN2\CAO\ProviderLib\DENSO\RC8\Samples\Simple\Robot\VBA |
| Task (Simple) | C:\ORiN2\CAO\ProviderLib\DENSO\RC8\Samples\Simple\Task\VB |
| Variable (Simple) (VB6) | C:\ORiN2\CAO\ProviderLib\DENSO\RC8\Samples\Simple\Variable\VB6 |
| Task (VB6) | C:\ORiN2\CAO\ProviderLib\DENSO\RC8\Samples\Task\VB6 |
| Variable (VB6) | C:\ORiN2\CAO\ProviderLib\DENSO\RC8\Samples\Variable\VB |
NetwoRC Provider Samples
| Sample Name | Directory Path |
|---|---|
| File | C:\ORiN2\CAO\ProviderLib\DENSO\NetwoRC\Samples\File\VB |
| Info | C:\ORiN2\CAO\ProviderLib\DENSO\NetwoRC\Samples\Info |
| Joystick | C:\ORiN2\CAO\ProviderLib\DENSO\NetwoRC\Samples\Joystick |
| Log | C:\ORiN2\CAO\ProviderLib\DENSO\NetwoRC\Samples\Log |
| Robot | C:\ORiN2\CAO\ProviderLib\DENSO\NetwoRC\Samples\Robot\VB |
| Task | C:\ORiN2\CAO\ProviderLib\DENSO\NetwoRC\Samples\Task\VB |
| Tracking | C:\ORiN2\CAO\ProviderLib\DENSO\NetwoRC\Samples\Tracking |
| Trans | C:\ORiN2\CAO\ProviderLib\DENSO\NetwoRC\Samples\Trans |
| Tree | C:\ORiN2\CAO\ProviderLib\DENSO\NetwoRC\Samples\Tree |
| Variable | C:\ORiN2\CAO\ProviderLib\DENSO\NetwoRC\Samples\Variable\VB |
Owner's Manual Reference
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article
