SCL Problems, calling an FB

svoicum

Member
Join Date
Sep 2006
Location
Cluj
Posts
43
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.
 
This will not compile as there are loads of variables in OB1 that are not declared (tempo1 etc) - please post the code as you would expect someone else to compile it and get the same error you are getting.
 
SimonGoldsworthy said:
This will not compile as there are loads of variables in OB1 that are not declared (tempo1 etc) - please post the code as you would expect someone else to compile it and get the same error you are getting.

my problem is not tempo1 and those variables, because those variables are declared in the symbol table. the problem i'm getting is when i call the function.

i'm posting here the whole project so that you can compile it and get the same errors as i do.
http://rapidshare.com/files/2540419/Test04.zip.html
{the file}
 
When you call a function block you must specify the parameter names, not just a list of values. See example below.

Code:
FB_Scalare.Scalare(valcitita := 15
			,minR := 0
			,maxR := 16
			,minM := 202
			,maxM := 27400
			,offset := 202
			);
 
thank you for your reply. it sure helped me.
as i said before this is my first project with siemens, and i'm just 18 years old, and i'm helping my father to do this project because he can't do it all by himself.
 
Last edited:

Similar Topics

Hi Im trying to use SFC20 BLK Move in a piece of SCL code in Step7. I need to copy/move one string[16] in a DB to another DB place ! If a block...
Replies
5
Views
13,502
HI i would like to know how to get a variable that will store the amount of times a program has been executed. The issue is I have 3 DBs for 1 FB...
Replies
2
Views
75
Hi, I have an intermediate-advance knowledge of programming with TIA Porta in Ladder, would you recommend me to start learning SCL for it to...
Replies
11
Views
558
Hello nice to meet you, im new in here, I'm currently trying to convert code written in STL for a S7-400 to SCL for an S7-1500, because when i run...
Replies
5
Views
316
Hi everyone, I am new to this amazing world of PLC, well... I mean, in practice, since I already knew electronics, programming languages, IT, and...
Replies
7
Views
652
Back
Top Bottom