Dynamic choosing DB in PLC STEP7

Sergihno

Member
Join Date
Oct 2016
Location
Ukraine
Posts
70
Hello,

Who can help with syntax of choosing DB by parameter number in PLC from HMI, for example?

How to present some variable as parameter number of DB?
 
Which HMI and which PLC are we talking about?

If using S7 300/400's and WinCC Flexible, you can use indirect addressing (also called multiplexing) to access the data.

If you declare a tag pointing to a an address, it would normally look like this:
Code:
DB5.DBW142
However, if you want to do indirect addressing, then you would write it like this, storing the value of the actual DB number you want to access in DBNUMTAG:
Code:
DB[DBNUMTAG].DBW142
Note that if DBNUMTAG has an invalid value, the tag won't update correctly.
 
indirect addressing is not supported, if you use classic step 5.4
Only way is to use STL, but you can put STL on own FB or FC block and call FC/FB block from ladder.

On newer Tia portal indirect addressing can be used on ladder. It would be preety much DB[DBNUMTAG].DBW142 on move block
 
If you declare a tag pointing to a an address, it would normally look like this:
Code:
DB5.DBW142
However, if you want to do indirect addressing, then you would write it like this, storing the value of the actual DB number you want to access in DBNUMTAG:
Code:
DB[DBNUMTAG].DBW142
Note that if DBNUMTAG has an invalid value, the tag won't update correctly.


It doesn't work. I can't write in this way. I use SFC20 to move DB.
Direct addressing is working so:
Code:
P#DB1.DBX0.0 BYTE 16
But indirect one doesn't work with parameter in square brackets.

How to write it properly?
 
I'm working with STEP7 v5.5. Is it possible to do it there?

It is not possible on step7 5.5. You need to go SCL or STL coding.

"indirect addressing is not supported, if you use classic step 5.4
Only way is to use STL, but you can put STL on own FB or FC block and call FC/FB block from ladder. "
 
Indirect addressing is possible in ladder - e.g. here's an example that copies data from a fixed DB to a variable DB using SFC20. Give exact specifics of what you want to do for further examples.

ladind.jpg
 
Could you explain where you are combining these L registers into destination address structure?
Could you please, attach your FC content area?
 
Last edited:
Here's the source code.

Code:
FUNCTION FC 3 : VOID
TITLE =
VERSION : 0.1


VAR_TEMP
  Data : ANY ;    
  iSFC20RetVal : INT ;    
END_VAR
BEGIN
NETWORK
TITLE =pointer format = byte

      L     W#16#1002; 
      T     LW     0; 
      NOP   0; 
NETWORK
TITLE =byte count

      L     10; 
      T     LW     2; 
      NOP   0; 
NETWORK
TITLE =dest db

      L     2; 
      T     LW     4; 
      NOP   0; 
NETWORK
TITLE =dest area

      L     P#DBX 0.0; 
      T     LD     6; 
      NOP   0; 
NETWORK
TITLE =block copy

      CALL "BLKMOV" (
           SRCBLK                   := P#DB1.DBX0.0 BYTE 10,
           RET_VAL                  := #iSFC20RetVal,
           DSTBLK                   := #Data);
      NOP   0; 
END_FUNCTION
 
Here's the source code.

Code:
FUNCTION FC 3 : VOID
TITLE =
VERSION : 0.1


VAR_TEMP
  Data : ANY ;    
  iSFC20RetVal : INT ;    
END_VAR
BEGIN
NETWORK
TITLE =pointer format = byte

      L     W#16#1002; 
      T     LW     0; 
      NOP   0; 
NETWORK
TITLE =byte count

      L     10; 
      T     LW     2; 
      NOP   0; 
NETWORK
TITLE =dest db

      L     2; 
      T     LW     4; 
      NOP   0; 
NETWORK
TITLE =dest area

      L     P#DBX 0.0; 
      T     LD     6; 
      NOP   0; 
NETWORK
TITLE =block copy

      CALL "BLKMOV" (
           SRCBLK                   := P#DB1.DBX0.0 BYTE 10,
           RET_VAL                  := #iSFC20RetVal,
           DSTBLK                   := #Data);
      NOP   0; 
END_FUNCTION

You've just converted it to STL).
Could you explain in what registers I can put the structure of what I want to copy?
You put your structure to destination address to L area.
In what way you connect these L areas, containing structure, with your output #Data ?
 
In Step 7 go to the help system and search for the format of the ANY pointer. The help is very good and will show you the 10 byte structure.

The STL that was posted is the source code for the ladder, so you can copy it and place it in your block to see how it works.

The L addresses are the direct address of Temp variables.

Once you look up the format of the ANY pointer you will be able to dynamically changed the DB you reference in the BLK_MOV
 

Similar Topics

Hello, I have a requirement to manage the text alignment dynamically. So, for example: 1. English Texts should be displayed from Left in...
Replies
0
Views
90
Rockwell Tech Support seemed to have hit a wall with this question. Already updated the version to 5.00.13 per their suggestio but am still...
Replies
2
Views
214
Maybe this is just not possible, or maybe I am doing something wrong. Background; I have a data array of over 1500 products. For sorting I...
Replies
6
Views
757
HEllo, still satruggling with the curse WinCC Unified. See attached picture. I just want to change the fill colour from turqoise to grey and then...
Replies
5
Views
464
I need assistance with writing a logic for sending data from a Station PLC using 1 MSG instruction to an AGC PLC in every cycle using a CIP Data...
Replies
2
Views
580
Back
Top Bottom