Welcome, Guest

Temperature-controlled Soldering Station

Soldering Station 1 Top view

Soldering Station 1 Top view

Brian Neale describes how he designed and fitted a replacement control circuit and program for a defunct Weller soldering station using an Arduino Uno as a testbed. He is happy to enter into discussion with members. If you wish to do so, just leave your comment in the space provided at the end of he article and he will get back to you.

 

 

Introduction

Some years ago I intercepted a Weller temperature-controlled soldering iron and associated “soldering station” on its way to the skip. It had a label taped to it saying “Display broken”, which seemed promising if that was all that was wrong. Unfortunately, it should have just said, “Broken”! No display, no heating, nothing. However, it was one of the more sophisticated variable-temperature irons rather than the “Magnastat” single-temperature irons, so seemed to be worth a closer look.

I did some digging around on the Internet and was pleased to find a circuit diagram for this model. However, it appears that although Weller sold similar models over a significant period, internally there were various changes and my later model used a couple of ceramic printed-circuit boards with surface-mount components with the key semiconductor items hidden under blobs of epoxy. There were no obvious broken tracks or similar, and while the circuitry had some similarities to the information that I had found, there was little chance of doing any intelligent fault-finding. Even the display was soldered on to one of the boards in a way which made it difficult to remove without damage. So, at this point, I had a soldering iron with working 24V element and PTC thermistor temperature sensor, and stand with a temperature control pot and 24V power supply. It seemed worth continuing as these are good-quality tools and spare tips and so on are still available. All I needed to replace was the circuitry to sense tip temperature, read the temperature setting pot position, and regulate power to the element accordingly. I also needed to replace the temperature display and find a way to drive it. So, no problems there, then…

Actually, although I did this work for a soldering iron, exactly the same techniques could be adapted for any temperature-control requirement. A heat-treatment oven, maybe, or perhaps improve the temperature stability of my coffee-maker?

The new design

Rather than try to emulate the original circuitry, I wanted to investigate the use of a digital temperature control system. I broke the requirements down to four main functional blocks.

Soldering Station  Underside

Soldering Station Underside

The heart of the new system would be an ATmega 8-bit microcontroller. I chose this as it was familiar to me as the controller for my 3D printer. It is a member of the microcontroller family used in the Arduino range of hardware, for which there is plenty of open-source software available including a useful (and free) software development environment. I had already used this for updating my 3D printer controller. I also had access to the open-source temperature-control software used by the 3D printer as a starting point for ideas. While the Arduino boards are very useful and easy to use, I didn’t need all the facilities offered by these but could do software development using one. I could then take the bare ATmega chip and add a few additional components to give a usable embedded system. The ATmega 328P, as used in the Arduino Uno, is a 28-bit device that plugs into a DIL socket but includes analogue to digital (AD) conversion and sufficient digital I/O pins, and only costs a few pounds. I’m sure that there are other even cheaper options available, but the combination of acceptable cost, familiarity, and ease of use made the decision easy. I was able to programme an Arduino, and test with the other circuitry assembled on a breadboard. Once tested, I swapped the 328P to a socket on the Veroboard on which the rest of the circuit was built.

The other three blocks which needed development were temperature sensing, digital display, and power control for the element. The aim was to use the existing 24V transformer plus rectifier/capacitor and temperature-setting variable resistor.

Temperature sensing was a challenge as the iron used a PTC thermistor with a low value (of the order of 30R). The 3D printer uses a more common 100K NTC thermistor, and the temperature measurement is by charging a capacitor via the sensing thermistor and measuring the voltage after a fixed interval. I needed to find a way of turning small resistance changes in a small resistance into something useful, and I ended up with a bridge circuit driving the input of a fairly high-gain opamp. This gave a sufficient voltage swing over the temperature range of interest to be useful. Output from the opamp goes directly to one of the analogue input pins on the 328P. The AD converter on the 328P turns an input voltage range of 0-5V into a number 0-1023; the output of the sensor circuitry over the useful temperature range was about 2-4V, so giving a digital number range of about 400-800. This means that the resolution of the temperature values inside the programme is not very high, but it is adequate for the job. The target temperature is set by using the existing pot fed with 5V and with the wiper connected to a further analogue input pin.

Soldering Station 4 Detail

Soldering Station Detail

The display uses a cheap 3-digit 7-segment LED device, chosen partly because it fitted the existing front panel hole with just a little bit of trimming. The segments and the digit select inputs are driven from 328P digital output pins via a set of cheap general-purpose switching transistors to handle the currents involved. The total current draw would have been pushing the limits of the 328P if it had to drive the display directly. The digit decoding to illuminate the appropriate bars of the display and do digit selection is all handled by the 328P rather than add any further external circuitry. There are standard decoder/driver chips around that would do the job and in retrospect I might go that way if I had to do the job again.

I planned to use a triac to switch power to the element under control of the 328P. I considered using 24V DC and, for example, a MOSFET with PWM proportional control of heat input, instead of 24V AC and the triac. The original design used a triac and AC switching, and I went the same way on the grounds that I could avoid switching transients – I would have been switching about 2-3A using DC. My 3D printer uses PWM for extruder nozzle temperature regulation, and very well it does (within 1degC at around 190degC), but I was concerned about the high-frequency noise generated by switching DC. Using a triac and AC, I was aiming to switch at zero-crossings of the mains cycle, so never switching significant current.

To allow me to use the same transformer to give a 24V DC supply to the electronics and 24V AC for the heating element, I included an opto-isolated triac driver which also made it very easy to control the triac from a 328P output. Opto-isolation means no direct connections between the input and output side – complete electrical isolation. The triac automatically gives zero-crossing switch-off but I was aiming to use zero-crossing switch-on as well to avoid switching transients. To achieve this, I took an AC feed from the power transformer and used a couple of diodes to give positive-going pulses, clipped to the DC supply voltage. This went to one of the 328P pins which was configured to give an interrupt on one edge of the input pulse. The interrupt service routine was where the on or off decision was made, so that switch-on should occur at or very close to a zero of the AC supply voltage. At the same time as turning on the triac, the interrupt service routine started a timer which turned off the triac drive after 14msec, so well into the second half-cycle of the AC input. This way, the triac itself would turn off at the end of the cycle ready for the on/off decision at the start of the next. I would like to have tested just how accurately all the pulse timing works, but my oscilloscope came from the same source as the “heading for the skip” soldering iron and I haven’t got round to fixing it yet…

PID control

The 328P microcontroller implements a PID-based temperature control algorithm. Well, it would do if I had included the “D” element of it, but that didn’t seem to add much to the temperature control capability so I dropped it after some experimenting. For those unfamiliar with PID, sometimes called three-term, control, it is the process of using measurements of the actual temperature (or whatever it is that you are trying to control), comparing it with what you want it to be, and increasing or decreasing the input power until they match. The P element is easy. P stands for proportional. Take the difference between the actual and required values, and add or subtract power (in this case) proportional to the difference. Big difference = lots of input power, and as the actual temperature approaches the required temperature, the input power reduces. The problem with a proportional-only control system is that it generally doesn’t let you actually reach the required temperature. Heat input is driven by the size of the error (difference between actual and required) and you end up always having some small error because if the error is zero, then the correction is also zero. The easy way to get round this is to measure the cumulative error over some period, and generate a correction to the heat input based on that. The longer the actual temperature has some small error, the bigger the correction becomes and over some period, this gets you to the target value. This is the I or Integral component. Those whose memory goes back to school maths and calculus lessons might remember integrals as being to do with the sum of lots of small values, which is what we are doing here. In crude hand-waving terms, the P error feedback drives the output close to what is wanted, and the I component helps it get bang on. The D (Differential) component looks at how quickly the actual temperature is approaching the required value, but I have not found this to be particularly useful in practice. Balancing P and I components can do a pretty good job.

In practice, it’s all slightly more complicated than this. What my system does (based heavily on the temperature control mechanism from the Sprinter code for 3D printers) is have built-in knowledge of how much power is needed for a particular temperature. I set up a test system which allowed me to vary the power input across a range of preset values, and I measured the temperature that resulted. The values were stored in the programme downloaded into the microcontroller. I was then able to set up the control programme to deliver about the right amount of heat for any required tip temperature, and in principle that would have got me fairly close. The PID controller then adds or subtracts a calculated amount of power based on the P and I errors as described to bring the tip temperature spot-on. It also means that it heats up faster (as it uses full power when heating and then backs off when it gets close) and can correct for loss of heat at the tip when in use, if there’s a draught in the workshop, or whatever.

The programme has a couple of parameters which adjust how much the P and I “correction” factors change the basic heat input value. I spent some time tuning these; for example, if the I factor is too big, the temperature will get to the target quicker, but will then overshoot and undershoot continuously; too small and it takes longer to reach the target. This is where the Arduino board as part of a breadboard setup really scores – it’s so easy to tweak the code, download a new version, test it, and repeat until happy.

Interrupts and power switching

The output of the PID calculations is a number which represents the proportion of power between zero and full that needs to be applied. To explain, it’s easiest to think about this “proportion” as a number between 0 and 100, so in effect the percentage of full power to be applied. I can only switch power in full mains cycles, so 50% power means turning the heater on for 50 cycles out of 100, 66% power means 66 cycles out of 100, and so on.

The hardware is set up to deliver an interrupt to the microcontroller at the start of every mains cycle. An interrupt in computing terms is a way of telling the processor that it has to respond to some external event, now. In effect, “stop whatever you are doing, immediately run some specified bit of code, and then go back to what you were doing.” The alternative is that the processor “polls” an external quantity. This is how the programme measures the tip temperature, or the value of the temperature-setting pot. The programme decides when it is going to do this. An interrupt is needed when an immediate response is needed, as in this case where we have to make a switch on/switch off decision at the start of every mains cycle.

The simplest way to turn the PID output value into a switching decision is with a counter. There is an interrupt at the start of every mains cycle, and the interrupt code counts interrupts (=mains cycles). The logic is:

                (interrupt occurs)

                If PID value >= counter

                                Turn heat on

                Else

                                Turn heat off

                Endif

                Counter = counter + 1

                If counter > 99

                                Counter = 0

                Endif

                (end of interrupt processing)

What happens is that for the first “PID value” cycles of a 100-cycle period the power is turned on, and off for the rest of the period. With 50Hz mains, that means over a 2 sec period, and 50% power would mean on for 1s, off for 1s. In practice, for greater resolution, I use a 0-255 range for “PID value” and the maximum counter value rather than 0-100, which means that control is over a roughly 5 sec period. I was concerned that this would allow too much temperature fluctuation due to the relatively long on/off periods, and I looked for a way to do better. Ideally, 50% should mean alternate on/off cycles, 66% mean two cycles on, one cycle off, etc. Much finer granularity, and potentially better stabilisation of temperature, if I could do it.

The method I came up with might not be original, given that little is original in this kind of thing, but l don’t remember seeing it described anywhere. Again, we use a counter but this time we use it slightly differently.

                (interrupt occurs)

                Counter = counter + PID value

                If counter > 99

                                Turn heat on

                                Counter = counter – 100

                Else

                                Turn heat off

                Endif

                (end of interrupt processing)

 

To see how this works, the easiest way is to work through it with some sample values. For example, assume that the counter starts at 0 and PID value = 25.

After pass 1:       counter = 25; heat off

After pass 2:       counter = 50; heat off

After pass 3:       counter = 75; heat off

After pass 4:       counter = 0; heat on

…and we’re back to the start. You can see that the heat is on for 1 out of 4 mains cycles = 25%.

Try with PID value = 67.

After pass 1:       counter = 67; heat off

After pass 2:       counter = 34; heat on

After pass 3:       counter = 1; heat on

After pass 4:       counter = 68; heat off

After pass 5:       counter = 35; heat on

After pass 6:       counter = 2; heat on

…and so on. That’s 2 mains cycles out of 3, and if you go on for long enough, you will find that the heat is on for precisely 67% of the time (occasionally the heat will be on for 3 out of 3 mains cycles and the algorithm takes care of this automatically). Clever, eh? It works for any value of PID value, and it also works in my case where PID value is between 0 and 255 and the counter threshold is 254 rather than 99. I use 255 rather than 100 just for slightly finer granularity of heater control although I doubt if it makes any real difference in practice.

Triac switching

The output of the microcontroller drives an opto-isolated triac driver. The output side of the triac driver triggers the triac which controls the 24V AC supply to the heating element. The opto-isolator is easily driven directly from a micro-controller output pin, and also provides electrical isolation between the control electronics and the triac and its 24V supply. This allows the same supply to power the control electronics and the heater element without any problems.

Main programme

This is pretty straightforward. The microcontroller has an internal clock which can be read from within a programme. The programme just runs round the same loop continuously, checking the clock each time. Every half-second, the code reads the target temperature from the temperature control pot, reads the iron tip temperature, and recalculates “PID value” (the proportion of available heater power required) for use in the interrupt routine. It also updates the temperature display every 2 seconds. Whenever the temperature control pot is changed by more than some small amount, the display changes to show the target temperature for 5 seconds, and then goes back to showing the tip temperature.

The display driver code is also simple. Pick out successive digits from the temperature value, then call the corresponding subroutine to light up the appropriate segments of the 7-segment displays by setting the associated output pins. There are therefore 7 pins dedicated to segment display output, plus a further 3 which drive the “digit select” lines on the display module. I didn’t need to use the decimal points for temperature display, so I chose to use these to indicate when the power is on to the heater. Typically, they stay on while the iron is heating and then just flicker a bit once the tip is at target temperature.

On the whole, this display code is not very successful. One big problem is that the apparent brightness of any digit depends on how long that particular set of segments are illuminated, and it is quite difficult to make sure that each digit is on for the same amount of time. This is one reason why it would be useful to use an external display driver as these typically handle brightness control and so on. An external driver would also remove the need for the 10 switching transistors, but curiously a suitable decoder/driver chip typically costs more than the microcontroller! Still, as long as the code fits into the memory space available and there are enough CPU cycles available, complexity costs nothing (once it’s written…) and the current setup works adequately. In practice, the display is a little on the bright side but the digits are pretty close to the same brightness.

Building and testing

Soldering Station Detail

Soldering Station Detail

The photographs show the general construction technique. This was very much an experiment when I started, so I threw something together fairly crudely on Veroboard. One board holds the analogue circuitry – the temperature sensing components and associated amplifier, the mains pulse squaring circuit, and the connections from the temperature-setting control. It also holds the opto-triac driver and the triac itself. The second board holds the micro-controller, the display, and the display driver transistors. The microcontroller has two capacitors and a timing crystal, which is all the external support circuitry it needs. Actually, it could probably manage with less but with poorer timing accuracy but when I started the project, I wasn’t sure whether I would need accurate timing or not.

The boards are connected with a short length of ribbon cable and fit in the space occupied by the original board assembly plus an extra compartment within the casing. There are a couple of 3-pin regulator chips in there somewhere, giving 12V for the op amp circuitry and 5V for the microcontroller and display. Both boards would have been much tidier using printed circuit boards, but they do work!

Soldering Station  Test rig

Soldering Station Test rig

For testing, I used an Arduino Uno board running the code that would be used on the target embedded micro-controller. The photograph of the test setup shows the Uno board connected to the “real” board with jumper wires connecting the corresponding pins. At this point I was testing the temperature control code so did not need the display connections in place; the connections are for temperature sensing, temperature setting, mains pulse for interrupt, and heater output. Other wires are power and ground. With this setup, I could put debugging code in the programme and send useful information back to the laptop running the Arduino programming environment. It is really useful to get this kind of information out of a system when you are developing it because otherwise it’s just a black box which works or not, as it sees fit, and you have no visibility of what’s happening internally. For example, the heater power algorithm needs a good estimate of the required power for any given temperature, and the PID feedback mechanism then corrects this by small amounts as required. To find the required power, I could modify the code to set a fixed power setting (30%, 40%, or whatever) and let the temperature settle. Doing this for a few different power settings gave a graph of temperature against heater power. I could also monitor the PID feedback quantities while the iron was heating up and settling to temperature to help tune the feedback variables. Based on my 3D printer heater experience, I was looking for a system that would heat quickly, overshoot by no more than about 5% of the target temperature, and then settle to the target value.

Conclusions

I have ended up with a temperature-controlled iron that will quickly heat up (on full power) and then settle to within, typically, ±4degC of the target temperature, which is good enough for all practical purposes. There is still a problem with random fluctuations from the temperature-setting pot which cause the display to change to “set temp” every so often; the pot is over 20 years old and they do get “noisy” after a while. I am thinking of changing the pot to a rotary encoder; there are spare input pins on the micro-controller which would let me count pulses to use for temperature up/down setting. I would also like to find a way to easily vary the display brightness; if I get hold of a small rotary encoder with a push switch, maybe I could use it for modifying both temperature and brightness. That’s the great thing about micro-controllers – it’s easy to add this kind of functionality with very little extra hardware needed.

The core of this design could be easily adapted for other purposes. The biggest change would be on the temperature-sensing side, but anything that delivers a reasonable range of voltage between 0-5V for the required temperature range would do. If I had the choice, I would use the NTC thermistor that my 3D printer uses and reuse the code from the printer control programme, but that is only good for about 250C, and would have meant modifying the iron as well. The output triac is capable of switching mains voltage directly at about 4A but similar devices capable of switching 16A cost only a few pennies more.

On the other hand, I could have just gone out and bought a cheap Chinese temperature-controlled iron with much less effort and for little more cost. But where’s the pleasure in that?

Leave a Reply