Sign in to follow this  
Followers 0
kysytoctrang

[Q]About call Subrountine in FX1N

8 posts in this topic

Hi, I'm learning program Mitshubishi PLC and don't know how to funtion Call Subrountine do. I've read manual but not clearly about it do: Any one can give me some example about it to known clearly and use Call funtion. Thanks !

Share this post


Link to post
Share on other sites
Programming software and language please (Ladder/Structured Ladder/IEC...)

Share this post


Link to post
Share on other sites
Just to clarify your example 1) All sub routines & interrupts are programmed after de FEND instruction (end of standard program) 2) The subroutine always ends with SRET 3) When a Call a subroutine it runs the sub routine and then jumps back to the program after the CALL instruction.

Share this post


Link to post
Share on other sites
I'm using GFX developer V8 and ladder program. "3) When a Call a subroutine it runs the sub routine and then jumps back to the program after the CALL instruction." Dose it will process Subrountine after jump back to the program after the Call instruction ?

Share this post


Link to post
Share on other sites
Venerable Gambit just did a typo. Instead of 'CALL' in the third item should be read 'SRET'.

Share this post


Link to post
Share on other sites
I try to program and had an error with FX1N© when write program to PLC the led Error is blinking This is my program : Can you show me error on my program ? Edited by kysytoctrang

Share this post


Link to post
Share on other sites
Your pointer is attached to the FEND instruction. It has to be attached to the first line of the subroutine. In your case, the line beginning with X1. The manuals are pretty clear on this topic. 1. Program scan ends at the FEND. 2. Subroutines go after FEND and before END. 3. Each subroutine begins with a pointer, and ends with SRET (subroutine return). 4. The logic in the subroutine is only executed while the CALL instruction is active (logic in front is true). So while your X0 is on, the subroutine is called each PLC scan while X0 is on. When the SRET is reached, processing is returned to the program at the CALL instruction, and the program continues to run from there to the FEND.

Share this post


Link to post
Share on other sites
kysytoctrang, Not directly related to your questions, but the the actions in your subroutine make no sense, unless each call is preceded by I/O refresh. Otherwise, the X do not change during scan, and repeated processing of this logic will not change the result. Similarly, if the subroutine is not followed by output refresh, Y will drive the physical output only once per scan. The fragment from the manual in the initial post illustrates subroutine nesting: P12 is called from within P11. Edited by Sergei Troizky

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0