"Zero"ing an array of values in SCL?

cbattles

Member
Join Date
Dec 2008
Location
Ellenton, FL
Posts
8
What's the best way to "zero" an array of values in SCL? See code below. I think I have what I need but I'm not sure how to "reset" or "zero" the array. Any ideas??


FUNCTION_BLOCK FB3
TITLE = 'MAX RECHARGE PRESSURE'
VAR_INPUT
COUNT_UP: BOOL;
MIDNIGHT_RESET: BOOL;
FLOWRATE: REAL;
END_VAR
VAR_OUTPUT
MAXFLOW: REAL;
MINFLOW: REAL;
AVERAGE: REAL;
END_VAR
VAR_TEMP
// Temporary Variables
END_VAR
VAR
COUNT: INT;
RANGE: INT;
FLOWTEMP: REAL;
TIME1: TIME_OF_DAY;
INDEX: INT;
SUM: REAL;
DATA: ARRAY[0..179] OF REAL;
END_VAR
BEGIN
IF COUNT_UP THEN
DATA[COUNT]:=FLOWRATE;
IF DATA[COUNT]<FLOWTEMP THEN
FLOWTEMP:=DATA[COUNT];
END_IF;
IF FLOWTEMP>MAXFLOW AND FLOWTEMP <> 10000 THEN
MAXFLOW:=FLOWTEMP;
END_IF;
COUNT:=COUNT+1;
END_IF;
IF COUNT>179 THEN
COUNT:=0;
END_IF;
IF COUNT=0 THEN
FLOWTEMP:=10000.0;
MINFLOW:=DATA[COUNT];
END_IF;
IF COUNT>=1 AND DATA[COUNT]<MINFLOW THEN
MINFLOW:=DATA[COUNT];
END_IF;

IF MIDNIGHT_RESET THEN
MAXFLOW:=0.0;
END_IF;
RANGE:=180;
SUM:=0.0;
FOR INDEX:=1 TO RANGE DO
SUM:=SUM+DATA[INDEX];
END_FOR;
AVERAGE:=SUM/RANGE;
END_FUNCTION_BLOCK
 
One simple solution would be to write "while" loop and initialize every array element to zero.
Something like:
Code:
FOR n := 1 TO array_size BY 1 DO
    array[n] := 0.0;
END_FOR;
 
Last edited:
Well, I don't have much experience with SCL myself, but you can try that simple solution and see if it works for you.

Regards
 
Last edited:
In Omron PLCs I use the BSET (block set) function - I do not know if AB have it.

You set the starting word, end word and value - in this case #0000 would set the whole block to zero. Ther is no limit on block size.

I sther a move or block command available you can use? That looks absolutely painful.
 

Similar Topics

Hi. If any member of the forum has strong IntervalZero background, I may be able to buy some hours of consulting. We are developing a PROFINET IO...
Replies
0
Views
560
I have a zero center pressure sensor where 0.0 is 12mA, 0.5 is 20mA and -0.5 is 4mA. I cant figure out a way to get accurate results I have...
Replies
11
Views
2,813
Lesson Motor 230VAC-1.2A-1700RPM-62.5PF I am having trouble understanding this. My motor rotates at 0vdc reference with the run forward command...
Replies
39
Views
11,728
I'm trying to use a Numeric input enable to let users change their HMI password. The only problem is it deletes leading zeros when you enter it. I...
Replies
2
Views
1,923
Hello, I have a problem with Factory TalkView Studio. I have been programming loops RSlogix 5000. I have a tag called DrumSP (Real) going into...
Replies
3
Views
1,631
Back
Top Bottom