To all Siemens STL programmers or masters

drspanda

Member
Join Date
Oct 2005
Location
Damanjodi
Posts
155
Hello everyone,

I am presenting STL code and I want to clarify the statements shown in red color. For example IF DB300.DBW34=22, then #p_rec_db =222....Does OPN DB [#p_rec_db] opens DB 222?? if that is the case I am not finding DB 222 in the blocks folder of the S7 program...

OPN DB 300 //create recipe pointer
L DBW 34
L 200
+I
T #p_rec_db //Temporary variable INT
OPN DB [#p_rec_db] //get sp values
A DBX 0.3
= #br_mode_conti_field17
L DBW 42 //temperature
ITD
DTR
T #sp_temp_field17
T #sp_temp_conti
L DBW 2 //which DB? Is it DB 300 or DB 222
T #rec_no_field17
L DBW 58 //oil pressure
T #oil_press
L DBW 72 //combAir pressure min
T #combAir_press_min
L DBW 74 //combAir pressure max
T #combAir_press_max
L DBW 50 //lambda
T #la
 
#p_rec_db should be in WORD format and if 22 is added to 200 should indeed be DB222.

I presume you have looked off-line for the DB, try on-line, sometimes DB's are generated by the code. In a system I am working with at the moment, the file contains DB's up to 500, in the PLC there are 1200.

If you status the code, you should be able to see the DB opened in the status column, you may have to turn on the option on what to see in the status column.

All DB access after that open instruction would be the inditrectly addressed DB.
 
Hey

OPN DB 300 //create recipe pointer
L DBW 34
L 200
+I
T #p_rec_db //Temporary variable INT
OPN DB [#p_rec_db] //get sp values
I am presenting STL code and I want to clarify the statements shown in red color. For example IF DB300.DBW34=22, then #p_rec_db =222....Does OPN DB [#p_rec_db] opens DB 222

That's true, if DB300.DBW34=22, u add it with 200 and transfer it in the #p_rec_db variable. So this will call DB222.

L DBW 2 //which DB? Is it DB 300 or DB 222


it will be DB222 if DB300.DBW34=22
 
One remark. Often programmer can insert bug in this type code if he wants to call another DB directly inside of indirect call. If you need to use it, you must to reopen indirectly addressed DB. Example:
Code:
OPN DB 300 //create recipe pointer
L DBW 34
L 200
+I 
T #p_rec_db //Temporary variable INT
[color=#ff0000]OPN DB [#p_rec_db][/color] //get sp values
A DBX 0.3
= #br_mode_conti_field17
L DBW 42 //temperature
ITD 
DTR 
T #sp_temp_field17 // All OK, this is DB222
T DB100.DBD20
L DBW 2 //[color=#ff0000] Bug! This is attempt to load DB100.DBW2 instead of DB222.DBW2![/color]
[color=#ff0000]
[/color]
 
Gambrinus said:
One remark. Often programmer can insert bug in this type code if he wants to call another DB directly inside of indirect call. If you need to use it, you must to reopen indirectly addressed DB. Example:
Code:
OPN DB 300 //create recipe pointer
L DBW 34
L 200
+I 
T #p_rec_db //Temporary variable INT
[color=#ff0000]OPN DB [#p_rec_db][/color] //get sp values
A DBX 0.3
= #br_mode_conti_field17
L DBW 42 //temperature
ITD 
DTR 
T #sp_temp_field17 // All OK, this is DB222
T DB100.DBD20
L DBW 2 //[color=#ff0000] Bug! This is attempt to load DB100.DBW2 instead of DB222.DBW2![/color]
[color=#ff0000]
[/color]


Not sure how this relates to indirectly addressed DB's. The above would open DB100 and leave that block open afterwards, this is the case whatever.

One of my pet hates is seeing people code DB bits as flags and then using them as such, constantly switching the open DB, perhaps not even considering the above example of what they are doing.

A DBX1.0 already takes more memory and scantime to perform than a simple A M1.0 type instruction, add to that the OPN DBx when using instructions scuch as A DB100.DBX1.0.

Simply having the DB part there uses up scantime, even if the DB was already open.
 
PeterW said:
If you status the code, you should be able to see the DB opened in the status column, you may have to turn on the option on what to see in the status column.

How should I turn on the option to see in the status column?
 
Right click with the mouse pointer in the status area, then select show, this will give you a list of options to display.
 

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
675
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,207
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