Siemens STL explanation

Join Date
Oct 2008
Location
Copenhagen
Posts
24
Hi Guys

I am trying to figure out, what exactly is happening in the below code.
I can see that they are looping through all the errorbits in DB50, but I am unable to figure out what they are doing with each bit.

Code:
      L     #NUMBER_OF_ERRORS   
M001: T     #ERROR_NUMBER     

      +     -1                          // 1 SUBSTRACT AS BIT START AT 0.0 AND NOT AT 0.1
      LAR1  

      OPN   DB [50]      		// OPEN error DB

      A     DBX [AR1,P#0.0]   

      OPN   DB [55]			// Open acknowledge DB

      TAR1  
      SLW   3                        
      LAR1                         
      =     DBX [AR1,P#0.0]             

      L     #ERROR_NUMBER
      LOOP  M001
 
The code checks for active error bits in DB50 and then sets the corresponding acknowledge bit located in DB55.
 
The bit number for DB50 is incremented, but for DB55 the byte number is incremented, e.g.

Code:
A DB50.DXB0.0
= DB55.DBX0.0
 
A DB50.DBX0.1
= DB55.DBX1.0
 
A DB50.DBX0.2
= DB55.DBX2.0
 
etc....
 
L #NUMBER_OF_ERRORS
M001: T #ERROR_NUMBER
+ -1 // Align with 0.0

// Load into address register 1
LAR1 OPN DB [50] // OPEN error DB

// And DBX[ERROR_NUMBER,P#0.0]

A DBX [AR1,P#0.0]

OPN DB [55] // Open acknowledge DB

// Transfer Error_Number back to Accumulator
TAR1

// Shift left 3 places to enter Byte area
SLW 3

// Load back into Address Register 1
LAR1

// = DB55.DBX [Error_Number,P#0.0]
= DBX [AR1,P#0.0]

// Load Error_Number into Accumulator
L #ERROR_NUMBER

// decrement 1 and jump to Label M001 until zero achieved
LOOP M001
 
It's been a while since I used S5, LOOPS and JUMPS. I don't see where you are jumping out of the loop to prevent timeout errors. You always have to be careful about jumping UP in a program loop as to not get caught in an endless loop.
 
t
It's been a while since I used S5, LOOPS and JUMPS. I don't see where you are jumping out of the loop to prevent timeout errors. You always have to be careful about jumping UP in a program loop as to not get caught in an endless loop.

This is not S5 but S7.
The LOOP instruction decreases AKKU 1 with 1 and loops to the label M001 until AKKU 1 is zero. The ERROR_NUMBER is used as loop counter.

Kalle
 

Similar Topics

Hi Siemens Experts, I am hoping someone can shed some light on my issue. I have uploaded the code from a S7-300 (317-2PN/DP) using Step 7...
Replies
9
Views
674
I'm having trouble trying to convert this code to ladder, anyone able to help me? A M4.0 A M4.1 A M117.0 AN M17.7 A ( A I38.6 AN I3.7 O ( A M4.5...
Replies
8
Views
1,206
Hello, I am still new to STL. But from what I understand is the JC mnemonic should jump if RLO = 1. If we review both pictures the M0bf RLO = 1...
Replies
5
Views
1,051
Hello, I am working on a project to upgrade some old S5-100U processors. The programs are all uploaded and I don't have descriptors...ugh. Be that...
Replies
4
Views
1,167
I really struggle with STL in Siemens Step 7 Classic. I'll learn chunks, but then I don't use it enough to retain and build on the knowledge. When...
Replies
17
Views
3,216
Back
Top Bottom