rmshahid
Hi thiagoralves,
I am following Heat Exchanger PID example as given in 
https://openplc.discussion.community/post/how-to-set-up-the-pid-block-on-openplc-editor-9322249?pid=1303400586&random=11913

Can you please provide mathematics for this model. Like plant parameters A,B,C,D matrices. Actually what I intend to do is to analyse the plant under different disturbances and for that i need model parameters. If you can provide me with such information I will be much thankful to you. Thanks in advance!

best regards,
rmshahid
Quote 0 0
thiagoralves
I have no idea.... the mathematics were created by a chemical engineering student. But in any case, if you know the math behind heat exchange, I believe the simulink model might be quite readable.
Quote 0 0
rmshahid
Hi Thiago,
I studied the heat exchanger process mathematics and it was inherently a non-liner system. So I used a simple state space block as my plant and PID block to model my problem. Following is my model. plant.png  Above model works perfectly and PID parameters are as follows:
Kp = -0.00515
Ki = -0.103
Kd = 0

I am using the multiply by 0.01 and 100 blocks to further extend my model with OpenPLC PID block as follows:
opplant.png 
For OpenPLC PID block following is PLC program PID.png  I have set setpoint=100 and pid_kp= -0.00515 and pid_tr= - 0.103 and pid_td =0 but a big hurdle is the uint16 input and output anything below zero is not communicated between PLC and Simulink. (Are my OpenPLC PID parameters in conformance to Simulink PID block). Can I resolve the unint16 problem somehow? Thanking in advance.

regards,
Quote 0 0
thiagoralves
Well that’s the easiest part. Just define an offset from the reading, like 20000 for example. Then after converting IW0 to REAL, subtract your offset and you will have negative values. Do the same thing on the PLC output, before converting back the REAL output to INT on QW0 you add 20000 to the PID output to remove the negative part. Of course you will have to do the same thing on your Simulink model as well, so that the number stays on a valid range. This is how real sensors actually work. Take a 4-20ma sensor measuring temperature  for example. If the sensor measurement range is from -20C to 100C, 4ma (a positive current value) will represent a negative measurement (-20C) according to the range of the sensor.
Quote 1 0
rmshahid
It works, thank you so much! Another question but sorry if it seems off topic. I am using chart on scadaBR GUI for plotting the plant output and a pulse. What I observe is that when pulse is zero that is a constant value the chart does not updates and went blank and when it is 1 it shows a value update for just one point and another when it goes zero again developing a slant line not a pulse(how can I force the chart to display the actual signal like a pulse). Also when there are small fluctuations in output the scale is such that those fluctuations seem far too much (is there any set vertical axis limits option in chart). Thank you so much.
Quote 0 0