PID temperature controller DIY Arduino

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's up my friends welcome back well I want to build my own following station and for that I will use this pony for what soldering iron with a thermocouple inside it will also have an LCD and some sort of control in order to be able to set your temperature value and also an Arduino inside that will create the PID algorithm but before we do that we first have to understand how temperature PID controller works so today we'll build our own PID controller for temperature here I have a commercial PID controller but this one is based on a relay so is that that precise because it will only turn on and off on a certain range and that will result in an oscillating value but I want to build today it's a fully PID controller for a very precise rate control so today we will see how to read the temperature value using a k-type thermocouple and then we will generate the PD algorithm inside of the arduino and apply a pitiable signal to a MOSFET in order to control the power plight or heating element for today's project I would use the nozzle from a 3d printer since it already has the heating element inside so it would be a great example in order to learn how PID controller works for temperature so guys let's get started [Music] this project is brought to you by jl CPCB which is a manufacturer of quick PCB prototypes for more than 10 years and is the site that i use for all of my PCBs once design applied your Gerber files on the GLC PCB site get a full review of the PCB select your desired settings and order the PCB for amazing prices i've ordered ten of my prototype PCBs for only $2 and receive those in six days crazy right so order your quality PCB and make your projects look a lot more professional what's up my friends welcome back what I want is this block to have let's say exactly 100 degrees I will control the real temperature using this thermocouple to read the data I will use the max 60 675 module and control the PID algorithm with an Arduino finally to apply power we will make a small circuit using a MOSFET or maybe a triac in case of high AC voltages this will be a closed loop the thermocouple measures the real values the Arduino creates the signal applied to the MOSFET and this transistor will control the power of the heating element inside of the aluminum block and once again the thermocouple will measure the real value that's why it is a closed loop so the first thing is to understand how PD temperature control will work as in any PD system we need to define the final process in our case will be the final temperature that we want to achieve in order to control this temperature we will need a feedback so any PID control will have some sort of feedback in our case that feedback is made using a k-type thermocouple that will measure the real temperature of the system this type of control we'll also need a set point which in our case is the desired temperature the system will make the difference between the desired value and the feed from the output and using three constants the proportional the integral and derivative we can change the output according to the feedback so if we want the heated block to have exactly 100 degrees what we will do first it supply power to it this will start heating up by the time it reaches the setpoint value which in this case is 100 degrees the feedback will inform that to the PID control and this will start lowering the power applied to the heating element and in our example that will be made using a PWM signal applied to a MOSFET that will control the voltage that goes to the heating element inside of this aluminum block so it is obvious if the real temperature is higher than the setpoint will lower the power value but if the real temperature is lower than the setpoint well we increase the power till it reaches the desired value if we do just that this is called a peak control or proportional control and it will end up in a temperature oscillation between certain values and it will very difficult or never be stable for that we add a D control or derivative this kind of control will react to the speed of temperature change so for example if I blow air on the aluminum block the derivative will fast push the power to maximum in order to keep the same temperature finally we have the I or integral this will sum the error on each loop getting bigger and bigger with each loop or in case of negative error getting lower and lower the sum of all these parts the P the I and the D makes a PID control it is our job to find the correct constants for each of these PID elements so guys let's start building this project the first thing that we will do is to see how to read the real temperature this is a k-type thermocouple and this is the max 66 75 breakout module this will amplify and compensate the voltage created by the thermocouple it has an SP communication so we will have to connect these pins to the Arduino SPI port now use these connections and let's test it out on the breadboard I connect the Mac 66 75 and the thermocouple be careful the thermocouple has polarity so connect the positive to positive and negative to negative now connect the SP pins to the Arduino and also supply 5 volts and ground now upload this next code to the Arduino Uno you can find the code below in the description and it is called thermocouple read example code this code will just read the SPI data from the module and that gives us the real temperature we print the value on this LCD screen I hid the thermocouple with a lighter and there you go I have the real value on the LCD by the way this LCD screen has I squared C communication so you don't need a lot of wires just the data pin and the clock okay so now that we know how to read the real temperature let's mount this next Kemetic and control the power applied to the heating element with a MOSFET I mount the circuit on a breadboard once again and now I upload the next code the second code has the PID algorithm already created we read the temperature we calculate the error sum the PID values and create the PWM signal on digital pin d3 that will be applied to the MOSFET please read all the comments in this code in order to understand it better now I set the desired temperature at 100 degrees and use the LCD screen to print the set value and the real temperature the temperature starts rising and as you can see once reached the temperature stays at that value but this is after trying a lot of PID constants and that is the tricky part of this project so what you will have to do is to try your own values till you get the correct ones I advise you to start with the I and the D values equal to zero and then increase those values slowly till you get good results now here on my oscilloscope I have the PWM signal of the MOSFET connected at the beginning till the system reaches the desired value the post has a small width since I use a BJT transistor to activate the n-channel gate so the MOSFET in this case will be activated with low values once the set value is reached it starts to womble around and by that maintaining the temperature as you can see if I try to cool down the heating element by blowing air with this tube the pwm signal gets lower in order to keep the same value so the control works now all the system needs is some sort of control together with the LCD screen in order to view and also be able to set the desired temperature value as this commercial PID controller has the set up and down buttons for that I will use this rotary encoder it has a push-button integrated so I can use it to enter the setpoint menu and increase or decrease the value this is the final schematic of this project we have an LCD screen to print the values the rotary encoder with push-button inside for control the thermocouple with the Max 60 675 module the MOSFET and the BJT as a driver circuit that will control the power and the heating element make sure that the thermocouple is touching the heating element in order to know the real value I mount everything on the breadboard and now let's test the new code which by the way you could also download from a link below and it is called PD temperature control code the default value is now zero degrees press the set button of the rotary encoder rotate the encoder in order to increase or decrease the temperature value now press the set button once again and now you can set the P constant for the PID control press it once again and select the I value finally press the button again and select the D value now press the button and exit the menu and the new settings are stored I set it once again to 100 degrees and now as you can see the real temperature starts increasing till it reaches the desired value and then it stays there when we reach the desired value you can see the P mm signal wombling in order to maintain the same value so there you go the PT of temperature works I could 3d print a case for this project just as the commercial one has but since I will use this project for my soldering station in a future tutorial I won't do that now in that future project I will use this Tony for what soldering iron with a thermocouple inside and make my own solder extension so stay tuned for that guys have in mind that today's project is only for DC power control so only DC heating elements will work in the future I will also make a tutorial on temperature PID control but for AC 220 volts voltage using a track control as in my past trying to toriel this here are 220 volts heaters and I will use this to build my own filament extruder and recycle all of my bed 3d printed parts but that is for another future video if my videos helped you and you would like to help my projects I have a patreon campaign the link is down below as always I will really appreciate that guys and it will help my workshop for new projects and keep this channel going by the way thanks to all my patrons I hope that you enjoyed this small tutorial on PID control if so don't forget to click the like button like crazy and share this video with your friends if you have any question about this video or any other just leave it in the comment section below or on my Q&A page also don't forget to subscribe and watch all of my other great to Tory Alandra member if you consider helping my projects check my patreon page as well thanks again and see you later guys [Music]
Info
Channel: Electronoobs
Views: 269,116
Rating: undefined out of 5
Keywords: PID, Arduino, thermocouple, max6675, temperature, controller, rotary, encoder, tutorial, homemade, diy, soldering, station, thermistor, DC, MOSFET
Id: LXhTFBGgskI
Channel Id: undefined
Length: 12min 30sec (750 seconds)
Published: Sun Apr 08 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.