dynamic Array indexing - SIEMENS PLC

Is this possible somehow:
i want to call specific FB with dynamic DB, so like this

if MW50 = 2 then
FB40.DB102();
end_if;
if MW50 = 3 then
FB40.DB103();
end_if;
if MW50 = 4 then
FB40.DB104();
end_if;

Is this possible to do somehow in SCL without if else statements,
something using WORD_TO_BLOCK_DB() function or w/e
 
OPN DB400
L "MD80"
L 2
*D
SLD 3
L P#DBX 36.0
+D
LAR1
L 50
T D [AR1,P#0.0]

If i PUT INSIDE md80 = 1(IT'S dword)
i WANT TO PUT INSIDE db400.dbw38 = 50
IF i PUT inside md80 = 2 then
i WANT TO PUT INSIDE db400.dbw40 = 50
and so on.
I checked my LAR1 binary format adress and it's correct:
if MW80 is 1 theen pointer point on db400.dbw38, for 2 it's
db400.dbw40,
BUT FOR SOME unknown reason to me I always get value 50 in the
higher adress for 2 bytes. FOR example, if MW80=1 then db400.dbw40 = 50, if MW80=2 then db400.dbw42 = 50,
MD80 is DWORD
and DB400.DBW36... are INT variables
Why this happens?
 
Last edited:
OPN DB400
L "MD80"
L 2
*D
SLD 3
L P#DBX 36.0
+D
LAR1
L 50
T D [AR1,P#0.0]

If i PUT INSIDE md80 = 1(IT'S dword)
i WANT TO PUT INSIDE db400.dbw38 = 50
IF i PUT inside md80 = 2 then
i WANT TO PUT INSIDE db400.dbw40 = 50
and so on.
I checked my LAR1 binary format adress and it's correct:
if MW80 is 1 theen pointer point on db400.dbw38, for 2 it's
db400.dbw40,
BUT FOR SOME unknown reason to me I always get value 50 in the
higher adress for 2 bytes. FOR example, if MW80=1 then db400.dbw40 = 50, if MW80=2 then db400.dbw42 = 50,
MD80 is DWORD
and DB400.DBW36... are INT variables
Why this happens?

You are writing double words to ints.
 

Similar Topics

Hello All, Needing some help with finding Min max values in an array that can have a dynamic element count. The Sort function in Logix 5K only...
Replies
9
Views
5,719
Hi, I want to create a block that takes a dynamic number of inputs like the AND, OR or MUX blocks in Unity Pro for Schneider Quantum PLC. You...
Replies
4
Views
6,035
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
241
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
765
Back
Top Bottom