How to simulate Simatic PID algorithm (cont_c)

morto

Member
Join Date
Jan 2008
Location
pl
Posts
3
Hi all!

In Siemens help PID controller is K(1+1/Tis+Tds). I did in matlab some model with object described Transfer Function and this PID form. With Matlab I can find good K, Ti, Td for this process,
but what should I do to transfer this values to PID DB block in PLC ?
I tried to connect my model in Matlab (only object via OPC) with PID algorithm in PLC. But this controller does not work good.
Maybe I need to scale K,Ti,Td to use them correctly in PLC.

Does someone knows How to simulate better behavior of Cont_C in Matlab?

Regards


ob.jpg
 
Last edited:
Hello morto,

Siemens FB41 PID block is a little bit more complicated, but basically it can be described with the following transfer function K(1+1/Tis+Tds), just as documentation stated. I know of application where process is simulated in Matlab, downloaded to dSpace board (which produces only voltage signals as an interface to outer world), and loop is closed with SIMATIC S7 PLC. It worked well, and differences in responses very negligible. I don't know how did you confidured that OPC connection, but I assume problem is there in scaling values that are exported from matlab and imported to FB41.
Problem is not strange behavior of FB41, but the way how data is exchanged.

Best regards.
 
Thank you Pandiani!

I am not sure if this conection is done in right way:
I send data from matlab to DB block. Set point goes to SP_INT, LMN is imput of the object and PV_IN is output (input of pid in PLC). I set up also : Man_on and PVPER_on - False
Maybe I should use some scaling function Fc105. What do you Think?


thanks a lot
 
It looks to me like you have a data latency issue. You can't get data between your MatLab simulation and the PLC fast enough using an OPC connection. Can you increase the OPC connection rate (more transfers per second)? Or better yet, can you make an anlaog connection between your MatLab simulation and the PLC?

Keith
 
Analog connection would be right choice, I agree, because you'll have a real time simulation. In order everything to be OK, Matlab should be adjusted to simulate process in real time, you do use Real Time Target don't you?
There's also one more thing, are you sure you're using FB41 properly? It should be placed in OB35 (cyclical interrupt default 100ms) like in my example.
Scaling is necessary if you're using analog inputs and outputs of PLC.

Hope this helps.
 
Yes, analog connection will be the best solution but I haven't any analog board to connect to PLC.
However I use OPC toolbox to conect to PLC. It can't be use with Real Time Target but let running Simulink models in pseudo real time, by slowing the simulation to match the system clock.
I can increase the OPC connection rate but the result is the same.

I must tell You that when I change K, Ti, Td in DB block everything start work fine.
I attach model of Pid block, maybe this is incorrect..

I set up in DB:
Gain=KP
Ti=1/Ki
Td=Kd

pidmatlab.jpg
 
Morto, what are you trying to achieve is very interesting. I'm not sure if I can help you any further except to ask you to consider differences between FB41 and Matlab's PID form. If you wish you can contact me by private message , I'll give you my email address so you can send me your files to try it myself. Maybe I'll be able to find out what is the cause of this.
It will be also valuable learning experience for me too. I'd like to know how you manage to export data from Matlab and write it to datablock in STEP7 and how OPC toolbox really works.
 
I think I see a couple of things you may want to look at.

It looks to me like the MatLab PID controller is the independent form and the Siemens FB41 controller is the dependent form. You may need to mo0dify your Ki and Kd by Kp before converting them to times for use in the Siemens controller.

The MatLab controller appears to be doing the differential on the process variable or is in some other way handling the derivative action when the setpoint takes a step. The initial action on the two graphs is significantly different.

Keith
 

Similar Topics

Hi there, I'm doing some extensive testing and commissioning with a slew of new Emerson PACSystems RX3i PLCs. It would be convenient to...
Replies
5
Views
117
Hello, I have a small application with a S7-1200 CPU 1212 and a KTP400 Basic HMI. When i am connected to the PLC with my PC i would like to...
Replies
1
Views
552
Hello everyone, i would like to test and run os server in pcs7 v8.2 project without rear PLC.i used plcim on ES and nettoplcsim and adjust the...
Replies
4
Views
1,344
Hi all, Im new to Allen Bradley software, so i was given a existing studio 5000 plc program. i already know how to use emulator and rslinx but as...
Replies
2
Views
1,419
I want to run a simulation of a program uploaded from a rockwell PLC, but I can't configure the CPU on the emulate to match the actual CPU.
Replies
10
Views
2,271
Back
Top Bottom