array addressing in s7 300

Join Date
Dec 2013
Location
Baroda
Posts
11
Dear All ,



I have written a small program in SCL as below .

/////////////////////////////////////////////////////////////

FUNCTION FC1:VOID
VAR_INPUT
GEA1_TO_T, GEA2_TO_T, NPL_TO_T :ARRAY[1..3] OF BOOL ;
END_VAR
VAR
I:INT;
END_VAR
VAR_OUTPUT
G1,G2,NPL:ARRAY[1..3] OF BOOL ;
END_VAR
FOR I:= 1 TO 3 BY 1 DO ;
IF GEA1_TO_T=1 AND G2=0 AND NPL=0
THEN
G1:=1 ; // Statement section IF
ELSE
G1 := 0 ; // Statement section IF
END_IF;
END_FOR;
END_FUNCTION


//////////////////////////////////////////////no error//////////////////////////////

I have defined array in db2 as shown in attachment .

Please let me know how to write address in OB1 while calling FC1 as shown


CALL FC 1
GEA1_TO_T:= ??????
GEA2_TO_T:=???????????
NPL_TO_T :=????????????
G1 :=??????
G2 :=??
NPL :=??

db2.PNG
 
Code:
function fc2:void

fc1(gea1_to_t:=db2.gea1_sel,
    gea2_to_t:=db2.gea2_sel,
    npl_to_t:=db2.npl_sel,
    g1:=db2.gea1_sel,
    g2:=db2.gea2_sel,
    npl:=db2.npl_sel);
    
end_function
 
I hate it when you write logic in this way.
Code:
IF GEA1_TO_T[I]=1 AND G2[I]=0 AND NPL[I]=0
THEN
G1[I]:=1 ; // Statement section IF
ELSE
G1[I] := 0 ; // Statement section IF

I suggest change it to
Code:
G1[I] := GEA1_TO_T[I] AND NOT G2[I] AND NOT NPL[I] ;
 
Thanks

Thank You very much and I amended as suggested as in attachment

/////////////////////////////////////FC1///////////
FUNCTION FC1:VOID
VAR_INPUT

GEA1_TO_T,GEA2_TO_T,NPL_TO_T :ARRAY[1..3] OF BOOL ;

END_VAR
/////////////////
VAR
I:INT;
END_VAR
//////////////////
VAR_OUTPUT

G1,G2,NPL:ARRAY[1..3] OF BOOL ;
END_VAR
/////////////////////////////
FOR I:= 1 TO 3 BY 1 DO ;
G1 := GEA1_TO_T AND NOT G2 AND NOT NPL ;
END_FOR;
END_FUNCTION

////////////////////////////
and FC1 compiled without any Error.
///////////////////////////////

But when I have to call this block ,for example in OB1 ,as below

CALL FC 1
GEA1_TO_T:=
GEA2_TO_T:=
NPL_TO_T :=
G1 :=
G2 :=
NPL :=


So my problem is

CALL FC 1
GEA1_TO_T:= WHAT SHOULD BE ARRAY PARAMETER
GEA2_TO_T:= WHAT SHOULD BE ARRAY PARAMETER
NPL_TO_T := WHAT SHOULD BE ARRAY PARAMETER
G1 := WHAT SHOULD BE ARRAY PARAMETER
G2 := WHAT SHOULD BE ARRAY PARAMETER
NPL := WHAT SHOULD BE ARRAY PARAMETER


Requesting your help !!!

OB1.PNG SCL_FC1.PNG
 
Last edited:
I hate it when you write logic in this way.
Code:
IF GEA1_TO_T[I]=1 AND G2[I]=0 AND NPL[I]=0
THEN
G1[I]:=1 ; // Statement section IF
ELSE
G1[I] := 0 ; // Statement section IF
I suggest change it to
Code:
G1[I] := GEA1_TO_T[I] AND NOT G2[I] AND NOT NPL[I] ;


And for me it is easier to undestand with =, as variables can also be words.
 
So my problem is

CALL FC 1
GEA1_TO_T:= WHAT SHOULD BE ARRAY PARAMETER
GEA2_TO_T:= WHAT SHOULD BE ARRAY PARAMETER
NPL_TO_T := WHAT SHOULD BE ARRAY PARAMETER
G1 := WHAT SHOULD BE ARRAY PARAMETER
G2 := WHAT SHOULD BE ARRAY PARAMETER
NPL := WHAT SHOULD BE ARRAY PARAMETER


Requesting your help !!!


They have to be same types than on code / FC
 

Similar Topics

Hello, I will try to be as succinct as possible, and hopefully this will make some sense. Say, in Logix Designer, I have a generic Ethernet...
Replies
5
Views
5,050
I'm creating an FB with a variable input and I would like to copy all of the bits to an array (declared as temp) I've declared the array in TEMP...
Replies
8
Views
3,460
how do I address the bit inside of a dint array in Omron? I made my global DINTArray[4] (starts at W11) how can I address the bit of W11.00 I...
Replies
3
Views
2,303
Hi Guys, I have an int array of 500 elements and would like to display them on a panel view plus 6. Now I can't make 500 numerical displays, so I...
Replies
2
Views
2,806
I've got a rung that uses the first pass bit to initiate a For argument. In the Routine named 'Alarm' I have something like this...
Replies
15
Views
9,961
Back
Top Bottom