indirect addressing

martin3885

Member
Join Date
Aug 2005
Location
Saarland
Posts
144
Hi everyone!
Is it possible to call FB which number will be given by indirect addressing? I mean I need to call the FB No. where No. is the parameter which stores a number of an FB which I want to call. In other words I don't want to call for example a FB1 but FB No. Sometimes No.=1, sometimes No.=10... The same thing I need to do by opening a data block.

Best regards
Martin
 
To call FB's and FC's indirectly, you cannot pass parameters in the call and you use the following method:

L 1
T MW 100
UC FB [MW 100]

If you want to use parameters, declare them in the interface and load them manually before you call the FB, then read them manually after calling the FB. You must set AR2 and the instance DB yourself. I think there is another thread that gives a more specific example, I'll have a look for it.
 
Thanks RMA.

One more question, it should be easy(but not for me:) ). How can I print my program to the txt or doc file? I do it with print instruction but I can only print to the pdf file.
 
From the block editor, options/customize/sources tick the box "Generate Source Automatically". Every time you save a block, the source code will be produced in your source code folder. You can then export the source code or open the source code and cut/paste the text. Hope this is what you are trying to do.
 
Hi,
I was looking at the Simons' programm http://www.plctalk.net/qanda/showthread.php?p=95075&highlight=ar2#post95075,
and I don't know one thing.
In the network 3 we do following thing:

TAR2 #dwar2Store //save AR2 as it points to this FBs instance data, don't refer to static data in this network !
L P##fbQ1 //point to start of data
+AR2 //for first instance
L P##fbQ2 //point to next instance

I mean we do +AR2. It means that we add Akku1 to the AR2, but how do we know what is in AR2 on the begining?
Why don't we use here an instruction TAR2?
 
At the start of the call to FB3, AR2 points to the static data area associated with this instance of FB3 and will depend on where FB3 has been called from (as well as how many other instances have been declared). Note also that the only requirement for the static data area is that FBQ1...FBQ5 follow on from each other, if more static data was to be declared before them, I need to point to the start of FBQ1's static data area and add this offset on to AR2 to keep the code generalised.

Try declaring FB3 as several instances in another FB, then call the second instance only. If you monitor AR2 you will see it will point part way through the instance DB and not the start of the DB.
 
"Try declaring FB3 as several instances in another FB, then call the second instance only. If you monitor AR2 you will see it will point part way through the instance DB and not the start of the DB."

You mean to make some static variables of type FB3?
For example: Object1 type:FB3
Object2 type:FB3
.
.
.
 

Similar Topics

Howdy folks, I am an Allen Bradley guy currently living in an Emerson world. Working with Rx3i on PacSystems Machine Edition v. 9.6? i think...
Replies
3
Views
620
Hello, I'm very new to programming with absolutely zero schooling in this field and pretty hands off training in my new role, it's been fun...
Replies
4
Views
666
Hello Friends, I am trying to index M Bits, however GX Works2 is not allowing it with following message. https://ibb.co/zPcqj6M...
Replies
3
Views
1,376
Hi All, which the best way to do the indirect addressing in an optimize DB? Ccurrently this is my partial code inside an FB...
Replies
7
Views
2,271
Hey everyone, Just used the PLC5/Logix migration utility to convert a program, and while addressing the PCEs, I noticed a lot of errors for "XIC...
Replies
12
Views
1,968
Back
Top Bottom