S7, Indirect Jumping Possible ??

pethoek

Member
Join Date
Apr 2009
Location
Järbo
Posts
105
I wonder if there is a way of doing indirect jumping in S7.

This is what i would like to do....
Code:
LAR1 P##Ptr // Pointer addr
L W#16#1018 // FC - Type
L W [AR1,P#0.0]
L W#16#0
T W [AR1,P#2.0] // Word 2 = 0
T W [AR1,P#4.0] // Word 4 = 0
T W [AR1,P#6.0] // Word 6 = 0
L W#16#2 // FC 2
T W [AR1,P#8.0] // FC Number
Now i was hoping i could do something like

CALL Ptr, instead of CALL FC 2

And by changing the number for FC in the pointer, be able to call for different FC's.

I can ofcource use some kind of jump table
if x=1 then call FC 2
if x=2 then call FC 3

But i think it would be a nice way of calling different FC's just by passing a FC-number to some FC and the call for that FC was made.

Is there a way of doing this in S7.

Best Regards
Pethoek
 
Last edited:
Guess a simple solution to my problem would be something like...

Code:
L #ID
 
L 2
==I 
CALL FC 2
 
TAK 
L 3
==I 
CALL FC 3
 
TAK 
L 4
==I 
CALL FC 4
 
"
"
"
 
... with some jumps around the calls (JCN skp2) and a jump to the end of the table after each call (accu will have changed) of course!
 
Here's how to call an FC indirectly. No parameters can be passed but if the FC does have parameters they will be read as if they are parameters from the code that is after the UC

popl.JPG
 
Sorry to mislead you but this is not a practical method. I am pointing out that if you called an FC using the UC FC method and the FC had parameters, the FC would attempt to access the parameters using the data present in the calling block immediately after the call - this would be the S7 opcodes !!!
 
I would also add limits here incase a FC is selected and doesnt exist inside your program.

Obviously the JL method would handle this.
 
You can pass parameters in a register or..

you can pass a pointer to the parameters in a register. These parameters can't be accessed as input or output parameters though. Essentially this is what the S7 code does when it calls a FB. AR2 is loaded with a pointer to the DB. This makes L D [AR2,P#0.0] first method more usable.

I really wish I could do this
L D [AR2,P#VAR1]
L D [AR2,P#VAR2]
+
T D [Ar2,P#VAR3]
 

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
Hey, I'm trying to do the following, I have some experience with Citect but can't seem to figure this out. I/O Tag: BoxPos1_ProdNum (Data Type...
Replies
0
Views
577
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
668
Hi, I have this code: LAR1 P##structy L 0 T LW [AR1,P#0.0] which resets all the bits in this struct called structy...
Replies
1
Views
641
I have upgraded an old RS500 project to Studio 5000, it has thrown multiple errors which I am currently working through. I have looked through...
Replies
8
Views
1,724
Back
Top Bottom