parni_valjak77
Member
Hi,
I have a small problem, where I am trying to do following:
trying to run a script where it will check for matching input byte number (done in Vat table), and compare it with specific place in DB (expl. DB300.DBD108). If it deasn't find the matching number it will add 30 bytes to last address in DB300 (last address DB300.DBD100) and then compare the byte number from Vat table again, and so on, untill it reaches DB300.DBD318. If it finds matching number then it will copy next 30 bytes from that point in DB300, and place them in DINO with offset of 8 bytes. Here is what I have so far, but for some reason plc exceeds cycle time and goes into stop mode. Can someone give me any pointers to what I might be doing wrong? Thanks
Pointer_Destination and Pointer_Source are ANY pointers
// load the number of FP we are looking for
L #FP_No_Char_1
T LB 4
L #FP_No_Char_2
T LB 5
L #FP_No_Char_3
T LB 6
L #FP_Sc_Char_1
T LB 7
//open DB300
OPN DB300
// start at byte 108
L 108
SLD 3
LAR1
// loop to find matching FP
top: A(
L DID 4
L D [AR1,P#0.0]
)
==D
JC S001
A(
L 318
SLD 3
TAR1
)
==D
JC END
L 30
SLD 3
LAR1
+D
LOOP top
TAR1
L #offset_A
S001: L P##Pointer_Source
LAR1
L W#16#1002 //10h for ANY type pointer, 02h for data type BYTE
T LW [AR1,P#0.0] //Transfer to the first part of the ANY Parameter
L 30
T LW [AR1,P#2.0]
L 300 //Load the Data Block number
T LW [AR1,P#4.0]
L P##offset_A //Load the address of the first byte
T LD [AR1,P#6.0]
L B#16#84 //84h is the DB memory area type
T LB [AR1,P#6.0]
L 8
SLD 3
T #Dest_Byte_Offset
// load AR1 into destination db
L P##Pointer_Destination
LAR1
L W#16#1002
T LW [AR1,P#0.0]
// length of copying range in bytes
L 30
T LW [AR1,P#2.0]
// db no.
L DINO
T LW [AR1,P#4.0]
// byte no. of start for db
L #Dest_Byte_Offset
T LD [AR1,P#6.0]
L B#16#84
T LB [AR1,P#6.0]
////////////////////////////////////////////////////////////////
// BLKMOV
CALL "BLKMOV"
SRCBLK :=#Pointer_Source
RET_VAL:=#SFC20_RET_VAL
DSTBLK :=#Pointer_Destination
END: SLD 0
I have a small problem, where I am trying to do following:
trying to run a script where it will check for matching input byte number (done in Vat table), and compare it with specific place in DB (expl. DB300.DBD108). If it deasn't find the matching number it will add 30 bytes to last address in DB300 (last address DB300.DBD100) and then compare the byte number from Vat table again, and so on, untill it reaches DB300.DBD318. If it finds matching number then it will copy next 30 bytes from that point in DB300, and place them in DINO with offset of 8 bytes. Here is what I have so far, but for some reason plc exceeds cycle time and goes into stop mode. Can someone give me any pointers to what I might be doing wrong? Thanks
Pointer_Destination and Pointer_Source are ANY pointers
// load the number of FP we are looking for
L #FP_No_Char_1
T LB 4
L #FP_No_Char_2
T LB 5
L #FP_No_Char_3
T LB 6
L #FP_Sc_Char_1
T LB 7
//open DB300
OPN DB300
// start at byte 108
L 108
SLD 3
LAR1
// loop to find matching FP
top: A(
L DID 4
L D [AR1,P#0.0]
)
==D
JC S001
A(
L 318
SLD 3
TAR1
)
==D
JC END
L 30
SLD 3
LAR1
+D
LOOP top
TAR1
L #offset_A
S001: L P##Pointer_Source
LAR1
L W#16#1002 //10h for ANY type pointer, 02h for data type BYTE
T LW [AR1,P#0.0] //Transfer to the first part of the ANY Parameter
L 30
T LW [AR1,P#2.0]
L 300 //Load the Data Block number
T LW [AR1,P#4.0]
L P##offset_A //Load the address of the first byte
T LD [AR1,P#6.0]
L B#16#84 //84h is the DB memory area type
T LB [AR1,P#6.0]
L 8
SLD 3
T #Dest_Byte_Offset
// load AR1 into destination db
L P##Pointer_Destination
LAR1
L W#16#1002
T LW [AR1,P#0.0]
// length of copying range in bytes
L 30
T LW [AR1,P#2.0]
// db no.
L DINO
T LW [AR1,P#4.0]
// byte no. of start for db
L #Dest_Byte_Offset
T LD [AR1,P#6.0]
L B#16#84
T LB [AR1,P#6.0]
////////////////////////////////////////////////////////////////
// BLKMOV
CALL "BLKMOV"
SRCBLK :=#Pointer_Source
RET_VAL:=#SFC20_RET_VAL
DSTBLK :=#Pointer_Destination
END: SLD 0