Creating an Array in Compactlogix_17JUN19

6 posts in this topic


I have several DINT tags N42_-0, N42_1, N42_2, N42_50, N42_51, N42_52, N42_53 and N42_60 that i would like to put into one array so a higher level DCS can read/write to these tags.  Any thoughts on the best way to do this?

Share this post

Link to post
Share on other sites

DCS_Array defined with 8 elements, then MOV or COP each to a element in DCS_Array.

Share this post

Link to post
Share on other sites

Thanks! One more question I have also can an array be created for data types that are float?

Share this post

Link to post
Share on other sites

no difference, when creating the tag/array make it REAL

Share this post

Link to post
Share on other sites

In short you can create an array of any defined type including UDTs.

Share this post

Link to post
Share on other sites

This got way longer than what your question warranted...

It's already been covered but you can even make a String Array (put the text for an HMI in the string and you only have to reference the string tag in the HMI rather than type it. That gives you dynamic tagname and descriptions.

If you know what the N's are (aside from being godawful SLC 500 imports vs writing the program properly for CLX) make a UDT so the tags and description makes sense to the next victim then map the N's over to the tags

A UDT only allows single dimension arrays (but there is a workaround by using a UDT inside the UDT. It's a bit of a kludge in my world but might be useful in some industries)

You can play with all of this in an offline blank program

Single Dimension Array: TestTag DINT[10] will give you  10 DINT's starting With TestTag[0] to TestTag[3]

Try TestTag DINT[10,10] for some real fun. You get TestTagp[0,0 to TestTag[0,9] up to Test[9,0] to Test[9,9], ie 100 DINT's

But... depending on what the data is the tag doesn't really make sense. The power of CLX is that you can make the program more clear by using tags that make sense.

Lets say N1 = Speed Min, N2 = Speed Max, N3 = Step Number, N4 = Status

Make a UDT, call it... I can't think of anything nice to call N's imported from a SLC so you make the name up...

The UDT (Look under Data Types for User Defined Data Type) might look like this 

Name  Data  Type  Style  Description  External Access

SMin    DINT    Decimal    Speed Minimum    Read/Write
SMax    DINT    Decimal    Speed Maximum    Read/Write
Step     DINT    Decimal    Step Number    Read/Write
Status  DINT    Decimal    Status of Operation    Read/Write
Now make a tag UDTest [put UDT name here]. I called my testing UDT Alf so UDTest[Alf]

UDTest    <normal>            Alf    Standard    Test    Read/Write    0        
UDTest.Smin                DINT    Standard    Test Speed Minimum    Read/Write        Decimal    
UDTest.Smax                DINT    Standard    Test Speed Maximum    Read/Write        Decimal    
UDTest.Step                DINT    Standard    Test Step Number    Read/Write        Decimal    
UDTest.Status                DINT    Standard    Test Status of Operation    Read/Write        Decimal    

If you make the tagname make sense, without getting too wordy (UDTest is too wordy) then the tagname is useful


Real world (my world, not useful for other industries) UDT

The UDT is called Motor. It's literally made for anything that we have that is driven by an electric motor. It looks like this:

String1    STRING            Read/Write    1    0
String2    STRING            Read/Write    2    0
SW    INT    Decimal        Read/Write    3    0
A    BOOL    Decimal        Read/Write    5    0
A_Stop    BOOL    Decimal    Auto Stop     Read/Write    6    0
A_Start    BOOL    Decimal    Auto Start    Read/Write    7    0
Stop_I    BOOL    Decimal    Stop Input    Read/Write    8    0
Start_I    BOOL    Decimal    Start Input    Read/Write    9    0
HMIStop    BOOL    Decimal    HMI Stop Button    Read/Write    10    0
HMIStart    BOOL    Decimal    HMI Start Button    Read/Write    11    0
RunStat    BOOL    Decimal    Run Status    Read/Write    12    0
Stop    BOOL    Decimal    Motor Stop    Read/Write    14    0
Run    BOOL    Decimal    Motor Run    Read/Write    15    0
AStop_OS    BOOL    Decimal    Auto Stop One Shot    Read/Write    16    0
AStart_OS    BOOL    Decimal    Auto Start One Shot    Read/Write    17    0
FStart_OS    BOOL    Decimal    Field Start One Shot    Read/Write    18    0
HStart_OS    BOOL    Decimal    HMI Start One Shot    Read/Write    19    0
SOS    BOOL    Decimal    Start Counter One Shot    Read/Write    20    0
RH    DINT    Decimal    Run Hours    Read/Write    21    0
S    DINT    Decimal    Number of Starts    Read/Write    22    0
FailTMR    TIMER        Fail to Start Timer    Read/Write    23    0
T1    TIMER            Read/Write    24    0
T2    TIMER            Read/Write    25    0
T3    TIMER            Read/Write    26    0
T4    TIMER            Read/Write    27    0
T5    TIMER            Read/Write    28    0
T6    TIMER            Read/Write    29    0
T7    TIMER            Read/Write    30    0
T8    TIMER            Read/Write    31    0
T9    TIMER            Read/Write    32    0
T10    TIMER            Read/Write    33    0
RMT    TIMER        Run Minute Timer    Read/Write    34    0
RMC    COUNTER        Run Minute Counter    Read/Write    35    0

Note the mix of data types and the descriptions. Also note that T1 thru T10 do not have a description. These are timers that are available for anything related to Pump Start/Stop logic and the description can be anything. 10 Timers is as many as we need so far. I can edit the UDT if we need more.

An example tag looks like this

 P5200    <normal>            Motor    Standard    P-5200    Read/Write    0        
P5200.String1                STRING    Standard    P-5200    Read/Write            
P5200.String2                STRING    Standard    South Mainline Pump    Read/Write            
P5200.SW                INT    Standard    P-5200 Status Word    Read/Write        Decimal    
P5200.A                BOOL    Standard    P-5200 Auto Mode    Read/Write        Decimal    
P5200.A_Stop                BOOL    Standard    P-5200 Auto Stop    Read/Write        Decimal    
P5200.A_Start                BOOL    Standard    P-5200 Auto Start    Read/Write        Decimal    
P5200.Stop_I                BOOL    Standard    P-5200 Stop Input    Read/Write        Decimal    
P5200.Start_I                BOOL    Standard    P-5200 Start Input    Read/Write        Decimal    
P5200.HMIStop                BOOL    Standard    P-5200 Stop Control from HMI    Read/Write        Decimal    
P5200.HMIStart                BOOL    Standard    P-5200 Start Control from HMI    Read/Write        Decimal    
P5200.RunStat                BOOL    Standard    P-5200 Run Status    Read/Write        Decimal    
P5200.Stop                BOOL    Standard    P-5200 Motor Stop    Read/Write        Decimal    
P5200.Run                BOOL    Standard    P-5200 Run Motor    Read/Write        Decimal    
P5200.AStop_OS                BOOL    Standard    P-5200 Auto Stop One Shot    Read/Write        Decimal    
P5200.AStart_OS                BOOL    Standard    P-5200 Auto Start One Shot    Read/Write        Decimal    
P5200.FStart_OS                BOOL    Standard    P-5200 Field Start One Shot    Read/Write        Decimal    
P5200.HStart_OS                BOOL    Standard    P-5200 HMI Start One Shot    Read/Write        Decimal    
P5200.SOS                BOOL    Standard    P-5200 Start Counter One Shot    Read/Write        Decimal    
P5200.RH                DINT    Standard    P-5200 Run Hours    Read/Write        Decimal    
P5200.S                DINT    Standard    P-5200 Number of Starts    Read/Write        Decimal    
P5200.FailTMR                TIMER    Standard    P-5200 Fail to Start Timer    Read/Write            
P5200.SDTimer                TIMER    Standard    P-5200 Low Suction Pressure Shutdown Delay Timer    Read/Write            
P5200.SD1Timer                TIMER    Standard    P-5200 Low Differential Pressure Shutdown Delay Timer    Read/Write            
P5200.SD2Timer                TIMER    Standard    P-5200 Low Flow Shutdown Delay Timer    Read/Write            
P5200.VSD1Timer                TIMER    Standard    P-5200 Motor Outboard Bearing Vibration Shutdown Delay Timer    Read/Write            
P5200.VSD2Timer                TIMER    Standard    P-5200 Motor Inboard Bearing Vibration Shutdown Delay Timer    Read/Write            
P5200.VSD3Timer                TIMER    Standard    P-5200 Pump Inboard Bearing Vibration Shutdown Delay Timer    Read/Write            
P5200.VSD4Timer                TIMER    Standard    P-5200 Pump Middle Bearing Vibration Shutdown Delay Timer    Read/Write            
P5200.VSD5Timer                TIMER    Standard    P-5200 Pump Outboard Bearing Vibration Shutdown Delay Timer    Read/Write            
P5200.RMT                TIMER    Standard    P-5200 Run Minute Timer    Read/Write            
P5200.RMC                COUNTER    Standard    P-5200 Run Minute Counter    Read/Write            

Note how P-5200 in the first description ends up in every tag description

If there are 9 pumps and the logic is essentially the same (other than what shuts it down) then you make 10 tags with the correct tagname (P5100 thru P5900, data type Motor), then write the logic for one pump (tag is P5100), then copy and the past original routine to 8 more routines, rename them, then edit each routine by doing a search and replace for P5100 and replacing it with the correct tag for the routine... 95% of the programming work for the pumps is done at this point. All you have to do is true up the shutdown logic and maybe the start and stop logic. UDT's are very handy...


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now