Calling SFB41 or SFB42 (PID Controller) in Step7

F

Thread Starter

FR

I am about ready to do a project with many PID loops therefore I am doing a little research on the strengths of Siemens Step7 software. I have found that Step7 already has some predefined function blocks for PID control. these blocks are SFB41 for continuous control and SFB42 for step control. I've managed to find these blocks in the Step7 Standard Libraries but don't know how to go about making a call to them so that I can use them in my application. Does anyone out there have any idea as to how to go about doing this?. your help will be appreciated, Thank you!
 
G

Gabriele Corrieri

Hello FR,
I use the SFB 41 or SFB 42 same as FB41 and FB42 avaiable in Step7 package.
Otherwise if you use SFBs you save memory for other blocks of function.

Hope this help.

Gabriele Corrieri
[email protected]
 
D

david mertens

SFB41 and 41 are not available in all CPU's, only in a very limited series of CPU's (Mainly in 300 series). Use the FB41 and FB42 if your CPU doesn't have the SFB's, the functionality is identical. You can call the SFB's exactly like any other FB.
 
N

Nijssen.Ronald

I would suggest using FB41 and FB42, these are compatible with the SFB's You will have to create a program, either separate or as part of a CPU
Hardware configuration In the program you will find a folder for Blocks. If you want your PID's to execute in a predefined cycle, check which cyclic OB's the CPU you will use supports. Change the cycle time if needed Then create the selected OB by inserting it into Blocks folder.
Now open it, and create a network, if you selected Ladder as programming language,
Call the PID FB in the network and specify a Datablock, the editor will create a Datablock for this PID loop, with all variables automatically, now provide values and variables on all connectors of the block.
Create a network, with a FB call and a unique DB number for each call, for each PID loop you require.
Check that the execution time, while calling many PID's, doesn't exceed the cycle of the OB.

Download all blcks and switch the PLC to run, debug each block either by means of the network call, variable table or open the DB

Step7 provides a tool, to be found under the start-button, that allows the PID parameters to be specified more comfortable

Regards
Ronald
 
R

Ranjan Acharya

For Step7 and PCS-7 there is a separate PID package you will need to buy to get the best tuning and support features. It adds some FBs and so on. It may or may not now be included as a standard feature. I haven't touched Step7 or PCS-7 for quite a while.

RA
 
Thank You very much gentlemen for your input. I have achieved what i wanted. what i ended up doing was making a call to FB41 from OB1 and then linking a DB to the FB. Now that I've finally accomplished that. I need to make a call to FB41 numerous times because I need a substantial number of loops. Since I had to associate a DB to the FB41 call, Does this mean that I need to create a separate DB for each loop?. I am going to be using a S7-400 processor with DP. Which one?, I don't know yet!! :)

Thanks Again!!
 
D

david mertens

>> Thank You very much gentlemen for your input. I have achieved what i wanted. what i ended up doing was making a call to FB41 from OB1

The PID blocks have to be called in a timed OB (e.g. OB35). This is because the blocks need a fixed sample time (The PID algorithm uses the rate of change). If you put them in OB1, you will never achieve stable control as the PID parameters will be influenced by the cycle time of your OB1.

>>I need to make a call to FB41 numerous times because I need a substantial number of loops. Since I had to associate a DB to the FB41 call, Does this mean that I need to create a separate DB for each loop?.

Yes, every FB in the S7-CPU needs an instance datablock, this block is needed to store the remanent data of the program (The FB is a program), only temporary variables are stored in the stack.

>>I am going to be using a S7-400 processor with DP. Which one?, I don't know yet!! :)

For selecting a CPU, you have to estimate the calculation time and memory requirements for your program. A PID controller takes about 0.8 ms in an S7-416 CPU and needs about 6K of storage + 600 bytes for every instance. If you use a cycle of 1 second this means that you could get a maximum of 500/0.8 = 625 controllers in this cycle (without any other logic!!!). If you go for a 5 second cycle, this would of course be 5 times more. The memory required for this 625 controllers would be 6K + 625*600 = 372K, again without any other program parts. If you take a slower CPU, the execution time of the PID block is bigger, so less would fit in the same cycle. If you are going to automate a process plant with the CPU, I would opt for the PCS7 engineering toolkit, as this offers more convenient ways to design process automation programs with CFC,SFC and SCL programming languages and PID controllers ready made with more options than the bare PID algorithm of the FB41 (auto/manual, internal/external setpoints, engineering units, alarm limits, etc...).
 
R

Ronald Nijssen

You can create a "Parent" FB where the FB41 is declared multiple times in its header, you can then use the declared instances (aka multi-instances) locally in the logic of the parent. You will only need a DB for each time you call the Parent from OB1, this implies that one DB may hold for example the data of 10 loops
The additional benefit will be that you will be able to program much more efficient (making 10+10 calls to create 100 loops for example)
A good thing is to make sure that the data of each loop that needs to be modified or connected is wired to input/output pins of the Parent,
otherwise you will have to address the data as follows :
<ParentInstanceDB>.<DeclaredName>.<Variable>

Regards
Ronald
 
D

Donald Pittendrigh

Hi All

This approach is O.K. but remember to use the last cycle time value as the PID algorithm scan time otherwise the time based components of the algorithm cannot work properly, the last cycle time value is available as a standard
parameter of OB1, it is a #TIME constant and must first be converted to an integer before being attached to the scan time parameter!!

Cheers
Donald Pittendrigh
 
Top