PDA

View Full Version : Simatic S7 Question


arocon
August 21st, 2011, 04:38 PM
Could anyone please explain me the following code ? How do it got DB number ? What is the use of the current_offset and RT_Int_ Offset? Why used in the code ITD, SLD 3, LAR1 ?? What is doing the code in between CNT and LOOP_CNT ?

// set BR = 1
SET
SAVE

// load constants
L "GlobalConstants".RT_Int_DB
T #DB_To_Open

L "GlobalConstants".RT_Int_Number
T #RT_Number

L "GlobalConstants".RT_Int_Size
T #RT_Size

L #Table_ID
T #Table_ID_Temp

// check for a valid DB number
L 0
L #DB_To_Open
==I
SPB DNE
T #DB_To_Open

// open block
AUF DB [#DB_To_Open]

L 0
T #Current_Offset

L #RT_Number

CNT: T #RT_Int_Counter
L #Current_Offset
ITD
SLD 3
LAR1
// offset for table id is 12
L DBW [AR1,P#12.0]
L #Table_ID_Temp
==I
SPB OFD
L #Current_Offset
L #RT_Size
+I
T #Current_Offset
L #RT_Int_Counter
LOOP CNT
DNE: L 0
T #RT_Int_Offset
BE
OFD: L #Current_Offset
T #RT_Int_Offset
BE


Thanks

L D[AR2,P#0.0]
August 21st, 2011, 05:14 PM
How do it got DB number ?


Back in the mists of time, the author of this program decided to create a global constants data block. In that data block he decided to store the number of the data block relevant for this code segement. Why he did this, we will probably never know. Maybe he was waiting for some potatoes to cook and they took longer than expected ?


L "GlobalConstants".RT_Int_DB
T #DB_To_Open


later on in this epic program, we find:


// open block
AUF DB [#DB_To_Open]