what is the advantage of BLOCK_FC Parameter Type?

drspanda

Member
Join Date
Oct 2005
Location
Damanjodi
Posts
155
Dear Experts,

What is the advantage if FC5 is transferred to FC6 as DATA TYPE BLOCK_FC IN Parameter? Where do I find its application?

Why do we need to transfer? We can call as well...I mean I can call FC5 from FC6, Why should I transfer FC5 as IN Parameter..

Below is the help and I may be provided with example and difference between call and transfer.

You can only assign this data type for variables which you declare as Formal Parameters.
Using BLOCK_FC, you determine that a Function (FC) is to be transferred to the declared formal parameter as an Actual Parameter when the logic block is called.


Data Type Length Format (n = Block Number) Information Provided
BLOCK_FC 16 bits FC n Number of the function
Example:

Call FB 10, DB110(

:
Input_Var_FCNR:= FC5, // FC5 is transferred to
// FB10 for processing
 
One use of this parameter type is that the called block can examine the BLOCK_FC parameter and determine which FC number is being passed. Processing which depended on the FC number could then be done. For example:

You have a library of FC's and decide that FC5 is obsolete for your current hardware but it needs to be retained for legacy support and FC55 is the latest FC. Your processing could check the FC number and if it equals 5 then call fc55 instead.
 
L D[AR2 said:
For example:
You have a library of FC's and decide that FC5 is obsolete for your current hardware but it needs to be retained for legacy support and FC55 is the latest FC. Your processing could check the FC number and if it equals 5 then call fc55 instead.

I am sorry that I could not understand completely...Can you provide me a simple example where its use in programming.
 
Back to your original question


drspanda said:
What is the advantage if FC5 is transferred to FC6 as DATA TYPE BLOCK_FC IN Parameter? Where do I find its application?

Why do we need to transfer? We can call as well...I mean I can call FC5 from FC6, Why should I transfer FC5 as IN Parameter..

Below is the help and I may be provided with example and difference between call and transfer.

You can only assign this data type for variables which you declare as Formal Parameters.
Using BLOCK_FC, you determine that a Function (FC) is to be transferred to the declared formal parameter as an Actual Parameter when the logic block is called.


Data Type Length Format (n = Block Number) Information Provided
BLOCK_FC 16 bits FC n Number of the function
Example:

Call FB 10, DB110(

:
Input_Var_FCNR:= FC5, // FC5 is transferred to
// FB10 for processing


BLOCK_FC as an IN parameter.

You may design a block where internally you call one of 2 FC's (or more). In the code you may put the logic if condition x, call FCx, if condition y call FCy, etc. In your logic you would only call one of these FC's per call to the original block.

If you know which before you call the original FC, then instead of making a decision in the block, you could specify the FC in the block call IN parameters.

An example off the top of my head, say you had 3 message types in a comms interface. You may create an FC for each of the interfaces, where you take the three types of messages and convert to a format for you program.

Message types 1 to 3 are handled by FC4 to FC6. You then create FC3 to be a block to handle the result in a standard way. You could then call FC3 at 3 places in the code, depending on the message type and in each case the IN parameter designated BLOCK_FC would have the correct FC assigned.

Message type 1 would call FC3, with FC4 as the BLOCK_FC. Message type 2 would call FC3, with FC5 as the BLOCK_FC, etc.

edit: the blocks called via BLOCK_FC should not have any IN, OUT parameters assigned, as these will not be processed.
 
Last edited:
Here's an example in the form of source code. Compile it and call FC2 from OB1

Code:
FUNCTION FC 1 : VOID
TITLE =
VERSION : 0.1

VAR_INPUT
  fcBlock : BLOCK_FC ; 
END_VAR
VAR_TEMP
  iFC : INT ; 
END_VAR
BEGIN
NETWORK
TITLE =if FC5 passed then call fc55 instead,otherwise call fc specified
	  L	 5; 
	  L	 P##fcBlock; 
	  CAD   ; 
	  CAW   ; 
	  ==I   ; 
	  JC	sk5; 
	  JU	no5; 
sk5:  L	 55; 
no5:  T	 #iFC; 
	  L	 1000; //ignore any FC >1000
	  >I	; 
	  JC	igno; 
	  UC	FC [#iFC]; 
	  SET   ; 
	  SAVE  ; 
	  BEU   ; 
igno: CLR   ; 
	  SAVE  ; 
END_FUNCTION
FUNCTION FC 2 : VOID
TITLE =
VERSION : 0.1
BEGIN
NETWORK
TITLE =use Fc5 inside FC1 (but FC1 overrides and calls fc55 instead)
	  CALL FC	 1 (
		   fcBlock				  := FC	 5);
	  NOP   0; 
NETWORK
TITLE =use FC3 inside FC1
	  CALL FC	 1 (
		   fcBlock				  := FC	 3);
	  NOP   0; 
NETWORK
TITLE =pass fc2000 - but fc1 ignores it
	  CALL FC	 1 (
		   fcBlock				  := FC  2000);
	  NOP   0; 
END_FUNCTION
FUNCTION FC 3 : VOID
TITLE =
VERSION : 0.1

FUNCTION FC 55 : VOID
TITLE =
VERSION : 0.1
BEGIN
NETWORK
TITLE =Dummy prog for test use
	  AN	M	0.1; 
	  =	 M	  0.1; 
END_FUNCTION

BEGIN
NETWORK
TITLE =another dummy program for test use
	  AN	M	  0.2; 
	  =	 M	  0.2; 
END_FUNCTION
 

Similar Topics

Ever use this instruction and what was your reason?
Replies
1
Views
891
Hi! I use a s7-1200 with a HSC single phase on input i0.0 100kHz, and input filter set to lowest 0,1uS. It is around 1300pulses on each step we...
Replies
7
Views
1,778
Hello, In our company, we are currently looking to change our way of programming since we've been growing for the last 10 year and our projects...
Replies
1
Views
5,070
Hi all, We are replacing a old SLC50/2 with a new MICROLOGIX 1220. Old inputs were wired 24vdc sinking. Is there an advantage to this? Should I...
Replies
5
Views
2,172
Hi All, Who can tell me what's the benifit to use isolated DI/DO module. Our customer spec 2 modules in a project: ALB1769IA8I ALB1769OW81...
Replies
6
Views
5,885
Back
Top Bottom