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.
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];
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 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 := AD_1;
ADArray[1 ] := AD_2;
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?
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?
|Thread starter||Similar threads||Forum||Replies||Date|
|C||Answer to another set of posts.||General Automation Chat||3|
|A||Prescribed intrinsic curvature control of a set of springs||Motion Control||0|
|G||How to set threshold for my flame sensor?||General Automation Chat||1|
|S||Putting Barriers in field||General Automation Chat||6|
|D||Putting GSE450 weigh scale in the setup mode||Sensors & Calibration||1|
by Seth Price