Call Step7 FB with indirectly addressed DB

sryan

Member
Join Date
Sep 2005
Location
NJ
Posts
7
Hi all,

I'm trying to call an FB with an indirectly addressed instance DB. Something like

//instance DBs start at DB100, zone #s start at 0
L #zone
+ 100
T #dbnum //dbnum now has the number of the correct DB
CALL FB100, [#dbnum]

I've seen things like calling with an indirectly addressed multiple instance area, but nothing with data blocks.

Any ideas?

Thanks!
 
Got it!

Duh- I've been beating my head against the wall all day on this- and 20 seconds after I post, I got it.

For anybody who's interested,

L DINO
T #intCurrentDINum //save the current DI number so we can restore it after the call

L #zone
+ 100
T #intDINum
OPN DI[#intDINum]
UC FB100
OPN DI[#intCurrentDINum]

Make sure the DI registers are declared INT, and don't forget to restore your original DI before accessing any local variables.

I hope this saves somebody some time- I'd hate to think I'm the only one dumb enough to miss this solution.
 

Similar Topics

Hi All In RSLogix is always a JSR to call in all Programm Routines into the main Program. HOW IS SAME DONE IN SIMATIC MANAGER and TIA Portal to...
Replies
12
Views
2,808
In older step7 versions it was not preferable using direct acess to UDT data in the block interface. (defined as in/out paramters to FB/FC blocks...
Replies
2
Views
3,399
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
566
I created this FC and it compiles, but when I use it in my MAIN OB1, it appears to have two outputs. See pictures. What am I doing wrong here...
Replies
9
Views
1,392
Is there a way in CX-Programmer to call Ladder Instructions from a structured text program? I can see several functions in the autocomplete...
Replies
3
Views
1,822
Back
Top Bottom