Thanks for your reply. I am using ComAp controllers as my PLC.Array data type
An array is a set of data elements of the same type. Basic and user-defined data types, function block types, and classes may be used as array element types.
Example:
TYPE
TArray1: ARRAY[0..9] OF INT := [1,2,3,4,5,6,7,8,9,10];
TArray2: ARRAY[1..2, 1..2] OF USINT := [11,12,21,22];
END_TYPE
of their web site https://kb.mervis.info/doku.php/en:..._basic:6-data-types:2-user_defined_data_types
looks like IEC 61131
maybe something like TArray1[5] to access element five...usually the data type can be whatever you like. They probably declare reals ...as REAL.
Maybe you need to download the user manual for ST programming ...if they don't have such a thing then download one of the main brand PLCs and just transpose the software...I'm sure your PLC has its quirks but it looks like standard ST.
What are you programming as a matter of interest?
This is not working. I am having compilation errors.ADArray: ARRAY[0..9] OF REAL;
ADArray[0] := AD_1;
ADArray[1 ] := AD_2;
etc
does that work? not sure what you want to do but that moves it around ...you can make a loop to store AD values ..but be careful loops in ST chew up the processor. Don't go out of bounds on your array loop and the use of magic numbers like [0..9] is a bit of a no no distracts from the readability of the code better to give it a more meaningful full name,,, but that's another issue.
Is your AD a real number? ...usually, after you scale it you convert it to a real value before that it's probably just a 2^n number.
does that work...what are you trying to accomplish?
I want to sort these analog values in ascending order.This is not working. I am having compilation errors.
This is for an actual project. Below is the code I've written in a function block for bubble sorting and it doesn't show compiling error. I have defined the array as a VAR not with TYPE ... END-TYPEstyle.ok ...show me the code and show me where you have declared the variables...
ascending order of what ....the actual AD channel or the value coming from the channel...
is this an actual application or is it a learning exercise?
if it's the latter then I can point you in a direction if it's the former then it would nice to know exactly what you are trying to achieve.
Bubble sorting comes to mind if you want to sort the value in a particular order,, exactly why you would want to do this..I don't know?
by Bob Odhiambo
by Seth Price