Siemens S7 PID Control Problem

qee

Member
Join Date
Dec 2003
Posts
23
Hello All,

I’m afraid that I’m new to PID control but what I have read on the subject so far leads me down the following path.....

I am programming an application to control the water level of a tank.
To achieve this I am using a PID loop to control a pump via a variable speed drive that is controlled by an Analogue Output 4-20mA.

The value that I write to the Analogue Output will be derived from a Siemens PID Data Block DB201 CONT_C after being “unscaled” to give the appropriate analogue speed signal to the drive.

I also think that I need the following values inputted into DB201 to allow for the control of the drive:

Update Time (seconds) – CYCLE
Control Level (metres) – SP_INT
Actual Water Level (metres) – PV_IN
Gain – GAIN
Integral Time (seconds) – TI
DeadBand (metres) – DEADB_W

Can anyone give their opinion on whether or not I’m on the right track or if I am missing further variable/bits that need to be written to the DB in order for the PID loop to produce an output?

Any advice on this matter will be greatly appreciated.

As I say, I am new to the whole PID philosophy and although I can appreciate what the overall outcome will be, I’m not overly sure of all the components that are needed to/from Data Block 201 to achieve this. That's if 201 is the right Data Block to use?

Many Thanks
Qee.
 
Just a quick thought as I'm not familiar with S7 PID:
It doesn't sound to me that you need to use a PID for keeping the water level in a tank, unless it have to be very accurate.

If it doesn't need to be accurate, you can choose to use a 3-point regulation rather than the PID, even though the PID is more fun getting to work.
 
have you ever solved this ?
I need to do the exactly same thing using sinamics S120 vector control.
I wonder if I would use regulation with certain points (which seems not to be that easy either) or pid control.

Any help/ideas would be much appreciated :)
 
qee said:
Hello All,

I’m afraid that I’m new to PID control but what I have read on the subject so far leads me down the following path.....

I am programming an application to control the water level of a tank.
To achieve this I am using a PID loop to control a pump via a variable speed drive that is controlled by an Analogue Output 4-20mA.

The value that I write to the Analogue Output will be derived from a Siemens PID Data Block DB201 CONT_C after being “unscaled” to give the appropriate analogue speed signal to the drive.

I also think that I need the following values inputted into DB201 to allow for the control of the drive:

Update Time (seconds) – CYCLE
Control Level (metres) – SP_INT
Actual Water Level (metres) – PV_IN
Gain – GAIN
Integral Time (seconds) – TI
DeadBand (metres) – DEADB_W

Can anyone give their opinion on whether or not I’m on the right track or if I am missing further variable/bits that need to be written to the DB in order for the PID loop to produce an output?

Any advice on this matter will be greatly appreciated.

As I say, I am new to the whole PID philosophy and although I can appreciate what the overall outcome will be, I’m not overly sure of all the components that are needed to/from Data Block 201 to achieve this. That's if 201 is the right Data Block to use?

Many Thanks
Qee.

I'm assuming you plan on using FB41 "CONT_C" Function Clock?

Place this in OB35 (Time based Interupt set as 100mSec by default)
Call FB41 and used whatever DB you want (as long as it's unused elesewhere). You will need to use the following:
Update Time (seconds) – CYCLE, Set it for 1Sec (T#1.0S)
Control Level (metres) – SP_INT (Variable Setpoint 0.0~100.0 Real)
Actual Water Level (metres) – PV_IN (Variable Feedback (Scale it 0~100.0%
Gain – GAIN (Try 2.0 and tweek from there)
Integral Time (seconds) – TI (try T#20.0S)
DeadBand (metres) – DEADB_W (Leave as 0.0 for now)
LMN_HLM (Hight limit) 100.0
LMN_LLM (Low limit) 0.0
Output (Real 0-100.0) LMN

Download the works and you should be in business (OB35, FB41, DBxxx)


Scale LMN to what you need and throw it at drive)

Nick

(S120 has built in PID)
PID41.JPG
 
Thank you nick.

"S120 has built in PID" --> you suggest using that one ?
Or do I need the block FB41 together with it ?

There are some conditions. When there is taken very less water, we dont want the pump to be pumping at for example 10 hz.
In such case we want to wait a little longer at 0 hz so it can pump at higher speed at little later.

Is this all possible with PID regulation ?
Does that work with the high/low limit I feed to the pid ?

The output value could be a value between 0 and 100% if I understand this well. Could I just scale that to the drive setpoint range ? Or how would I start this.

Is there any way to test pid regulation offline (simulation) ?


I really would like a simple alternative to put in it too. The installation is already in the field. The first time it's restarted I want to be sure I have something that certainly works.
 
Last edited:
Nick_B

There's one very important piece of information for running FB41 successfully that I can't see in your advice. There is no point in leaving OB35 set at 100mS (which calls FB41 every 100mS) but then telling FB41 that its cycle time is 1S. If it's being run at 100mS tell it the truth! Tell it 100mS, or else adjust the cycle interrupt time for OB35 to 1S.

Whatever the frequency of execution is, you have to tell FB41 the correct value. Otherwise calculations can start to get screwed up. Let's say a process change takes place between two calls of FB41 which results in the PV_IN altering by 1%. FB41 thinks it took 1S for this second to occur but in reality it happened in 100mS, 10x faster. FB41 won't adjust parts of the output enough, especially the integral component, to compensate and meanwhile the change continues uncorrected.

Regards

Ken
 
Ken M said:
Nick_B

There's one very important piece of information for running FB41 successfully that I can't see in your advice. There is no point in leaving OB35 set at 100mS (which calls FB41 every 100mS) but then telling FB41 that its cycle time is 1S. If it's being run at 100mS tell it the truth! Tell it 100mS, or else adjust the cycle interrupt time for OB35 to 1S.

Whatever the frequency of execution is, you have to tell FB41 the correct value. Otherwise calculations can start to get screwed up. Let's say a process change takes place between two calls of FB41 which results in the PV_IN altering by 1%. FB41 thinks it took 1S for this second to occur but in reality it happened in 100mS, 10x faster. FB41 won't adjust parts of the output enough, especially the integral component, to compensate and meanwhile the change continues uncorrected.

Regards

Ken

Ken,
I see what your saying but should he need to do another Time Based Interrupt the CPU he's got may not support this and he'll have to do a hardware download and change value back. OB35 defaults at 100mSec and as such I didn't want to confuse him with to many steps. He's doing level control...I suspect 10 Sec would work. I was just trying to keep it simple and not load up his CPU with superfluous tasks.

Nick
 
See below:



JGS said:
Thank you nick.

"S120 has built in PID" --> you suggest using that one ?
Or do I need the block FB41 together with it ?
NB: Use the PLC (I'm old school Amplifiers are Amps...)

There are some conditions. When there is taken very less water, we don't want the pump to be pumping at for example 10 hz.
In such case we want to wait a little longer at 0 hz so it can pump at higher speed at little later.
NB: Yes you can achieve this in drive

Is this all possible with PID regulation ?
Does that work with the high/low limit I feed to the pid ?
NB: Yes

The output value could be a value between 0 and 100% if I understand this well. Could I just scale that to the drive setpoint range ? Or how would I start this.
NB: Depends on your style
I would work in INCHES for SP & PV and 0-100.0% for Output

Is there any way to test pid regulation offline (simulation) ?
NB: Do you have the PLC simulator PLCSIM?


I really would like a simple alternative to put in it too. The installation is already in the field. The first time it's restarted I want to be sure I have something that certainly works.
NB: This works (I tried it on my simulator) and gives you more options. I would leave it as 0-100% and use a compare instruction so as not to run the drive when demand is below x speed and error is with allowable limits
 
Nick
I was just trying to keep it simple...
It is simple, but it's still wrong.

You may get away with it in this application and other slow dynamic applications but it will catch someone out some day on another job. The trouble with open forums like this is you're never just answering one person about one problem. Many people will read and use this guidance in other PID applications whether we mean them to or not. We have a duty to them as well not to miss bits out.

If other timed-interrupt tasks are needed then the correct way to handle this is by doing task scheduling within OB35. If you leave it running at 100mS but only want FB41 to cycle every 1S, then only call FB41 once every tenth execution of OB35. I've seen a PLC like this where 20 PIDs were needed, all at a 1S interval. One alternative was to have OB35 run once a second and call all 20 instances of FB41 in that scan. You can imagine the effect that had on the scan time during that one scan! The other alternative was to have it running at 100mS and call nos.1 and 2 during cycle one, 3 and 4 during cycle two, 5 and 6 during cycle three etc. Only two FB41s were being executed at a time, but they were all being updated once a second, and the effect on the scan time was smeared out across all scans. Now then OB35 was running at 100mS and the loops were being executed at 1S intervals, so what was the correct value for CYCLE_TIME? Well, T#1S. This connection absolutely has to be correct if you want accurate control.

Regards

Ken
 
Ken M said:
Nick It is simple, but it's still wrong.

You may get away with it in this application and other slow dynamic applications but it will catch someone out some day on another job. The trouble with open forums like this is you're never just answering one person about one problem. Many people will read and use this guidance in other PID applications whether we mean them to or not. We have a duty to them as well not to miss bits out.

If other timed-interrupt tasks are needed then the correct way to handle this is by doing task scheduling within OB35. If you leave it running at 100mS but only want FB41 to cycle every 1S, then only call FB41 once every tenth execution of OB35. I've seen a PLC like this where 20 PIDs were needed, all at a 1S interval. One alternative was to have OB35 run once a second and call all 20 instances of FB41 in that scan. You can imagine the effect that had on the scan time during that one scan! The other alternative was to have it running at 100mS and call nos.1 and 2 during cycle one, 3 and 4 during cycle two, 5 and 6 during cycle three etc. Only two FB41s were being executed at a time, but they were all being updated once a second, and the effect on the scan time was smeared out across all scans. Now then OB35 was running at 100mS and the loops were being executed at 1S intervals, so what was the correct value for CYCLE_TIME? Well, T#1S. This connection absolutely has to be correct if you want accurate control.

Regards

Ken

Ken,
I was answering his specific question and application. Question based on what he wanted to do and limited information (he didn't even list which FB he wanted to use I offered my suggestion). In the future I will ask for a PO and let my lawyer look it over before I cut it loose.

I have two questions for you:

1. Does it work?
2. Is the person who asked the initial question happy?

On the matter of whether it's wrong. I understand it's different platform but look at the way Siemens generates code for the S7-200 wizard. They do largely the same thing. Generate a 100mSec Interrupt and count off 10 times before it executes. In a PCS7 project from memory the wizard does about the same thing.

Oh and a Ken...he's not running 20 PID's...then I would have answered accordingly.

Nick
 
Simply put, Ken is right.

Don't take shortcuts, 'Even If It Works'.

You are telling the PID FB that is is updating 10 times slower than it actually is. As pointed out in several other threads here, that will throw the gains completely off, especially if the interrupt time is changed, or the PID is copied to another project. The update time for the FB should be equal to the period in which it is called.

End of story.
 
I must say this is pointless, I was far enough to get the idea that the sample time should be correct and I'm happy with nick's answers.
He seems to be the only one that replies that is actually trying to help me further in stead of discussing endlessly about the sample time. If you are so good with it, help me than please ;)

Anyhow if anyone still wants to help.
This is what I can try to do. Correct me where I'm wrong

The situation:

- 2 pumps of 11 Kw are filling a pressure tank and this water is also going to the field.
- 1 pump works as hot spare or it could also help when one pump is not enough (this never happened yet)
- This installation is pretty old and will now be updated with the following key components:

Siemens CPU 315-DP
2x Sinamics S 120 (with cu310)
1x analog water level measurement in pressure tank
1x analog pressure meter

The idea:

Not starting and stopping the pumps as often as before.
The pumps are regulated by the water level in the pressure tank

How could I do it ?

a)Using a simple on/off between 2 water levels
b)perhaps trying to use PID BUT
I dont want the pumps to be running at too slow speeds because the efficency would be too low.

So if I understand correctly:

- I can use the FB41
- I can just update the setpoint in the sinamics via profibus with the output from my PID (with properly scaling the output)
- if I config the drive for example for a minimum speed of 20 hz, will that fix my problem ? Or would I better calculate this myself ?

LMN_HLM (Hight limit) 100.0
LMN_LLM (Low limit) 0.0

This is the input I suppose ? No option to set a minimum output in the pid fb ?

I have PLCSIM but I cant imagine how I can simulate the process in a good way (I cant update the input like it would be more or less in reality I THINK) Or do you have a good simulation idea about this ?

Any tips/hints I should know when I try to start up this thing ? Will it act weird ? Other things I should know ?

Thanks for your input thus far :)
 
Last edited:
CALL "CONT_C" , DB10
COM_RST :=
MAN_ON :="piddata".mode[1]
PVPER_ON:=
P_SEL :=
I_SEL :=
INT_HOLD:=
I_ITL_ON:=
D_SEL :=
CYCLE :=
SP_INT :="piddata".setpoint[1]
PV_IN :="piddata".pv[1]
PV_PER :=
MAN :="piddata".moutput[1]
GAIN :="piddata".gain[1]
TI :="piddata".ti[1]
TD :="piddata".td[1]
TM_LAG :=
DEADB_W :=
LMN_HLM :=
LMN_LLM :=
PV_FAC :=
PV_OFF :=
LMN_FAC :=
LMN_OFF :=
I_ITLVAL:=
DISV :=
LMN :="piddata".blk_output[1]
LMN_PER :=
QLMN_HLM:=
QLMN_LLM:=
LMN_P :=
LMN_I :=
LMN_D :=
PV :=
ER :=











why do not u used the logic in the drive . Micromaster 440 has a pi algorithm
 
rdrast said:
Simply put, Ken is right.

Don't take shortcuts, 'Even If It Works'.

You are telling the PID FB that is is updating 10 times slower than it actually is. As pointed out in several other threads here, that will throw the gains completely off, especially if the interrupt time is changed, or the PID is copied to another project. The update time for the FB should be equal to the period in which it is called.

End of story.

It's seems you fail to understand who the block executes. If the cycle time has not elapsed it simply jumps through. What is the default update time for OB35? 100mSec. Siemens application guides show the same kind of solution. Did you ever think that I structured my answer towards the skill set of the person with the question. It's obvious by the fact that he thought he had to use DB201 we probably has limited Siemens experience?

I kept it simple and I feel gave him enough info to get started. Depending on which CPU he has he may not have another Time based Interrupt to use. I left it as and I stand by it would and does work well. He doesn't have 20 PID's and we seems happy with what I gave him. I suggest seeing as you know better you right a more comprehensive example.

It does not through the gains off...try it yourself.




Nick
 
Nick and JGS

Let's start with an apology. Sometimes our words run away with us and meanings get implied and inferred which should never have been there in the first place. So, I'll say I'm sorry if we've got a bit tangled up in this issue.

However ... ;) (there's always a 'however', isn't there!)

Nick
If the cycle time has not elapsed it simply jumps through.
Are you suggesting that the FB41 schedules itself depending on the value of the actual parameter presented at CYCLE_TIME ? If so, this is the first time I've heard this mechanism proposed and I'd love to see some supporting evidence. To demonstrate the symptoms that can arise from badly matched CYCLE_TIME and 'real' execution intervals, have you ever tried calling FB41 from OB1? This really gets the irregularities showing! What is the point in calling the PID algorithm on a fixed timebase if that timebase is wrong?

I was answering his specific question and application. Question based on what he wanted to do and limited information (he didn't even list which FB he wanted to use I offered my suggestion).
Ah, but which specific question were you answering? Someone called FGS asked a question which included the statement "I need to do the exactly same thing using sinamics S120 vector control." So he was asking about PID control in a variable-speed drive. You provided an answer about how to do it in an S7 PLC. Where was the evidence that there was any PLC involved at all, far less an S7? Oh, I'm sorry. You had decided to answer the question originally posted 3 years ago by someone called Qee which was about S7 PID control? You can't have it both ways. Your solution can't fit both questions, and still be specific.
He doesn't have 20 PID's
Agreed. I was the one who introduced the example of a PLC which did. I was illustrating my experience with an application which did require other time-based interrupts (a concept that you had introduced earlier). I can't see anything in my writing which could be construed to suggest I thought JGS required 20 PID's. It was an example, that's all.

JGS
I'm happy with nick's answers. He seems to be the only one that replies that is actually trying to help me
OK, if you're happy then who am I to stop you. But please try to understand my point of view that a web forum is not a simple question-and-answer problem-and-solution place. It is, above all, a place for discussion, for sharing and challenging ideas, for offering opinions and having them corrected. This aspect of execution time when associated to PID calculations is, I believe, fundamental to good control. I initially offered that as an additional piece of information Nick's original solution. It was a small but vital element. But it now seems to have a life of its own in this thread. I stand by what I originally said until someone can convince me otherwise. If what Nick says is true, then it makes PID control in S7 a lot easier all of a sudden.

Regards

Ken
 

Similar Topics

Hello all, A group I am involved with is just completing converting a Siemens APACS control system over to an RSLogix PLC. The subject came up of...
Replies
1
Views
1,141
Hello I have test a program today using FC41 for a flow control(flow meter feed back(4~24mA,0~6.5 m3/h); positioner for the butterfly...
Replies
2
Views
2,080
Hi Sorry for the long explaination I am commisioning a new install with these PID control blocks which are supposedly auto tuning. The process...
Replies
4
Views
7,452
Hi Can anyaone please help..? I need to bild a line following robot it will be steered and driven by pneumatics, I need to be sent into a...
Replies
5
Views
2,436
Hello to all, I need its aid. I need to implement a control of pH for acid water neutralization and will use a PLC Siemens S7200, the problem is...
Replies
10
Views
7,278
Back
Top Bottom