PC SDK - Setting Program Pointer

hello

my thesis presentation is due in the next few days so if anyone can help me it would be greatly greatly appreciated.

i need to set the program pointer.
i am using VB.net to program with PC SDK.


SetProgramPointer

Sets program pointer to the first instruction of a routine (global or local).

in the PC SDK help reference file it shows SetProgramPointer as a member of Task.However when i try to do this in Visual Studio it does not come up as an option.

is it possible to do using VB?
and second question if it cant be set, my current program pointer is set at main, so if i edit the routine main it would kinda do what i want anyway.
How do you edit an entire routine?

please if anyone can help i have spent weeks trying to get this working.

Hi,
I managed to change the program pointer by this way (in C#):

control.Logon(UserInfo.DefaultUser);
Mastership master;
master = Mastership.Request(control.Rapid);
Task task;
task = control.Rapid.GetTask(“T_ROB1”);
task.SetProgramPointer(“MainModule”, “urunvar”);
control.Rapid.Start();
control.Logoff();

this code changes the pointer to the proc named “urunVar”. Instead of editing entire routine i wrote a proc to do what i want.
Hope this helps,
Best

In this reply I’m using the “Create a simple PC SDK application” from the PC SDK Application Manual as the base. Its in the “Using the PC SDK” chapter.
So to paste this in you need to follow the basic instruction from there first. You need a Button1 and a Button2 as well.

You need a main and a Path_20 proc in the controller, preferably with different actions so that you can see which is run.

Steps;
Start controller
Start app
doubleclick controller
click the buttons

As you can see I’m using this to move the PP and start execution:
tasks = controller.Rapid.GetTasks()
Using m As Mastership = Mastership.Request(controller.Rapid)
'Perform operation
tasks(0).SetProgramPointer(“Module1”, “Path_20”)
tasks(0).Start()
End Using

john thank you for the help.
this has been a great help, it allowed me to see there was a problem with my system setup.

i worked out the problem i had the whole time, when my mentor was trying to fix another problem he reset all my rab libraries back to version 10. This has been behind alot of my other problems.

i have now learnt not to listen to my mentor :wink:

thank you again for the help and speedy reply.

Glad to be of service.
:+1:

Hi,John!
Maybe there is a problem here.On one controller maybe there are different modules,but it can only be one ‘MAIN’,and if i want to give a “main routine”,i should give it another name,like "main 1""main 2"“main 3”… so how can i know the routine name of a module(i want click a button to choose a ".mod"file,and then the vc perform it,so i want the pc get a name by some program)?

Hi doc-zoo,

I am sorry, I have problems understanding what exactly you want in most of your responses, including this one. Maybe it would be easier if you posted code and showed what your issue is?
In my example above you can just change the line
tasks(0).SetProgramPointer(“Module1”, “Path_20”)
to whichever module and routine you want. So what they are called does not matter.

How to load a module using the PC SDK is described in the Application manual
“Using the PC SDK - Rapid domain
Working with RAPID modules and programs”
How to search for specific procedures is described in
“Using the PC SDK - Rapid domain
RAPID symbol search”

If you want to know which PROC a .mod file contains before loading it you can just open it like a text file and parse through it to find all PROCs.

:question:

hi,John!
Maybe there is a problem when i expressed myself.The code like this:
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = “Mod Files (.mod)|.mod|All Files (.)|.*”;
openFileDialog1.FilterIndex = 1;
string text1 = openFileDialog1.FileName;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
FileInfo filename = new FileInfo(openFileDialog1.FileName);
string fn = filename.Name;
this.master = Mastership.Request(controller.Rapid);


tasks(0).SetProgramPointer(“Module1”, “???”)
tasks(0).Start()

}
what should i do here"???"

tasks(0).SetProgramPointer(openFileDialog1.FileName??O"???")
tasks(0).Start()

WARNING!
The way you do that in your code is VERY dangerous. You allow the user to select ANY procedure, regardless of where the robot arm is. That means that you have no control on what the robot actually will do. The user could even mistakenly select the wrong procedure which could lead to damages and injuries.
You have no way to control which module is loaded and which procedure is selected, I would rethink that design.
WARNING!

But I already told you how to do it; Read The Fantastic Manual
[QUOTE=John Wiberg]How to search for specific procedures is described in
“Using the PC SDK - Rapid domain
RAPID symbol search”[/QUOTE] If you need to know the names of procedures you use the SearchRapidSymbol function.

Continuing on the example above, you need to add two listboxes and two more buttons.
Steps;
Start controller
Start app
doubleclick controller
click button3 to list modules in listbox1
select a module name in listbox1
click button4 to list procedures in listbox2

[code] Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
ListBox1.Items.Clear()
Dim sProp As RapidSymbolSearchProperties = RapidSymbolSearchProperties.CreateDefault()
sProp.Types = SymbolTypes.Module
tasks = controller.Rapid.GetTasks()
Dim rsCol As RapidSymbol()
rsCol = tasks(0).SearchRapidSymbol(sProp, String.Empty)
If rsCol.Count = 0 Then
ListBox1.Items.Add(“Not found”)
Return
Else
Dim rs As RapidSymbol
For Each rs In rsCol
ListBox1.Items.Add(rs.Name)
Next
End If
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
ListBox2.Items.Clear()
If ListBox1.SelectedItem = “” Then
ListBox2.Items.Add(“No module selected in ls1”)
Else
Dim sProp As RapidSymbolSearchProperties = RapidSymbolSearchProperties.CreateDefault()
sProp.Types = SymbolTypes.Procedure
tasks = controller.Rapid.GetTasks()
Dim selModule As ABB.Robotics.Controllers.RapidDomain.Module
selModule = tasks(0).GetModule(ListBox1.SelectedItem.ToString)
Dim rsCol As RapidSymbol()
rsCol = selModule.SearchRapidSymbol(sProp, String.Empty)
If rsCol.Count = 0 Then
ListBox2.Items.Add(“Not found”)
Return
Else
Dim rs As RapidSymbol
For Each rs In rsCol
ListBox2.Items.Add(rs.Name)
Next
End If
End If
End Sub[/code]

Please note that in my example above it lists both system modules and program modules. In your code you load a module so then you should take the module name and just list for that directly.

Hi,John!
First thanks a lot for your help ,it helps me a lot!But there is a new problem in my code.
when i write the code like this:

tasks[0].SetProgramPointer(listBox1.SelectedItem.ToString(),listBox2.SelectedItem.ToString());
tasks[0].Start();
.. …
there`s an erro like this:
“SetProgramPointer” is not defined in the"ABB.Robotics.Controllers.RapidDomain.Task"
In chinese like this:
"?“T?__ 4 ?oABB.Robotics.Controllers.RapidDomain.Task?__?1??,?O.?_??_oSetProgramPointer?__?s,?rs?1% F:ABB??-?”

Look at the top of the code, do you have
using ABB.Robotics.Controllers.RapidDomain;
Then look at the References, do they have a warning? Are they the correct version?

I have using ABB.Robotics.Controllers.RapidDomain;
and i have done the References, there are no warning, i don`t know whether they are the correct version.and can you give me the address to download it?My RS is 5.13.01

By the way,when i use "Reset Program Pointer ",there is no error .May be i use the wrong version

Hi,John! Sorry to trouble you again.I have some problems trouble me a lot days.I copy a module and load it,then when i copy another module ,there`s error like:
"
Event Message
Error in T_ROB1-Line6
Description
Global routine name main ambiguous.
Data for this message is not saved in any robot controller event log.
If acknowledged the message will be removed.

Actions
Global routine must have names that are unique among all the global types,data,global routines and modules in the entire program .Rename the routine or change the conflicting name.

"
the c# code like this:

private void button7_Click(object sender, EventArgs e)
{
string localDir = controller.FileSystem.LocalDirectory;
string remoteDir = controller.FileSystem.RemoteDirectory;
controller.FileSystem.RemoteDirectory = remoteDir ;
controller.FileSystem.LocalDirectory = localDir + “/downmod/”;
File.Copy(controller.FileSystem.LocalDirectory + “xadd.mod”, controller.FileSystem.RemoteDirectory + “xadd.mod”, true);

…}
private void button4_Click(object sender, EventArgs e)
{
runxadd();
}
public void runxadd()
{
string localDir = controller.FileSystem.LocalDirectory;
string remoteDir = controller.FileSystem.RemoteDirectory;
if (controller.OperatingMode == ControllerOperatingMode.Auto)
{
tasks = controller.Rapid.GetTasks();
this.master = Mastership.Request(controller.Rapid);
UserAuthorizationSystem uas = controller.AuthenticationSystem;
if (uas.CheckDemandGrant(Grant.LoadRapidProgram))
{
tasks[0].LoadModuleFromFile(remoteDir + “xadd.mod”, RapidLoadMode.Replace);
// RapidSymbolSearchProperties sProp1 = RapidSymbolSearchProperties.CreateDefault();
// sProp1.Types = SymbolTypes.Procedure;
// tasks = controller.Rapid.GetTasks();
//Module selModule1 = tasks[0].GetModule(strmainname);
//RapidSymbol rsCol1 = selModule1.SearchRapidSymbol(sProp1, string.Empty);
tasks[0].ResetProgramPointer();
tasks[0].Start();
}
//tasks[0].ResetProgramPointer();
// this.master.Dispose();
this.master.Dispose();
}

the module code like this:
the"Module1.MOD"code like this:
MODULE Module1
CONST robtarget p10:=[[524.77,-968.58,952.68],[0.422439,-0.0807052,0.55852,-0.709286],[-1,-1,-1,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
CONST robtarget pHome:=[[113.55,-940.17,909.68],[0.394354,-0.0151111,0.0387188,-0.918018],[-1,-1,-1,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
CONST robtarget p30:=[[179.47,1049.78,948.14],[0.880088,-0.416906,0.074412,0.214701],[0,-1,-1,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
PROC main()
rInitAll;
rHome;
rMoveRoutine;
WaitTime 0.3;
ENDPROC
PROC rHome()
MoveJ pHome, v7000, z50, tool0;
ENDPROC
PROC rInitAll()
AccSet 100, 100;
VelSet 100, 5000;
ENDPROC
PROC rMoveRoutine()
MoveJ p10, v4000, z50, tool0;
MoveJ p30, v4000, z50, tool0;
ENDPROC
ENDMODULE

the "xadd.mod"code like this:
MODULE MainModule
PROC main()
VAR robtarget rob_tar1;
rob_tar1:=CRobT();
rob_tar1:=Offs(rob_tar1,30,0,0);
MoveL rob_tar1,v1000,z50,tool0;
ENDPROC
ENDMODULE

Event Message Error in T_ROB1-Line6 Description Global routine name main ambiguous.
This just means that in RAPID you are not allowed to have the PROC name “main” more than once. Its a reserved name.
Just rename your “main” PROC to something else and you will be fine, since if you use it in two different modules at the same time, then its not really a “main” PROC anyway.

Because i can only use "ResetProgramPointer()"method that can only reset the pp to the “main”,i cant use the "SetProgramPointer()"method. when i use "SetProgramPointer",theres always problem i have ask you before.So can you tell me how can i solve it?