How to Read the max/min position error record

             How to Read the max/min position error record
20200325 by advan
Description
TwinCAT NC provide max/min position error value . The record will start after axis controller enable , Reset  record after axes reset(MC_Reset)
ADS Address
Port 501 
Index Group = 0x4100 + AxisID
Index Offset = 0x00n0 0000  , n: element   index start from 0

Len
TC2 (112 byte)
TC3 (256 byte)
TC2 "Index offset" specification for axis state (Index group 0x4100 + ID)
Index offset
(Hex)
Access
Axis type
Data type
Phys. unit
Definition range
Description
Note
0x00n00000

n = Axis element  index

like second encoder , drive , control


First element  n = 0

Second  element n = 1
Read
every (online structure for axis data)
{


AXIS ONLINE STRUCTURE
(NC/CNC)
Cannot be traced by 
oscilloscope!
(NCAXISSTATE_ ONLINESTRUCT)
INT32
1

Error state
REAL64
e.g. mm

Actual position
REAL64
e.g. degree

Modulo actual position
REAL64
e.g. mm

Set position
REAL64
e.g. degree

Modulo set position
REAL64
e.g. mm/s

Optional: actual velocity
REAL64
e.g. mm/s

Set velocity
UINT32
%
0...1000000
Speed override (1000000 == 100%)
REAL64
e.g. mm

Following error position
REAL64
e.g. mm

PeakHold value for max. negative following error (pos.)
REAL64
e.g. mm

PeakHold value for max. positive following error (pos.)
REAL64
%

Controller output in percent
REAL64
%

Total output in percent
UINT32
1
≥ 0
Axis-Status-DWord
UINT32
1
≥ 0
Axis-Control-DWord
UINT32
1
≥ 0
Slave coupling state (state)
UINT32
1
0; 1,2,3...
Axis control loop index
}


112 bytes



TC3 "Index offset" specification for Axis state (Index group 0x4100 + ID)
Index offset ( Hex )
Access
Axis type
Data type
Phys. unit
Definition range
Description
Note
0x00n00000

n = Axis element  index

like second encoder , drive , control


First element  n = 0

Second  element n = 1


Read
every (online structure for axis data)
{


AXIS ONLINE STRUCTURE (NC/CNC)
Changed from TC3, not oscilloscopeable! (NCAXISSTATE_ONLINESTRUCT)
INT32
1

Error state
INT32


Reserved
REAL64
e.g. mm

Actual position
REAL64
e.g. degree

Modulo actual position
REAL64
e.g. mm

Set position
REAL64
e.g. degree

Modulo set position
REAL64
e.g. mm/s

Optional: actual velocity
REAL64
e.g. mm/s

Set velocity
UINT32
%
0...1000000
speed override (1000000 == 100%)
UINT32


Reserved
REAL64
e.g. mm

Following error position
REAL64
e.g. mm

PeakHold value for max. neg. position lag (pos.)
REAL64
e.g. mm

Peak hold value for max. pos. following error. (pos.)
REAL64
%

Controller output in percent
REAL64
%

Total output in percent
UINT32
1
≥ 0
Axis status double word
UINT32
1
≥ 0
Axis control double word
UINT32
1
≥ 0
Slave coupling state (state)
UINT32
1
0; 1,2,3...
Axis control loop index
REAL64
e.g. mm/s^2

Actual acceleration
REAL64
e.g. mm/s^2

Set acceleration
REAL64
e.g. mm/s^3

Set jerk (new from TC3.1 B4013)
REAL64
e.g. 100% = 1000

Set torque or set force (reserved, not implemented)
REAL64
e.g. 100% = 1000

Actual torque or actual force (new from TC3.1 B4013)
}


256 byte

PLC Sample Code (TC3)
Define a struct same as memory  layout & fulfill data size 256 bytes & define pack mode continuously(TC3) 
{attribute 'pack_mode' := '1'}
TYPE TC3_NCAXISSTATE_ONLINESTRUCT :
STRUCT
Error_State : DWORD;
Dummy_0004 : DWORD;
Actual_Position : LREAL;
Modulo_Actual_Position : LREAL;
Set_Position : LREAL;
Modulo_Set_Position : LREAL;
Actual_Velocity : LREAL;
Set_Velocity : LREAL;
Speed_Override : UDINT; (*  1000000 == 100% *)
Dummy_0052 : DWORD;
Position_Lag : LREAL;
PeakHold_Max_Neg_Position_Lag : LREAL;
PeakHold_Max_Pos_Position_Lag : LREAL;
Controller_Output_In_Percent : LREAL;
Total_Output_In_Percent : LREAL;
Axis_Status_Dword : DWORD;
Axis_Control_Dword : DWORD;
Slave_Coupling_State : DWORD;
Axis_Control_Loop_Index : DINT;
Actual_Acceleration : LREAL;
Set_Acceleration : LREAL;
Set_Jerk : LREAL;
Set_Torque : LREAL; (* or force *)
Actual_Torque : LREAL; (* or force *)

Dummy_0160  : ARRAY[0..95] OF BYTE;
END_STRUCT
END_TYPE
PROGRAM MAIN
VAR
stTC3AxisData : TC3_NCAXISSTATE_ONLINESTRUCT;
FB_AdsRead : ADSREAD;
END_VAR
 FB_AdsRead(NETID:= , (* Assign target *)
PORT:= 501, 
IDXGRP:= 16#4101, (* 16#4100 + Axis ID  *) 
IDXOFFS:= , (* most case = 0 *)
LEN:= SIZEOF(stTC3AxisData), 
DESTADDR:= ADR(stTC3AxisData), 
READ:= , 
TMOUT:= , 
BUSY=> , 
ERR=> , 
ERRID=> );
PLC Sample Code (TC2)
Define a struct same as memory  layout & fulfill data size 256 bytes & define pack mode continuously(TC3)
{attribute 'pack_mode' := '1'} 
TYPE TC2_NCAXISSTATE_ONLINESTRUCT : (* TC2 NC 112 bytes *)
STRUCT
Error_State : DWORD;
Actual_Position : LREAL;
Modulo_Actual_Position : LREAL;
Set_Position : LREAL;
Modulo_Set_Position : LREAL;
Actual_Velocity : LREAL;
Set_Velocity : LREAL;
Speed_Override : UDINT; (*  1000000 == 100% *)
Position_Lag : LREAL;
PeakHold_Max_Neg_Position_Lag : LREAL;
PeakHold_Max_Pos_Position_Lag : LREAL;
Controller_Output_In_Percent : LREAL;
Total_Output_In_Percent : LREAL;
Axis_Status_Dword : DWORD;
Axis_Control_Dword : DWORD;
Slave_Coupling_State : DWORD;
Axis_Control_Loop_Index : DINT;

END_STRUCT
END_TYPE

PROGRAM MAIN
VAR
stTC2AxisData : TC2_NCAXISSTATE_ONLINESTRUCT;
FB_AdsRead : ADSREAD;
END_VAR

 FB_AdsRead(NETID:= , (* Assign target *)
PORT:= 501, 
IDXGRP:= 16#4101, (* 16#4100 + Axis ID  *) 
IDXOFFS:= , (* most case = 0 *)
LEN:= SIZEOF(stTC2AxisData), 
DESTADDR:= ADR(stTC2AxisData), 
READ:= , 
TMOUT:= , 
BUSY=> , 
ERR=> , 
ERRID=> );

留言

這個網誌中的熱門文章

[補充資料] EtherCAT Slave 定址 & Protocol 解析

Access TwinCAT EtherCAT CoE / SoE Object via ADS

ESC SII usage memo(Load Fail)