Pid fb41 matlab opc simatic

kolchak

Member
Join Date
Dec 2016
Location
Moscow
Posts
20
Hello!

Please help with the answer to the question of the right choice of TI and TD parameters for PID FB41 block.
I have a process model in Matlab-simulink, the PID controller is in Step7, FB41 block. Data communication takes place on the OPC protocol. The output of the PID controller (Step7) enters the object in Matlab, where I see the result of the process to scope.

I know that the formula FB41 - K (1 + 1 / Tis + Tds).
Parameters PID controller Matlab I have chosen the following:
Kp=5.7417
Ki=1.6724
Kd=9.4678


I used a variable block FB41 - PV, for input (OPC Read) and output (OPC write).
I also tried to use the signal for the job via the OPC FB41 setpoint (SP_INT), PV ( for the signal after the object) and LMN (for input to object in Matlab).
As a result, in both cases I received a completely different graphics, different from PID controller Matlab and FB41 (Step7) .


How should I choose the parameters of TI and TD, and correctly configure block PID controller FB41 (Step7) knowing the coefficients PID controller Matlab / simulink?

I looked a lot of articles, documentation of FB41, but did not understand how to implement the controller using Matlab and the OPC protocol.

I can send you the Step7 project with the FB41, for example.

I really hope for your help.
Thanks for the answer.

model.jpg
 
What are the controller gain units? %/%, min, sec, rep/sec etc..?

Also, your Simulink model is using a parallel form of PID, and (i think) the FB41 uses the interacting formula.


---totally unrelated thought: the continuous du/dt block has problems in earlier versions of Simulink. Consider using the discrete time version instead.
 
Last edited:
Also, your Simulink model is using a parallel form of PID, and (i think) the FB41

This model describes the regulation of the oven temperature.
I know that Siemens PID controller has a different formula different from PID controller Matlab.
I do not know how to determine the TI and TD for the FB41 block in the Step7 ...
 
Gentlemen, need your help.
In this screenshot shows the results:
scope1 - PID contoller, Matlab/simulink;
scope2 - PID contoller, FB41 / Step7;

OPC Write / OPC Read - PV_IN
:confused:

opcpid.jpg
 
The diagram doesn't make sense. The feed back has a gain of 1.4?
The feed back will either be in counts or degrees.
The plant appears to have 3 poles. How did you figure this out?
Do you know how to do system identification?
The derivative time constant does not look right. It should be smaller than the integrator time constant.

Your plant appears to be free of dead time. This is rare. Most temperature systems are modeled as FOPDT or SOPDT ( first order plus dead time or second order plus dead time ).
If you have a valid plant model in the s domain it is easy to calculate the controller gains.

I doubt the Matlab integrator and derivative parameters are expressed as time constants, they are probably gains.
 
Last edited:
The diagram doesn't make sense. The feed back has a gain of 1.4?

If you have a valid plant model in the s domain it is easy to calculate the controller gains.

Yes, I uploaded model system in Matlab above, in the first message.
But I do not know how to calculate the TI and TD, and configure the PID controller in Step7, so that I could work with it on the OPC...


It is important to use 3 variables to communicate by OPC data to the block in the Step7 PID: SP_INT(setpoint) , PV(output to object) and PV (feed back)? Or is possible to use one variable (PV) for input and output, as I did?
 
Last edited:
What is the FB41 controller action setting?

Can you verify that the output of port V is the PV?
That 950 constant with the sum circle is giving you some issue too. The setpoint exists in the FB41.
 
Forget about OPC. OPC has NOTHING to do with the PLC. The PLC knows NOTHING about OPC.

Kolchak, you haven't answered my questions.
The model you present doesn't make sense. If you have a record of time, output and PV then this Scilab program can find the gain and time constants. I assume the gain for temperature systems is %control_output/degree_error. You haven't told us how the system is scaled yet.
Usually the input is scaled degrees per count and the output is scaled %output/count.
The PIDs are usually scaled counts out per counts in so there must be scaling on both the input side and the output side.
 
What is the FB41 controller action setting?

Can you verify that the output of port V is the PV?
That 950 constant with the sum circle is giving you some issue too. The setpoint exists in the FB41.

I made screenshots of settings in the Step7 project blocks. Please take a look.
What should I choose as the input and output for the FB41 block to connect by OPC?
What should I do with a constant 950 and the gain 1.4 after the constants for the set point?

Forget about OPC. OPC has NOTHING to do with the PLC. The PLC knows NOTHING about OPC.

Kolchak, you haven't answered my questions.
The model you present doesn't make sense. If you have a record of time, output and PV then this Scilab program can find the gain and time constants. I assume the gain for temperature systems is %control_output/degree_error. You haven't told us how the system is scaled yet.
Usually the input is scaled degrees per count and the output is scaled %output/count.
The PIDs are usually scaled counts out per counts in so there must be scaling on both the input side and the output side.

Can you help please determine the coefficients TI and TD in the Scilab?

file "pic.png" - Voltage of imbalance of the bridge circuit dU (error signal) is supplied to the regulator (P). The control action U amplified by an amplifier (G), the output voltage of which is controlled by the executive engine (M).

db.jpg db2.jpg fb41_settings.jpg pic.PNG
 
Last edited:
I received your PM but I am no particular expert with any of this. So it is better for you to keep this on the forum.

We will address these issues one at a time. For the purposes of this discussion we will assume that the process model as you have it in Simulink is an accurate representation of the system you want to control. This may or may not be true but for now we will assume it is. For the purposes of this discussion we really don't care. We simply want the S7 response to match the Matlab response.

We will start with gain conversion. The Matlab control structure is independent whereas the Siemens structure is dependent. The conversion would be:
Siemens Gain = Matlab Kp
Siemens Ti = Matlab Kp/Ki
Siemens Td = Matlab Kd/Kp

But it looks like you have a much more fundamental issue that just gain. The last Matlab configuration you posted is the configuration you want. Make sure the data types match and are correct in both the S7 and Matlab. Make sure your controller in the S7 is in auto mode.

Unless I'm missing something with element gain the S7 would need to produce an output to Matlab of 1875 to settle at a PV of -300. Dose that match what you are seeing? I would expect the PV to settle at -675 if there was nothing being produced by the S7, unless there is some scaling in the graph function that we don't know about.

In case you don't have this, I have attached a link to a manual that talks about the various S7 controllers:

https://www.fer.unizg.hr/_download/repository/S7pidcob.pdf

Info on FB41 starts in section 3-1.

Keith
 
kamenges, thanks you for answer!

I tried to implement PID controller in Step7 for other models: the air temperature control in the room. The sensor (type Pt100) is used as a sensor in the feedback: 1/(20s+1) after output of LMN I use 'Gain4'=16/100, because %(LMN) conversion to (4-20 mA), is that correct?

If tuned PID controller in Matlab with the coefficients:
Kp: 3.6182
Ki: 0.0095
Kd: 0.01
Then in Step7 (FB41)should select Kp= 3.6182, Ki = 1 / 0.0095=105,263 ??? , Kd = 1 / 0.01=100 ??? Please correct if I am wrong.

Look the screenshots please my model and the results of scopes.
Thanks!




 
Last edited:
Given the tuning values from Matlab:
Kp = 3.6182
Ki = 0.0095
Kd = 0.01

The values for the S7 would be:

Gain = Kp = 3.6182
Ti = Kp/Ki = 3.6182/0.0095 = 380.86
Td = Kd/Kp = 0.01/3.6182 = 0.00276

FB41 assumes the values of Ti and Td are in seconds and automatically scales them by the value in the CYCLE parameter. So make sure that you enter the cycle time of the FB41 call in the CYCLE parameter of FB41 in seconds.

Finally, FB41 assumes setpoint and process variable inputs in percent with a range of +/- 100%. So until you can fully understand what is happening I would use setpoint values below 50 so both systems will respond as if the values are in percent. In that same thought I WOULD NOT add the 16/100 gain after the controller when using FB41. That has the same effect as changing the plant gain as far as FB41 is concerned. Until you are sure what is happening the two controllers should be controlling the same system. Also, the setpoint and PV of FB41 are floating point (REAL) values. Make sure these are showing up correctly in the plc. If the OPC link is sending them as integers that would be an issue.

Keith
 
Please post the contents of the PM you sent me here as it has some things others will need to see.

You are obviously closer. But either I made a mistake in the Ti and Td conversions or the value you have entered in CYLCE parameter in FB41 doesn't match the actual interval that you are calling FB41. The graph looks like the integral isn't acting as quickly as it should.

CYCLE is used to tell FB41 how often it is being called. The effect of Ti and Td are scaled by the value of CYCLE to keep the response the same regardless of how often the function block is called. You have 1 second entered for CYLCE based on the screen shot you posted. If, for example, the actual call interval of FB41 is 0.1 seconds and you have 1 second entered in CYCLE, the time based effects of the PID (the integral and derivative responses) will be 1/10 of what you expect. It looks like you are unconditionally calling FB41 from OB35. As I recall the default interrupt rate for OB35 is 100 ms. I think if you change the value of CYCLE to 100ms you will get a closer response to the Matlab response.

If you really want a more identical controller I would also set the value of TM_LAG equal to the CYCLE value. I believe this is a time constant for a first order filter to remove noise from the derivative response. Unless the Matlab derivative block has something similar, them set them equal to each other. Your FB41 currently has this set to 2 seconds. However, your dominant plant pole is so far right that I don't think this is affecting anything anyway.

Keith
 

Similar Topics

HI.I REVIEWED A PROJECT DONE. THIS FB41 PID BLOCK WAS USED FOR THE PASTEURIZATION PROCESS. THE PROCESS I CAN'T UNDERSTAND IS THE ACTION. WHILE THE...
Replies
2
Views
1,076
We have to migrate a project from S7 300 to S7 1500 where FB41 CONT_C is used. It is called in OB (every cycle), I see that the parameter 'Cycle'...
Replies
1
Views
1,871
hello, I'm new in automatics, and i'm working on a speed control project for a hydraulic turbine. i'm using FB41 pid bloc, but the LMN give me 0...
Replies
3
Views
2,241
hi , I'm trying to implement PID in step 7 using FB41.the FB41 is implemented in OB35. I know how to set parameters of PID also I know the inputs...
Replies
16
Views
4,004
Hello, Please see attached pictures and tell me why does the output change can you please pin point my mistake i have been searching the net for...
Replies
2
Views
1,919
Back
Top Bottom