How to PID control a Peltier element? - Page 1
Forum section: electronics / projects

author: hyperion007
author_rank: Newbie
timestamp: January 31, 2014, 11:28:21 am
content: I want to be able to PID control a peltier element but I do not know how.The microcontroller part is not the problem, but the other part isI got a couple of cheap ebay TEC1-12715 peltiers to play around with and from what I have read while google:ing the subject is that PWM is a no go, PWM is ok with pulses longer than 10 seconds, use a relay, do NOT use a relay etc etc. You get the pointMy thought was that maybe it would be best to adjust the current flowing through the peltier element? On full whack it could draw say 14 amps to be a bit on the safe side, and when it reaches set target temperature it would throttle off and maintain a steady temperature at a lower current.I have no idea if this is a good idea or not, much less if it's even doable. If it is a good idea, how would one go about it? I'm kind of a n00b with much to learn still.Thank you/Daniel from SWEDEN, not Switzerland

author: dannyf
author_rank: Super Contributor
timestamp: January 31, 2014, 11:48:38 am
content: -I want to be able to PID control a peltier element but I do not know how-very simple: tell us what devices you can pid control, I will tell you how to pid control a peltier.

author: hyperion007
author_rank: Newbie
timestamp: January 31, 2014, 11:54:26 am
content: Ok, being a n00b I might not have understood your question but I think you are asking what other inputs will be used to determine the output to the peltier?I am going to be using a thermocouple I have and the input from it will determine the output of the peltier element. But what to output and to what "device" is the question I am asking here (I think).

author: johansen
author_rank: Super Contributor
timestamp: January 31, 2014, 12:26:07 pm
content: pwm is a no-go but stick an inductor in series and bump the pwm freq to 50 khz and you'll be fine.the pid control itself shouldn't be hard, google searching should deliver you code for almost every micro proc out there. you could also do it via analog circuitry as well.

author: hyperion007
author_rank: Newbie
timestamp: January 31, 2014, 12:32:00 pm
content: Something like this product (15A version):http://www.electrondynamics.co.uk/e/node/68But I want to make it myselfInductor you say, any circuit schematic you can point to as an example? or other reading material?

author: Psi
author_rank: Super Contributor
timestamp: January 31, 2014, 12:44:35 pm
content: i think he means feed it super fast PWM and use an inductor based filter on it so, from the peltiers perspective, it's getting a flat adjustable DC voltage.Peltiers don't like rapidly changing temps, it stresses out the element and can crack it.So to maintain a temp you either drive it by pulsing full-on/full-off with a very long delay eg 10sec, or you drive it with raw DC and vary the voltage as needed.Since you need fine control to do PID the long delay option is off the table and you're left with DC voltage.

author: hyperion007
author_rank: Newbie
timestamp: January 31, 2014, 12:48:59 pm
content: Ok, so I should adjust the voltage basically (through inductor filtered PWM) and not the current?

author: Psi
author_rank: Super Contributor
timestamp: January 31, 2014, 12:51:30 pm
content: Well they're both doing the same thing really, adjusting the power into the peltier.I dont know which is the best approach but its probably whichever gives the most linear control response.Controlling the current seems like more work as you first have to measure it, but i only have a passing knowledge of peltiers.

author: hyperion007
author_rank: Newbie
timestamp: January 31, 2014, 01:05:51 pm
content: Thanks! I'll get cracking with searching for more information on inductors and PWMI'm doing some reading about MOSFETs for another project so I can pick out a couple of MOSFETs for this at the same time (I think)

author: Fraser
author_rank: Super Contributor
timestamp: January 31, 2014, 01:42:37 pm
content: I found a paper on controlling a Peltier element in a thermal camera. I will link to it soonest.

author: Fraser
author_rank: Super Contributor
timestamp: January 31, 2014, 01:46:16 pm
content: Please take a look at this thread that I produced. It is about Microbolometers but these TEC's and the documents detailed provide an insight into how it is done. A standard TIC microbolometer needs a very stable temperature control loop to work well.Chapter 4 of the study paper by Fukaya covers the thermoelectric cooling design and control. The technique shown uses a PWM driving a switching circuit power supply to the TEC. You even get provided with the schematic for the controller that drives the PWM.https://www.eevblog.com/forum/projects/thermal-imaging-camera-microbolometer-design-detail/msg312455/#msg312455

author: electros6
author_rank: Regular Contributor
timestamp: January 31, 2014, 02:12:16 pm
content: Just get the step response of the element you want to control.From that calculate parameters of P , D ,I gain and implement the controller using PWM

author: kaindub
author_rank: Regular Contributor
timestamp: February 06, 2014, 12:04:14 am
content: Do you really need PWM control?Most thermodynamic (ie heating or cooling systems) have time contracts of minutes.As a previous poster suggested, a simple on and off control (similar to your fridge) will probably work well.If you are not using a feedback loop, just use an adjustable linear regulator ie a linear power supplyRobert

author: calexanian
author_rank: Super Contributor
timestamp: February 06, 2014, 04:57:22 am
content: I am not up on the common chips, but I might try looking at high power LED drivers that can generate an adjustable brightness. Might be something there that can be modified and have the current control, switching, and filtering already designed for you. Just a thought. Even though a LED is current controlled, I have a gut feeling the Peltier device will work with one if the voltage can be made high enough.

author: johansen
author_rank: Super Contributor
timestamp: February 06, 2014, 05:50:02 am
content: Quote from: kaindub on February 06, 2014, 12:04:14 amno but it is more efficient to use pwm.heat transfered is proportional to current, minus the thermal conduction across the chip.most TECs cannot reach more than 60C difference.peak "efficiency" is on the order of 30C temp difference.heat wasted in the electrical resistance is proportional to current squared.thus, on-off control at 50% duty cycle consumes 41% more electricity to move the same amount of heat as does 50% current at 100% duty cycle.

author: johansen
author_rank: Super Contributor
timestamp: February 07, 2014, 01:35:33 am
content: Quote from: EmmanuelFaure on February 07, 2014, 12:03:35 amthat's exactly what i said.however, thermodynamic efficiency is Zero at DeltaT= 0.yes, it moves the most heat, but the point is to make something colder.

author: hyperion007
author_rank: Newbie
timestamp: February 07, 2014, 06:57:16 am
content: I got some help while playing around in LTspice and it looks to be doable. I have attached the LTspice file if anyone wants to have a look and check that it's ok.

author: hyperion007
author_rank: Newbie
timestamp: February 07, 2014, 09:46:07 am
content: Hi,I had been looking at those Maxim ICs but since I need 15A and they were spec:ed at 6A max I didn't think that they would work for my application?

author: NadAngel
author_rank: Contributor
timestamp: February 07, 2014, 11:49:12 am
content: Quote from: hyperion007 on January 31, 2014, 12:48:59 pmI'm not an expert on the subject, but this is how I would do it. If you are going to use a PID controller to control the temperature of the peltier element, your feedback signal is going to be the temperature from the temperature sensor. The PWM signal has to to be filtered with an inductor, so by changing the duty cycle of the PWM you will in turn regulate the average current trough the inductor and the peltier element. This will give you a nice linear response, because peltier heat transfer is linearly proportional to the current. You have to be careful not to drive the inductor into saturation by limiting the maximum duty cycle.

author: georges80
author_rank: Frequent Contributor
timestamp: February 07, 2014, 04:27:28 pm
content: PWM is fine if you run it high enough to not stress the TEC.http://www.tellurex.com/technology/peltier-faq.phphas a lot of info.In a previous job I designed a PID controller for either heating or cooling (reverse the power leads to the TEC) that was used to heat/cool a CMOS camera sensor for characterization of its noise levels.It was a simple FET controlled by an Atmel AVR. Input voltage set below the Vmax of the TEC we were using. A small LCD panel to display target temperature and measured temperature. The thermistor (for PID feedback and temp display) was thermally epoxied into a small hole drilled near the end of the copper rod that was the interface between the TEC and the back of the CMOS sensor. The PCB was designed with a hole to allow the copper rod (with thermal paste) to contact the back of the sensor. A test socket with a hole in the base was found. The entire assembly made use of parts of a pentium heatsink assembly (included the tension springs etc).Anyhow, PWM and PID with a thermistor sensor worked just fine to control the temperature. Stability was well within +/- 1C which was fine for our use. The PID algorithm would allow a new temperature to be reached fairly quickly, typically within 20 - 30 seconds for say a 10 to 20C jump, so all was good.Tuning the PID didn't take too many attempts, mainly observing how fast it would reach the target temperature and determining the undershoot/overshoot characteristics to do the fine tuning.Unfortunately the source code stayed with the company.cheers,george.

author: johansen
author_rank: Super Contributor
timestamp: February 08, 2014, 01:41:46 am
content: Quote from: hyperion007 on February 07, 2014, 09:46:07 amfeed the output of the half bridge into a gate driver and drive external mosfets. keep in mind the high switching frequency requires robust design, low inductance connections, etc

author: t0m
author_rank: Regular Contributor
timestamp: February 08, 2014, 02:53:56 pm
content: Thanks Georges80, the Tellurex link was very informative.

author: scientist
author_rank: Frequent Contributor
timestamp: February 08, 2014, 09:25:52 pm
content: Quote from: georges80 on February 07, 2014, 04:27:28 pmDon't FETs get hot when switching really fast?

author: fmaimon
author_rank: Unknown
timestamp: February 09, 2014, 12:03:48 am
content: Quote from: scientist on February 08, 2014, 09:25:52 pmOnly if you don't drive it correctly. In some applications they are switched with frequencies above 1 MHz.

author: georges80
author_rank: Frequent Contributor
timestamp: February 09, 2014, 12:09:26 am
content: Quote from: scientist on February 08, 2014, 09:25:52 pmUmm... really fast isn't very scientific is it?If you read the link you would see the recommendation for TEC PWM was in the low KHz range. It also depends on what FET, what drive circuit etc etc.I have FET's running at 1MHz in high power LED drivers and they certainly don't run "hot". Of course they are driven with appropriate driver stages to deal with their gate charge and capacitance.cheers,george.

author: jeremy
author_rank: Super Contributor
timestamp: February 09, 2014, 01:11:43 am
content: As an aside, do you really need PID (specifically the integral feedback)? The heating and cooling with respect to the atmosphere should handle the integral part, as usually one does not care for undershooting to correct for overshoot in thermal applications (I'm thinking temperature stabilizing lasers here)

author: georges80
author_rank: Frequent Contributor
timestamp: February 09, 2014, 01:45:10 am
content: PID allows rapid response to a change in target temperature with minimal overshoot and this fast settling.Obviously if it is just a fixed temperature requirement that the OP is after, then other feedback schemes will work fine given time to stabilise.Though implementing the PID is such a small deal - my 'memory' says that the whole PID routine I coded up was just a handful of lines of C code (not much more than maybe 10 - 15 lines), so not like it's a big task either way...cheers,george.

author: jeremy
author_rank: Super Contributor
timestamp: February 09, 2014, 01:59:10 am
content: Quote from: georges80 on February 09, 2014, 01:45:10 amIt is definitely easy to implement, but in my experience you are much more likely to have an oscillating or unstable response with three feedback parameters rather than two. Also doing loop tuning on two gains is easier than three.Keep it simple!

author: IanB
author_rank: Super Contributor
timestamp: February 09, 2014, 02:04:35 am
content: Quote from: jeremy on February 09, 2014, 01:59:10 amNot with correct tuning. It is hard to tune the derivative action, but if you get it right in conjunction with the integral action then you can have a faster response with less overshoot and less oscillation.It is true that derivative action is often not needed, but in systems where the process has a slow response and inherent capacitance then derivative action can help.

author: georges80
author_rank: Frequent Contributor
timestamp: February 09, 2014, 02:40:39 am
content: IanB, exactly.My goal was to be able to change a target temperature and have the TEC get there quickly without oscillation. Getting things to the point I could make a 10 - 20C change and have the temp probe near the sensor end stable in just 30 sec or less was great.The tuning was really easy - maybe I was lucky or had a gut feel for what I was doing, but it really only took maybe 30 mins at most from running code, to good response time.Obviously the whole PID tuning process is very dependent on the response time of the system. With a TEC and thermal path to the sensor it is a pretty slow responding system - but of course easy to overshoot due to the lag. The PID really is nice since with tuning it can 'predict' the lag and provide a critically damped solution quite easily.Anyhow, ymmvcheers,george.

author: jeremy
author_rank: Super Contributor
timestamp: February 09, 2014, 02:45:07 am
content: Although tuning the integral is easier than tuning the derivative, tuning both the integral and derivative together is more difficult simply because there is a smaller solution space of stable solutions.fromhttp://www.facstaff.bucknell.edu/mastascu/econtrolhtml/pid/pid2.htmlQuotefromhttp://newton.ex.ac.uk/teaching/cdhw/Feedback/ControlTypes.htmlQuote

author: IanB
author_rank: Super Contributor
timestamp: February 09, 2014, 04:35:00 am
content: Quote from: jeremy on February 09, 2014, 02:45:07 amAlthough more difficult, the benefits can be worth it.From one of the same sites linked above:http://www.facstaff.bucknell.edu/mastascu/econtrolhtml/pid/PID3.htmlQuote

author: jeremy
author_rank: Super Contributor
timestamp: February 09, 2014, 05:00:29 am
content: Quote from: IanB on February 09, 2014, 04:35:00 amTrue, PID is of course better in terms of final SSE for some systems (otherwise it wouldn't exist!). But my argument is that because a peltier element has the characteristics of a thermal capacitor, the integral part of the system is not usually required as the integral term only corrects for past errors. Most temperature stability systems I have heard of do not care about past error in temperature, rather they only care about the temperature *right now*. In fact, if you take into account past overshoots/undershoots with an integral term when you actually only care about the instantaneous result, your response from PID will be worse than just a PD controller. Instead of stopping at the set point after an overshoot, an integral term will swing past the set point to correct for any previous error (which is bad!). On top of this, leaving out the integral term means a larger solution space of possible proportional and derivative gains.This sort of behaviour would be useful if the problem open loop; for example, filling a tank with water, or injecting a specific amount of heat (in joules) into a specimen via a peltier as the integral term would ensure that all errors throughout the process were corrected for. But for realtime temperature stability, PD is best.Another way to think of this is to imagine having a pot of water on the stove, and someone asks you to turn the heating knob up and down to keep the water as close to 50 degrees celcius as possible. At any point in time, it doesn't matter what temperature it was in the past, it only matters what temperature it is right now (proportional) and how fast it is heating/cooling (derivative). If you added the integral term, that would mean that if the temperature accidentally went too high (say 55 degrees), you would have to turn the knob down to stay at 45 degrees for a while to counteract the integral error. Whereas the correct behaviour should be to try to move to 50 degrees and not take into account past errors.There are also other problems that pop up when you put in an integral term, like integral windup. Such a problem would be disastrous for a temperature stability controller.