S7 Push / Pop

mjoha266

Member
Join Date
Jan 2008
Location
Gothenburg
Posts
34
Hello!

So I have a little problem... ...again...
I want to call a little code snippet where I do some instructions and the go back to the exact same place I were before. The thing is that I want to be able to call it from different places (in one network, the snippet is also in that same network (for now at least)) so I can't use jump instr. because I don't know where to jump.

Now, I have read a assembler course and I remember a simular problem there, however that was solved with the PUSH and POP instr. so somewhere in the code I could PUSH, then jump and do stuff, then POP and continue at the same place...

I see that there is PUSH and POP instr. in S7 to, but from the help it only stores the ACCU's and I want to store some kind of ProgramPointer as well.

Any Ideas?

/Thanks!
 
I'm not quite sure what your problem is. If you have your "code snippet" in its own FC and call it from another FC, once the called FC has run the program returns to the instruction after the FC call in the calling FC. This is handled by the operating system,, so there is no need for you to do anything special.
 
Cant you use an address register AR1/2? you could then use the instruction TAR to save your data to a Temp Dword, then load the temp dword back using LAR after you have done what you need to do.
 
RMA said:
I'm not quite sure what your problem is. If you have your "code snippet" in its own FC and call it from another FC, once the called FC has run the program returns to the instruction after the FC call in the calling FC. This is handled by the operating system,, so there is no need for you to do anything special.

Well that would probably work, just get one problem... I use Pointers and I can't find any way to redirect the pointers from my first block to in ports on the "support block"... They just get's red.

But if you know how to solve that....
 
Ok so this is a more schematic image o what I want to do... Don't really understand the TAR instr. there "STL???" I need to be able to "jump" back to where i was before the fist jump.

plc111.jpg


So in the bleu boxes there should be some kind of jump directions, and at the end of the green box there shall be a instruction to go back to where it were before the call (or the row after the jump...)
 
Last edited:
Put your repeatable code in a FC with no parameters (say FC99). Call the FC using UC FC99. FC99 will then execute with the accumulators and address registers as set in the calling block. If you need to save anything, save in local data at the start and restore it at the end.
 
Well I have two POINTERS that have to go in to that block otherwhise maby I could have put a pointer in the AR1 or 2 and save it there, and I can't hardcode it in FB99. so... ?


plc112.jpg

i.e. I have one in pointer in my primary block. And I want to redirect that pointer to anather block then, but that dosn't work.
 
Are the parameters DB pointers or Any pointers.
If DB pointers, then extract the DB and Area pointer and pass these two variables on to your other FC. You cannot pass on DB pointers.
If they are any pointers then you will have to create the any pointer you are passing on from the original any pointer.
 
You may use JL:
I think it will work, but i didnt tried that



SUB:
.......
L www //Load jump destination number into ACCU 1-L-L.
JL ww1 //Jump destination if ACCU 1-L-L > 3.
JU SEG0 //Jump destination if ACCU 1-L-L = 0.
JU SEG1 //Jump destination if ACCU 1-L-L = 1.
JU SEG2 //Jump destination if ACCU 1-L-L = 2.
JU SEG3 //Jump destination if ACCU 1-L-L = 3.
ww1: JU END
SEG0:
..............
L 1
T www
JU SUB
SEG1:
.........
L 2
T www
JU SUB
SEG2:
.........
L 3
T www
JU SUB
SEG3: .........
L4
T www
JU SUB

END:
..........
 
Hi mjoha266,

When looking at your schematic image I think of the solution to just make an FC (or FB for that matter) of the "Repeatable code"- part and then make conditional calls of that FC between the different "Specific code"-parts and send different values for the in-parameters.

If your in-parameter to this FC is a ANY-pointer you will have to construct this pointer in a dynamic way.


I agree with RMA, it is easier to understand what you want to achive if you post your code.


Regards Wille
 

Similar Topics

FactoryTalk View ME running on PanelView Plus 7, connected to Compact GuardLogix 5380 PLC Customer is asking for a physical push button to be...
Replies
6
Views
181
Looking for some help ! I need to change an inverters frequency using two speed steps. The operator uses a momentary push button. So first press...
Replies
8
Views
1,387
I have 2 Absolute Encoders 8192 steps per Rev. (Model TR Electronic CEV65m-11003) These Encoders communicate to the PLC5-60 via Parallel push/pull...
Replies
3
Views
1,514
Hello all, I'm currently working on a project where I need to have a reset in place on my HMI (PanelView Plus 1500 for reference) to put my...
Replies
5
Views
1,427
Hello everyone, Does anybody know if there is a way of simulating the behaviour of a FTV momentary push button on iFix? I am trying to create a...
Replies
5
Views
1,766
Back
Top Bottom