Jump to content
OMRON Forums

How to obtain the current axis position


BoneSkier
 Share

Recommended Posts

How do I obtain the current axis position in a part program (as opposed to the current motor position). I need this to do my regression testing.

 

I know I can do "&1p" to get the position of all axes at the terminal, but I need the position of just "X", "Y", or "Z".

 

I need to know the Raw Position as well as the Kinematic Position effected by kinematics (scaling, rotation, etc).

 

Link to comment
Share on other sites

  • Replies 10
  • Created
  • Last Reply

Top Posters In This Topic

Power PMAC does not automatically compute the axis ("tool-tip") positions on an ongoing basis. It converts the commanded axis positions for a move end point (for a non-segmented move) or move segment point (for a segmented move) to motor positions through the transformation matrix (if any) and then through either the axis definitions or the inverse kinematic subroutine. From that point on, all automatic calculations of command and actual position are done in motor coordinates.

 

If you want tool-tip data for various reporting purposes, we provide the axis data querying functions, of which your "&1p" is one form. The on-line commands for these functions provide the data for all used axes in text form. It seems that you would rather not parse this text response to isolate your X, Y, and Z axis values.

 

It looks like using the buffered program equivalent "pread" command from a PLC program would be a better option for you. This puts the axis positions calculated from the present (actual) motor positions into local "D" variables for the coordinate systems: the X position is in D6, Y in D7, and Z in D8. It does this by processing the motor positions either through the automatically inverted axis definition statements or through the forward kinematic subroutine. If there is an axis transformation matrix, these "base" axis positions are then processed through the automatically inverted axis transformation matrix to get the "transformed" (programmed) axis positions.

 

Your PLC program can then process these values further and/or send them somewhere for logging etc. If you want the "base" (which is what I think you call "raw") axis positions, you can multiply these values by the transformation matrix values. For example:

 

MyBaseX = Tdata[1].Diag[6] * D6 + Tdata[1].XYZ[0] * D7 + Tdata[1].XYZ[1] * D8 + Tdata[1].Bias[6]

MyBaseY = Tdata[1].XYZ[2] * D6 + Tdata[1].Diag[7] * D7 + Tdata[1].XYX[3] * D8 + Tdata[1].Bias[7]

MyBaseZ = Tdata[1].XYZ[4] * D6 + Tdata[1].XYZ[5] * D7 + Tdata[1].Diag[8] * D8 + Tdata[1].Bias[8]

Link to comment
Share on other sites

  • 2 weeks later...

Hello Curtwilson,

 

I want to get the tool-tip posion to display in the HMI,and i used the "pread" in the plc,it seems not work in the plc but in program.The code like this:

 

Ldata.coord =1;

fread;

d32=$1ff;

p1=d1

p2=d2

p3=d3

p4=d4

p5=d5

p6=d6

p7=d7

p8=d8

 

I can get P1..8 value when using in program.but plc can't.

Could you give some suggestion?

 

Thanks

Link to comment
Share on other sites

I want to get the tool-tip posion to display in the HMI,and i used the "pread" in the plc,it seems not work in the plc but in program.The code like this:

 

Ok - from a plc (my coord system was CS0) this works:

 

open plc 1

 

cmd"&0p p1=d6 p2=d7"

 

close

 

The values displayed in P1 and P2 match the axis positions.

Link to comment
Share on other sites

I have no trouble using the "pread" command in a PLC program to get the axis ("tool-tip") positions from the selected coordinate system.

 

You should be reading D32, not writing to it. It tells you which axes have been reported. If you know already, you don't need to bother reading it, but it is a good diagnostic tool -- what value does it return for you?

 

My PLC program text:

 

open plc 17

Ldata.coord = 1;

dread;

P6 = D6;

P7 = D7;

P8 = D8;

disable plc 17;

close

Link to comment
Share on other sites

Haha,it's strange!

It's my plc14.

 

open plc 14

 

p1=p1+1

cmd"&1p p11=d6 p12=d7 p13=d8"

p2=p2+1

 

Ldata.coord =1;

 

dread;

p3=p3+1

 

p1001=d1

p1002=d2

p1003=d3

p1004=d4

p1005=d5

p1006=d6

p1007=d7

p1008=d8

p1009=d32

 

pread;

p4=p4+1

p2001=d1

p2002=d2

p2003=d3

p2004=d4

p2005=d5

p2006=d6

p2007=d7

p2008=d8

p2009=d32

close

 

pread.bmp

 

Everything return to me is zero.

It maybe have a relationship with forward program,but i'm not sure.

Here is my code for anyone would like to check.

usrcode.txtforward.txt

 

Thanks for your replay!

Link to comment
Share on other sites

I believe the problem may be in your forward kinematics script file. Try using this as your forward kinematics Script file and then try pread in your PLC again:

 

#define Forward_Kinematics_State 0
#define Inverse_Kinematics_State 1
#define KinematicsType1 1
#define KinematicsType2 2
// Define storage flags for the error code returns
&1
csglobal ForwardKin1ErrCode,ForwardKin2ErrCode,InvKin1ErrCode,InvKin2ErrCode;

open forward (1)
if (KinVelEna) callsub 100;
KinAxisUsed = $1C6; // X, Y, Z, B, and C axis results
N100: 
ForwardKin1ErrCode = CfromScript(1,Forward_Kinematics_State,KinematicsType1,0,0,0,0);
return;
close 

 

Please let me know if that works for you.

Link to comment
Share on other sites

dzrong,

 

I was able to get pread to work just fine while using CfromScript kinematics. I have attached a sample project for your reference so you can compare any differences between my and your code.

 

Also, make sure you have UserAlgo.CFunc=1 since it seems you are calling pread (which then calls CfromScript) from a background PLC, which requires this structure to be set to 1.

dzrong dread problem.zip

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share


×
×
  • Create New...