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!
Tom
Posts: 22
Joined: Sun Dec 19, 2010 11:16 pm

Re: Arduino/ATMega based Digital Soldering station

Post by Tom » Mon Sep 23, 2013 12:33 pm

It looks like based on the simulations that the current design isn't dropping much below 5v. Peak is at 4.996, the minimum is 4.968v. That's not ideal. And even if it was the proper voltage its not replicating the sine wave very well.

If you want, I have some lm358s somewhere, they might be in the box of all my stuff if you know where that was. I ordered 5 I think. They're stuck in a piece of foam in a little bag if I remember correctly.

Anyways, if you want the current etch there's a chance you and dad may be coming over today, we used 13000 gallons of water last month... Got a leak somewhere.

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

Re: Arduino/ATMega based Digital Soldering station

Post by foxmiles » Mon Sep 23, 2013 2:01 pm

Yea, it doesn't look good, but I'm not sure I trust the simulation. We get a much bigger swing than that.

I found the opamps, both the inverting and non-inverting circuits seem to work, more testing will verify. R1 (ltspice) can be increased for a wider input range (less likely to latch?). I've found several different charts of mv/temp and I'm not sure quite where it should be. I think 1-30mv should be acceptable (R1=2K). It seems to be around 5-6mv at room temp and climb well over 10mv as I heat it with a lighter. I need to hook it up to a pwm mosfet and test it properly.
Digging with a spoon will accomplish more than leaning on a shovel.

Tom
Posts: 22
Joined: Sun Dec 19, 2010 11:16 pm

Re: Arduino/ATMega based Digital Soldering station

Post by Tom » Mon Sep 23, 2013 11:44 pm

Why not measure the output of the thermocouple on the board I have?

Also setting up the circuits on a breadboard and measuring the output with an oscilloscope when applying a sine wave from my signal generator seems like a decent idea.

Also, as a thought, how does your soldering station measure the temperature? Would it be possible to find the output at certain temperatures so we have a baseline?

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

Re: Arduino/ATMega based Digital Soldering station

Post by dearangelo » Wed Oct 02, 2013 1:44 pm

I on the other hand, realized the opamp as it is refereed here http://www.bristolwatch.com/img/ther_amp.png
There is a slight difference with both of your proposed designs, allthough you claim you did follow this particular schematic, t is somewhere in the region of the pin #2, the input...
Anyways, so far I have managed to put together a working routine, with the early hillclimp approach, and added the lcd. I will try to implement the mosfet thiw weekend, I do not see any bugs so far. I would like to be able to read the room temp via the thermocouple, but I can live without it too. I have also included a variable resistor for extra adjustment... the one I had around, was a 47K, but I will get a 100K soon.
One request, can I have the complete final code that you guys are using now?

here is my current one...
mostly coming off yours...


#include <LiquidCrystal.h>

/*----------------------- DECLARATIONS --------------------------*/

int sensorValue = 0;
int value = 0;
int desiredValue = 150;
int outputValue = 0;
int ledPin = 9;
int hillclimb = 0;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

/*------------------------ SETUP --------------------------------*/
void setup()
{
pinMode(A1, INPUT);
Serial.begin(9600);
lcd.begin(16, 2);
}

/* ----------------LOOP---------------------------------------*/

void loop()
{
analogWrite(ledPin, 150);
value = analogRead(A1);
analogWrite(ledPin, 150);
sensorValue = avrValue(A1);
hillclimb = hill(sensorValue, desiredValue, hillclimb);
outputValue = map(hillclimb, 0, 1023, 0, 255);
analogWrite(13, outputValue);
/* ----------------------------------------------LCD display, screen composition -------------------------------*/

Serial.print("ver 1.00");
lcd.setCursor(0,0);
lcd.print("T>");
lcd.print(value);
lcd.print(" ");
lcd.setCursor(8,0);
lcd.print("set>");
lcd.print(desiredValue);
lcd.setCursor(15,0);
lcd.print("C");
lcd.setCursor(8,1);
lcd.print("pwm>");
lcd.print(0.392157 * outputValue,0);
lcd.print("% ");
delay(200);
}

/* --------------------------subcalcs------------------------*/

int avrValue(const int pin)
{
int sensorValue = 0;
int buffer = 0;
int count = 0;
while (count < 30){
sensorValue = analogRead(pin);
buffer = buffer + sensorValue;
count++;
delay(10);
}
return (buffer / count);
}


// Simple hill climbing algorithm, just pass it a value you're reading, the desired value and the last value it gave you like: hill(read, want, last)
// you can change the values for faster adjustment or finer control as needed.

int hill(int av, int sp, int out) {


//if the desired value is over 25 points high correct by dropping output value by 10 points
if (av >= sp+25 && out >= 26){
out = out - 10;
}
//if the desired value is over 5 points high correct by dropping output value by 1 points
else if (av >= sp+5 && out >= 1){
out = out - 1;
}
//if the desired value is over 25 points low correct by increasing output value by 10 points
else if (av <= sp-25 && out <= 998){
out = out + 10;
}
//if the desired value is over 5 points low correct by increasing output value by 1 points
else if (av <= sp-5 && out <= 1023){
out = out + 1;
}
return(out); // return the next value to try.
}

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

Re: Arduino/ATMega based Digital Soldering station

Post by dearangelo » Wed Oct 02, 2013 3:18 pm

foxmiles wrote:Yea, it doesn't look good, but I'm not sure I trust the simulation. We get a much bigger swing than that.

I found the opamps, both the inverting and non-inverting circuits seem to work, more testing will verify. R1 (ltspice) can be increased for a wider input range (less likely to latch?). I've found several different charts of mv/temp and I'm not sure quite where it should be. I think 1-30mv should be acceptable (R1=2K). It seems to be around 5-6mv at room temp and climb well over 10mv as I heat it with a lighter. I need to hook it up to a pwm mosfet and test it properly.

Hello, so, may I ask what is the conclusion, which resistort combo would give a "readable" output so to be able to display temps from around 0C or 32F...
is it possible to read from below zero, lets say 0F?
thank you fro your time
regards
angelo e

ps, why are you being so "cut throat" about being able to get 100%, to max out, the 5VDC rail, out of the lm358?

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

Re: Arduino/ATMega based Digital Soldering station

Post by foxmiles » Thu Oct 03, 2013 3:40 am

Hi dearangelo, I'll give you the info I have, though I haven't had time to do much more on it than what was in my last post.
which resistor combo would give a "readable" output so to be able to display temps from around 0C or 32F.
Honestly I don't know, I would grab a k-type thermocouple chart and play around in ltspice, then on a breadboard. (see below the next quote)
The ltspice simulations and a breadboard test indicate that a 2K R1 and 330K R2 (on the ltspice schematic, not the board) should do soldering temperatures nicely. I don't think it will do low temperatures though. Side note: In the schematic you linked R2 and R3 are replaced by R2 in my version (I eliminated the pot). Other than that I think it's the same as my inverting version. (It's a textbook inverting amplifier and a voltage follower / buffer)
is it possible to read from below zero, lets say 0F?
Absolutely, it may not be easy though. It all depends what the voltages do, you may need a dual-supply opamp (with a negative voltage supply) as the thermocouple voltage will drop below 0V around 0C. Lets say it amplifies it to -2v to +2v then set up the second opamp set up to offset that voltage to 0.5-4.5v (so the adc can read it). I'm just thinking how I would approach this problem, I don't know if it would work. It may be possible to introduce some sort of an offset voltage to the thermocouple in order to avoid a dual supply, but I haven't looked into that either. Side note: the range of a k-type thermocouple (in the chart I looked at) is -270C to 1370C.

I'm going to mess with this, but it may be a few weeks before I have time.
ps, why are you being so "cut throat" about being able to get 100%, to max out, the 5VDC rail, out of the lm358?
I'm actually really not trying to max anything out, in fact I'm trying very hard to avoid that. What I am trying to do is to make sure that the range we need fits within the range of the opamp while at the same time amplifying it enough to be easily read by the adc. The problem we are having (with the current board) seems to be the opamp saturates way before we reach solder melting tempreatures, which is a big problem. We need a nice linear amplification of the very low voltage of the thermocouple to something we can read with the adc. The adc is 10 bit or 1024 points between 0 and 5v (4.88mv/bit). It's not super critical to this project, but if my useful range falls between 2-3v I waste most (4/5) of the adc's range, and loose accuracy. Again, it's not a big deal, but as long as I've got 1024 steps I'd like to use them.

Side thoughts:
It shouldn't be a huge problem to calibrate against a chart, I'll look into this at some point. The big problem with calibration is there are other variables that affect it. You can't use a thermocouple alone to take an accurate room-temperature reading as room temperature (actually every other junction temperatures in the op-amp - thermocouple - ground circuit) is in the equation to calibrate a thermocouple. Some light reading: http://www.omega.com/temperature/Z/pdf/z021-032.pdf.

As I recall the atmega's have an internal temperature sensor that might supply an acceptable calibration reading, but I haven't messed with reading it (yet). At the temperatures we're working with I don't think a slight deviation will hurt anything. (but a room temp reading would improve accuracy)
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 Oct 03, 2013 4:51 am

foxmiles wrote: ...
Side thoughts:
It shouldn't be a huge problem to calibrate against a chart, I'll look into this at some point. The big problem with calibration is there are other variables that affect it. You can't use a thermocouple alone to take an accurate room-temperature reading as room temperature (actually every other junction temperatures in the op-amp - thermocouple - ground circuit) is in the equation to calibrate a thermocouple. Some light reading: http://www.omega.com/temperature/Z/pdf/z021-032.pdf.

As I recall the atmega's have an internal temperature sensor that might supply an acceptable calibration reading, but I haven't messed with reading it (yet). At the temperatures we're working with I don't think a slight deviation will hurt anything. (but a room temp reading would improve accuracy)
...
A month ago, and before I found your postings, I did buy one controller from ebay, there are basically two kinds being offered, one with a 7 seg led and one with an lcd display, I bought the second one. This particular design utilizes a thermistor, on the board, I have not had the time to trace its connections, but I should do it one of these days...
in any case we can just calibrate it with another heat source, around the melting temp of the soldering compound, that should be enough. I like that you are really exploring the opamp properties in this implementation, my architectural education barely allows me to follow all this, but I want to teach my self, only out of curiosity... hehehe living in Greece in 2013 means we are in a destroyed economy, where real estate is a burden. Thank you very much for taking the time to explain all this to me, I feel deeply obliged.
b r angelo e

btw that controller is driving me nuts, it tends to fall asleep all too often, becoming unusable, the code is crap, not to say that it does not reach top temp, around 400C that easily, it struggles, for that reason, I am planning on winding a transformer with a 20V/5A output, to make sure I have the power... them asian guys, even used a grinding tool to take off the markings of the chip, it is some kind of 28 pin atmega type

here is some about temp measure ability of atmegas...
http://playground.arduino.cc/Main/Inter ... tureSensor
not sure how it could be used...

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

Re: Arduino/ATMega based Digital Soldering station

Post by foxmiles » Thu Oct 03, 2013 5:26 pm

Yea, I've considered a thermistor on the board, it's probably the way to go, the internal one would be room temp on boot and should stay within ~10C, but it requires some work to read, so I might just read it once on boot and assume it will stay close enough (it would improve the accuracy without additional parts). We'll see. First we need it to work, then we'll worry about additional features. I'm sure a new board will be needed, so we'll look into a thermistor and any other features we think of before then.

Curiosity is my motivation too, I don't have a background in electronics. I like to fix things and the more I learn the better I am at it. I'm just getting into opamps now, so I'm playing with them on this project more than perhaps is necessary. I'm pushing the limits of my understanding too, but that's how I learn best. It's fun when something "clicks".

I love chips with the markings removed, if someone's going to steal a design they'll just make it work with whatever chip they're used to, so it really only hurts someone trying to solve a problem. You may be able to figure out the pinout on your controller and replace the chip or something. I'm guessing, but it's probably Atmel or PIC.

You could watch for old laptop power supplies, they tend to be around the range we're looking for (my laptop's is 19.5v, 3.35a, 65w) you would need a bridge rectifier and some filter caps if you go the transformer route.

Latest untested code: I've changed it to not scale the adc readings, made a few other optimizations here and there, and add a bunch of documentation. It may not work.

Code: Select all

/*
Soldering Station designed by Thomas and Stephen Evans.
We read a thermocouple and a potentiometer, PWM a mosfet,
and display status to a 16x2 LCD

*/
// define pins and save memory rather than have them as int's
#define TC_PIN A2 // input from thermocouple amp
#define SET_PIN A0 // pot for setting temperature
#define OUT_PIN 3 // pin output MOSFET is connected to. Must be PWM capable
#define MAX_PWM 255 // max pwm setting
#define MAX_TEMP 1000 // max temperature will not excede this even if set higher. (note this is an adc reading, not F or C)


int setting = 0;
int reading = 0;
int pwm = 0;

#include <LiquidCrystal.h>

LiquidCrystal lcd(A5, A4, 13, 12, 11, 10); // (rs, enable, D4, D5, D6, D7) see liquidcrystal example for more 

void setup() {
  
  // Setup Our Pins
pinMode(OUT_PIN, OUTPUT);
pinMode(SET_PIN, INPUT);
pinMode(TC_PIN, INPUT);

//Initialise LCD
lcd.begin(16,2);
lcd.print("Solder Station");
lcd.setCursor(0,1);
lcd.print("trythistv.com");
delay(2000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("SET T/C PWM");

// Not using pin 11, I'll have to look up the settings for pin 5. Falling back to analogWrite.
// See the atmega328p Datasheet for more information on the following:
//  TCCR2A = _BV(COM2A1) | _BV(WGM20) | _BV(WGM21); // COM2A1 = Set output compare Bit (needed for pwm output), Set WGM20 & WGM21 Bits for Fast PWM Mode
//  TCCR2B = _BV(CS20); //clock select CS20 is max speed, about 62khz w/fast pwm mode on a 16mhz arduino
}

void loop() {
  // put your main code here, to run repeatedly:
display(setting/2, 0, 1); // remember these are adc readings, not actual temperatures! They are
display(reading/2, 4, 1); // scaled to 0-511 (when we get it working good we'll work on calibration)
display(pwm, 8, 1);       // actual pwm value

  setting = map((analogRead(SET_PIN)), 0, 1023, 1023, 0); // read the Pot. We also use map() to reverse the pot's direction 
                                                          // because that's how it's wired on the board for now
  delay(10); // let ADC settle
  reading = analogRead(TC_PIN); //read the TC. I've gone back to full resolution and only scaling for display. don't know if it will work
  pwm = hillclimb(setting, reading, pwm); // get the new pwm value
  analogWrite(OUT_PIN, pwm);
  //  OCR2A = pwm; //to use fast pwm mode (use pin 11 only) (62khz)
  
  //Make sure we don't excede the max temp setting. this loop forces the mosfet off while the TC exceeds the limit.
  while (reading >= MAX_TEMP){
   reading = analogRead(TC_PIN); // keep reading the input so we can exit the loop.
   analogWrite(OUT_PIN, 0); // force the mosfet off
   lcd.setCursor(8,1);
   lcd.print("XXX"); // let us know it's doing something
   delay(200);
  }
  
  delay(75); // slow things down a bit, eliminate or adjust this as you add code, serial likes it (basically for debugging)
}


/*Simple hillclimbing function intended for pwm use. s and r should be int's with values 0-1023, o is 0-255. output is an adjusted value constrained to 0-255
 We subtract where we are (r) from where we want to be (s) divide by 8 so we don't just bounce off the limits then add our current 
 output (o) The closer to where we want to be the smaller the changes we make. Then make sure out result is between 0 and 255 and 
 return the result
 example 1: s=512, r=0, o=0, we would return 64, with o=64 we would return 128 and so on we make big steps as the difference is large
 example 2: s=512, r=500, o=100, we would return 101, with o=101 we would return 102 and so on we make small steps as the differences are small
 example 3: s=512, r=600, o=100, we would return 89, then 78...it reduces the value of o when r exceeds s.
 o is going to vary around, it's just the pwm setting, it's normal.
 */

int hillclimb(int s, int r, int o) // s=setting, r=reading, o=pwm (current value)...returns adjusted pwm value
{
  o = ((s - r)/8) + o; // this line does all the work. adjust /8 lower (/6-/2) for faster response / quicker swings (and possibly lower temperature stability?)
 
  // make sure result is within pwm range and return the limit (0 or 255) if it's out of range:
  if (o >= MAX_PWM){
    return MAX_PWM;
  }
  if (o <= 0){
    return 0;
  }
 
  return(o);
}

// This function takes a 1 to 3 digit number and displays it properly where we want it
void display(int num, int row, int col) {
  // mulitple number Display code
  if (num >=100) {
    lcd.setCursor(row, col);
    lcd.print(num);
  }
  else if (num >=10) {
    lcd.setCursor(row, col);
      lcd.print(" ");
    lcd.print(num);
  }
  else{
    lcd.setCursor(row, col);
      lcd.print("  ");
    lcd.print(num);
  }
}
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 Oct 03, 2013 6:50 pm

Dear Tom, it is Tom isn't it?
ok, here is what I guthered from a little looking around, in order to focus better on the issue of the op amp.
the parameters are, the top temp, its volt output, after being amplified, should not exceed 5 volts, input limitations of the atmega.
the low, it would be nice to be able to start from room temp... not really nesessary... we 'll see.
so for 1 C the probe output (K type), and opamp input is 41mV 0,0041V, and for tops, lets indulge, 500 C, the output is 0,0205V.
for 1C x 41mV x 230 = 0,00984V opamp low output, low indeed
for 500C x 41mV x 230 = 4,92V -----//------- high and clear...
there should be issues on the display in the lows... not a functional issue.

so an R1 = 10K, and R2 = 2.3M sets the ratio to sutisfy the above conditions.

*note, in the driver that I already bought, that uses similar components, lcd etc, it does not display the current temp, just some percentage of the covered difference... some way that they did niot have to show the lows... I guess.

also, here there is
http://www.daycounter.com/Calculators/O ... ator.phtml
what it says, and the schem, shows a single, or just the one opamp being utilized... what do you think about it? is it of "lesser" fidelity?
your opinion?
also, in another design, the Russian design as I call it, http://macoprojects.blogspot.gr/2010/09 ... ation.html
the design utilizes half of the double LM358N opamp.

also, I tried changing my opamp setting to follow your resistor suggestion, but it did not work. I went back to the EXACT schmatic of http://www.bristolwatch.com/ele/thermal ... lifier.htm
and I used an 1.2M and a 10K without the pot, and it works well, the ratio might be alittle off, but I did not have a 1M at hand.
but.... I will try setting up the scheme I came up, that I talked about, above, and let you know...
I value very much your thoughts about it, you seem to know the subject very well, while, I am an amature by all means...


thank you for your time
regards
angelo e.


should I narrow the spread? from 1 - 500 down to 1 to 350 or 400? that is how others do it... and I was wondering why...

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 Oct 03, 2013 7:04 pm

...about the calibration thru the thermistor, it is something that will be useful perhaps only once or twice.
the room temperature should have no impact on the tip of the gun, I do not see how it could.

once you have the ΔV that is missing for the probe to be true, then you can "inject" the volts needed, and forget about it, till next time you will need to re-cal due to usage and drifting... it should be a pretty constant system.

Another thought to add, I will be using a zener diode, as a voltage limiter, for safety reasons at the op amp's output.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests