JSR/RET using RSLogix 5000 Structured Text

dskplc

Member
Join Date
Aug 2013
Location
New Zealand
Posts
119
Hello, I please need your help why I cannot get the return parameter from the RET instruction to go into the return parameter in the JSR return parameter using structured text. It worked in Ladder Logic but am new to structured text and something is missing in my code to cause it not to return to the JSR. Thanks in advance for any advice for where I am going wrong and how to fix this.

Here is my code for structured text in RSLogix 5000:
----------------------------------------------
In JSR Routine going to RET Routine:
// JSR -> RET: 1 Return Parameter on Both (INT)
JSR(ST_RET_1,1,ST_RET_1_In_Param_1);

RET Routine from JSR Routine:
// RET with 1 parameter
ST_RET_1_Src := 10;
ST_RET_1_Return_Param_a := ST_RET_1_Src; // MOV Value in Source to Destination
RET(ST_RET_1_Return_Param_a);
----------------------------------------------
I need ST_RET_1_Return_Param_1 = ST_RET_1_Return_Param_a.
Thank you.
 
Hello, I please need your help why I cannot get the return parameter from the RET instruction to go into the return parameter in the JSR return parameter using structured text. It worked in Ladder Logic but am new to structured text and something is missing in my code to cause it not to return to the JSR. Thanks in advance for any advice for where I am going wrong and how to fix this.

Here is my code for structured text in RSLogix 5000:
----------------------------------------------
In JSR Routine going to RET Routine:
// JSR -> RET: 1 Return Parameter on Both (INT)
JSR(ST_RET_1,1,ST_RET_1_In_Param_1);

RET Routine from JSR Routine:
// RET with 1 parameter
ST_RET_1_Src := 10;
ST_RET_1_Return_Param_a := ST_RET_1_Src; // MOV Value in Source to Destination
RET(ST_RET_1_Return_Param_a);
----------------------------------------------
I need ST_RET_1_Return_Param_1 = ST_RET_1_Return_Param_a.
Thank you.

In your JSR() call you are not declaring a return parameter.
Syntax should be JSR(routine name,input param count, input, return)
example to call a SBR called "mysub" with 2 input parameters and a return parameter.
JSR(mysub,2,int_a,int_b,intResult)
 
Thank you for your reply and help. My return parameter in the JSR is
ST_RET_1_In_Param_1 and is supposed to be getting the value from the RET parameter ST_RET_1_In_Param_a. I just don't get why the value does not come across from the RET instruction. Do I need to add more code somewhere?
 
Do you know where I can find examples of this. I just don't understand why I can get this to work in Ladder but not structured text (ST). Thanks for any help.
 
I found my issue. For JSR(ST_RET_1, 1, ST_RET_1_In_Param_1) this should be JSR(ST_RET_1, 0, ST_RET_1_In_Param_1). For a RET that has parameters the JSR will have a zero for InputCount.
 

Similar Topics

On site and another Programmer is getting a Major Fault when downloading code that I gave him to interface withour machines. I have JSRs that...
Replies
3
Views
882
I was told that all subroutines should have a RET in them, even if the subroutine runs til the end of the ladder, then the last rung should be a...
Replies
10
Views
6,459
Jsr
We have a motor control JSR with Input and Output parameters, There are 36 motors that are controlled by the same JSR. What or how can I view...
Replies
8
Views
527
I intend to pass a BOOL array to an ST routine (for loop) to count the true bits. (should never have used a Bool array, lesson learned) The ST...
Replies
10
Views
853
Currently, I have a 1769-L36ERM that is being using to control a machine with 15 servos. Due to the nature of the process, the code is very...
Replies
9
Views
1,549
Back
Top Bottom