Arduino/ATMega based Digital Soldering station

Think you've got a good idea? Share it with us and it might just end up on the show!
foxmiles
Posts: 90
Joined: Fri Dec 24, 2010 1:57 pm
Contact:

Re: Arduino/ATMega based Digital Soldering station

Post by foxmiles » Thu Nov 14, 2013 9:07 pm

OK, I had a chance to build it on a breadboard and take some measurements. Here's what I found (so far)

1. With a 5v supply the lm358 saturates around 3.5v (vcc-1.5v), the output range is about 0-3.5V. For some reason I thought it was 0.5-4.5v. No idea why I thought that. My 330K resistor makes it saturate before it gets to a reasonable temperature. I swapped it out for a 100K and it works a whole lot better. That also means about 100x gain, so 1mv in == 100mv out, Which makes measuring the temperature much easier, at least with a chart. Next time I buy parts I'm getting some rail to rail opamps that should recover most of the upper ADC range. I think the lm358 is still usable, I just want to compare them.

2. I don't know why, but the reading on the thermocouple goes way up when I apply power to the heating element. I'd assume it's inductance in the wire or heater itself, but the output from the opamp is correct. It may read ~50mv in and 1000mv out, unplug and it drops to 10mv in 1000mv out (roughly). It must be in my measuring wire hookup or something, I have a bit of a rat's nest growing on my bench.

3. I measured the current and I'm getting 0.5A when it's at 100% on, so yea, these laptop PSU's might be a problem (haven't checked the voltage yet).

4. I taped a thermocouple to the iron and read it with a multimeter. It seems to follow the chart (very rough measurements), there is a considerable lag of course, comparing tip temperature and internal heater temperature.

5. I noted earlier that I was getting much higher readings than I expected, it turns out it was just error on my end, I was measuring with a DSO and hadn't spent much time setting it up for what I was trying to do. (I know they're not real accurate, but I had the leads hooked up anyway) with some tweaks I'm seeing what I expect. Some of the error was definitely #2 as well.

6. I think we could offset the ground terminal of the thermocouple somewhere around 10mv to allow reading low (room) temperatures.
Digging with a spoon will accomplish more than leaning on a shovel.

dearangelo
Posts: 16
Joined: Sat Sep 21, 2013 11:55 am
Location: athens, greece

Re: Arduino/ATMega based Digital Soldering station

Post by dearangelo » Thu Nov 14, 2013 10:05 pm

nice work!
so what is the "verdict" as per the resistors combination? also, in one other controller of similar design, they were also using that lm358 opamp... so..perhaps this is the best option, but I am curious, if you can come up with something better.. please let me know what combination of resistors are you using to drive the lm385...
b regards
angelo e

foxmiles
Posts: 90
Joined: Fri Dec 24, 2010 1:57 pm
Contact:

Re: Arduino/ATMega based Digital Soldering station

Post by foxmiles » Fri Nov 15, 2013 3:49 am

Here's a very preliminary first draft of my Rev B schematic. It wouldn't let my upload a pdf, so here's a hi-res jpg:
Solder station.jpg
Preliminary Solder station Schematic Rev B
A 1k(r4) and 100k(r5) combo seems to work good for me. It gives about 100x gain. (10k and 1M would be the same gain)

I've messed with the board design a bit and haven't got far yet, I'm really not ready to do that yet anyway. I'm sure I'll have to tweak the schematic a bit as I do the layout.
I tried offsetting the thermocouple by ~5mv and it seems to work even below 0C (gave it a blast with some liquid canned air), how accurate it is I don't know.
If you have any ideas that need hardware now would be a good time to come up with a list (no promises).

So far I've implemented (untested and all optional):
1. PTC Thermistor for ambient temperature measurement.
2. TC Offset - allows TC measurement around and below ambient
3. FTDI Header
4. Crystal - not needed if the chip is configured for the internal oscillator

I'm considering:
1. Replace pot with rotary encoder (or have it as an option)
Digging with a spoon will accomplish more than leaning on a shovel.

foxmiles
Posts: 90
Joined: Fri Dec 24, 2010 1:57 pm
Contact:

Re: Arduino/ATMega based Digital Soldering station

Post by foxmiles » Sun Nov 17, 2013 3:16 am

Math (or at least algebra) is not my specialty, in fact it's a pretty big weak spot that I'm working on. I've been looking into ways to convert the reading from the adc to MV and then to degrees C.

So far I've got preliminary compensation code:

Code: Select all

mv = reading*(4950/1023)-136-80; //reading*(vcc/1023)-opampoffset-roomtempcompensation - Might be 1024, further testing needed
and a neat polynomial to convert MV to degrees C (after the above compensation). I think it works, at least within our expected range (-20mv to 35mv), definitly need a lot of testing. Now if I could figure out how to reverse it and convert degrees C to MV.

Code: Select all

// This function takes a float value of Volts (ie 0.0025) and converts it into a degrees C for a K type Thermocouple.
// Call like T = MVtoC(mv/100000.0) (reading / 1000 to get opamp V, dev by 100 for opamp gain.) I think that's right.
float MVtoC(float mv){
   float a[9] = {0.226584602, 24152.10900, 67233.4248, 2210340.682, -860963914.9, 48350600000., -1184520000000., 13869000000000., -63370800000000.};
   float T=a[0];
   for(int i=1; i<9; i++){
      T = T+(a[i]*pow(mv, i));
   }
   return T;
 
} 
TODO:
1.I think the atmega328 can read the supply voltage, that would cancel one error point.
2.Read a ptc thermistor, calibrate it and use it to compensate the thermocouple.
3.With these two compensated we can determine the offset in the op-amp and associated circuitry and compensate for that.
4.That should leave us with a pretty well calibrated thermocouple circuit (there are other uses for that too, like a 6 channel thermocouple display for smd / bga rework?)
5.Function to convert C to MV so we can compensate #2 above and set a temperature without running the polynomial too many times. (it's going to be fairly slow on an 8bit mcu)
6. Put it all together.
Digging with a spoon will accomplish more than leaning on a shovel.

dearangelo
Posts: 16
Joined: Sat Sep 21, 2013 11:55 am
Location: athens, greece

Re: Arduino/ATMega based Digital Soldering station

Post by dearangelo » Sun Jul 27, 2014 8:08 am

Hello! I have been reading thru the posts, after a long period of absence... Perhaps I should try to make a come back...

foxmiles
Posts: 90
Joined: Fri Dec 24, 2010 1:57 pm
Contact:

Re: Arduino/ATMega based Digital Soldering station

Post by foxmiles » Thu Dec 04, 2014 2:05 pm

Wow, It's been ages since I've been here. got the urge to finish this project again, so here's another polynomial, this time one that hopefully works. I think the other one didn't, at least not on an Arduino (variable size problems (needed 64bit floats?), also not the right coefficients anyway, not sure where they came from...). I need to build the whole thing on a breadboard again and see if It works.

Code: Select all


// K-Type Thermocouple MV to C polynomial from 0C to 500C 
// (0mv to 20mv). Takes a float (10.02) and returns a float
// (124.03) seems fairly accurate, +-0.1C. I highly recommend 
// comparing the output to a chart. Hope this one actually works!
// See: http://www.omega.com/temperature/z/pdf/z198-201.pdf
// http://www.keysight.com/upload/cmc_upload/All/5306OSKR-MXD-5501-040107_2.htm?&cc=US&lc=eng

float mvtoc(float mv){
  float temp = 0.0;
  float cof[] = {0.0,
                 2508355.0,  
                 7860.1060,  
                -25031.310,  
                 8315.2700,  
                -1228.0340,  
                 98.040360,  
                -4.4130300, 
                 0.1057734,  
                -0.001052755}; 
               
  for(int i=0; i<10; i++){
      temp += cof[i] * pow(mv, i);
  }
  return(temp/100000.0);
}

Digging with a spoon will accomplish more than leaning on a shovel.

dearangelo
Posts: 16
Joined: Sat Sep 21, 2013 11:55 am
Location: athens, greece

Re: Arduino/ATMega based Digital Soldering station

Post by dearangelo » Tue Dec 16, 2014 5:03 pm

So nice to hear from you again!
well, here is what I have done, I discovered that the soldering handle I was trying to implement was a variable resistane and not a thermocouple, it is the Hekko 907 based on the A1321 heating element, and as such it needed a comparator and nothing else...
so I modofied a sketch
see the top four links for details...
it worked like a charm!!!!!


//http://wiki.ladyada.net/tutorials/learn ... istor.html
//http://www.thinksrs.com/downloads/progr ... ulator.htm
//http://www.eevblog.com/forum/reviews/ge ... 9284;image
//http://www.eevblog.com/forum/reviews/ge ... -a1321/30/



//-------------------IO SETTINGS ------------------------
#include <LiquidCrystal.h>
#define PTC_nominal_res 46.14 //VALUES GIVEN 46.6@27C, 94.5@250C, 127.5@400C
#define nominal_PTC_temp 25
#define A0_sampling_times 30
#define PTC_B_coefficient -497.06
#define pad_resistor 217
#define btnMode 6
#define btnUp 7
#define btnDown 8
#define btnZero 9
#define pwmHeater 10



int samples[A0_sampling_times],tA=150,tB=220,tC=270,tD=350,tE=400;
float average=0.00,current_temp=0.0,Delta_theta=0.0,temp_setting=0.0;
long previousMillis=0,interval=1000;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const char compile_date[] =__FILE__", "__DATE__ " " __TIME__;

//---------------- SETUP ---------------------------------------
void setup() {
analogReference(DEFAULT); // 1.1v ref ALITTLE FIDDLING HERE WAS DONE
lcd.begin(16, 2);
pinMode(pwmHeater, OUTPUT);
pinMode(btnMode, INPUT);
pinMode(btnUp, INPUT);
pinMode(btnDown, INPUT);
pinMode(btnZero, INPUT);
Serial.begin(9600);
lcd.setCursor(2, 0);
lcd.print(__FILE__);
lcd.print(" ");
delay(3000);

}

//------------------ KEEP DISPLAY UPDATED -----------------
// IT HAS TO BE OUTSIDE THE LOOP, IT IS CALLED THRU MILLI FUNCTION

void RefreshDisplay() {
lcd.setCursor(0, 0);
lcd.print(" T= set= ");
lcd.setCursor(3, 0);
lcd.print(current_temp,0);
lcd.setCursor(12, 0);
lcd.print(temp_setting,0);
lcd.setCursor(0, 1);
lcd.print(" ohm ");
lcd.setCursor(4, 1);
lcd.print( average, 2);
}

//------------- BUTTON & PRESERTS ------------------------------------
void ReadButtons() {
if (digitalRead(btnUp) == HIGH){
temp_setting = temp_setting + 5.0 ;
if (temp_setting > 400.0) {
temp_setting = 400.0 ;
}
}
if (digitalRead(btnDown) == HIGH){
temp_setting = temp_setting - 5.0 ;
if (temp_setting < 0.0) {
temp_setting = 0.0 ;
}
}
if (digitalRead(btnZero) == HIGH) {
temp_setting = 0.0;
}
if (digitalRead(btnMode) == HIGH) {
temp_setting = temp_setting + 5.0;
if (temp_setting < tA) {
temp_setting = tA ;
}
if ( (temp_setting > tA) && (temp_setting < tB ) ) {
temp_setting = tB ;
}
if ( (temp_setting > tB) && (temp_setting < tC ) ) {
temp_setting = tC ;
}
if ( (temp_setting > tC) && (temp_setting < tD ) ) {
temp_setting = tD ;
}
if ( (temp_setting > tD) && (temp_setting < tE ) ) {
temp_setting = tE ;
}
if (temp_setting > tE) {
temp_setting = 0.0 ;
}
}
}

void ReadHekko907() {
uint8_t i;
for (i=0; i< A0_sampling_times; i++) {
samples = analogRead(A0);
delay(10);
}
average = 0;
for (i=0; i< A0_sampling_times; i++) {
average = average + samples;
}
average = pad_resistor / (1023 / (average / A0_sampling_times) - 1);
current_temp = (1.0 / (((log(average / PTC_nominal_res)) / PTC_B_coefficient) + 1.0 / (nominal_PTC_temp+ 273.15))) - 273.15;
}

//---------------------------- MAIN LOOP ----------------------
void loop() {
ReadHekko907();
if (current_temp <0){
temp_setting = 0.0 ;
lcd.setCursor(0, 0);
lcd.print(" no handle ");
lcd.setCursor(0, 1);
lcd.print(" attached! ");

}
else{
Delta_theta = temp_setting - current_temp;
if (Delta_theta < 0) {
analogWrite(pwmHeater, 0);
}
else {
analogWrite(pwmHeater, 255);
}
unsigned long currentMillis = millis();
if(currentMillis - previousMillis > interval) {
previousMillis = currentMillis;
RefreshDisplay() ;
}
}
ReadButtons();
}


all this time I was under a wrong impression till I found this...
http://www.eevblog.com/forum/reviews/ge ... -a1321/30/

and I also implemented this...
http://wiki.ladyada.net/tutorials/learn ... istor.html
with a rearranged Steinhart formula and all went smooth!
did not even need to seek a PID solution, the simple on-off works perfect with a little 5 degrees fluxuation only...
Highly suggest that you look into it, the hekkos 907 are cheap and reliable...and parts are everywhere...
that is my experience... for instance... http://www.ebay.com/itm/New-Soldering-S ... 1c3cf06fb8
so how have you been?
angelo e

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest