Just another JSR question

hprado

Member
Join Date
Aug 2015
Location
Belo Horizonte
Posts
3
Hey guys. I'm new to plc programming and I'm in trouble here. I apologize in advance if this question is so dumb.

There is a file attached to ilustrate my question.

I've two JSR blocks in the first rung of the main program that leads to two different routines (let's name them as sr_01 and sr_02) in SFC. I've also added two extra rungs with a simple pair of input/output.

My doubt is about the execution cycle in this case. How is it going to happen?

In my mind the plc would proccess the diagram like this:

- Process the first rung reaching on the JSR block on top;
- Jump to sr_01 executing it to the end;
- Reach the second JSR block;
- Jump to sr_02 executing it to the end;
- Process rung number 2;
- Process rung number 3;

How much wrong am I?

I was expecting the JSR calls to block the execution of the main routine until the end of the execution of the sub routine called... But right now I'm not sure about this. Are these routines going to execute in parallel?

Thank you very much.

plc_pic.jpg
 
In my mind the plc would proccess the diagram like this:

- Process the first rung reaching on the JSR block on top;
- Jump to sr_01 executing it to the end;
- Reach the second JSR block;
- Jump to sr_02 executing it to the end;
- Process rung number 2;
- Process rung number 3;

How much wrong am I?
0%. In other words, you have it exactly right.

The PLC handles one instruction at a time. From left to right and top to bottom in most cases.

So when the processor encounters a JSR instruction on a true rung, it jumps over to the logic in that routine. When it reaches the end (or return) instruction, it comes back to where it left off within the calling program.

Even those PLCs that can "multi-task" have to interrupt one routine to work on another. The timing and mechanisms by which they do that can cause the appearance of a parallel operation.
 
Last edited:
Thank you very much for the prompt help OkiePC!(y)

Even if I have nested calls do other JSR (inside the SFC routines) I'll see the same behaviour?

Unfortunately I can not share the full project here due to company's rules.

The strange behavior that I'm facing is that inside one of these sub routines (lets consider sr_01) there is an step that has two actions (with different qualifiers) like follows:

Name: END
Action 1: N| (flag := 1);
Action 2: P0| (flag := 0);

And the transition to the step is:

END.T > 2000; (Time based transition)

This "flag" tag is also used in the main routine as a condition (lets consider the condition at rung 1 in the figure).

I'm not sure if I know how to use action qualifiers correctly in SFC laguage, but I think is that after leaving the step END the value of "flag" should be 0. Right?

This "flag" tag is not used anywere else in the entire program but in this step and in the rung at the main routine. In the way the code was made, this "flag" tag is used to set the correspondent latch (as the one that follows the condition in the figure), but I can not understand why since I think that the flag will always be false.

Don't get me wrong. I don't have access to the PLC to test the code neither to a PLC simulator. So all that I can do right now is analyze the code.
 
After some more time researching I finally discovered where I was misunderstanding.
The way nested SFC executes is completely different than I thought. The processing returns to the calling routing after computing the condition of any transition (it depends on how it is configured).
 

Similar Topics

Hi, The hardware is: Click Plc model # CO-O1DD1-O HMI model # S3ML-R magnetic-inductive flow meter model # FMM100-1001. I will set the flow meter...
Replies
4
Views
132
So I had an odd request from a customer for the above. I have written the logic and tested it all in one PLC with only using 7 outputs and 7...
Replies
15
Views
427
Hello I need to message read the entire 16 channel raw analog inputs from a 1769-L33ER Compact Logic controller to another 1769-L33ER Compact...
Replies
8
Views
243
I am noticing a problem where i am using MOV instruction and writing literal text into source and String datatype in destination. It works fines...
Replies
6
Views
486
I'm not actually in front of the equipment yet, but this is the information that I have been given by a client: ------------ Data from HART...
Replies
2
Views
336
Back
Top Bottom