Logix 5000 Enumeration

keshik

Lifetime Supporting Member
Join Date
Jun 2011
Location
Portland, OR
Posts
408
Hi,

I've recently started using Logix/Studio 5000 after a few years of primarily using CoDeSyS based systems. I'm wondering if there is a way to create enumerated tags in Logix.

Example:
  • 0 = off
  • 1 = on
  • 2 = pizza
  • 3 = hamburger
 
Probably the closest thing would be using an array, but there is no inherent enumeration data handler. I'm specifically saying 'data handler' rather than type, because an enumeration in common programming languages is just an abstraction that the compiler handles transparently.
 
You can define tags as constants. So an option is to use constant tags for comparisons. It is not the same thing as an enumerated data type, but it accomplishes the main objective of enumerated data, making the program more readable.

eg, DINT tag name Pizza is a constant set to 2.
Now

--------+-EQU------+--------( )---
| Order|
| Pizza|
+----------+


is more readable, like it would be with an enum data type, even though you aren't actually using an enumerated data type. If you wanted to you could group the constants in a UDT.
 
Last edited:
What TConnolly suggested is also what I try to do on a Siemens platform. I wish we could do enums, but alas.

I've also seen people use structures where each possible enum choice is a bool tag in the structure, and then only one is allowed to be on at a time. I'm not sure how well that carries over to the Logix platform, though.
 
I like that idea TConnolly. I was also thinking that one thing that I could do (for status/error information from a AOI) would be to just declare a STRING output and use a CASE statement to put text into it.
 
I've also seen people use structures where each possible enum choice is a bool tag in the structure, and then only one is allowed to be on at a time. I'm not sure how well that carries over to the Logix platform, though.


I've done that with state engines using a Logix construct called a bit overlay. Bit overlays are advanced programming though and you have to create them using XML and import them, you can't create them in Logix5000. However, since a bit overlay names the bits of a DINT (much like Timer.DN is a named bit of a DINT word) you can use a simple bit twiddling hack to make sure that one and only one bit can be on. I don't want to derail this thread, but I've mentioned bit overlays in several posts so a forum search should turn it up if you're interested and a google search on bit twiddling hack will show you how to make sure only one bit, the lowest significant bit, can be on.
 
Thread Necromancing here:

I am assuming there is no way to define a default value in a UDT.

So yes you could create a bunch of member tags in a UDT definition but there values would have to be set for each instance that uses the UDT correct?
 
Thread Necromancing here:

I am assuming there is no way to define a default value in a UDT.

So yes you could create a bunch of member tags in a UDT definition but there values would have to be set for each instance that uses the UDT correct?

Correct afaik. The only things that have default values that I'm aware of are AOI.
 
I create enumeration UDTs with each member being the named enumeration of a class of constants:

PackML example:
"Undefined" DINT 0
...
"State_Clearing" DINT 1
"State_Stopped" DINT 2
"State_Starting" DINT 3
"State_Idle" DINT 4
"State_Suspended" DINT 5
"State_Execute" DINT 6
"State_Stopping" DINT 7
...
"Result_Ok" DINT 0
...
"Cmd_Reset" DINT 1
"Cmd_Start" DINT 2
...

In a periodic task, I use a single AOI instance to set a single controller-scoped UDT instance passed by reference to any module needing it.

I do the same thing for Common Industrial Protocol, ISA88, and company enumerations.

At the UDT level, you can also set its members' external access to Read Only or None as an added layer of protection.
 
Last edited:
I create enumeration UDTs with each member being the named enumeration of a class of constants:

PackML example:
"Undefined" DINT 0
...
"State_Clearing" DINT 1
"State_Stopped" DINT 2
"State_Starting" DINT 3
"State_Idle" DINT 4
"State_Suspended" DINT 5
"State_Execute" DINT 6
"State_Stopping" DINT 7
...
"Result_Ok" DINT 0
...
"Cmd_Reset" DINT 1
"Cmd_Start" DINT 2
...

In a periodic task, I use a single AOI instance to set a single controller-scoped UDT instance passed by reference to any module needing it.

I do the same thing for Common Industrial Protocol, ISA88, and company enumerations.

COuld you elaborate on the AOI?

Also I <3 your tag prefixes. Vague tag names make me :mad:
 
Yes, see the screenshots for what it does. The second one shows a consuming AOI put the enumerations to use.
I think I gotcha now.

Also did I get my tag prefixes from some screen shot you shared somewhere once. Weird. Because I use very similar.

Cmd_ A command

Cfg_ Things that should NOT change during runtime

I also use
Param_ Changeable data that a object needs during runtime


Maybe I should also start using Ref_ when I am passing by Reference.... hmmmm
 

Similar Topics

I recently did a program conversion from logix 500 to studio 5000 and when machine runs it depends on two ton instructions to keep the machine in...
Replies
17
Views
525
Hello, I am trying to read a barcode scanner input using a cognex dataman 280 barcode reader, store it another string, the compare with another...
Replies
1
Views
91
Hello. Why is my RSLogix 5000 start in grace period mode, even though I have a valid license? I also think I have a decently recent FT Activation...
Replies
3
Views
174
Hi folks, in the alarm manager of Rslogix 5000, the tag-based alarm has been created. But when I tried to change the condition, it was found the...
Replies
2
Views
194
Back
Top Bottom