2013 Step7 L D[AR2,P#0.0]

: 2012-12-27

: komatic

: Step7



, - ! :)
L D[AR2,P#0.0].



:

Step7 , Q0.0 PLCSIM.
Q0.0:
() Q0.0 . .
Q0.1 ?


puzzle


puzzle





:

OB 1:

ORGANIZATION_BLOCK OB 1
TITLE = "Main Program Sweep (Cycle)";
VERSION : 0.1

VAR_TEMP
OB1_EV_CLASS : BYTE ; //Bits 0-3 = 1 (Coming event), Bits 4-7 = 1 (Event class 1)
OB1_SCAN_1 : BYTE ;//1 (Cold restart scan 1 of OB 1), 3 (Scan 2-n of OB 1)
OB1_PRIORITY : BYTE ; //Priority of OB Execution
OB1_OB_NUMBR : BYTE ; //1 (Organization block 1, OB1)
OB1_RESERVED_1 : BYTE ;//Reserved for system
OB1_RESERVED_2 : BYTE ;//Reserved for system
OB1_PREV_CYCLE : INT ; //Cycle time of previous OB1 scan (milliseconds)
OB1_MIN_CYCLE : INT ; //Minimum cycle time of OB1 (milliseconds)
OB1_MAX_CYCLE : INT ; //Maximum cycle time of OB1 (milliseconds)
OB1_DATE_TIME : DATE_AND_TIME ;//Date and time OB1 started
ww : WORD ;
x : INT ;
LL : WORD ;
BB : BOOL ;
END_VAR
BEGIN
NETWORK
TITLE =

L 0;
T #x;
LAR1 P##OB1_DATE_TIME;
L B [AR1,P#5.0];
BTI ;
+ 1;
T B [AR1,P#5.0];
L 0;
T B [AR1,P#4.0];
UC FB [LW 16];
OPN DB [LW 16];
L LW 16;
SLD 3;
LAR1 ;
A DBX[AR1,P#0.0];
FP DBX [AR1,P#1.0];
JCN a;
L MB 100;
+ 1;
T MB 100;
T DBW [AR1,P#2.0];
a: NOP 0;
L 60;
T #ww;
b: CALL "TEST_DB";(
DB_NUMBER :=#ww,
RET_VAL :=#x,
DB_LENGTH :=#LL,
WRITE_PROT :=#BB);

L #LL;
L 256;
<>I ;
JC c;
L #ww;
+ -1;
T #ww;
L 0;
>I ;
JC b;
L 255;
T DB1.DBB 255;
JU d;
c: A M 100.5;
L P#I 0.0;
L DW#16#1000000;
+D ;
LAR1 ;
= [AR1,P#0.0];

d: OPN DI 1;
LAR1 AR2;
LAR2 P#DBX1.0;
UC FB 100;

END_ORGANIZATION_BLOCK

OB 121:


ORGANIZATION_BLOCK OB121;
TITLE = "Programming Error"
VERSION : 0.1

VAR_TEMP
OB121_EV_CLASS : BYTE ;//16#25, Event class 2, Entering event state, Internal fault event
OB121_SW_FLT : BYTE ; //16#XX Software programming fault
OB121_PRIORITY : BYTE ;//Priority of OB Execution
OB121_OB_NUMBR : BYTE ;//121 (Organization block 121, OB121)
OB121_BLK_TYPE : BYTE ;//16#88/8A/8B/8C/8E Type of block fault occured in
OB121_RESERVED_1 : BYTE ; //Reserved for system
OB121_FLT_REG : WORD ; //16#XX Specific register that caused fault
OB121_BLK_NUM : WORD ; //Number of block that programming fault occured in
OB121_PRG_ADDR : WORD ;//Address in block where programming fault occured
OB121_DATE_TIME : DATE_AND_TIME ; //Date and time OB121 started
END_VAR
BEGIN
NETWORK
TITLE =

UC FC 0;
L #OB121_BLK_TYPE;
L #OB121_BLK_NUM;

END_ORGANIZATION_BLOCK

FC 0:

FUNCTION FC 0 :VOID
TITLE =
VERSION : 0.1

VAR_TEMP
dwA : DWORD ;
wA : WORD ;
iA : INT ;
bA : BOOL ;
wB : WORD ;
ii52 : INT ;
bbusy : BOOL ;
F : ARRAY [1 .. 32] OF WORD ;
SZL_HEADER : STRUCT
LENGHTDR :WORD ;
N_DR : WORD ;
END_STRUCT ;
wData : ARRAY [1 .. 4] OF BYTE ;
pA : ANY ;
pB : ANY ;
G : ARRAY [1 ..126 ] OF BYTE;
h : BYTE ;
END_VAR
BEGIN
NETWORK
TITLE =

a: LAR1 P##dwA;
LAR2 P##dwA;
TAR1 #dwA;
JCN a;
S [AR1,P#0.0];
LAR1 #dwA;
L W [AR1,P#6.0];
T W [AR2,P#4.0];
L W [AR1,P#8.0];

CALL "TEST_DB" (
DB_NUMBER := #wA,
RET_VAL :=#iA,
DB_LENGTH :=#wB,
WRITE_PROT :=#bA);

L #iA;
L 0;
==I ;
JC b;
CALL"CREAT_DB"; (
LOW_LIMIT :=#wA,
UP_LIMIT :=#wA,
COUNT := W#16#100,
RET_VAL :=#iA,
DB_NUMBER :=#wA);

b: OPN DB [#wA];
L #wA;
SLD 3;
LAR1 ;
L DBB [AR1,P#0.0];
+ 1;
T DBB [AR1,P#0.0];
L 1;
T #wA;
CALL "TEST_DB"; (
DB_NUMBER :=#wA,
RET_VAL :=#iA,
DB_LENGTH :=#wB,
WRITE_PROT :=#bA);
L #wB;
L 256;
<>I ;
BEC ;

OPN DB [#wA];
L DBB 255;
L 255;
<>I ;
BEC ;
CALL "RDSYSST"; (
REQ := TRUE,
SZL_ID := W#16#1A0,
INDEX := W#16#2,
RET_VAL :=#ii52,
BUSY := #bbusy,
SZL_HEADER :=#SZL_HEADER,
DR := #F);

LAR1 P##F;
w: L W [AR1,P#0.0];
L W#16#B066;
==I ;
JC n;
+AR1 P#20.0;
JU w;
n: LAR2 P##wData;
L 800;
NEGD ;
+AR2 ;
L 0;
T D [AR2,P#100.0];
A [AR1,P#7.5];
L STW;
JCN q;
q: T #wA;
LAR1 P#DBX200.0;
L W [AR1,P#53.0];
NEGD ;
+AR2;
L 10;
z: T #iA;
L #wA;
T STW;
= [AR2,P#230.7];
= [AR2,P#220.6];
= [AR2,P#210.5];
= [AR2,P#200.4];
+AR2P#10.1;

JCN y;
y: L STW;
T #wA;
L #iA;
LOOP z;

CLR ;
k: LAR1 P##pA;
LAR2 P##pB;
JCN k;
L 4097;
T W [AR1,P#0.0];
T W [AR2,P#0.0];
L W#16#20;
T W [AR1,P#2.0];
T W [AR2,P#2.0];
L 0;
T W [AR1,P#4.0];
T W [AR2,P#4.0];
L P##wData;
L DW#16#1000000;
OD ;
T D [AR1,P#6.0];
L 0;
T D [AR2,P#6.0];
SET ;
S [AR2,P#6.7];
S [AR2,P#6.1];

CALL "BLKMOV"; (
SRCBLK := #pA,
RET_VAL :=#ii52,
DSTBLK := #pB);

END_FUNCTION

FB 100:


FUNCTION_BLOCK FB 100
TITLE =
VERSION : 0.1

VAR
BB : ARRAY [0 .. 255 ] OF BYTE;
END_VAR
VAR_TEMP
ii : INT ;
info1 : WORD ;
info2 : DWORD ;
END_VAR
BEGIN
NETWORK
TITLE =

L #BB[254];
L 255;
<>I ;
BEC ;
TAR2 #info2;
L P##BB;
L 800;
+D ;
L P#Q 0.0;
-D ;
L P#P 0.0;
+D ;
LAR1 ;
L B [AR1,P#0.0];
T #info1;
L 804;
T DBW 253;
CALL "WR_USMSG"; (
SEND := TRUE,
EVENTN := W#16#B066,
INFO1 := #info1,
INFO2 :=#info2,
RET_VAL :=#ii);
END_FUNCTION_BLOCK





S7 Puz12.zip (20.2 KB)







: 9151

: denis    : 2013-01-31

a: LAR1 P##dwA;
LAR2 P##dwA;
TAR1 #dwA;
JCN a;
??????????????

: komatic    : 2013-01-31

, :)

: S7_puzzle_solver    : 2014-01-23

?

: S7_puzzle_solver    : 2014-01-23

() ( ) )))

:

(4000 max):

: