Wednesday, August 12, 2015

5. The firmware

After having spent quite some time thinking about the best way to implement the tip temperature calculation, I came to the conclusion that the most elegant approach would be to make an universal solution that can be adjusted with a calibration menu. The user could then measure the temperatures of the soldering iron tip in regard to the reported (heater) temperature then enter the obtained values in the menu.

Internally, the firmware will then take these values and use them to make some virtual segments, each having a length of 25 degrees C. All these segments taken together form the temperature curve. The reason for using multiple segments to form a curve is that not all soldering irons have the same thermal characteristics. If you have look at the graph from the previous post, you'll see that the soldering iron I currently use has ~61% efficiency at 250 degrees C. The rest of the heat is lost to the environment or simply doesn't reach the tip due to the poor design or machining of the tip sleeve. You on the other hand might have a more efficient soldering iron that has lower losses. If a simple calibration constant would be used, the calculated temperature might be correct on a piece of the curve and incorrect on another. This approach involves quite a bit of math but the AVR was up to the task and I didn't notice any slowdowns in the tests.


The programming language

Having some prior experience with BASIC programming, I have chosen to write the firmware in GCBasic, a great compiler for AVR and PIC MCUs with a syntax similar to QBasic. It is very easy to learn and best of all, it's free and open source, not to mention it has a friendly community around it. The only apparent minus of GCBasic is the lack of floating point maths, but there are a few tricks that can be done to overcome this problem.

GCBasic's excellent IDE (SynWrite) running in Debian under Wine




How to use the firmware


The firmware currently has 3 screens:

The work screen is the mode in which the temperatures are shown. To increase the heating temperature, press Up and to decrease it press Down (short or long). Pressing Stand-by briefly will enter the Stand-by mode. Pressing Stand-by for more than 1 second then releasing it will enter the calibration menu. Pressing the Preset button short will go to the preset value (150 degrees C by default) while pressing it long and then releasing it will set the current temperature as the preset.
To enable or disable the beep made when reaching the desired temperature, press the Stand-by and Preset buttons at the same time briefly. The beep is symbolized by a bell that appears in the lower right position on the screen.
The main screen of the soldering station




The Stand-by screen is shown when the station is not in active use. The heater is still active, but the temperature is maintained at 150 degrees C. To go back to the work screen, press Stand-by short.

The stand-by screen



The calibration menu is used to enter the values needed for calculating the tip temperature:

The calibration menu


How to calibrate the soldering station:
  

1. By default, the firmware assumes 100% efficiency for the soldering iron. This means that the temperature reported by the thermocouple is assumed to be the same at the iron's tip. Of course, this won't be the case even with the most expensive handles out there.  

2. Set the soldering temperature to 300 degrees C. After the temperature stabilizes (about 1 minute), melt some solder and carefully measure the temperature of the tip with your multimeter's thermocouple by inserting it in the molten solder blob. Wait for some seconds until the temperature remains fixed. If the temperature reported by the multimeter / thermometer is lower than 300 degrees, carefully increase the temperature from the station until it reaches 300 degrees C. Make sure to do this in small increments so the temperature won't overshoot. After the temperature is stable, write down the value from the station's screen. To make things easy you can make a table that contains all the required temperature points:

Example calibration table

3. Lower the temperature until it is 25 degrees smaller on the multimeter (e.g. from 300 to 275), wait for stabilization then write down the temperature reported by the station's screen in the table.

4. Repeat step 3 until you reach the minimum temperature. You should now have all the values from the thermometer in 25 degree increments starting at 150 degrees up to 300 degrees.

5. To calculate the rest of the values, we must approximate the temperature of the thermocouple when the tip has 500 degrees C. To do this, take  the temperature reported by the station at 300 degrees C, substract 300 from it then add 530 to it. For example, if the difference between the tip and the heater temperature at 300 degrees C is 150 degrees, the approximated value will be 530 + 150 = 675 degrees. Now we need to enter this value in the calibration menu so that the station will be able to supply enough power to reach 500 deg. C at the tip. To enter the calibration menu, hold the stand-by button pressed for 2-3 seconds then release it. Then navigate to the 500 deg. C. item with the help of the Preset button and use the Up and Down buttons to set the value to the approximated one. Hold the stand-by button pressed for 2-3 seconds to exit the calibration menu. The station will restart.

6. Increase the temperature to 500 degrees C. Carefully tweak the temperature with the Up and Down buttons so that the tip temperature measured by the multimeter / thermometer reaches a stable 500 degrees. Write the temperature from the soldering station screen in the table.

7. Repeat step 3 until you reach 325 degrees C. You should now have all the values from the thermometer in 25 degree increments starting at 150 degrees up to 500 degrees. Proceed to enter all the values from the table in the soldering station calibration screen as shown in step 5.

8. Test the temperature at 250 degrees C. The value reported by the station should be very close to the one at the tip (reported by the thermometer).



Download firmware

I decided to make the firmware source code available under the BSD license so anyone can add new features or fix bugs. The file below contains both the sources and the HEX and EEPROM files to be written on Atmega168 or Atmega328P.

Download firmware v1.2



Writing the firmware on the AVR

To write the firmware I used the excellent USBASP programmer and avrdude. If you don't like using command-line tools, have a look at AVR8 Burn-O-Mat, it's open source and works on both Windows and Linux:


AVR-Burn-O-Mat - GUI for avrdude on Debian Linux


If you don't want to write the provided EEPROM file manually, after switching on the soldering station briefly press the power button.  This will reset the EEPROM to the factory parameters.

In the next post I'll talk about putting all the components together to form the final product. Please let me know if you find any problems with the software.

1 comment:

  1. came accross Great Cow BASIC to your Project, very good documented, nice Photos!

    ReplyDelete