Step 7 and Addressing a DB question

BachPhi

Member
Join Date
Dec 2007
Location
Los Alamos
Posts
641
When looking at the DB declaration ( see below pic), I did not see addresses like DB108.DBX203.0 or DB108.DBX205.0 and so on .... and yet they were used in the program. Can someone explain this to me? TIA


Step7_DBAddressing.gif
 
You will never see the DB108.DBX part in the DB view, all you will see is the address e.g 200.0
 
Lets break down DB108.DBX205.0:

DB = The memory location is a Data Block
108 = the Data block's number is 108
DBX = access a bit in a DB. X = bit, B (DBB) = byte, W = word, D = double word
205 = byte in DB
0 = bit in DB

In your case, 205.0 is not actually used in the DB you showed us. You might want to be using 204.0 instead. You could also identify the bits by tag name instead: DBNAME.wta.bel, as one example.
 
I am lost! The current program is using DB108.DBX205.0, and yet when I check the DB108, I did not see DBX205 declared. That is my question here.
//------------------------------- WT-Transport --------------------------

// // innerer Pl.:
A DB108.DBX 203.0
= "WT.TRi_BEL" // belegt
A DB108.DBX 203.1
= "WT.TRi_GER" // gereinigt

// // äußerer Pl.
A DB108.DBX 205.0
= "WT.TRa_BEL" // belegt
A DB108.DBX 205.1
= "WT.TRa_GER" // gereinigt
 
I am lost! The current program is using DB108.DBX205.0, and yet when I check the DB108, I did not see DBX205 declared. That is my question here.

See my response above:

In your case, 205.0 is not actually used in the DB you showed us. You might want to be using 204.0 instead. You could also identify the bits by tag name instead: DBNAME.wta.bel, as one example.

It looks like a programmer error, however it might accidentally work anyway.

Technically, even though the bits are not declared, they are still in the DB regardless. As long as the programmer is consistent in accessing them, then it will probably work correctly. Obviously, this is not recommended practice.
 
I see. Just to clarify here, a bit address in the DB was assigned to a memory bit "WT.TRa_BEL", even though that bit address has not been declared, but the program will accept it?
 
Absolute address access sometimes works without anything being defined. You can definitely access M302.1 whether a tag for it has been declared or not. In some circumstances, it might work for a DB as well.

For symbolic address access (based on tag names), that definitely has to be declared. For M bits, the tags would be declared in the symbol table.

Depending on settings, Step 7 may automatically replace absolute names with symbolic ones, if they exist.
 
The STRUCT datatype will define 2 bytes as a minimum whether you allocate a symbol to each bit or not.
The absolute address is declared as part of the struct which is valid and will work just fine. It's absolutely confusing, so if you want to make a tag for it, just define the rest of the STRUCT as bools and address 205.0 will now be accessible as a symbolic tag. Just because it isn't "defined" doesn't mean it isn't there.

+204.0 WTA STRUCT
+0.0 bel
+0.1 ger
+0.2 spare_2
+0.3 spare_3
+0.4 spare_4
+0.5 spare_5
+0.6 spare_6
+0.7 spare_7
+1.0 NewTagName (THIS is DB108.DBX205.0)
+1.1 spare_11
+1.2 spare_12
+1.3 spare_13
+1.4 spare_14
+1.5 spare_15
+1.6 spare_16
+1.7 spare_17
 
There is bool db108.dbx202.0 and DB108.dbx204.0 defined.
Even that you dont define addresses DB202.2 onwards, DB block have bits db202.2- 203.7 addressed.
This is because next available address is DBx204.0

You can see this on db declaration, there is marking = 2.0 which means that addresses 202.0-203.7 are used on DB block.

Bits are also addressed on DB block if you have word addressing.
If you have DB204.DBW0 defined, You can also use bits DB203.DBX0.0 - DBX1.7, bits don't have symbol names on that case, but absolute addressing can be used for bits.

p.s travispedley writed faster
 
Last edited:
Siemens doesn't allow data types to start on an ODD byte address.
Even if you only declare 1 BOOL it will allocate 2 bytes.
Both images are the exact same, DB1.DBX1.3 is absolutely valid in both, but in one DB it isn't exactly defined, it's implicit.

explicit.jpg implicit.jpg logic.JPG
 
Got it! Thank You! They were implicitly declared, that makes sense.
I thought f%$#!Deutsche is normally more accurate than anybody else. :mad:
 

Similar Topics

Hello, what is wrong with the program like below to write 100 to DB81.DW24? %DB81.DW(IDX :=24) := 100; Or how should I write the program...
Replies
16
Views
5,157
Need the explaination of the code given below... Wgy not adding more than 8 real values.... L P##Measuring_values //Address of...
Replies
3
Views
2,097
Hello all, I have a question that hopefully has a yes :) I am scanning a bar code and bringing in that string in a DB34. I am trying to compare...
Replies
3
Views
3,609
I get a weekly email from Siemens Tech Support. It has Tech notes updates etc. This week they have the following example of indirect addressing...
Replies
0
Views
2,461
I am trying to modify an assembly machine that is capable of making several part types. I am adding an lvdt and want to be able to store different...
Replies
28
Views
15,866
Back
Top Bottom