from the PLC Control department...
PID Control using FB41 for Siemens S7-300 PLC
PLCs and related questions. topic
Posted by Donald Tan on 20 December, 2002 - 11:19 am
I am currently trying to program a Siemens S7-300 PLC (CPU 313) for PID control using FB 41. Where can I find more examples and more details on how to use FB41.

I have tried to run the controller_update.pdf which I have downloaded from the PLCArchive section on my PLC. I have no problems compiling the source code. However, when the program was downloaded and run on the PLC, the PLC SF Software Error LED was turned on.

I tried to read through the manual on PID control but find it hard to understand the explanation.

Essentially, what are the important inputs and outputs parameters that I should take note. I am only interested to design a single input and single output PID controller.

I am trying to control the input voltage to a valve using the controller in order to control the temperature of a reaction vessel.

Any advice on the above would be greatly appreciated. Please feel free to email me at pwdt2002(AT) if you could offer me any help.

Thanks and wishing all of you at Control.Com Merry Christmas and a Happy New Year.

Posted by Gary Wrotnowski on 23 December, 2002 - 8:25 am
1. Create an OB35 100 millisecond time interrupt routine. program a call... such as...


The result is the Instance Data Block, DB41 will be created automatically. Symbolic names are automatically created for you for all the Block parameters of FB41. However you would want to assign a Global Variable name to DB41 such as "Tank"

Then you can work with Symbolics. Referring to the PDF files that install on your computer with STEP7 you can find documentation on the SFB41 System function. For example P,I,D parameters would be

"Tank".Gain REAL Number such a 5.00 P
"Tank".TI T#2s TIME format 2 seconds reset I
"Tank".TD T#1s TIME format 1 second ,derivative D

Good Luck ... let me know if you have further questions.

gary wrotnowski
770 740 3096
PLC instructor

Posted by Jan Steen Nielsen, Denmark on 10 January, 2003 - 4:36 pm
Forget all about FB41 - It does't work properly!.
I have through many years developed a PID-Controller myself, starting with S5 and now also for S7-300 & S7-400 and it have been used in many applications in real life.
My controller is both types in the same FB(121):
An analog + Step-controller and is very easy to program and understand. Furthermore you call this FB121 where ever you want in your program, because it have its own time-share inside for calculations and have also a built-in correction for the actual scantime, in fact it MUST be called every scan to work properly.
E-Mail to me ( and you get this work together with many other blocks in a little (packed) program in OB1, where all blocks are listed. Hereafter you "Retrieve" the program directly in S7-Software and copy-paste which block you need.
Note: I will send this work for FREE, because I feel sorry for you to use much more time on FB41.

Posted by Juma on 1 June, 2003 - 10:58 am
dear colleaques,
i am looking for some teaching examples of PID controller ...i have experience in S7-300 but never work with PID..any one can assist me by sending some documents for self training...

Posted by Rishabh on 22 June, 2009 - 2:36 am
Hey Jan,

thanks alot. I would like to get this. Can u plese mail it to me on:
rishabh.mishra [at]

Thanks Buddy....Keep Booming

Posted by Mladen Milenkovic on 10 February, 2012 - 4:01 am
Mr. Nielsen's functions should be downloadable from following link:

Mladen from Sarajevo, Bosnia-Herzegovina

Posted by hammad on 15 March, 2012 - 1:52 pm
i have a large plc program comprises on many FB , DB, FCs ..n now i wana change PID values i will find that PID settings are in which block. cause whole program is without comments? plz guide me

Posted by AMIR OVCINA on 25 March, 2014 - 1:08 pm

Posted by Jan Steen Nielsen on 27 August, 2014 - 12:19 pm
Hello Amir Ovcina (and others)

I have made an all-in-one PID-Controller (FB121) and many other useful functions for Simatic S7-300/400 series for free downloading under PLC Archive+"PID-Control" in

You (and others) are wellcome to get the latest issue of this work of mine. Many of those functions are now open for free.

My old e-mail (L-N@mbox301...) is not active anymore, but you may use my new mail:

Kindly regards
Jan Steen Nielsen

Posted by Kevin E. Moore on 22 February, 2003 - 12:05 pm
If you are using Step7 V5.1 or later, it is better to use FB58 from the PID Control folder in the Standard Library. It is greatly improved over FB41 and there is a built-in operator interface tool you access by double-clicking on the data block you create when you call FB58 from OB1 or OB35.

Posted by michele Bellini on 5 March, 2003 - 1:39 pm
Hi , i'm an Italian beginner with the PLC PID control.
I must control a speed across voltage regulator; but i read the real speed 2 second later that the reality.
I analize at the moment the FB 41 and the FB 58.

The FB 58 is not only for temperature or?

Thanks for you answere

Your use of this site is subject to the terms and conditions set forth under Legal Notices and the Privacy Policy. Please read those terms and conditions carefully. Subject to the rights expressly reserved to others under Legal Notices, the content of this site and the compilation thereof is © 1999-2014 Nerds in Control, LLC. All rights reserved.

Users of this site are benefiting from open source technologies, including PHP, MySQL and Apache. Be happy.

If only God would give me some clear sign! Like making a large deposit
in my name at a Swiss bank.
-- Woody Allen, "Without Feathers"
Advertise here
our advertisers
Help keep our servers running...
Patronize our advertisers!
Visit our Post Archive