HELLO!
I've created a FB that's supposed to return a value through an output variable.
here's the FB code:
FUNCTION_BLOCK FB_Scalare
VAR_INPUT
valcitita:INT;
minR:INT;
maxR:INT;
minM:INT;
maxM:INT;
offset:INT;
END_VAR
VAR_OUTPUT
p1:REAL;
BEGIN
p1:=(maxM-minM)/(maxR-minR)*valcitita+offset;
END_FUNCTION_BLOCK
this is the OB:
ORGANIZATION_BLOCK CICLU_TK1
(*******************************************************************************
CYCLE corresponds to OB1; that is, it is called cyclically by the S7 system
Part 1 : Calls function block and transfers input data
Part 2 : Copies output data and outputs data with switch to output
********************************************************************************)
VAR_TEMP
systemdata : ARRAY[0..20] OF BYTE; // Range for OB1
//tempo_ana:WORD;
END_VAR
BEGIN
TON.DB1(IN :=TK1_DI_M02_1,PT :=T#2S);
TONMOTOR1:=DB1.Q;
TON.DB2(IN :=TK1_DI_M02_1,PT :=T#2.5S);
TONMOTOR2:=DB2.Q;
TK1_DOR_M07_1:=NOT TK1_DI_M02_1;
//CONTOR PORNIRI MOTOR
IF TK1_DI_M02_1 AND NOT TK1_DI_M02_1 THEN
MOT1_BIT_CONTROL:=TRUE;
END_IF;
IF MOT1_BIT_CONTROL=TRUE AND DB1.Q=TRUE THEN
MOT1_CONTOR:= MOT1_CONTOR+1;
MOT1_BIT_CONTROL:=FALSE;
END_IF;
tempo1:=(tempo_citit1);
tempo3:=(tempo_citit3);
tempo5:=(tempo_citit5);
tempo7:=(tempo_citit7);
//MS_IN_COND_TG:=PIW548;
FC_CONTOR.TEST();
FB_Scalare.Scalare (15,0,16,202,27400,202);
p1:=Scalare.p1;
END_ORGANIZATION_BLOCK
when i compile the OB the debuger tell's me i have an error "Right paranthesis missing", and it point's the cursor between the right paranthesis and ";".
PS. FB_Scalare it's the symbol for the FB and Scalare it's the symmbol for the DB used for FB.
Any clues about this?
thx in advance.
I've created a FB that's supposed to return a value through an output variable.
here's the FB code:
FUNCTION_BLOCK FB_Scalare
VAR_INPUT
valcitita:INT;
minR:INT;
maxR:INT;
minM:INT;
maxM:INT;
offset:INT;
END_VAR
VAR_OUTPUT
p1:REAL;
BEGIN
p1:=(maxM-minM)/(maxR-minR)*valcitita+offset;
END_FUNCTION_BLOCK
this is the OB:
ORGANIZATION_BLOCK CICLU_TK1
(*******************************************************************************
CYCLE corresponds to OB1; that is, it is called cyclically by the S7 system
Part 1 : Calls function block and transfers input data
Part 2 : Copies output data and outputs data with switch to output
********************************************************************************)
VAR_TEMP
systemdata : ARRAY[0..20] OF BYTE; // Range for OB1
//tempo_ana:WORD;
END_VAR
BEGIN
TON.DB1(IN :=TK1_DI_M02_1,PT :=T#2S);
TONMOTOR1:=DB1.Q;
TON.DB2(IN :=TK1_DI_M02_1,PT :=T#2.5S);
TONMOTOR2:=DB2.Q;
TK1_DOR_M07_1:=NOT TK1_DI_M02_1;
//CONTOR PORNIRI MOTOR
IF TK1_DI_M02_1 AND NOT TK1_DI_M02_1 THEN
MOT1_BIT_CONTROL:=TRUE;
END_IF;
IF MOT1_BIT_CONTROL=TRUE AND DB1.Q=TRUE THEN
MOT1_CONTOR:= MOT1_CONTOR+1;
MOT1_BIT_CONTROL:=FALSE;
END_IF;
tempo1:=(tempo_citit1);
tempo3:=(tempo_citit3);
tempo5:=(tempo_citit5);
tempo7:=(tempo_citit7);
//MS_IN_COND_TG:=PIW548;
FC_CONTOR.TEST();
FB_Scalare.Scalare (15,0,16,202,27400,202);
p1:=Scalare.p1;
END_ORGANIZATION_BLOCK
when i compile the OB the debuger tell's me i have an error "Right paranthesis missing", and it point's the cursor between the right paranthesis and ";".
PS. FB_Scalare it's the symbol for the FB and Scalare it's the symmbol for the DB used for FB.
Any clues about this?
thx in advance.