Internet PLC Forum
General => Technical support => Topic started by: StefanA on September 05, 2013, 10:20:36 AM
-
Need some help with a programming problem.
We assumes that DM1-48 contains various reading from a ADC. I want to identify the highest and lowest of the readings. Any good suggestions?
-
Scan through DM[1..48]. The following code scans through DM and records the maximum value in A and the index to this value in B:
A = -1 ' start with a value that is less than minimum data value
B = 0 ' illegal index into DM[]
for I = 1 to 48
if DM > A
' value in DM is greater than previous maximum value
' Remember it...
A = DM
B = I
endif
next
Not much to it! You can easily add another test to check for minimal values within the same for/next loop
Gary d.
-
Thank you very much Gary.