SCL block calling, S7 Siemens

Daye.04

Member
Join Date
Jul 2012
Location
Fredrikstad
Posts
70
Hey gang.

I hope I'm not too much of an annoyance for you guys, but I need some more help ^^

I'm more or less just getting started at programming SCL. I thought that since I have som experience programming C++, this would be ideal for me. But there seems there are some key points I just can't wrap my head around like at all.

The current wall I'm meeting is how to call on a FB block from an OB block. This is supposed to be a moot, I know. I just can't seem to get it going ...
 
Well. I might be dense, or there may be some terminology I just don't understand. Or both. But I just can't seem to figure out where they perform the call, and so how it's done.

From what I could gather the block was called "acquire", but the only thing resembling a call was "acquire.acquire[something](" and that can't be right ...
 
In the SCL editor, you can chose to insert a block. It can be any block from the project block folder. You browse for the block and it will be inserted at the cursor. The various parameters (and eventual instance data block for an FB) has to be filled out manually.
 
Allright, so I assume I have to have a Datablock in correlation with the FB in order to call it. Because when I tried using that command, it would not use the FB I allready had (Nr. FB1). And when I permitted it to make another one, nothing but ".DBxxx" came up. I understand that the x'es are to be replaced with the corresponding number of the block I'm referring to, but is that the only commands required to call on a block? a dot and the blocknumber?
 
Here's a simple example that compiles without using symbols:

Code:
ORGANIZATION_BLOCK OB1
VAR_TEMP
    info : ARRAY[0..19] OF BYTE;
END_VAR
FB1.DB1(iData:=1);
END_ORGANIZATION_BLOCK
FUNCTION_BLOCK FB1
Var_input
iData:INT;
end_var
    idata:=iData+1;
END_FUNCTION_BLOCK
DATA_BLOCK DB1  FB1
BEGIN
END_DATA_BLOCK
 
Using the following symbol table entries you can use them in the SCL.

(Note that two passes of the compiler are required when you are creating DB's for the first time)

syx.JPG
 
SCL source:

Code:
ORGANIZATION_BLOCK OB1
VAR_TEMP
    info : ARRAY[0..19] OF BYTE;
END_VAR
ACQUIRE.ACQUIRE_DATA(iData:=1);
END_ORGANIZATION_BLOCK
FUNCTION_BLOCK ACQUIRE
VAR_INPUT
iData:INT;
end_var
    idata:=iData+1;
END_FUNCTION_BLOCK
DATA_BLOCK ACQUIRE_DATA  ACQUIRE
BEGIN
END_DATA_BLOCK
 
Different example:

Code:
ORGANIZATION_BLOCK OB1
VAR_TEMP
    info : ARRAY[0..19] OF BYTE;
    rResultOfSquareRoot:REAL;
END_VAR
FB5.DB5(rANumber:=4.0);
rResultOfSquareRoot:=DB5.rSqrt;
END_ORGANIZATION_BLOCK
FUNCTION_BLOCK FB5
VAR_INPUT
rANumber:REAL;
END_VAR
VAR_OUTPUT
rSqrt:REAL;
end_var
    rSqrt:=SQRT(rANumber);
END_FUNCTION_BLOCK
DATA_BLOCK DB5  FB5
BEGIN
END_DATA_BLOCK
 
For FBs with IDBs, you have to have assigned the symbolic names before you use the FBs or IDBs. One way to do it is to select the SCL option "assign block numbers automatically".
Also, the order of the compilation is important.
First the declarations (i.e. UDTs and FBs) and then the blocks that are defined by the declarations (derived UDTs or FBs, and IDBs), and so forth, ending with OB1.

Here is a small sample how to do it in SCL:
Code:
(* sample FB
*)
FUNCTION_BLOCK MyFB
VAR_INPUT
  start_button : BOOL ; // N.O.
  stop_button : BOOL ; // N.C.
END_VAR
VAR_OUTPUT
  contactor : BOOL ;
END_VAR
VAR
  run_state : BOOL ; 
END_VAR
run_state := (start_button OR run_state) AND stop_button ;
contactor := run_state ;
END_FUNCTION_BLOCK
 
(* sample IDB
derived from MyFB
*)
DATA_BLOCK MyIDB MyFB
BEGIN
END_DATA_BLOCK
 
(* sample use of FB + IDB in OB1
*)
ORGANIZATION_BLOCK OB1
VAR_TEMP
    // Reserved
    info : ARRAY[0..19] OF BYTE;
END_VAR
MyFB.MyIDB(start_button :=  I0.0
           ,stop_button :=  I0.1
           ); 
Q0.0 := MyIDB.contactor; 
 
END_ORGANIZATION_BLOCK
 

Similar Topics

FUNCTION_BLOCK FB283 VAR_INPUT DB_number: BLOCK_DB; add : int; END_VAR VAR_OUTPUT out:INT; END_VAR VAR end_var BEGIN...
Replies
2
Views
3,182
In scl fb contains 5 input pins and 1 output pin plz explain the 5 input pins and how to use that pins ... i want to convert 4-20 mA analog input...
Replies
7
Views
2,988
Hi All, I am currently writing a new function in SCL, And I have a array at 300 bytes (tmpArray[0..299] OF Bytes) to this function. Questions...
Replies
3
Views
3,430
I'm making a quick foray into using a FBD routine in order to use the SCL instruction and I found a couple things I could not find an explanation...
Replies
4
Views
6,746
Hey, I have one data block that was created by someone else and it is used only to send values from a MMI to it so they can be used throughout...
Replies
8
Views
7,079
Back
Top Bottom