RsLogix, array as input to JSR

LasseHansen

Member
Join Date
Oct 2007
Location
Esbjerg
Posts
1
Is it possible to use an array as input to a "jump to subroutine" in function block diagram and structured text?

The help file says that i can use tag and array tag as input and output in them both, but i get an error every time i try in function block. If i use an element of the array it´s seems okay.

When i try to use an array as input in structured text, i get no errors, by right now i can´t test the code to see if it works.

I hope some of you can help me

(new to PLC programming by the way)
 
LasseHansen said:
Is it possible to use an array as input to a "jump to subroutine" in function block diagram and structured text?

The help file says that i can use tag and array tag as input and output in them both, but i get an error every time i try in function block. If i use an element of the array it´s seems okay.

When i try to use an array as input in structured text, i get no errors, by right now i can´t test the code to see if it works.

I hope some of you can help me

(new to PLC programming by the way)
*****

Im guessing you have software with the Function Block and Structured text options as they are not included in RSLogix standard.
**********************************************************


jsr, sbr, ret, tod, frd, input/output reference and connection wires fbd instructions.
trnsp.gif
Question jsr, sbr, ret, tod, frd, input/output reference and connection wires fbd instructions
trnsp.gif
Answer
Instructions covered by this kb are the input/ output reference, input/ output wire connector, jsr, sbr, ret, tod, frd

Input/ output reference (iref, oref)

Input/output references are used to bring data into and out of a function block diagram. They can be used to access i/o tags or data tags. The data in an iref is latched when a function block routine begins. Multiple iref's can use the same tag. If the same tag is used in multiple iref's within a fbd routine they will all use the same value. Iref's tags can be used in multiple routines. An iref and oref cannot access the same tag in a routine. Iref's cannot access data within a function block instruction within the routine that it is located in. However they can be used to access data within an instruction in another routine. You can enter a constant into an iref instruction.

Tags within an oref can only be used once within per routine. However multiple routines can write to the same oref tag.

input/output wire connector (icon, ocon)

Input and output wire connectors are use to continue wire connections to other sheets. They cannot be used between routines. Multiple icons with the same tag can be used within the same routine. They can be on the same sheet or on different sheets, but they must be used in the same routine. Oref's tags can only be used once within a routine.

Jump to Subroutine (jsr)

Jump to subroutine was introduced in the version 10 of the ControlLogix. It allows you to call different fbd or ladder routines within the same program, or call the same routine multiple times from the same fbd. Calling the same routine allows you to create general fbd routines that can execute the same function but use different data. This can be done by either manipulating iref/oref tag or by passing a value and optionally have the result returned. Data being passed to or returned can be of the type bool, sint, int, dint, real, immediate, array, or a structureThere is no error detected when data type mismatches on passed parameters unless one of them is a boolean or structure. If the passed parameter type doesn't match and its a boolean or structure then you'll get a compile error. When passing a structure the structure, if you point to the first element then only that element is passed. There is no data conversion on the passed parameters. If you pass a dint to a real the value will show up in the real as a different value than the one passed. Passing data from an int to a dint is ok but if you pass a dint to an int and the value is greater than an int (+/- 32767) it will be corrupted. The limit for number of elements that can be passed are based on available stack. This check is done real time.There is no check to see if the number of passed parameters match the number of accepted parameters in the sbr. There is no limit to the number of levels of jsr's that you can use. Be careful to not create a recursive subroutine where you end up with a subroutine calling the routine where the jsr resides. There is no compiler check for these.

Subroutine (sbr)

Subroutine was introduced in version 10. If a jsr instruction passes a value into a routine, the routine must have a subroutine (sbr) instruction. The sbr instruction allocates a memory location to accept the data that is being passed by the jsr instruction. The order of the data types and values must match the data types and values in the order from the jsr instruction. Their name can be unique from the calling subroutine. If you use the same tag names in the jsr and sbr, and change the order of the tags the data will not be the same in the tag before and after the call to the subroutine. In most cases you will want to use different names in the jsr to avoid instances where the subroutine is being called multiple times, causing the data to be corrupted. This is critical with function blocks since the order of execution can not be determined by the programmer.

 

Similar Topics

Hi. Not the fist time I'm saying this but just to give a background. 95% of my PLC programming has used Schneider over the last 10 years on...
Replies
66
Views
4,939
Hey all, I am trying to figure out how to import some alarm messages without having to type them all in by hand. They are in the format of an...
Replies
4
Views
1,126
Hello i have been trying to figure out a good way to take hex and convert it to an array of SINT[]. Here is what my failed attempt looks like.
Replies
5
Views
1,267
I have a subroutine that gets called to copy a UDT In an array to a tag. This subroutine will be called around once per minute and has been...
Replies
4
Views
2,118
Hello! I have an application where I can only have 3 pumps running out of 6. I load the pumpRunning bits into an array. What I need to do is...
Replies
6
Views
3,127
Back
Top Bottom