Introduction: Closing the Loop on Surface Mount Soldering
Temperature seems like the easiest thing in the world to control. Turn on the stove and set the temperature you want. Switch on the furnace in the morning and set the thermostat. Adjust the hot and cold water to make the shower just right. Easy! But what if you want to control temperature beyond these everyday applications? If you want temperatures outside the normal ranges, or want stable temperature within a narrow range, you’re mostly on your own.
In my case, I wanted to control the temperature of a hot plate used for surface mount soldering. Initially, I used pulse width modulation to provide stable temperatures and experimentally determined settings to create the temperature profile required. You can read all about that in this Instructable. This system works and control of temperature in this manner is all well and good, but it has shortcomings.
Works only for my specific hot plate. Others are similar, but not identical and experiments are required to determine the settings and times needed to produce the requited profile.
Same situation if I want a different profile or temperature.
The soldering process takes a long time since stable temperatures must be approached slowly.
Ideally, we could just specify a temperature- time profile, press a button, and the controller would cause the hot plate to perform as programmed. We know this is possible since there are many industrial processes that use exactly this sort of control. The question is can this be done easily and inexpensively at home?
As you might have guessed, since I’m writing this Instructable, the answer is yes! This Instructable will show you how to build your own industrial-strength temperature controller. I’ll particularly target surface mount soldering, but any process requiring precise time temperature profile can use this system.
Note: When I use the name “Arduino” I mean not just the (not quite) copyrighted Arduino itself, but also the many public domain versions collectively known as “Freeduino”. In some cases I use the term “Ard/Free-duino”, but the terms should be considered interchangable for the purposes of this Instructable.
The temperature control scheme used in the Extreme Surface Mount Soldering Instructable is known as open-loop control. That is, a value that has produced the desired temperature in the past is expected to produce the same temperature when used again. Frequently this is true and produces the desired result. But if conditions are slightly different, say the garage where we’re working is a lot cooler or warmer, then you may not get the expected result.
If we have a sensor that can read the temperature and report it back to a controller, then we have closed-loop control. The controller is able to set an initial value to increase the temperature, look at the temperature as time passes, and adjust the setting to make the temperature go higher or lower until the desired temperature is reached.
Our approach will be to replace the AVRTiny2313-based PWM controller with a more powerful ATMega-based controller. Programming will be done in the Arduino environment. We’ll use a pc (Linux-Mac-Windows) running Processing to display the results and adjust the controller.
For the sensor, we’ll use an Infrared Temperature Sensor from Harbor Freight. The IR sensor will be modified to output the temperature as a serial data stream that the controller can read. We'll use an Ard/Free-duino as the controller, with a PC (Mac – Linux – Windows) for input to the controller. When we’re all done, the system will look like the picture. (You may have less extraneous circuitry on your breadboard however. That's OK.)
Step 1: Modifying the IR Sensor
Many thanks to my clever friend, Scott Dixon, for his careful detective work in figuring out how this instrument works and how to make it generally useful with a controller by exposing its serial interface.
The device we'll start with is Harbor Freight Part Number: 93984-5VGA. Costs about $25. Don't bother buying the warranty. :)} Here's the link.
Figures 1 and 2 show Front and Back Views. The arrows on Figure 2 indicate where the screws are that hold the case together.
Figure 3 shows the inside of the case when the screws are removed and the case is opened. The laser pointer module can probably be removed and used for other projects, although I haven't done this yet. The arrows point to the screws to remove if you want to take the board out to solder to it (screws removed in this picture). Also indicated is the area where a cut out should be made for your wiring to exit the case. See also Figure 5. Make the cut out while the board is removed, or at least before you solder the wires on. It's easier that way. ;)}
Figure 4 shows where the wires will be soldered. Note the letter of each connection so you'll know which wire's which when you close the case.
Figure 5 shows the wires soldered in place and routed through the cut out. You can now put the case back together and the instrument should operate as it did before your operation. Note the connector on the wires. I use longer wires to actually connect to my controller. If you use small wire, a small connector, and keep the wires short, you can tuck it all back in the case if you wish and the instrument looks unmodified.
Scott has also created the software to interface this device. He used this document if you want the details. That's it! You now have an IR temperature sensor that will work from -33 to 250 C.
Step 2: Software for Control
Useful as it is, the IR temperature sensor is only part of the system. To control temperature, three items are required: a heat source, a temperature sensor, and a controller that can read the sensor and command the heat source. In our case, the hot plate is the heat source, the IR temperature sensor (as modified in the last step) is our sensor, and an Ard/Free-duino running appropriate software is the controller. All software for this Instructable can be downloaded as an Arduino package and as a Processing package.
Download the file IR_PID_Ard.zip. Unzip it in your Arduino directory (usually My Documents/Arduino). Download the file PID_Plotter.zip. Unzip it in your Processing directory (usually My Documents/Processing). The files will now be available in the appropriate sketchbooks.
The software we’ll use was originally written by Tim Hirzel. It is modified by adding the interface to the IR sensor (provided by Scott Dixon). The software implements a control algorithm known as the PID algorithm. PID stands for Proportional – Integral – Derivative and is the standard algorithm used for industrial temperature control. This algorithm is described in an excellent article by Tim Wescott on which Tim Hirzel based his software. Read the article here.
To tune the algorithm (read about this in the article mentioned) and to change target temperature settings, we will use a Processing sketch, also developed by Tim Hirzel. It was developed for roasting coffee beans (another application of temperature control), and was called the Bare Bones Coffee Controller, or BBCC. Name aside, it works great for surface mount soldering. You can download the original version here.
Modifying the software
In the following, I assume that you are familiar with Arduino and Processing. If you are not, then you should go through the tutorials until things start making sense. Be sure to post Comments to this Instructable and I'll try to help out.
The PID controller must be modified for your Arduino/Freeduino. The clock line from the IR sensor must be attached to an interrupt pin. On an Arduino, this can be 1 or 0. On Freeduinos of various sorts, you may use any interrupts available. Attach the data line from the sensor to another nearby pin (such as D0 or D1 or another pin of your choice). The control line to the hot plate can come from any digital pin. On my particular Freeduino clone (describe here), I used D1 and the associated interrupt (1) for clock, D0 for data, and B4 for the control line to the hot plate.
After you've downloaded the software, start your Arduino environment and open IR_PID from the File/Sketchbook menu item. Under the pwm tab, you can define the HEAT_RELAY_PIN as appropriate for your Arduino or Freeduino variant. Under the temp tab, do the same thing for the IR_CLK PIN, IR_DATA PIN, and IR_INT. You should be ready to compile and download.
Similarly, start your Processing environment and open the PID_Plotter sketch. Adjust the BAUDRATE to the correct value and be sure to set the index used in Serial.list() to the correct value for your system (my port is index 1).
Step 3: Hooking It All Up
The hot plate AC control system is detailed in the Extreme Surface Mount Soldering Instructable already mentioned, or you can buy your own SSR (solid state relay). Be sure it can handle the hot plate load with sufficient margin, say a 20 to 40 watt rating, since the testing done by the Chinese may leave something to be desired. If you use the hot plate AC controller from my Instructable, then run a jumper from the resistor on the control input to ground on the Ard/Free-duino and a jumper from the control output (B4, or whatever you chose) to Control Signal Input. See the picture of the controller. The yellow jumper is the Control Signal Input and the green jumper goes to Ground. I like to use an blinkenlight (led with a resistor to ground) on the output pin so I know when it's on. Connect your jumper between the led and the port as shown. Refer to the Teensy++ Hookup Diagram.
Now rig up a support to hold the IR temperature sensor over your hot plate. The picture shows what I did. Simple but sturdy is the rule. Keep anything flammable well away from the hot plate; the sensor is plastic and seems to be just fine 3 inches above the surface of the plate. Run wires from the connector on your sensor to the appropriate pins on your Ard/Free-duino. Connections for the IR sensor are shown in the Teensy++ Hookup Diagram. Adapt these as needed for your Ard/Free-duino.
Important Safety Note: The IR sensor has an led pointer that aids in aiming it. If you have cats like mine, they love to chase the led pointer. So cover the led with some opaque tape to keep your cats from jumping on the hot plate when you're using it.
Before you plug the hot plate AC controller into120V, here's how to test the system out and set initial target values for temperature. I suggest a target temperature of 20 C so heating doesn’t start immediately. These values will be stored in EEPROM and used next time, so be sure you always store a low value as the target temperature when you’re done with a soldering session. I find it a good idea to start the temperature controller with the hot plate unplugged at first. Make sure everything is working before you plug it in.
Connect your serial port to your Arduino and power it up. Compile the Arduino sketch and download it. Start the Processing sketch to interact with the controller and display results. Occasionally, the Arduino sketch will not synchronize with the Processing sketch. When this happens, you'll see the message “No Update” in the console window of the Processing sketch. Simply stop and restart the Processing sketch and things should be OK. If not, have a look at the Troubleshooting section below.
Here are the commands for the controller. “Delta” is the amount that a parameter will change when commanded. First set the value of delta that you want to use. Then adjust the desired parameter using that delta. For example, use the + and – to make delta 10. Then use T (capital “T”) to increase the target temperature setting by 10 degrees C, or t (lower case “t”) to decrease the target temperature by 10 degrees. Commands:
+/- : adjust delta by a factor of ten
P/p : up/down adjust p gain by delta
I/i : up/down adjust i gain by delta
D/d : up/down adjust d gain by delta
T/t : up/down adjust set temp by delta
h : toggle help screen on and off
R : reset values – do this the first time you run the controller
Once you’re getting temperature updates, the graphic window of the sketch should look like the picture. If you have a large grey area imposed on the screen with some commands described, simply type “h” to clear it. When you start for the first time, you may be prompted to reset the initial values. Go ahead and do that. The values in the upper right corner are the current readings and settings. “Goal” is the current target temperature and is changed by the “t” command as described above. “Curr” is the current temperature reading from the sensor. “P”, “I” and “D” are the parameters for the PID control algorithm. Use the “p”, “i”, and “d” commands to change them. I'll discuss them in a moment. “Pow” is the power command from the PID controller to the hot plate. It's a value between 0 (always off) and 1000 (always on).
If you put your hand under the sensor, you should see the temperature (Curr) reading jump up. If you now increase the target temperature, you’ll see the power (Pow) value increase and the output led will blink on. Increase the target temperature and the output led will stay on longer. When the hot plate is connected and operating, increasing the target temperature will cause the hot plate to turn on. As the current temperature approaches the target temperature, the on time will decrease so that the target temperature is approached with minimal over-shoot. Then, the on time will be just enough to maintain the target temperature.
Here’s how to set the parameters for the PID algorithm. You can start with the values I use. P of 40, I of 0.1 and D of 100. My system will do a 50C step in about 30 seconds with an overshoot of less than 5 degrees. If your system performs significantly differently, then you will want to tune it. Tuning a PID controller can be tricky, but the article referenced above explains how to do it very effectively.
Now it's time for the real thing. Plug the hot plate into the hot plate AC controller as described in Extreme Surface Mount Soldering. Be sure to read all the cautions in there as well. Position your temperature sensor so it is about 3 inches above your hot plate and pointing directly at it. Power up your Ard/Free-duino. Make sure all the connections are correct and that your software (the PID controller and the monitoring program) is running properly. Start with the target temperature set to 20 C. Then increase the target temperature to 40 C. The hot plate should come on and the temperature should increase smoothly to 40C +/- 2 C. You can now try increasing temperature as you observe the performance of your system. You'll notice that it takes much longer for the plate to cool down than it does to heat it up.
If the Processing sketch doesn’t run or doesn’t update the temperature, stop the Processing sketch and start a serial terminal (Hyperterminal on Windows, for example). Tap the space bar and hit return. The Arduino should respond with the current temperature reading. Adjust settings of baud rate, etc. until you get the desired response. Once this works, the Processing sketch should run. If you still have problems, be sure your pin assignments agree with your physical wiring and that you’ve connected power and ground to the appropriate pins of the temperature sensor.
Step 4: Surface Mount Soldering
Using the temperature control system described in this Instructable improves Extreme Surface Mount Soldering in two ways. First, temperature control is more accurate and significantly quicker. So instead of having a slow ramp from about 120C to 180C over 6 minutes or so, we can go quickly to 180C, hold for 2 ½ to 3 minutes, and go quickly to 220C to 240C for about a minute. We still have to watch for the point when the solder flows and turn off the power, or just quickly lower the target temperature. Since the temperature comes down very slowly, I usually slide my circuits off the hot plate as soon as the temperature has cooled below 210C. Put them on a piece of perf board or wood, not metal. The metal could cause them to cool too quickly. Note also that you might have to raise the target temperature over 250C (the maximum the sensor will read) in order to get the plate hot enough in certain areas. The plate will not reach a single temperature over the entire surface but will be cooler in certain areas than others. You’ll learn this by experimenting.
The second area of improvement is a reduction in the time between soldering cycles. With the open loop system, I had to wait for the hot plate to cool to room temperature (about 20C) to start a new soldering cycle. If I didn’t do this, then the temperature cycle would not be correct (change of initial conditions). Now I only need to wait for a stable temperature around 100C and I can start a new cycle.
The temperature cycle I now use is implied above, but here it is exactly. Start at 100C. Put your boards on the hot plate for two to three minutes to warm up - longer with large components. Set the target temperature to 180C. This temperature is reached in less than one minute. Hold here for 2 ½ minutes. Set your target to 250C. As soon as all the solder flows, decrease the target temperature to about 100C. The temperature of your plate will stay high. As soon as it decreases to 210C, or time of 1 minute elapses, slide your boards off the hot plate onto a cooling platform of perfboard or wood. Soldering is done.
If you wish to use a different temperature profile, you should have no trouble achieving it with this control system.
You may want to experiment with the position of the temperature sensor above your hot plate. I found that not all areas of the hot plate reach the same temperature at the same time. So depending on where you position your sensor, the actual time and temperature required to make the solder flow can vary. Once you work out a recipe, use the same positioning of the sensor for repeatable results.