PID control

Pandiani

Lifetime Supporting Member
Join Date
Apr 2005
Location
Tz
Posts
718
Is it necessary to place FB41 into OB35? Is it Ok to FB41 to be placed in OB1? Is there any chance that constant Ti will not be OK if FB41 is placed in OB1. Here we have problem. PID FB41 is placed in OB1 and with proporcional gain everything works fine, but when we enable integrative Ti then we get control signal saturation
Can you give me any advice?
 
Last edited:
You don't absolutely have to put FB41 in OB35 to get it to work. The problem with putting FB41 in OB1 is you don't have a consistent time between calls. OB1 will run as fast as it can, which tends to make it variable. Time dependent functions like integration and differentiation will not return consistent values they are called regularly OR unless they calculate their own time between calls. I don't think FB41 calculates a time between calls.

Another thing to consider is when you enter the update rate into the data block for FB41 you are telling it the call frequency, not setting an execution frequency. If you are telling FB41 it is being called every 35 msec but it is in fact being called every 3.5 msec, you will have 10 times the integral action you think you do.

It sounds to me like you have a different problem. You say your control signal saturates when you add integral. Does the process variable change when the control signal goes into saturation? Is it more correct to say you are going into oscillation?

Keith
 
student project

Thanks for reply. We have placed FB41 in OB1 first, but when enable integral action process output was oscilatory, and controll signal (output from PLC) was oscilating between +10V and - 10V.
But I feel need to explain a little further what the problem is. So please, read this:
I'm having the following problem. I need to set up PID control block
FB41 (Step 7).
I have an analog card SM 331 AI 8x12 bit.
I have one volatge signal that is supposed to be a reference input value.
That signal is from 0 to 10 V. And it is supposed to represent step reference input
(constant at 1 V). this will be one analog input. Also I have another potentiometer that
provide voltage from 0 to 10 V and that is supposed to represent proportional gain (so I
can play with proportional gain of PID and to record different outputs). This is supposed to
be second analog input. Process is 2/(4s+1) and it is simulated on dSpace platform. dSpace card
provide voltage in range (-10V to 10 V). So this is third analog input (process value,
actual output). Error signal in clasical closed loop sistem is reference-actual value.
I need to make PID controller K(1+1/(8s)+2s) and output from controller will be input to
process (dSpace card) so this is first and only analog output.
Now problem is how to set PID FB41 parameters. K is adjustable with potentiometer, so
I put TI input of PID as T#8s and TD as T#2s. Since input valueas are integers in range
(0, 27684) first I scale all inputs to range (-10, 10) so I can track what is going on
with STEP 7. Of course, output needs to be unscaled before sent to output card.
Here's what I have done so far. I can test it only tomorrow, but I'd like to read your
opinion and advices if I'm on the right track.
Can you look at the example in the attachment and tell me if it is good or not. I'm student
and I found Siemens documentation very poor. Am I using COM_RST and other paramteres properly?
Thanks you very much for your help, I'm looking forward to your answers.
 
You are going to need more high-powered help than I can provide. You are approaching this directly from the design side and you're looking to learn something specific. I could probably tell you how to get the thing stable but it would be completely iterative and not based on the system model you have developed.

It looks like you have the basics covered. Your cycle time value matches your OB35 time, which is good. It looks like you are treating the analog values as if they are unipolar. I believe they are bipolar. So a value of 0 is 0 VDC and the peripheral words go positive and negative.

Are you confident of your PID transfer function? I really can't help you with that but you may want to double-check that. Also, the manual says that the FB41 is implemented as an independent controller. However, it follows the ISA dependent form. It looks like your PID transfer function is designed this way. just thought I would point that out.

Sorry I can't be more help.
Keith

PS:
I just noticed that you are using the same values for time as you have for multipliers in your transfer function. Again, I'm a bit out of my league on this but I think you need to perform a conversion on these numbers to get true time values.
 
Last edited:
>I believe they are bipolar. So a value of 0 is 0 VDC and the peripheral words go positive and negative.
Well actual output value is certanily both positive and negative (-10V to 10V), however I fond in help (for scaling function) this:
Description

The SCALE function takes an integer value (IN) and converts it to a real value in engineering units scaled between a low and a high limit (LO_LIM and HI_LIM). The result is written in OUT. The SCALE function uses the equation:

OUT = [ ((FLOAT (IN) – K1)/(K2–K1)) * (HI_LIM–LO_LIM)] + LO_LIM

The constants K1 and K2 are set based upon whether the input value is BIPOLAR or UNIPOLAR.

· BIPOLAR: The input integer value is assumed to be between –27648 and 27648, therefore, K1 = –27648.0 and K2 = +27648.0

· UNIPOLAR: The input integer value is assumed to be between 0 and 27648, therefore, K1 = 0.0 and K2 = +27648.0

I believe that analog values is seen in STEP 7 project as numbers between 0 and +27648, so I set bipolar to zero. Maybe, I'm wrong here?
Can you comment this a little further.

>I just noticed that you are using the same values for time as you have for multipliers in your transfer function. Again, I'm a bit out of my league on this but I think you need to perform a conversion on these numbers to get true time values.
Oh, I see in the help that gain is in front of integral and derivative constant, so to the sumator (sum element) is going K/TI and not just TI, so mabye your telling me that I shod put to the PID parameter TI=8/K and not just 8, is that true?

Also, I'm not sure if I'm using rest of parameters properly (manual, INT_HOLD etc.) since I'm not familiar with it.

Thanks for the reply, I'm looking forward to continue this discussion to end this project successfuly.
 
Originally posted by Pandiani:
I believe that analog values is seen in STEP 7 project as numbers between 0 and +27648, so I set bipolar to zero. Maybe, I'm wrong here?
Can you comment this a little further.

It's been a while since I worked on a Siemens plc but I believe the numbers from/to the analog cards are bipolar. You can test this by looking at the raw value of the number from the analog input card. The card is configured for +/-10VDC operation. If the signal is bipolar then 0VDC will be a data value of 0. If it is unipolar 0VDC would be a data value of 13842. I think you need to either set the scale function to bipolar or set your lower engineering units value to 0 to get the correct scaling. I suggest setting the scale and unscale functions to bipolar.

You want to either connect something to the MAN_ON boolean input or set the value to zero in the data block. You must have done something with this already or you wouldn't be getting any control. This input selects manual mode if set to one. You should also set values for LMN_HLM and LMN_LLM to limit the value of the control variable.

As far as the gain values go, like I said I'm out of my league. But it looks to me like you are treating the 's' in your transfer function equivalent to time in seconds. This just doesn't seem right to me, although it may be.

Keith
 
Thanks for the reply, I'll change scaling so that reference is unipolar (since sigbal is from 0 to 10V) and proportional gain (same, from 0 to 10), but I'll set bipolar to actual output since its in range from -10V to 10V.
Well, I think that Siemens FB41 use this form of PID:
K(1+1/(sTi)+sTd) = K + K/(Tis)+ KTds. So I conclude that if i need to implement PID for instance 0.6(1+1/8s + 2s) just to set this:
gain = 0.6
TI = 8
TD=2
I'm also not sure if I'm doing this right. I hope someone will jump in with clear explanation.
Thank you very much for your effort
 
Pandiani, your PID calculations look OK.

I did a simulation of what you can expect.
ftp://ftp.deltacompsys.com/public/PDF/Mathcad%20-%20pandiani.pdf

Did you calculate the controller gains or where these values given to you?

I think you are only fighting the PLC at this point. I downloaded your code but you don't have much there yet. I looks to me like you only need to get the scalling correct.
I don't know that much about the S7 scaling conventions. So far they look awkward. Maybe some Siemens expert can tell us what is magic about 27648? I would think the limit should be some power of 2.

kamenges said:
As far as the gain values go, like I said I'm out of my league. But it looks to me like you are treating the 's' in your transfer function equivalent to time in seconds. This just doesn't seem right to me, although it may be.
s is the s operator or j*omega for the Laplace transform. See the .pdf.
 
I recognised the 's' in Pandiani's post as the s operator from a LaPlace transform. What I am missing is the direct equivalance of the coefficients of s in a LaPlace transform and the integral and derivative times in seconds in a PID implementation. I need to run through the math on this. It just seems odd that the 's' in a LaPlace transform is equivalent to seconds in real time.

The Siemens analog representations are a bit odd. The card is a 12-bit left justified signed value. So the lower 4 bits are dead. That still doesn't explain why the upper value isn't a power of two. Overrange maybe?

Keith
 
If the MANual ON boolean input is set to 1 then the manual setpoint REAL input is routed to the output (sorry, I'm at home and don't have Step7 with me). The default value for MAN_ON in the data block when it is created is one. The only way to change it as far as I know is to connect something to the MAN_ON input or set the value directly in the instance data block.

That's why I'm kind of confused. Based on your early posts it sounds like you can get some response out of FB41. But the value of MAN_ON in DB41 of your posted program is 0. So you shouldn't have been getting any response.

Step7 contains a block diagram of the PID in FB41. Open up the function catalog, expand the 'FB' selection, click the question mark in the menu bar then click on FB41 in the catalog. You will get the online quick explanation and the diagram.

Keith

Keith
 
kamenges said:
I recognised the 's' in Pandiani's post as the s operator from a LaPlace transform. What I am missing is the direct equivalance of the coefficients of s in a LaPlace transform and the integral and derivative times in seconds in a PID implementation.

??

kamenges said:
I need to run through the math on this.
Yes

kamenges said:
It just seems odd that the 's' in a LaPlace transform is equivalent to seconds in real time.
It isn't.

kamenges said:
The Siemens analog representations are a bit odd. The card is a 12-bit left justified signed value. So the lower 4 bits are dead. That still doesn't explain why the upper value isn't a power of two. Overrange maybe?
Analog value should be left hand justified. 27648 is still odd.

pandiani said:
Yes, PID parameters are given to me, I didn't calculate them
I will let you figure out the S7 PID. I can tell you how the PID gains were calculated. In the real world the systems are not so simple and the instructors do not provide the gains. The S7 is just a tool. There are many PLCs and each is different. Knowing how to calculate the PID gains is where the true knowledge is.

I will update my .pdf
 
Peter Nachtwey said:
??

There are many PLCs and each is different. Knowing how to calculate the PID gains is where the true knowledge is.

hehe, you caught me. Real truth is that I have calculated them, but process transfer function is a bit more complicated 2*exp(-4s)/(4s+1). And I've used Ziegler-Nichols method and playing with Matlab, I manage to determine that parameters.
I still have dilemas about my step 7 project. In 2-3 hurs, I'll test it, but I'd like everything to be OK. In attachment 1123 you can see where I found (-27648, 27648).
here's what I've found in documentation. So, if signal is bipolar, than if I understood
correctly, integeres on PIW... will be in range (-27648, 27648).
Also since analog card is biplar, I'll set all scaling and unscaling to biplolar, although
first two inputs are in range (0 , 10 V).
Also if you can look at my Step7 project, I changed a few things,
When you say I don't have much things, what do you mean exactly, since I intend to test this just like you see (in attachment PID.zip)
Am I'm missing something here, maybe?
I'm planning to download this project to PLC and start testing.
Thanks
 
kamenges said:
That's why I'm kind of confused. Based on your early posts it sounds like you can get some response out of FB41. But the value of MAN_ON in DB41 of your posted program is 0. So you shouldn't have been getting any response.

Well, in my early posts I was reffering to older project where FB41 was placed in OB1. Since, I found in this forum that it needs to be in OB35, I deleted older project and create a new one, which you may see in attachment. I dind't test this, and I'm not sure if this will work. On the old one, MAN_ON was set to zero.
 

Similar Topics

I have S7 1512C controler for controlling 48 PID temperature loop, the output is PWM. Please I need the best, most efficient way to write the...
Replies
13
Views
603
Hi all, I'm having trouble solving a problem I've been working on for several months, and thought you might like a stab at it. The machine runs...
Replies
22
Views
951
How can I connect PID Output to a valve. In ladder logic program is there any logic do I want to add between valve and PID? PV=SP What will be the...
Replies
7
Views
415
I am setting up control for Hypochlorite dosing. The easy part is the dosing calculation for flow pacing but I would also like to setup trimming...
Replies
8
Views
947
Hey guys! I'm a newbie in the control area, so I'm gonna drop some thoughts here... We want to control the opening of big silos (about 1900...
Replies
6
Views
1,488
Back
Top Bottom