Generating source in step7

Join Date
May 2009
Location
Halmstad
Posts
41
I've written a function block that calls several SFBs that I want to be able to export and import and compile. My question is how I do this the easiest way? Right now I simply call the SFBs, and have created instance DBs.

But if I remove the instance DBs and the FB, and try to compile the source, the compiler says the instance DBs are missing. This is of course true, but is it possible to have Step7 automatically create the instance DBs, or is it possible to include the called SFBs instance DBs in the FBs instance DB?

Thanks
 
It is posible to include SFbs in the header for an FB that calls them. They need to be declared in the STAT section e.g. Name: send Type: SFB12. In your code you would call send and not SFB12.

Nick
 
If you want the instance DBs to be generated by the compilation process you have to generate the source code for the DBs. Here some example source which I compiled to generate all the blocks:
Code:
DATA_BLOCK DB 1120
TITLE =
AUTHOR : SIMATIC
FAMILY : COM_FUNC
VERSION : 0.0
 SFB 12
BEGIN
END_DATA_BLOCK

DATA_BLOCK DB 1121
TITLE =
AUTHOR : SIMATIC
FAMILY : COM_FUNC
VERSION : 0.0
 SFB 12
BEGIN
END_DATA_BLOCK
FUNCTION_BLOCK FB 1
TITLE =
VERSION : 0.1
BEGIN
NETWORK
TITLE =
      CALL SFB   12 , DB  1120 ;
      NOP   0; 
NETWORK
TITLE =
      CALL SFB   12 , DB  1121 ;
      NOP   0; 
END_FUNCTION_BLOCK
 
ORGANIZATION_BLOCK OB 1
TITLE = "Main Program Sweep (Cycle)"
VERSION : 0.1

VAR_TEMP
  OB1_EV_CLASS : BYTE ; //Bits 0-3 = 1 (Coming event), Bits 4-7 = 1 (Event class 1)
  OB1_SCAN_1 : BYTE ; //1 (Cold restart scan 1 of OB 1), 3 (Scan 2-n of OB 1)
  OB1_PRIORITY : BYTE ; //Priority of OB Execution
  OB1_OB_NUMBR : BYTE ; //1 (Organization block 1, OB1)
  OB1_RESERVED_1 : BYTE ; //Reserved for system
  OB1_RESERVED_2 : BYTE ; //Reserved for system
  OB1_PREV_CYCLE : INT ; //Cycle time of previous OB1 scan (milliseconds)
  OB1_MIN_CYCLE : INT ; //Minimum cycle time of OB1 (milliseconds)
  OB1_MAX_CYCLE : INT ; //Maximum cycle time of OB1 (milliseconds)
  OB1_DATE_TIME : DATE_AND_TIME ; //Date and time OB1 started
END_VAR
BEGIN
NETWORK
TITLE =

      UC    FB     1; 
END_ORGANIZATION_BLOCK
 
@Manglemender: This was exactly what I was looking for, thanks!

Only one question remains: If I use the sample program you attached, is it possible to call the "send" and "rec" functions more than once, or do I have to declare a new function for each call? In my code, I call two SFBs three times each.
 
If you want to call the same FB/SFB multiple times then each instance must be declared individually in the header e.g. Send1, Send2, Send3 etc.

Nick
 

Similar Topics

Hi! First time posting here. New to AB PLC family and working on this new project. Using Micro850 PLC and PV800 HMI and CCW. The project is to...
Replies
1
Views
1,439
Im using studio 5000, in my software, Im using E300 overload protection relay to control a motor. Studio 5000 Version 32.12 E300 Version 7...
Replies
5
Views
2,865
Hi, I have a new PCS7 project with a 6ES7 417-4XT07-0AB0 CPU. When compiling the System/module CFCs are generated from the hardware. But in my...
Replies
1
Views
1,260
Hello Guys, I spent some time searching the web to learn how to generate the report (to be printed out or to be saved as pdf file) which would...
Replies
0
Views
1,212
Hey all, I'm trying to use a OB16IEF to generate a 24V PWM signal. According to the manual all i have to do is set... Local:#:C.Pt[#].PWMEnable...
Replies
7
Views
2,923
Back
Top Bottom