| 

.NET C# Java Javascript Exception

7
Parameter lists are an interesting alternative for transferring parameters to PLC libraries. Strictly speaking, these are global constants (VAR_GLOBAL CONSTANT) whose initialization values can be edited in the Library Manager. When declaring arrays, their boundaries must be defined as constants. At the time of compilation, it must be known how large the array should be. […]

Parameter lists are an interesting alternative for transferring parameters to PLC libraries. Strictly speaking, these are global constants (VAR_GLOBAL CONSTANT) whose initialization values can be edited in the Library Manager.

When declaring arrays, their boundaries must be defined as constants. At the time of compilation, it must be known how large the array should be. The attempt to define the array boundaries by a variable is rejected with an error message.

PROGRAM MAIN
VAR
 nUpperBound : INT := 5; 
 aTest : ARRAY [1..nUpperBound] OF INT;
END_VAR
 
// Compiler error: Border 'nUpperBound' of array is no constant value

Only the use of constants solves the problem.

PROGRAM MAIN
VAR
 aTest : ARRAY [1..nUpperBound] OF INT;
END_VAR
VAR CONSTANT
 nUpperBound : INT := 5;
END_VAR

This can lead to problems, especially in PLC libraries. For example, if you want to map a data buffer to an array, it is not necessarily known at the time of library development how large this data buffer has to be in the respective applications.

The solution here is a parameter list, which is inserted when creating a PLC library.

A parameter list can be added at any point in the PLC project (the PLC project from which the PLC library originates). Parameter lists are usually created for the global variable lists (GVLs).

The parameters are declared as constant global variables.

{attribute 'qualified_only'}
VAR_GLOBAL CONSTANT
 cUpperBound : INT := 3;
 cString : STRING := 'Hello';
 cIntArray : ARRAY [1..cUpperBound] OF INT := [1, 2, 3];
 cStructArray : ARRAY [1..3] OF ST_Test := [3( (nValue := 1,
 fValue := 3.1,
 wsValue := "abc") )];
 cEnum : E_Test := E_Test.eValue02;
 cStruct : ST_Test := (nValue := 1, fValue := 3.1, wsValue := "abc");
END_VAR

The variables can be pre-initialized by initialization values. Even more complex variable structures can be initialized with values.

These parameters can be edited in the Library Manager in the application in which the library was integrated. The Library Manager is opened by double-clicking on the respective library reference.

The fields in the column Value (editable) can now be changed as required. These changeable constants can be used within the respective PLC library or in the application that references them.

FUNCTION F_AddArrayValues : INT
VAR_INPUT
 aTest : REFERENCE TO ARRAY[1..Param.cUpperBound] OF INT; 
END_VAR
VAR
 nIndex : INT;
END_VAR
 
FOR nIndex := 1 TO Param.cUpperBound DO
 F_AddArrayValues := F_AddArrayValues + aTest[nIndex];
END_FOR

The changed initialization values are stored in the respective PLC project file (*. plcproj). Thus, each application that references a library with a parameter list has its own values. The library itself remains unchanged.

The values set in this way also withstand a PLC reset, both a cold reset and resetting to the original values. The values are not reset until the library is removed and reinserted. This means that parameter lists can also be used to transfer general parameters.

All parameters in a parameter list are usually accessible via ADS. The fact that parameters always have to be declared with CONSTANT does not prevent them from being written via ADS.

If a parameter is used as an array boundary, changing these variables will have serious consequences. Especially if the value of the parameter is increased.

aTest : ARRAY [1..MyLibrary.Param.cUpperBound] OF INT;

Even if the parameter is increased at runtime of the PLC program, the array retains its original size. If this parameter is also used in the loops, accesses outside the allowed array boundaries can occur.

FOR nIndex := 1 TO MyLibrary.Param.cUpperBound DO
 aTest[nIndex] := nValue;
END_FOR

To prevent this, the attribute tc_no_symbol can be used to prevent ADS symbol generation. Access via ADS using the symbol name is then no longer possible for this parameter.

VAR_GLOBAL CONSTANT
 {attribute 'tc_no_symbol'}
 cUpperBound : INT := 5;
END_VAR

iec-61131-3 oop codesys-v3 twincat plc interfaces inheritance iec-61131-3-(english) methods
Weitere News:
2 Meinungen
0
sehr bequem, danke
0
Dieser Artikel ist einfach zu sehen, ohne irgendwelche Besonderheiten zu verlassen und zu genießen. Ausgezeichnete Arbeit! Sie haben bestimmte Faktoren ausgefüllt, denen Sie vertrauen, wenn Sie diese Website ausprobieren. Ich habe festgestellt, dass fast alle Personen Ihre Website akzeptieren und eine Recherche über sie durchgeführt haben. https://kamilfokamil7.wixsite.com/download-torrent
Schreibe einen Kommentar:
Themen:
methods iec-61131-3-(english) inheritance interfaces plc twincat codesys-v3 oop iec-61131-3
Entweder einloggen... ...oder ohne Wartezeit registrieren
Benutzername
Passwort
Passwort wiederholen
E-Mail