Newbie, can't get started w/ Add-On Instr. in CLX5000

Join Date
Nov 2009
Location
Maryland
Posts
11
I'm just getting started with ControlLogix (V17) and am trying to create a very simple Add-On instruction, using Structured Text, that increments the integer given to it, but don't seem to have the first clue how to do so, in spite of the docs and help.

First I created an Add-On Instruction with an input DINT "InputInteger" and an output DINT "OutputInteger", and wrote the following ST into it:
OutputInteger := InputInteger + 1;
Then I wrote the following lines in my main program, which has two tags, J and K, both of them DINT:
J := 7;
MakeBigger(J,K);

The idea was that K would wind up being 8. But instead it returns this error: Parameter 1: Invalid data type. Argument must match... And InputInteger, OutputInteger, J and K are all definitely DINT tags.


I also tried other ways. I hoped this would define a function that returns a value, so I could say:
K := MakeBigger(J);
but not so. It just says "Instruction not allowed in expression".

In the programming manual for add-on instructions, the examples of using an Add-On Instruction all seem to work like this:
MakeBigger(MakeBigger_ST,J,K);
where the first argument does not seem to correspond to anything inside the Add-On, and is its name plus an underscore plus an acronym for the language used to write it. But when I try this I just get "Too many arguments", and "MakeBigger_ST tag not defined".
Can anybody straighten the new guy out?
Thanks!
 
When you create an AOI, just like creating a User Defined Type, you are creating a template.

To use a User Defined Type you create a tag of the TYPE of your user defined type.

Think the same way about an AOI. This is a description for a chunk of logic. When you invoke an AOI you are making a copy of that logic for this specific use.

So you have created a logic template called MakeBigger. To use it your create a specific instance, 'MakeBigger_ST' which is of the type of the AOI 'MakeBigger'. I'm not sure how this works in StructuredText, I use ladder logic. But maybe this helps.

In ladder I would right-click on MakeBigger_ST and create a 'new' of type MakeBigger (it should show up in the defined types once the AOI is fully defined).
 
Last edited:
Wow. Thanks, Bernie! This works. This feels object-oriented, at least in the sense of creating a class and instantiating an object out of it.
Now that I understand this, I have gone over the Add-On Instructions programming manual a couple of times, and still do not find any clear hint of it. The closest thing I find is one of the "Programming Tips" that says "A data type defined with the Add-On Instruction is used for the tag that provides context for the execution from your code." However, even in hindsight I'm not sure they're referring to instantiation. Do you suppose it is possible Rockwell does not know about this?

Anyway, this fixes everything. Thanks again.
 

Similar Topics

Hello all, I'm a new member here. I've joined as I want to learn about PLC programming. I've got a few questions to begin with. To get me...
Replies
37
Views
4,547
Howdy folks. Been doing PLC programming for like 15 years now in LD and ST, but I'm trying to learn SFC now and have a kind of dumb question... I...
Replies
4
Views
1,387
Hello. New to Unity and had a couple quick questions. Can a Modicon M340 output to a small multiline LCD screen and not a full HMI?
Replies
4
Views
962
Hi. I'm learning AOI programming in RSLogix 5000. I created an AOI with several input and output parameters but when I choose the AOI in the main...
Replies
17
Views
3,200
Good morning, I've had an inverter fail with firmware revision 5.002, the only spare is Rev 7.001, when updating the project with the new...
Replies
2
Views
1,260
Back
Top Bottom