Home Position

Hello,

This is the first time using RAPID and I am missing something. I want to define a home position and set an output when I am in that position and the output should turn off when I am not in that position. I copied the example out of the help and modified it slightly. Here is my code.

MODULE user (SYSMODULE) ! Predefined user data !********************* ! Declaration of numeric registers reg1…reg5
VAR num reg1 := 0;
VAR num reg2 := 0;
VAR num reg3 := 0;
VAR num reg4 := 0;
VAR num reg5 := 0;

! Declaration of stopwatch clock1 VAR clock clock1;
! Template for declaration of workobject wobj1
!TASK PERS wobjdata wobj1 := [FALSE, TRUE, “”, [[0, 0, 0],[1, 0, 0, 0]],[[0, 0, 0],[1, 0, 0, 0]]];

VAR wzstationary home;
PROC Home_Output()

VAR shapedata joint_space;
CONST jointtarget home_pos := [ [ 0, 0, 0, 0, 0, -45], [ 0, 9E9, 9E9, 9E9, 9E9, 9E9] ]; CONST jointtarget delta_pos := [ [ 2, 2, 2, 2, 2, 2], [ 5, 9E9, 9E9, 9E9, 9E9, 9E9] ]; WZHomeJointDef Inside, joint_space, home_pos, delta_pos;
WZDOSetStat, homeInside, joint_space, At_Home, 1;
ENDPROC
ENDMODULE

Is “CONST jointtarget home _pos” my position that will turn on the output? What is the second set of coordinates?

Can this be a “P”?

“CONST jointtarget delta_pos” is the position tolerance?

I always want this to be active and to initalize on power up.

I found another thread that related to this but I need a couple pieces of information to put it all together.

Thanks.

I have figured out most of what I needed. With the exception of this.

CONST jointtarget home_pos := [ [ 0, 0, 0, 0, 0, -45], [ 0, 9E9, 9E9, 9E9, 9E9, 9E9] ];

I would like to replace [ 0, 0, 0, 0, 0, -45] with a position variable such as “Home1”. I have tried a couple of different ways but no luck. Anybody know how this is done.

Thanks

I did it like this:

MODULE Module1
VAR robjoint Home1Rob:=[0,0,0,0,0,-45];
VAR extjoint Home1Ext:=[0,9E9,9E9,9E9,9E9,9E9];
VAR jointtarget home_pos;

PROC PathHome()
home_pos.robax:=Home1Rob;
home_pos.extax:=Home1Ext;
MoveAbsJ home_pos,v1000,fine,tool0;
ENDPROC

PROC main()
PathHome;
ENDPROC
ENDMODULE