How to use Enumeration in Studio 5000 (CodeSys background)

larbi16

Member
Join Date
Dec 2023
Location
Dallas,Texas
Posts
15
Hi everyone,
as this is my first experience with Rockwell Software i would like to know what's the best way to make Enumerations?
 
Pretty sure you will have to use User-Defined Data Types and Add On Instructions. If you could give me an example of what you are looking for, I could probably help you better.
 
i am trying to use the enumerations to organize the case statement so all i need to do is assign a constant Integer to a constant string value.
 
Las time I checked there were no enumerations. I Have used Constant tags in the past as a substitute. Unfortunately you cannot use them as states in case statements.
 
i am trying to use the enumerations to organize the case statement so all i need to do is assign a constant Integer to a constant string value.

Strictly speaking, integer values cannot be assigned to strings.

Perhaps you have an integer tag, which value one of a pre-defined set of integers, and each value in that set will correspond to a pre-defined string value, and you want to assign one of those pre-defined string values to an output string depending on which pre-defined integer value matches the value of an integer input tag?
 
Strictly speaking, integer values cannot be assigned to strings.

Perhaps you have an integer tag, which value one of a pre-defined set of integers, and each value in that set will correspond to a pre-defined string value, and you want to assign one of those pre-defined string values to an output string depending on which pre-defined integer value matches the value of an integer input tag?
thank you for help.
 
Are the integers contiguous (1,2,3,..., or 100,101,102,...)?

Or are the integers regularly spaced? (100, 200, 300, ...)?
 
Enums do not need to be contiguous or regularly space. Be default they will be assigned values beginning at 0 and incrementing by one unless other values are assigned. AFAIK RA does not support them (although I see some documentation about using them in Optix, not useful for this app though). OP may want to peruse this thread and associated links for workarounds to get close Logix 5000 Enumeration

In the code below the int sequence is: 0,10,11,20,21.

Code:
TYPE EnumState :
(
    Idle,
    Starting := 10,
    Running,
    Halting := 20,
    Halted
);
END_TYPE

//usage
VAR
    State : EnumState;
END_VAR

CASE State OF
    Idle:
        IF Start THEN
            State := Starting;
        END_IF
    Starting:
    ......
 

Similar Topics

Hi all, I’m doing some foundational HMI work and am looking for any (hopefully standard) resources that enumerate generic equipment. Sensors and...
Replies
4
Views
1,426
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...
Replies
14
Views
6,844
Hello, i've been at this for months now, i tried creating accounts on the aveva website but it seems to never approve my accounts or at least when...
Replies
0
Views
28
Hi Everyone. Not posted on here for a long time, but I am hoping someone can help me. I am doing a differential pressure calculation in a L27ERM...
Replies
15
Views
237
Hi, how do I convert 2x Integer registers to a Real? The two integers are from Modbus registers that contain a floating point value, I need to...
Replies
2
Views
119
Back
Top Bottom