Showing posts with label thermoelectric. Show all posts
Showing posts with label thermoelectric. Show all posts

Friday, May 15, 2009

Thermoelectric Temperature Controller - Part 4

As promised, here is the program code for use with the PICAXE and it's programming editor: Program Code

The verbal description of this program is this:
  1. Configure the display
  2. Read the temperature from the LM34
  3. Display the temperature on the LED display
  4. If the temperature set point is below the current temp, then perform a PWM command and turn on the Peltier device. The amount of drive is proportional to the error between the set point and current temp.
  5. If the temperature set point is above the current temp, then turn the PWM off.
  6. If at any point, the temperature set point button is pressed, flash the set point LED and enter the set temp mode. Read the temperature set point from the potentiometer. Press and release the button quickly to exit the set temp mode.
  7. Keep looping.
Some points within the program that may not be so obvious. First, when we read the temperature from the LM34, the picaxe reads the analog voltage and converts it to a digital value with ten bits of resolution. This means that the value has 2^10 or 1024 divisions. The digital value can then be calculated back into a voltage in mV within our program. The ADC is converting based on a 5V range, or 5000 mV. This means that a digital value of 0 is equal to 0 mV and a digital value of 1024 is equal to 5000 mV. Taking this further, each digital division is equivalent to 5000/1024, or 4.88 mV. By the way, 4.88 mV is the same as 0.488 deg F, so the resolution of our program is ~0.5 deg F. You can see from the program that when we mulitply the digital value by 4.88, we will in essence be calculating the temperature in deg F mulitplied by ten. Since the temperature is read in tens of millivolts, the actual whole number value of the temperature can be read once we divide TE_Temp_10 by 10.

I will update this discussion of my code at a later time, hopefully the code will speak for itself. Enjoy!

Tuesday, May 12, 2009

Thermoelectric Temperature Controller - Part 3


Since my last post I've have worked on developing a prototype small scale version of a wort fermentation cooler. This was mainly to prevent mistakes from becoming too costly and work out any kinks on the model before scaling up. In the small-scale model, I will simulate a fermentation vessel as a soda can - basically this will become a desktop soda cooler. If you are innovative and modify the circuit to allow for a change in the polarity (or just switch the leads) across the Peltier device, you could also have this work as a coffee warmer as well. This is one of the great things about these devices, the ability to use them for both cooling and heating.

This post will mainly focus on the control system and interface that I have developed for controlling the temperature of the vessel of interest. When controlling the temperature, the only way to go is by setting a temperature set-point and using loop feedback control. The algorithm for controlling the device to reach this temperature can be quite a bit more involved, ranging from proportional control up to proportional-integrative-differential (PID) and even on to fuzzy logic. Initially, for my system I have elected to go for proportional control since it is one of the simplest forms of control and it allows for the opportunity to just add on to it if it seems inadequate.

For the size of peltier device that I am using (CP40336, Digikey part no.
102-1671-ND
), I designed a circuit that could handle its max current of 3.9 amps. This circuit that can not, however, handle currents that would be required by my large fermentation cooling system, which may be in the 20+ peak amps range. The current to the peltier device is controlled by the IRF510 MOSFET (shown in circle A below) and has a max continous drain current of 4 amps, with a pulse drain of 20 amps. Note that these types of devices will need a heat sink as they get very hot. I chose this device because it is voltage controlled, which means it uses much less current than current controlled transistors, such as BJTs and it can be much simpler to control since we can control voltage straight out of the microcontroller. In addition, this device is also logic level controlled, meaning that I can control it with voltages that are in the range of my 12 V power supply. I will be using a AC-DC power supply that can provide a few amps like this one: VM 80W12.

The amplifier circuit shown in circle B allows the 0-5 V PWM voltage signal from the microcontroller to be pumped up to voltages almost as high as those supplied to the op-amp, in this case, close to 12V. There is some loss across the device and in my case was around 1.5 volts, meaning that the op-amp can put out about 10.5 V. This particular circuit is called a voltage follower. The circuit tries to match the voltage on pin 2 and pin 3. Since pin 2 is connected to a voltage divider circuit (the voltage on pin 2 is halfway between ground and the output of the device) it always sees a value that is half the output. This leads to the output being double the voltage of the input. This may sound confusing if you are a beginner to this so here is an example: If you supply a voltage of 3 V to pin 3, the device wants to match make pin 2 match this value. It does this by increasing the output voltage until these match or the device is maxed out. In our example, the output will reach 6 volts at which point pin 2 will be at 3 volts - now pin 2 and pin 3 match. The equation for this relation is shown below for reference. The ratio of the resistors can be modified to give you a range of ratios. If you want to look into this further, look for "non-inverting DC gain" amplifier circuits.


Since we are driving the op-amp with pulse width modulation from the microcontroller, the signal needs to be smoothed out a bit to give a near analogue signal. This is the function of the 0.68 uF capacitor - that's what capacitors are really good for, smoothing out voltages since they act much like a damper in a suspension system.

To control this circuit, I decided to go with a PICAXE 28-pin microcontroller (shown at left) since this is a cheap and pretty easy to use beginner microcontroller. It had the features that I desired in controlling this circuit, mainly an analog-to-digital converter and pulse-width modulation control. This size of PIC may be overkill, but I plan on using it for various other projects as well. It also has plenty of output and input pins should I want to add more sensors, LEDs or other devices I want to control such as fans.

The feedback to the controller is supplied by means of an analog temperature sensor, a LM34. This device is supplied 5V and delivers a voltage signal that is proportional to the temperature. In the case of teh LM34, it delivers 10 mV for every degree Fahrenheit, i.e. 70 deg F will give you 0.7 V, -20 deg F will give you -0.2 V. This device has an accuracy of 1 deg F and that should be good enough for our application. There are a lot of temperature sensing devices out there, from thermocouples to RTDs to digital output sensors. All have advantages in certain applications such as speed, accuracy and size. I like this one because it is simple to use and has good enough resolution. The LM34 is hooked up to my analog to digital converter pin on my microntroller. The microncontroller can then take this signal and use it in it's calculations to figure out if it's too hot or cold.

The LM3805 power regulation circuit in circle C supplies the required 5V to the micro controller and it's various LEDs and sensors. Notice that I tap into the regulated 12V supply before the 5V regulator for power to the op-amp and peltier device. I wouldn't recommend any large currents running through your control circuits - this may blow out your microcontroller.

To set the temperature, I'm using a button and potentimeter. I press the button to enter the set-temperature mode. I know I'm entering and have entered this mode by the flashing LED that then stays on solid. The potentiometer is attached to another analog to digital converter pin on the microcontroller. It uses the value of the voltage across the wiper of the potentiometer to calculate what temperature you want to set the contoller at through some calculations in the software. In the software, I can set the range and steps that this voltage relates too in terms of temperature. Once the temp is set, I press the button again, and the set-temp LED flashes to let you know that you are exiting the set-temp mode.

The current temperature and the setpoint temperature are displayed on a dual LED 7 segment display. Since I don't intend on going above 100 deg F or below -10 deg F, two digits seems to be enough. I created this as a separate circuit so that I could use in various projects as shown below. I used a MC14489B (the schematic shows the incorrect part number) display controller and it can be used to control up to 5 digits (banks). This takes the burden off the microncontroller to constantly display the values - the picaxe justs send over values to the MC14489B when it wants the display to change.


I have other diagnotic LEDs on the board to tell me the whent he 5V power to the board is on (Power_OnLED) and to tell me the power level of the peltier device (TEC_OnLED) - brightness corresponding the the amount of voltage that the op-amp puts out. Two additional off board LEDs were included to show when the user enters the set-temp mode (SET_LED) and when peltier device is active (TEC_ON_LED). This TEC on LED allows the user to know that the system is cooling.

The above circuit diagrams were created using a great and free program called Eagle from CadSoft. In addition to creating the circuit schematics, I was also able to create a printed circuit board once I had finished troubleshooting the circuit on a bread board. Sparkfun has an amazing tutorial going through, in detail, on how to create these PCBs and also offering some references on where to get them made cheaply, though not quickly, as well.

Above are images of the PCBs that I designed. They were in the $30 range for both and arrived in 2-3 weeks from BatchPCB, the quality was top notch!

I went from a bread board prototype that looked like this...


...to two squeeky clean boards that looked like this once the board was stuffed.


I've had a chance to hook these boards up and everything seems to be functioning well - good planning and breadboard testing are definitely required once you decide to have your own PCB boards made and will help to avoid many frustrating situations. You may notice that the shcematic and PCBs are not exactly alike, this is because I had placed the TEC plug in the wrong place in the circuit - the circuit diagram and PCB drawing have the corrected position, however, the PCB photo is incorrect. It functions, but is not ideal.

The one remaining piece of info needed to get this circuit up and running is the code. I will post the program I used to run the circuit in my next posting since it could be a bit hefty in addition to this post.


Thursday, March 12, 2009

Thermoelectric Temperature Controller - Part 1

Project Overview

Thermoelectric coolers (TECs - as shown at left courtesy of Marlow Industries) and generators (TEGs) have been around more than 200 years, but they've been getting more press lately in the automotive industry, specifically BMW. They have been using TEGs for producing electricity from the temperature gradient from the exhaust pipe to the ambient air. In the reverse, by passing current through the two materials, typically n- and p-type semiconductors, you can pull heat from one side and reject it on the other, and use them in a cooling capacity.

I wanted to use this amazing effect for another hobby of mine, brewing beer. The main idea is to control the temperature of 5-6 gallons of fermenting wort without using a typical refrigerator system. This was as much for the challenge as it was for learning about these "cool" little devices. Overall for a system of this size or larger, a typical compression refrigeration system may be more efficient - but that wasn't the point of the project.

In this and subsequent blogs, I would like to trace my development of this system from start to finish. I will describe the system requirements, heat transfer analysis and resulting prototype circuit design and fabrication.


Stage 1 - A Little Background

During the brewing process, the stage of converting the sweetened wort, with the help of yeast, to alcohol is called fermentation. Fermentation typically does not require real close temperature control; for many styles of beers fermentation at room temperature is good enough. Where you get into trouble, however, is the fermenting lager style beers. This style of beer requires temperatures cooler than room temperature, roughly 50 deg F, and a refrigeration system to maintain this temperature for several weeks.

The refrigeration system consists of three main items - 1) the item to be cooled, wort, 2) the box/cabinet to contain and circulate the cooled air and 3) the device to do the cooling work. Items 1 and 2 are passively acting to counterbalance the work done by the cooling device (in this case a thermoelectric cooler). The energy balance needs to be calculated first of to size the cooling device.

Of course, all of my calculations can be sized for your application and could be used to cool or heat a number of various mediums.

Stage 2 - Heat Transfer Analysis

The refrigeration system has to be able to overcome three major sources of heat in it's worst case condition - when the warm fermentation vessel is placed in the refrigerator. The overall energy balance is as follows:

where Q_boxloss [W] is the heat lost through the insulation of the refrigerator box to the ambient atmosphere, Q_ferm is the heat generated by the yeast converting sugars to alcohol, Q_cool is the amount of energy required to bring the temperature down from the yeast-pitching temperature to our ideal fermentation temperature over a given time and finally, Q_pumped is the heat pumped out of the system by the thermoelectric device.

What you are most interested in is this worst case scenario. The cooling device needs to be able to provide enough heat pumping to deal with this worst case or you will never get the temperature of the your wort down to your ideal temperature.
As the wort cools down to the final fermentation temperature, you only have the insulation losses and fermentation heat to contend with, which will be less than the worst case.

Let's go through how to calculate these values:

where A [m^2] is the total area of the outside of the refrigerator box , T_b [deg C] is the ideal inside temperature of the box , T_a [deg C] is the ambient room temperature (again don't forget to make this the worst case scenario, i.e. 85 deg F on a hot day), K [W/m-C] is the thermal conductivity of the insulation and x [m] is the insulation thickness. If you want to get real precise, you could also add in the wood/plastic/metal outershell and it's conductivity, but for simplicity here, I only am looking at the insulation for a rough estimate.

We must cool the wort down from it's initial temperature to a it's final temperature and this will take energy as shown here:

where m_w [kg] is the mass of the wort (density x volume), T_i [deg C] is the initial temperature of the wort, T_f [deg C] is the final idel fermentation temperature of the wort, c_p [J/kg-C] is the specific heat of the wort (i used a value slightly less than water here since it is comprised partially of sugars) and t [sec] is the amount of time that you would like to have the wort go from the initial to final temperature. If the volume you are cooling is large, say 5-6 gallons, 24 hours might no be unreasonable. For smaller volumes, say 12 fluid oz, 15 minutes might be reasonable; the time to cool will be dictated by your requirements.

For the beer experts, this next section might be useful, but if you are not cooling fermenting wort or your medium is not generating heat, you can skip this equation. I wanted to make sure that the fermentation process itself was accounted for. It turns out that the heat generated by yeast can be quite negligible compared to the insulation losses (unless you have an amazingly thermally tight refrigerator). I will add it here, however, for completeness. I would also like to give my due respects to Spencer Thomas for these following equations.

The yeast will convert a portion of the sugars present in beer to alcohol and during this conversion will generate heat. If we assume that sugars being fermented release 140 kcal/kg or 586 J/kg (1 kcal = 4.184 J), we then must then figure out how much sugar is fermented and mulitply it by 586 J/kg and divide by the time they take to do this. The fermentation energy is then:

where t is the time of fermentation is seconds, which in our case would be maybe 1 week. The initial mass of the sugar, m_si [kg], can be calculated from the original gravity of the wort (OG) as follows:

where m_w [kg] is the mass of the wort and,

where OG is in points, i.e. 1.050 = 50 OG in points.

The final mass of the sugar, m_sf [kg] is a little more involved.



where FG is the final gravity of the beer in points. RE and AE deal with the attenuation of the beer, which is when the beer is no longer just water and sugar but is also alcohol as well. This composite has a different density and must be accounted for in the mass calculations when you are looking at the final gravity.

There you have it, all the heat transfer components to the left hand side of the energy balance equation. In my next blog, I will identify how to find Q_pumped and how to best to implement it. This will include specifying a thermoelectric cooler module and the heat sinks required to reach it's optimum performance.