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 » Fri Oct 04, 2013 1:32 am

I'm Steve, I'm working with Tom on this (I'm his brother). A few thoughts:

As long as the opamp is supplied from the 5v rail and ground there is no need to worry about it's output exceeding 5v. The lm358 isn't a rail to rail opamp, so it will never go all the way to 0 or 5v, it will be somewhere in between. (unless you run a dual supply like +12v / -12v, then you could get 0 and 5) The second opamp is just a voltage follower, whatever is on the input you get on the output, it buffers the first op-amp. It's cheap insurance against noise / interference from the adc pin and everything in between. Note: if we're working with different op-amps or voltage supplies the resistor values may be very different.
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.
According to the k-type chart 1C should be 0.039MV not 39MV. Yikes! Too many zeros. I think it would be 0.000039V (I'm not arguing about 39 to 41, it's just what my chart said, it's minuscule) you're right on the 500C (my chart says 20.644mv or 0.020644V) I'm really only interested in soldering temperatures (100-500C ideal, 200-400C acceptable), that's where it needs to work well. If it works outside that great, but it's really not very important to me.

My breadboard tests have shown (considerably) higher mv readings than the chart specifies, so I'm not sure what to make of it. You might try the non-inverting design (I think it's a lot like the Russian design) in the ltspice files linked a few posts back. It may work better at lower temperatures, perhaps even down around room temp. It may need some resistor tweaks. If you don't have ltspice it's free from linear technologies (google it). It runs on windows, but I think it works in linux under wine.
NIAmp.jpg
Non-Inverting Amp
The reason for the extra temp sensor is to compensate for the "other" thermocouple(s). A thermocouple is just two different metals (wires) joined together, there is the joint we want to read and one (or more) at the other end of the wire, that will produce a voltage changing with temperature (generally room temperature). I'm not sure how much difference it makes, but that's what it's for.

I learn more when things don't work as expected than when they do, so have fun!
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 » Fri Oct 04, 2013 5:20 am

Thank you for pointing out that the max voltage can never exceed 5v as long as the rail is as such. I will wrap it up for the time, and move onto the adjustments via the software, ie formulas and stuff, in order to calibrate it.
I want to see how it actually works. I have made the "hefty" 5A trafo as I said earlier, and so I will have enough guts for speed and maintaining the temp. I will let you know of the outcome, I have to setup a breadboard and take measurements of the opamp in action, you are right, but it will have to wait.
I have one question, that I have not had a clear answer in my head yet, the opamp feeds xmvolts the pin# A1 (or whatever), what do I see as a reading? volts? is the reading maxing out at 1023 with max voltage in the pin being 5V ? is that it? so with an ideal opamp output, 0-5V for. would give a reading 0-1023? is that it?

any quick fix to that question?
Thank you so much for being ... helpful and kind...
best r
angelo e

* you are right about 1C output, it is 41μV and not 41mV.... 0.0000041V wow!!!

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

Re: Arduino/ATMega based Digital Soldering station

Post by dearangelo » Fri Oct 04, 2013 5:49 am

foxmiles wrote:
...
The reason for the extra temp sensor is to compensate for the "other" thermocouple(s). A thermocouple is just two different metals (wires) joined together, there is the joint we want to read and one (or more) at the other end of the wire, that will produce a voltage changing with temperature (generally room temperature). I'm not sure how much difference it makes, but that's what it's for.
...


perhaps pass to eeprom, the very first reading of the ic temp? as a room temp?
'cause later on, both, the ic and the thermistor, would be slightly hotter ..
or log the ic's temp and average it calibrate it and use that as steady temp...

or just take for granted that room temp is about 20-22C and use it without questioning...

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

Re: Arduino/ATMega based Digital Soldering station

Post by foxmiles » Fri Oct 04, 2013 12:42 pm

I have made the "hefty" 5A trafo as I said earlier
Cool! I've never made a transformer. Sounds like it will do the trick!
with an ideal opamp output, 0-5V for. would give a reading 0-1023? is that it?
Yep, that's it. Just multiply by 4.88 to get a MV reading (5000MV / 1024Steps).
As a side note you can apply a different voltage to the aref pin to get different step sizes. The adc will divide the voltage by 1024, there are limits of course, but it has it's uses. For example: apply 2.56V to aref and you have exactly 2.5mv steps from 0 to 2.56V.

As far as the calibration temp goes, either of your suggestions would work or you could read it on each startup (in the setup portion), assume it's right, and store it in a variable. For now I'd just assume 20-22 like you said. If the calibration is in the math as a variable rather than being hard-coded It would be easy to add something later to actually read and adjust it.

P.S. I breadboarded both the inverting and non-inverting designs (just the amp) last night and they both worked for me, I'm scratching my head as to why they're not working for you.
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 » Fri Oct 04, 2013 3:30 pm

foxmiles wrote: ...
As a side note you can apply a different voltage to the aref pin to get different step sizes. The adc will divide the voltage by 1024, there are limits of course, but it has it's uses. For example: apply 2.56V to aref and you have exactly 2.5mv steps from 0 to 2.56V.
--interesting... I 'll keep it mind
foxmiles wrote: As far as the calibration temp goes, either of your suggestions would work or you could read it on each startup (in the setup portion), assume it's right, and store it in a variable. For now I'd just assume 20-22 like you said. If the calibration is in the math as a variable rather than being hard-coded It would be easy to add something later to actually read and adjust it.
--Unfortunately, as I looked into it more carefully today, my arduino emplyees an atmega 168, that does not have the capability, while the 168A version does have an inner temp option thing...
so, I will get on with a simple thermistor, but it will have to wait... for the time being.
foxmiles wrote: P.S. I breadboarded both the inverting and non-inverting designs (just the amp) last night and they both worked for me, I'm scratching my head as to why they're not working for you.
I followed both of your designs, the one in the pcb, and the one in the simulator, both of them did not give me anything consistant, so I returned to the one proposed in that site a typical one... with a 1.2M and a 10K...

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

Re: Arduino/ATMega based Digital Soldering station

Post by foxmiles » Tue Oct 22, 2013 1:55 am

Sorry I didn't reply, was out of town for a bit. I don't know what's wrong (or different) with my circuit, I'll play with it when I have a chance, but I've got some stuff to finish up before it gets cold here.

I wouldn't worry too much about the temperature compensation thing at the moment, especially if you're using an arduino. Worst case you could have a simple way to input the current room temperature (or re-flash) if it varied a lot from the default room temp (for testing purposes). I'm thinking farther ahead than perhaps I should, I want to have temperature compensation covered before I start doing another board, but I really should concentrate on getting the current bugs worked out before adding features.

I'm not sure if I understand it right, but 20C should be room temp (68F). It may vary between say 15C and 30C (59F and 86F), at 20C a 15C discrepancy is a 75% error, but at 300C it's only 5%. So I may be trying to correct a smaller error than I originally thought (<5%), considering we're operating at much higher temperatures. I might be wrong here, it might be a bigger problem than that, another thing for to look into.
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 » Mon Oct 28, 2013 11:23 am

Hi Steve!
this is written from scratch, I could not figure out the reason of the terrible inaccuracies while applying current, and so I did built it up, using the pot to set the pwm directly and see how it goes...
anyways, this is as simple as it gets, from this point on, I can go on and make it "beautiful" with bells and whistles...
Of course I am going to have to outsmart the systems inertia and try to smooth out the bouncing problem (heat transfer and T/C inbuilt delay problems)
I would appreciate your input...
go ahead and change the i/o's and try it on your board....
b regards
angelo e

Code: Select all

#include <LiquidCrystal.h>
#define TC_PIN A1 
#define POT_OUT A0
#define OUT_PIN 11
#define OUT_LED_PIN 13
int reading = 0;
int setting = 0;
int lcdLed = 9;
int pwm = 255;


LiquidCrystal lcd(12, 10, 5, 4, 3, 2);
void setup() {
  pinMode(A1, INPUT);
  pinMode(A0, INPUT);
  pinMode(A1, INPUT);
  pinMode(11, OUTPUT);
  analogWrite(lcdLed, 150); // it is a pwm output therefore this can be fiddled with for  brightness
}
void loop() {
  reading = analogRead(A1);
  setting = analogRead(A0)/(1024/255);//to convert to 255 scale, I sarted out using this as a pwm value... now obsolete
  lcd.begin(16, 2);
  lcd.setCursor(0,0);
  lcd.print(reading,DEC);
  lcd.setCursor(0,1);
  lcd.print(setting,DEC);
  delay(2000); // without it, it gets ugly with terrible bouncing effect....


  TCCR2 = _BV(WGM20) | _BV(COM21) | _BV(COM20) | _BV(WGM21) | _BV(CS20); // this is taylored for the atmega8
  OCR2 = pwm;    // for ocr2=255 halts the output while 0 maxes it out, so there is a need to move further and control the pwm itself (?)
                 // for this is really a timer that toggles the pwm on and off, on a preset via the registers RTFM...

  if (setting - reading>0)
  {  
    if (setting-reading>3)  //need to fiddle with it for to buffer out the bouncing effect... value of (3)
    {                       // I will add a second pot to control this (3) thing to see where it gets me..
      pwm=0;                // all this is due to the delay of heat transfer as well as the response of the T/C.
    }                       // hate to get involved in further math modeling, that could be of course done... time/rise calcs etc...
    else   
    {
      pwm=((setting-reading)/3)*255;
    }
  }
  else
  {
    pwm=255;
  }
}
BTW. Thank you for pointing me to the direction of using the registers for setting pwm time ON etc... Really Short and efficient... they don't teach that in architecture schools lol

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

Re: Arduino/ATMega based Digital Soldering station

Post by foxmiles » Sat Nov 02, 2013 2:32 am

Cool, I think I'll build it up on a breadboard when I have chance. It'll be at least a week though. as far as inaccuracies when applying current it could be inductance. We're measuring very small voltages, so even a little EMI could cause problems.

One suggestion I have: you mentioned a bouncing effect that was helped with a 2000ms delay. It might be worth doing some averaging / smoothing. instead of reading the adc once read it 10 times, average and return a value. I can't test this right now, so it might not work, but it may give you an idea:

function called like:
reading = averageADC(TC_PIN);

In case you haven't played with functions yet, it would go below the last closing } in the code (outside the loop) and you would call it from inside the loop.

Code: Select all



// Function to read an adc pin and average it over ~ 10 readings, approx 200MS in this case.
int averageADC(int pin) {
  int o = 0;                                     // output variable.
  for(int x=0; x < 10; x++) {         // I think this should be 10, unless it's supposed to be 9, it's late.
    delay(20);                                  // multiply by 10 to get actual delay time of this function, replace with delayMicroseconds(10); for minimum delay.
    o = o + analogRead(pin);         // I think "o += analogread(pin);" would work here (unless I'm confusing languages)
  }
  return o / 10;                              // return an average of 10 adc reads over 200MS
}


Also you might need a small delay (10 microseconds comes to mind - delayMicroseconds(10);) between adc reads, so add a delay, spread them out in the code a little, or call this function. I'm not sure where I read that, something about letting the adc "settle". May not be true.
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 » Mon Nov 04, 2013 10:22 am

Hello Steve, this is the best I can come up with... so far. The averaging works, the code is short, and runs well, I can not climb higher than 430 or so, assuming it is because of the little trafo I have it hooked on, only 3. something Amps... I expect a big regulator chip from China to complete my 5A old fashioned trafo and see if I can get higher in degrees... the readout of the T/C is still showing a little jumpy, but it is ok.

Code: Select all

#include <LiquidCrystal.h>
#define TC_PIN A1 
#define POT_OUT A0
#define OUT_PIN 11
#define OUT_LED_PIN 13
//int reading = 0;
int setting = 0;
int lcdLed = 9;
int pwm = 255;
LiquidCrystal lcd(12, 10, 5, 4, 3, 2);

void setup() {
  TCCR2 = _BV(WGM20) | _BV(WGM21) | _BV(COM21) | _BV(COM20) | _BV(CS20)| _BV(CS21)| _BV(CS22); // this is taylored for the atmega8 and have revised it for fast pwm clock output, to have better response and narrower flax...
  pinMode(A1, INPUT);
  pinMode(A0, INPUT);
  pinMode(A1, INPUT);
  pinMode(11, OUTPUT);
  analogWrite(lcdLed, 150); // it is a pwm output therefore this can be fiddled with for  brightness
  lcd.begin(16,2);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("SET   T/C");
}

void loop()
{
  if (analogRead(A0)-avrReading(A1)>1)
  {OCR2=0;
  }
  else
  {OCR2=255;
  }
  display(analogRead(A0), 0, 1);          
  display(avrReading(A1), 6, 1); 
}

void display(int num, int row, int col) {
  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);
  }
}

int avrReading(const int A1)
{
  int reading = 0;
  int buffer = 0;
  int count = 0;
  while (count < 10){                 
    reading = analogRead(A1);     
    buffer = buffer + reading;             //perhaps different averaging for display than calc...
    count++;
    delay(10);
  }
  return (buffer / count);
}

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

Re: Arduino/ATMega based Digital Soldering station

Post by dearangelo » Fri Nov 08, 2013 2:02 pm

Hello again, yesterday I hooked it up to my bench psu, and at a 20VDC output, it did not draw above 1.2A nad it got hot as hell!!
my lesson? those switching Chinese psu's that we use for laptop charging, are worthless, I have been using a 19VDC, 3.4A max output, and it barely got the tip hot enough to melt the metal, there is a serious difference between name and actual output value!!!!! seriously. Another thing, those by my conservatove calcs, would give out about 19VDC*3.4A= over 60W!!!!!! I was surprised...but in real life, the pensil hardly draws 1.2A@20VDC=24Watts... something is fishy here... my advice, a noce old fashioned trafo at 20Vdc, 2A ability, would rock this thing!
switching as far as real power output, are worthless...

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests