Step 7 OB1 problem

stevelawson

Member
Join Date
Feb 2004
Posts
115
Hi everyone.
I have a small routine in FC 1 and when the routine is finished i would like to initiate a seperate routine in FC 2 using the same Inputs and Outputs but in a different order. The last instruction in FC 1 resets the routine to its start position with M 0.7

When M0.7 is set i want to block FC 1 in OB 1 from being processed, until FC 2 as finished doing its bit, then reset M 0.7 so that FC 1 gets processed again and the whole thing repeats.

This is what i wrote in OB 1

AN M 0.7
CALLL FC 1

A M 0.7
CALL FC 2

When i try to run this, the program appears to be running on the PC, all the relevant I/O go Green, but none of the valves operate. If i remove
A M 0.7
CALL FC 2
FROM OB 1 then FC 1 runs fine. What am i doing wrong please.

Many thanks.

Steve.
 
Well mate as OB 1 runs every scan & I assume that the outputs in FC 1 are set then you set the flag it will automatically run FC2 & this resets the flag so on next scan FC1 runs again, what you are doing is actually allowing both FC's to run one after another so the outputs are at the status of FC2 (outputs are updated at the end of the scan of OB1).

The only way is to delay one or the other within the FC's
i.e.
in FC1

.....
.....
....
a xxx
time value here
sd t100
a T 100
s M 100.0
BE
or some other logic that only sets the flag when processing of a correct status has been acheived.
 
As you have written the code in stl, you will need to use jump conditionals around the FC's to prevent them being called.For example:

AN M 0.7
jcn skp1
CALL FC 1 //FC1 only called if M0.7=0
skp1: nop 0

A M 0.7
jcn skp2
CALL FC 2 // FC2 only called if M0.7=1
skp2: nop 0
 
Last edited:
Two points:

Control M0.7 external to the FCs if you only want one of the FCs to run each scan. If you control M0.7 in the FC both FCs will run. Put a toggle of M0.7 after the FC2 call in OB1.

In case you didn't make this inference from from the last post, not all instructions are contingent on the RLO in a Siemens processor. CALL happens to be one of those items, as are (??I think??) all of the math instructions. Coming from AB programming that used to get me quite often.

Keith
 
Thanks for that guys, i will try this tomorrow.

Just one other thing, some of these abreviations are a little confusing for a S5 man. I assume that JCN is Jump conditional and maybe JUCN is Jump unconditional, but what is SKP?

Cheers.

Steve.
 
skp1 and skp2 are just labels for the jumps. They aren't instructions.

Also, JCN is 'Jump Conditional Not', which menas jump if the RLO is 0. JU is 'Jump Unconditional'.

Keith
 
I am so used to passing parameters to FC's that the jump method always comes to mind. If there are no parameters passed to the FC then the (more like step5) alternative method of coding would be:

AN M 0.7
CC FC 1

A M 0.7
CC FC 2
 
Thanks for that Keith.
JU is the same in both S5 and S7 then. However, if the RLO = 0 is that not an JU. Still a little confused.

S5 S7
JU Jump Unconditional JU Jump Unconditional
JC Jump Conditional is this the same
JCN Jump Conditional Not

Just need to clear this up.

Steve.
 
Thanks for that Keith.
JU is the same in both S5 and S7 then. However, if the RLO = 0 is that not an JU. Still a little confused.

S5 ................................S7
JU Jump Unconditional .............JU Jump Unconditional
JC Jump Conditional ...............is this the same
...................................JCN Jump Conditional Not

Just need to clear this up.

Steve.
 
In Step 7, all jumps JU,JC, JCN, etc, etc, refer to jumping to labels within a function or function block. They are used for looping structures or skipping past sections of code. If you want to pass control to another function or function block, you either use UC, CC (unconditional call or conditional call) for blocks that have no parameters (generally), or you use CALL followed by a list of parameters. If you want to call this type of block conditionally you must provide the code yourself and use jumps to skip around the call. Note that call is used in the more generic programming sense of calling a subroutine for example (as opposed to calling a data block in Step5! - the Step 7 alternative is opn DB 1 for example)

Does this clarify things ?
 
Most of the calls I have done in the past used parameter passing. I didn't even realise that CC and UC existed. You learn something new every day.


As for JU, JC, JCN:
JU completely ignores the RLO, JC will evecute if RLO=1, JCN will execute if RLO=0.

In a simple conditional case where the call is contingent on only a single variable:

AN M0.7
JC SKP1

is equivalent to:

A M0.7
JCN SKP1

However, if the RLO is contingent on many input conditions amd several output actions are contingent on the RLO, having both jump types is useful.

But as the previous post stated, in your case you are better off with CC.

Keith
 
Thanks for staying with me on this guys.

I'm sure i know what i want to do now. CC Conditional Call is the equivalent of JC in Step 5 and CU is the equivalent of JU in step 5.

I wish that Siemens would try to keep its labeling the same to avoid confusion. Its hard enough trying to learn new versions as it is without nonsense like this.

Anyhow, once again thankyou for youe help.

Steve.
 
I don't have Step 5 in front of me, but I think they are the same!

JU PB10 equivilant to UC FC10

JU =M001 equivilant to JU M001
 
if you wanted to, you could call the FC's unconditionally and then the first instruction could be:

A M 0.7
BEC

in one FC and

AN M 0.7
BEC

in the other.
 

Similar Topics

I read the other threads that come up with a search for SFC32. The program in question works. The PID in OB35 works. But I have had this error...
Replies
7
Views
4,474
I am having a step7 v5.4 program where the blocks are encrypted and locked. And the manufacturer is stopped the support. Is there any ways to...
Replies
2
Views
168
Good Morning, Hoping someone with some Siemens experience can give me a hand with this one. Customer has a S7-200 cpu, which has a 6GK7...
Replies
0
Views
243
HI! HOW COULD I OBTAIN THE NAMES OF THE STEPS OF A ROUTINE IN SFC LANGUAGE IN STUDIO5000? Or is there a system variable that gives me those...
Replies
0
Views
339
I'm just trying to figure out the right method of adding a DO card to an existing rack. It's not the *next* open slot, but I have to move the AO...
Replies
5
Views
543
Back
Top Bottom