Hello Everyone,
I am making an FB that is going to retrieve information from a Pilz Multi.
The information given from the Pilz Multi is made up of Tables and segments and for now I am only going to read the information from table 1 which has 9 (0-8) segments of 14 bytes.
To retrieve the information, the table number and segment number must be sent to the Pilz via two output bytes. Then the requested segment is sent via 14 Input bytes that I will transfer to a DB to be shown on an HMI later on.
I am kinda new to Pointers so I am hoping someone can help me find the error in my program.
The problem I am having is that the FB is only sending information to the first two sets of 14 bytes and I cant find why, If it is working for the first and second group of 14 bytes it should also work for the remaining 7 group of 14 bytes.
I think there is a problem with the any pointer I created for the DB but I dont know where the problem is
Here is the program I have created:
NETWORK 1:
// ANY address Structuring
LAR1 P##DB_Address // load AR1 with ANY pointer
L B#16#10
T LB [AR1,P#0.0] // Constante in S7
L B#16#2
T LB [AR1,P#1.0] // Datatype in Pointer (02 = Byte)
L 14 //
T LW [AR1,P#2.0] // Repetition factor (14 = 14 bytes)
L #DB_Info_Number
T LW [AR1,P#4.0] // DB number
L B#16#84
T LB [AR1,P#6.0] // Memory area (b#16#84 = DB)
NETWORK 2:
// cheack if a read is active, if not continue to start conditions
//If read is in progress Jump to send the next requested segment
ON #Get_Info
JC NA
O #Read_In_Progress
JC Send
// Start - Begin by Requesting Table 1, Segment 0
A #Get_Info
JCN NA // if Get_Info is not active do nothing
L 1
T #Table_Request
L 0
T #Segment_request
// send the Requested table and segment to the Pilz Multi
Send: L #Pilz_Input
SLD 3
LAR1 // load AR1 with Output Pointer
L #Table_Request
T QB [AR1,P#4.0] // Send requested Table
L #Segment_request
T QB [AR1,P#5.0] // Send requested Segment
S #Read_In_Progress // set to know a read is in progress
// ANY address Structuring for area where the data is to be stored
LAR1 P##DB_Address // load AR1 with ANY pointer
L #Segment_request
L 14
*I
T LD [AR1,P#6.0] // Memory area in which the information is stored
// Wait For Feedback from Pilz
// If the segment value recieved is FF then this means fault, go to next segment
L #Pilz_Input
SLD 3
LAR1
L B#16#FF
L IB [AR1,P#5.0]
<>I
JCN Seg
//Pilz must send same table and Segment to be able to copy information
// L IB [AR1,P#4.0]
L MB 500 // For testing
L 1
==I
// L IB [AR1,P#5.0]
L MB 501 // For testing
L #Segment_request
==I
JCN END
// Copy the information retrived to the DB
CALL "BLKMOV"
SRCBLK :=P#M 456.0 BYTE 14 // For testing replace with Pilz Input
RET_VAL:=#Trash
DSTBLK :=#DB_Address
// Check When the ma segment number is reached and end the current read
Seg: L #Segment_request // Check for max segment and End the read Progress
L 8 // Table 1 has 8 segments
==I
JC NA
// Add 1 to read the next segment in the next cycle
L #Segment_request
+ 1
T #Segment_request
JC END
// If get_Info is not active or max segment reached then send 0 to the Pilz Multi
NA: L 0 // Load zero
T #Table_Request
T #Segment_request
L #Pilz_Input
SLD 3
LAR1 // load AR1 with Output Pointer
L #Table_Request
T QB [AR1,P#4.0]
L #Segment_request
T QB [AR1,P#5.0]
R #Read_In_Progress // End the read progress to start again a new read
END: NOP 0
The FB has three inputs:
an INT input #DB_Info_Number
An INT input #Pilz_Input
and a bool input #Get_Info
Thanks for any help given
I am making an FB that is going to retrieve information from a Pilz Multi.
The information given from the Pilz Multi is made up of Tables and segments and for now I am only going to read the information from table 1 which has 9 (0-8) segments of 14 bytes.
To retrieve the information, the table number and segment number must be sent to the Pilz via two output bytes. Then the requested segment is sent via 14 Input bytes that I will transfer to a DB to be shown on an HMI later on.
I am kinda new to Pointers so I am hoping someone can help me find the error in my program.
The problem I am having is that the FB is only sending information to the first two sets of 14 bytes and I cant find why, If it is working for the first and second group of 14 bytes it should also work for the remaining 7 group of 14 bytes.
I think there is a problem with the any pointer I created for the DB but I dont know where the problem is
Here is the program I have created:
NETWORK 1:
// ANY address Structuring
LAR1 P##DB_Address // load AR1 with ANY pointer
L B#16#10
T LB [AR1,P#0.0] // Constante in S7
L B#16#2
T LB [AR1,P#1.0] // Datatype in Pointer (02 = Byte)
L 14 //
T LW [AR1,P#2.0] // Repetition factor (14 = 14 bytes)
L #DB_Info_Number
T LW [AR1,P#4.0] // DB number
L B#16#84
T LB [AR1,P#6.0] // Memory area (b#16#84 = DB)
NETWORK 2:
// cheack if a read is active, if not continue to start conditions
//If read is in progress Jump to send the next requested segment
ON #Get_Info
JC NA
O #Read_In_Progress
JC Send
// Start - Begin by Requesting Table 1, Segment 0
A #Get_Info
JCN NA // if Get_Info is not active do nothing
L 1
T #Table_Request
L 0
T #Segment_request
// send the Requested table and segment to the Pilz Multi
Send: L #Pilz_Input
SLD 3
LAR1 // load AR1 with Output Pointer
L #Table_Request
T QB [AR1,P#4.0] // Send requested Table
L #Segment_request
T QB [AR1,P#5.0] // Send requested Segment
S #Read_In_Progress // set to know a read is in progress
// ANY address Structuring for area where the data is to be stored
LAR1 P##DB_Address // load AR1 with ANY pointer
L #Segment_request
L 14
*I
T LD [AR1,P#6.0] // Memory area in which the information is stored
// Wait For Feedback from Pilz
// If the segment value recieved is FF then this means fault, go to next segment
L #Pilz_Input
SLD 3
LAR1
L B#16#FF
L IB [AR1,P#5.0]
<>I
JCN Seg
//Pilz must send same table and Segment to be able to copy information
// L IB [AR1,P#4.0]
L MB 500 // For testing
L 1
==I
// L IB [AR1,P#5.0]
L MB 501 // For testing
L #Segment_request
==I
JCN END
// Copy the information retrived to the DB
CALL "BLKMOV"
SRCBLK :=P#M 456.0 BYTE 14 // For testing replace with Pilz Input
RET_VAL:=#Trash
DSTBLK :=#DB_Address
// Check When the ma segment number is reached and end the current read
Seg: L #Segment_request // Check for max segment and End the read Progress
L 8 // Table 1 has 8 segments
==I
JC NA
// Add 1 to read the next segment in the next cycle
L #Segment_request
+ 1
T #Segment_request
JC END
// If get_Info is not active or max segment reached then send 0 to the Pilz Multi
NA: L 0 // Load zero
T #Table_Request
T #Segment_request
L #Pilz_Input
SLD 3
LAR1 // load AR1 with Output Pointer
L #Table_Request
T QB [AR1,P#4.0]
L #Segment_request
T QB [AR1,P#5.0]
R #Read_In_Progress // End the read progress to start again a new read
END: NOP 0
The FB has three inputs:
an INT input #DB_Info_Number
An INT input #Pilz_Input
and a bool input #Get_Info
Thanks for any help given