PID temperature control in matlab ???? - Page 1
Forum section: electronics / beginners

author: seyedsaeed
author_rank: Regular Contributor
timestamp: March 15, 2020, 08:02:50 pm
content: HiI want to control the temperature of the liquid tankBut I don't know how to do it at SimulinkSystem includedelectrical heater 2000watttriacliquid (water or paraffin or ...)20 literenvironment temperature 25Ctriac driver with zero crossingPWM 50hzAccuracy of temperature measurement 0.0625Ccycle of feedback 2secondePlease help me

author: rstofer
author_rank: Super Contributor
timestamp: March 15, 2020, 10:15:21 pm
content: There are a couple of educational tools atwww.apmonitor.com. One for Python, one for MATLABOr, you can Google for ‘MATLAB PID temperature control’. You can interact with an Arduino from MATLAB as apmonitor does. Or you can just search for Arduino pid temperature control.

author: seyedsaeed
author_rank: Regular Contributor
timestamp: March 17, 2020, 10:14:01 am
content: Thank youBut I searched before in Google

author: rstofer
author_rank: Super Contributor
timestamp: March 17, 2020, 03:12:23 pm
content: There are over 100,000 hits on Google for 'simulink pid temperature control arduino' includinghttp://ctms.engin.umich.edu/CTMS/index.php?aux=Activities_LightbulbSimulink, by itself, can't do anything other than simulate the system. If you want to actually control something, you will need a controller of some kind and the Arduino is as good as any other.The article linked above starts out with bang-bang control of a lightbulb (heater) and progresses to PID over a few different configurations.All of the logic is given, converting it to fit your system shouldn't be too difficult. There is going to be a temperature gradient in the tank so you are going to have to be careful where you place the sensor. Maybe you use multiple sensors and some clever algorithm to account for the gradient. Maybe there is some kind of stirring going on.QuoteI hope that is the accuracy of the sensor, not the accuracy of the temperature of the liquid because I don't think such accurate control is actually possible given the dynamics of any reasonable vessel.The real magic is in controlling an Arduino from MATLABhttps://www.mathworks.com/discovery/arduino-programming-matlab-simulink.htmlYou can also experiment with autotuning:https://www.mathworks.com/help/slcontrol/ug/pid-autotuning-for-a-plant-modeled-in-simulink.html

author: rodpp
author_rank: Frequent Contributor
timestamp: March 18, 2020, 02:08:56 pm
content: Search for Hardware in the Loop (HIL) simulation.Here a link that explains how it works:https://www.mathworks.com/discovery/hardware-in-the-loop-hil.htmlBasically you need a Data acquisition board in your PC with analog inputs and outputs.I use a National Instruments DAQ board along with Matlab/Simulink. It's a great tool to test different controllers (PID or any other) without changing the hardware.

author: ivaylo
author_rank: Frequent Contributor
timestamp: March 19, 2020, 05:05:08 am
content: Quote from: rodpp on March 18, 2020, 02:08:56 pmWhich DAQ board do you have, if you don’t mind sharing?

author: seyedsaeed
author_rank: Regular Contributor
timestamp: March 19, 2020, 07:16:29 pm
content: I had seen this link but wasn't sure how to convert my systemThe important problem is thisWhen the heater is switched off, the liquid temperature will continue to rise to 2 ° CAnd the cooling down of the liquid takes a long timeWhat is your suggestion?

author: max_torque
author_rank: Super Contributor
timestamp: March 19, 2020, 07:33:05 pm
content: Use the derivative (The D part in PID) to pre-decrease the output before the setpoint is reached! Read up about how the P, I, and D in a PID controller act and work! Then tune your controller to suit your plant

author: rstofer
author_rank: Super Contributor
timestamp: March 19, 2020, 09:43:31 pm
content: Google 'pid temperature control large thermal mass'You will find a lot of articles on tuning a PID control. In some cases, they discuss autotune which may, or may not, work in your application. I think the problem comes up if the thermal lag is too long.You can model the thermal mass in MATLAB/Simulink/Simscapehttps://www.mathworks.com/help/physmod/simscape/ref/thermalmass.htmlThe step response given in the article I linked earlier pretty much defines the system but it is expecting to work on the real system. I suppose it would be possible to use the Thermal Mass object in simulation.APmonitor.com has a neat little heater project board along with an entire curriculum based on using it with either Python or MATLAB.http://apmonitor.com/pdc/index.php/Main/ArduinoTemperatureControlThere are a TON of tutorials on PID controls and tuning on Google.

author: rodpp
author_rank: Frequent Contributor
timestamp: March 20, 2020, 04:31:39 am
content: Quote from: ivaylo on March 19, 2020, 05:05:08 amIt's the NI PCI-6281.Quote from: seyedsaeed on March 19, 2020, 07:16:29 pmThe desired and recommended approach is to model your system first, using the physics of the system if it is not complex, or using system identification technics. With the system model, you can design a controller to archieve the performance parameters of your project using the control systems theory (classical approach using Laplace transforms, root locus, etc; or modern control technics using state space in the time domain).If you want a fast and simple solution and your project performance parameters are not very much demanding, implement a PID controller and try a heuristic method of tuning it, like Ziegler-Nichols method.Using Matlab/Simulink with a DAQ board, you can implement the controller in software. The DAQ board will read the sensors, proccess that signal, and will output a analog signal to your actuator.

author: seyedsaeed
author_rank: Regular Contributor
timestamp: March 20, 2020, 08:46:51 pm
content: How do I find a system model of my plan?

author: rodpp
author_rank: Frequent Contributor
timestamp: March 20, 2020, 09:48:27 pm
content: I'm afraid that you'll not "find" one.Here's an introduction:https://x-engineer.org/graduate-engineering/modeling-simulation/systems-modeling/basic-principles-of-system-modeling/

author: wizard69
author_rank: Super Contributor
timestamp: March 24, 2020, 01:49:36 am
content: Quote from: seyedsaeed on March 20, 2020, 08:46:51 pmWell you could just hit the self tune button on a good process controller. That may or may not work depending on many factors. If not you have to engage in manual tuning of the PID loop. One of the earlier ways to do this is Ziegler-Nichols. Some of the first few search results:http://www.mstarlabs.com/control/znrule.html;https://en.wikipedia.org/wiki/Ziegler%E2%80%93Nichols_method;http://faculty.mercer.edu/jenkins_he/documents/TuningforPIDControllers.pdfand the list goes on and on. Mind you this is Ziegler-Nichols there are many other ways to tune a loop.However let not get carried away and start to heat up this tank!!!! You need to cover the safety issues and that may require a bit of mechanical engineering along with electrical engineering. The most important thing here is to make sue that failure of your controller does not cause harm at the vessel.

author: seyedsaeed
author_rank: Regular Contributor
timestamp: March 24, 2020, 07:05:29 pm
content: HiDo you think this electrical model is suitable for the heating system?