Code: Select all
FUNCTION "FC_SEW_SERVO_POS_ABSOLUT" : VOID
TITLE =SERVO ABSOLUTE POSITIONING (L2-DP) WITH 6-PD PROZESSDATA
{ S7_language := '7(1) Deutsch (Deutschland) 09.02.2007 11:05:27' }
AUTHOR :
FAMILY :
NAME : SEW_SERV
VERSION : 0.0
VAR_INPUT
CONTROLLER_INHIBIT : BOOL ; //REGLERSPERRE
POS_ABSOLUTE : BOOL ; //POSITIONIERUNG ABSOLUT
REFERENCE : BOOL ; //REFERENZFAHRT AUSLÖSEN
TOUCH_POS : BOOL ; //TIPPEN POSITIV
TOUCH_NEG : BOOL ; //TIPPEN NEGATIV
RELEASE : BOOL ; //FREIGABE
RESET : BOOL ; //QUITTIERUNG STOERUNG
START_DATA : INT ; //DATENBEREICH ANFANG (182 FEST)
SPEED_MAX : INT ; //MAXIMALE DREHZAHL
PERIPHERY : INT ; //PERIPHERIE ANFANGSADRESSE
END_VAR
VAR_TEMP
PERIPHERY_START : WORD ; //PERIPHERIE ANFANGSADRESSE
RETURN_VALUE_R : INT ; //RETUERN_VALUE READ
RETURN_VALUE_W : INT ; //RETUERN_VALUE WRITE
DATA_DESTINATION : ANY ; //DATENBEREICH ANFANG <- SEW
DATA_SOURCE : ANY ; //DATENBEREICH ANFANG -> SEW
TEMP : DINT ;
TEMP_ORDER : BYTE ;
END_VAR
BEGIN
NETWORK
TITLE =CALL DRIVE-DB
OPN DB ["BLOCK_NO_VAL:_DRIVE_1_N"]; // CALL DRIVE DB OPN DB611
L #PERIPHERY; #PERIPHERY = 1208
T #PERIPHERY_START;
NETWORK
TITLE =WRITE ADRESSREGISTER
L #START_DATA; // STARTADRESS - DB #START_DATA = 182
SLD 3;
LAR2 ; AR2 = 182*8 = 1456
NETWORK
TITLE =READ PROZESSDATA FROM FC
LAR1 P##DATA_DESTINATION;
L B#16#10;
T LB [AR1,P#0.0];
L B#16#2;
T LB [AR1,P#1.0];
L 12;
T LW [AR1,P#2.0];
L "BLOCK_NO_VAL:_DRIVE_1_N";
T LW [AR1,P#4.0];
L #START_DATA;
L 44;
+I ;
SLD 3;
L DW#16#84000000;
OD ;
T LD [AR1,P#6.0];
CALL "SFC_DPRD_DAT" (
LADDR := #PERIPHERY_START,
RET_VAL := #RETURN_VALUE_R,
RECORD := #DATA_DESTINATION);
A #RESET;
R DBX 70.5;
L #RETURN_VALUE_R; //FAULT PERIPHERY
L 0;
<>I ;
S DBX 70.5;
NETWORK
TITLE =REFERENCE / SYNCHRONIZE Interesting part:
L DBW [AR2,P#44.0]; //STATUSWORD 2 L DBW[1456+44 = 1560] ? How it accesses to DB611.DBW1560
T DBW [AR2,P#2.0]; //STATUSWORD 2 -> BIT Look at the DB611, the maximu address is 320.
A DBX 71.0; //#EN_RELEASE_P_S
AN DBX 71.1; //#EN_PRESET_SYNCHRON
JCN PEND;
L DBW 102; //#EN_PRESET_SYNCHRON_CONSTANT
DTR ;
L DBD 104; //#EN_RESOLUTION
/R ;
RND ;
L DBD [AR2,P#46.0]; //#EN_AXLEPOSITION
TAK ;
-D ;
T DBD [AR2,P#8.0]; //#EN_PRESET_SYNCHRON_VALUE
A DBX 71.0; //#EN_RELEASE_P_S
R DBX 71.0; //#EN_RELEASE_P_S
AN DBX 71.1; //#EN_PRESET_SYNCHRON
S DBX 71.1; //#EN_PRESET_SYNCHRON
PEND: NOP 0;
L DBD [AR2,P#46.0]; //#EN_AXLEPOSITION
L DBD [AR2,P#8.0]; //#EN_PRESET_SYNCHRON_VALUE
-D ;
T DBD [AR2,P#4.0]; //#EN_POSITION_ACTUAL
DTR ; //DOUBLE_INTEGER => REAL
L DBD 104; //#EN_RESOLUTION
*R ;
RND ; //REAL => DOUBLE_INTEGER
T DBW 108; //#EN_ACTUAL_VALUE
NETWORK
TITLE = PROCESSING CONTROL-WORD
AN #CONTROLLER_INHIBIT;
= DBX [AR2,P#13.0]; // CONTROLLER INHIBIT / RELEASE
A #CONTROLLER_INHIBIT;
= DBX [AR2,P#13.1]; // RELEASE / RAPID STOP
A #RELEASE;
= DBX [AR2,P#13.2]; // RELEASE / HOLD
CLR ;
= DBX [AR2,P#13.3]; // HOLDCONTROL ACTIVE / PASSIVE
= DBX [AR2,P#13.4]; // INTEGRATOR 2 / INTEGRATOR 1
= DBX [AR2,P#13.5]; // RESERVE
A #RESET;
A( ;
ON DBX [AR2,P#3.1]; // READY
O DBX [AR2,P#3.5]; // FAULT
) ;
= DBX [AR2,P#13.6]; // RESET
CLR ;
= DBX [AR2,P#13.7]; // RESERVE
NETWORK
TITLE = PROCESSING CONTROL-WORD (JOB-NO.)
A #RELEASE;
JC REF;
JU STOP;
REF: AN #REFERENCE;
JC ABS;
L 2#1;
JU SOLL;
ABS: AN #POS_ABSOLUTE;
JC TPOS;
L 2#100;
JU SOLL;
TPOS: AN #TOUCH_POS;
JC TNEG;
L 2#10;
JU SOLL;
TNEG: AN #TOUCH_NEG;
JC STOP;
L 2#11;
JU SOLL;
STOP: L 2#0;
SOLL: T #TEMP_ORDER;
L DBB [AR2,P#12.0];
SRW 3;
SLW 3;
L #TEMP_ORDER;
OW ;
T DBB [AR2,P#12.0];
NETWORK
TITLE =EVALUATE SET VALUE
//
//
//
L #TEMP_ORDER;
L 2#100; // POSITIONING ABSOLUTE
<>I ;
JC DREH;
L DBD [AR2,P#14.0]; // POSITION SET VALUE [mm]
DTR ;
L DBD 104; // RESOLUTION
/R ;
RND ;
L DBD [AR2,P#8.0]; //#EN_PRESET_SYNCHRON_VALUE
+D ;
T DBD [AR2,P#40.0]; // SET VALUE
DREH: L DBW [AR2,P#30.0]; // SPEED SET VALUE [%]
ITD ;
L #SPEED_MAX; // NOMINAL SPEED
*D ;
L 100;
/D ;
T DBW [AR2,P#32.0]; // SET VALUE
NETWORK
TITLE = SPS -> SERVO
L DBD [AR2,P#40.0]; //POSITION SET VALUE
T DBD [AR2,P#58.0];
L DBW [AR2,P#32.0]; //SPEED SET VALUE
T DBW [AR2,P#62.0];
L DBW [AR2,P#34.0]; //RAMP SET VALUE
T DBW [AR2,P#64.0];
L DBW [AR2,P#36.0]; //RES_WORD
T DBW [AR2,P#66.0];
L DBW [AR2,P#12.0]; //CONTROLWORD
T DBW [AR2,P#56.0];