12/13/2018 8:46 AM | |
Joined: 3/25/2015 Last visit: 9/5/2024 Posts: 43 Rating:
|
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. 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: // check if a read is active, if not continue to start conditions //If read is in progress Jump to send the next requested segment A #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 // Copy the information retrieved to the DB CALL "BLKMOV" SRCBLK :=P#M 456.0 BYTE 14 // normally here should be the Input bytes but for testing M456 RET_VAL:=#Move_Ret_Val DSTBLK :=#DB_Address // Check When the ma segment number is reached and end the current read 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 AttachmentTest_Proj.zip (58 Downloads) |
Last edited by: Rui_t at: 12/13/2018 9:00:21 AMLast edited by: Rui_t at: 12/13/2018 9:44:47 AM |
|
12/13/2018 11:29 AM | |
Joined: 1/17/2007 Last visit: 8/21/2024 Posts: 1545 Rating:
|
On initial inspection I can see obvious error and one possible error. The obvious error is that you are loading the area address into the wrong part of the ANY pointer. You should be merging the Plz_input value with the 16#84 to build an any pointer and then loading these 4 bytes (DW) into the pointer at offset 6 ([AR1,P#6.0]. |
Programming today is the race between software engineers building bigger and better idiot proof programs, and the universe producing bigger and better idiots. |
|
This contribution was helpful to
1 thankful Users |
Follow us on