Soldering station help

hi everyone,

Please bare with me i am still trying to learn electronics.

i am using this schematic: https://hacksterio.s3.amazonaws.com/uploads/attachments/384645/solder_station-13d13ff34fdb4191a518450565d8851d_Mi0esKciMT.png

i am trying to read the temperature from a soldering iron which has a thermocouple in series with the input current and I read that you cannot read the temperature using MAX6675 while there is voltage on the heater so what i am trying to do is stop the current to the iron while i read the value from the thermocouple using the IRF520 mosfet driver module. However I am unable to set the voltage to zero when the mosfet is turned off (input pin is LOW). When I use a voltmeter i still see a voltage of 5.4v (voltage only drops from 6v to 5.4v) which means the temperature cannot be read while there is voltage to the iron.

any help would make my day :slight_smile:

cheers

You might have read that, but missed the context. The thermocouple MUST be electrically insulated from the metal of the iron.
Paul

Give us maximum information about your soldering iron (link to seller's site, photo, type of connector, wiring diagram, all you have).

Hi,

It's a JBC c245 clone. Similar to the one used in the video by GreatScott DIY Soldering Station - YouTube

Thanks for your help

Who told you that you cannot measure temperature at the same time as heating?
The author of the video measures and other people measure.
It's just that the heater and thermocouple have a common lead that connects to ground.

i will elaborate as much as i can.

6 volts from power supply into v+ in/v- in of the irf520 mosfet
v+ out and v- out from irf520 mosfet go into the red wire of the iron (heater) and black wire of the iron (ground)
the thermocouple max6675 + connection is connected to the blue wire of the iron (heat sensor) and the - connection is connected to the same black wire of the iron (ground) as the wire used for V- out of the mosfet
the code basically sends a HIGH signal to the SIG pin of the mosfet to turn on power to the iron, when this happens the temperature read is zero. when i switch off the power supply to the mosfet input completely the thermocouple read the iron temperature ok. if i measure the voltage while the mosfet signal is LOW i can still see there is voltage but i can't work out why that is since the mosfet is supposed to be turning off output voltage when in LOW. i guess my problem is while there is current to the heater i cannot read the temperature and i am not able to switch off current to the iron completely using the mosfet. I must be doing something wrong. There are tons of projects online from people who built soldering stations.

below is my code:

//-- Libraries include

#include <Wire.h> 

#include <LiquidCrystal_I2C.h>

#include "max6675.h"    //thermocouple driver

#include "sav_button.h" //buttons library

#include "EEPROM.h"     //Memory Storage

#include <SoftPWM_timer.h>

//-- Libraries definition

//-- MAX6675 Thermocouple driver------------

const byte pinTcSO = 7;

const byte pinTcCS = 8;

const byte pinTcCLK = 9;

// -- movement sensor

const byte pinTilt = 12;

MAX6675 tc(pinTcCLK, pinTcCS, pinTcSO);

//-- PushButtons-----------------------------

const byte pinButtonUp = 4;

const byte pinButtonDown = 5;

const byte pinButtonOk = 6;

SButton Up    (pinButtonUp, 50, 0, 800, 100);

SButton Down  (pinButtonDown, 50, 0, 800, 100);

SButton Ok    (pinButtonOk, 50, 1000, 4000, 250);

//-- Types definition

enum myUnits {

  CELSIUS,

  PERCENT

};

//-- Constatnts definition

#define control 13 // pin that controls the MOSFET

const uint16_t minTemp = 50;//temperature minimum

const uint16_t maxTemp = 500;//temperature maximum

const uint16_t measInterval = 500; //measurement interval ms. Must be over 500

const uint16_t readInterval = 10000; //measurement interval ms. Must be over 500

const uint16_t measSleep = 60000;

const byte shortPressStep = 1; //temperature change step on button's short press

const byte autoPressStep = 5; //temperature change step on button's long press

const int  tempAddr = 0; // eeprom addresses

           

//-- Variables definition

uint16_t reqTemp = 60; //required temperature(celsius) from minTemp to maxTemp in temperature mode

uint16_t standbyTemp = 100;

uint16_t lastTemp;

uint16_t temp;         //Heater temperature

uint32_t measTime = millis(); 

uint32_t readTime = measTime; 

uint32_t sleepTime = measTime;

boolean isChanged = false; // is any changes

boolean standBy = true; //standby mode on/off

boolean heatingOn = false;

char messageLine1[21];

char messageLine2[21];

#define SCREEN_ADDRESS 0x27 ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32

LiquidCrystal_I2C display(SCREEN_ADDRESS, 16, 2);

void displayTemp(){  

  display.setCursor(0, 0);    

  sprintf(messageLine1, "%s    ", "TMP:");

  display.print(messageLine1);

  display.setCursor(8, 0);

  sprintf(messageLine1, "%i%c      ", temp, (char)223);  

  display.print(messageLine1);

   

  display.setCursor(0, 1);

  sprintf(messageLine2, "%s    ", "SET:");

  display.print(messageLine2);

  display.setCursor(8, 1);

  sprintf(messageLine2, "%i%c      ", reqTemp, (char)223);  

  display.print(messageLine2);  

}

void displayText(String text, boolean showTemp){    

  display.setCursor(0, 0);

  sprintf(messageLine1, "%-17s", text.c_str());

  display.print(messageLine1);

  display.setCursor(0, 1);

  if (showTemp){    

    sprintf(messageLine2, "%s   ", "TMP:");

    display.print(messageLine2);

    display.setCursor(8, 1);

    sprintf(messageLine2, "%i%c      ", temp, (char)223);  

    display.print(messageLine2);    

  }else{

    display.print(F("                "));

  }

}

// Read config from EEPROM

void readConf(){

  uint16_t t;

  EEPROM.get(tempAddr, t);

  if (minTemp<=t && t<=maxTemp) reqTemp = t;  

}

//save config to EEPROM

void saveConf(){

  EEPROM.put(tempAddr, reqTemp);

  displayText("Saved.", false);

  isChanged = false;

  delay(3000);

}

//set iron temperature

void setTemp(){

  if (temp>=reqTemp){

      digitalWrite(control,LOW); // Turn the MOSFET Switch OFF    

      heatingOn = false;

      Serial.println("powering off heater ...");  

  }else {

      digitalWrite(control,HIGH); // turn the MOSFET Switch ON    

      heatingOn = true;

      Serial.println("powering on heater ...");  

  }

}

void unitsUp(byte vStep){

  if ((reqTemp + vStep) <= maxTemp) {

    reqTemp += vStep;

    isChanged = true;

  }     

}

void unitsDown(byte vStep){

    if ((reqTemp - vStep) >= minTemp) {

          reqTemp -= vStep;

          isChanged = true;

    }    

}

void standByMode(){

  lastTemp = reqTemp;

  reqTemp = standbyTemp;  

  standBy = true;  

}

void setup() {  

  Serial.begin(9600);

  pinMode(pinTilt, INPUT_PULLUP);

  pinMode(control,OUTPUT);// define control pin as output

  Up.begin();

  Down.begin();

  Ok.begin();

    

  readConf();

  display.init();

  display.backlight();

  

  //---- Soft PWM-----------------------------------

  digitalWrite(control,LOW); // turn the MOSFET Switch ON

  //------------------------------------------------

  standByMode();

}

void loop() {

  if ((millis()-readTime) > readInterval){

    Serial.println("checking iron state ...");  

    readTime = millis();

    if (heatingOn == true){

      heatingOn = false;

      //SoftPWMSet(pinHeater, 0);

      digitalWrite(control,LOW); // Turn the MOSFET Switch OFF    

      Serial.println("turning off iron for reading temp ...");  

    }else{

      temp = tc.readCelsius();

      Serial.print("Temp=");

      Serial.println(temp);  

      heatingOn = true;

      digitalWrite(control,HIGH); // Turn the MOSFET Switch ON    

      //SoftPWMSet(pinHeater, 255);

    }

  }

  if ((millis()-measTime) > measInterval){

        //temp = tc.readCelsius();

        //temp = 200;

        measTime = millis();

        //setTemp();

        if (digitalRead(pinTilt) == LOW){

          Serial.println("iron on");                    

          reqTemp = lastTemp;

          sleepTime = millis();

          standBy = false;                    

        }else{

          if ((millis()-sleepTime) > measSleep && standBy == false){

            sleepTime = millis();

            standByMode();

            Serial.println("SLEEPING..."); 

          }

        }

        if (standBy == false){          

          displayTemp();    

        }else{

          displayText("STANDBY...", true); 

        }

  }

  switch (Up.Loop())

  {

  case SB_CLICK:

    if (standBy == true)

    {

      reqTemp = lastTemp;

    }

    sleepTime = millis();

    standBy = false;

    unitsUp(shortPressStep);

    break;

  case SB_AUTO_CLICK:

    if (standBy == true)

    {

      reqTemp = lastTemp;

    }

    sleepTime = millis();

    standBy = false;

    unitsUp(autoPressStep);

    break;

  case SB_NONE:

    break;

  case SB_LONG_CLICK:

    break;

  }

  switch (Down.Loop())

  {

  case SB_CLICK:

    if (standBy == true)

    {

      reqTemp = lastTemp;

    }

    sleepTime = millis();

    standBy = false;

    unitsDown(shortPressStep);

    break;

  case SB_AUTO_CLICK:

    if (standBy == true)

    {

      reqTemp = lastTemp;

    }

    sleepTime = millis();

    standBy = false;

    unitsDown(autoPressStep);

    break;

  case SB_LONG_CLICK:

    break;

  case SB_NONE:

    break;

  }

  switch( Ok.Loop() ){

      case SB_CLICK:  

        if (standBy==false && isChanged==true){               

          saveConf();

        }                                    

        break;

      case SB_LONG_CLICK:  

         standBy = !standBy;    

         if (standBy == false){ 

            displayText("Powering on...", false);

            reqTemp = lastTemp;

            sleepTime = millis();

            delay(3000);                   

         }else{            

            standByMode();

         }

                         

         break;

        case SB_AUTO_CLICK:

            break;

        case SB_NONE:    

            break;

    }    

}

link to the schematic https://hacksterio.s3.amazonaws.com/uploads/attachments/384645/solder_station-13d13ff34fdb4191a518450565d8851d_Mi0esKciMT.png

Let's all take turns.
Draw a diagram of your project. Use any online (EasyEDA, draw.io ...) or desktop tools. You can even draw the diagram by hand and take a nice photo. This will be clearer than a verbal description. For you and for us.
The diagram you are linking to does not quite fit, this is a diagram of a finished device, the heater and thermocouple are not visible there. Draw a diagram of your connections.
I think I know why your circuit is not working, but you should understand it.

Checkout the code according to the forum rules.

After that, it will be possible to speak more substantively.

Do you know what voltage is needed for your soldering iron heater?

yes the voltage should be 26v with a current of 6amps, however i managed to destroy 2 iron tips when it turned red hot. So at the moment i am experimenting with low voltage.
I will post a drawing my project shortly, thanks for all the assistance.

Hi,
I think you should begin writing your own code.
That code you are using is full of stuff that makes following the flow fairly difficult.

First write some code to read the thermocouple.
The some code to PWM the element with a pot.

Then look at some code to connect the two.
Ideally use PID to control the temperature.
Forget about a display, use IDE monitor while developing, then add some BASIC display figures.

We need to see your circuit diagram, reverse engineer what you have.

Tom... :smiley: :+1: :coffee: :australia:

here is a picture of the wiring.

i have followed TomGeorge suggestion and have removed everything except the basic code that reads the thermocouple. Here it is:

//-- Libraries include
#include <Wire.h> 
#include "max6675.h"    //thermocouple driver


//-- Libraries definition
//-- MAX6675 Thermocouple driver------------
const byte pinTcSO = 7;
const byte pinTcCS = 8;
const byte pinTcCLK = 9;

MAX6675 tc(pinTcCLK, pinTcCS, pinTcSO);

//-- Constatnts definition
#define control 13 // pin that controls the MOSFET

const uint16_t measInterval = 500; //measurement interval ms. Must be over 500
const uint16_t readInterval = 10000; //measurement interval ms. Must be over 500
           
//-- Variables definition
uint16_t reqTemp = 60; //required temperature(celsius) from minTemp to maxTemp in temperature mode
uint16_t standbyTemp = 100;
uint16_t lastTemp;
uint16_t temp;         //Heater temperature
uint32_t measTime = millis(); 
uint32_t readTime = measTime; 
uint32_t sleepTime = measTime;

boolean heatingOn = false;

//set iron temperature
void setTemp(){
  if (temp>=reqTemp){
      digitalWrite(control,LOW); // Turn the MOSFET Switch OFF    
      heatingOn = false;
      Serial.println("powering off heater ...");  
  }else {
      digitalWrite(control,HIGH); // turn the MOSFET Switch ON    
      heatingOn = true;
      Serial.println("powering on heater ...");  
  }
}

void setup() {  
  Serial.begin(9600);

  pinMode(control,OUTPUT);// define control pin as output

  //---- Soft PWM-----------------------------------
  digitalWrite(control,LOW); // turn the MOSFET Switch Off
  //------------------------------------------------
}

void loop() {
  if ((millis()-readTime) > readInterval){
    Serial.println("checking iron state ...");  
    readTime = millis();
    if (heatingOn == true){
      heatingOn = false;
      digitalWrite(control,LOW); // Turn the MOSFET Switch OFF    
      Serial.println("turning off iron for reading temp ...");  
    }else{
      temp = tc.readCelsius();
      Serial.print("Temp=");
      Serial.println(temp);  
      heatingOn = true;
      digitalWrite(control,HIGH); // Turn the MOSFET Switch ON    
    }
  }
}

Hi,
Do you have a 10K between the IRF520 gate and source on the MOSFET module?

IRF520 is not a Logic-Level MOSFET, so you may not be able to turn it fully ON.

What model Arduino controller are you using?

Tom..... :smiley: :+1: :coffee: :australia:

If I understand correctly internal structure of your soldering iron, then the heater and the sensor have a common point (-).
In this case, the IRF520 module is not suitable for you.
You need a high-side switch built on a P-channel MOSFET.
It should look something like this

You can also use an N-channel MOSFET with a charge pump if you know what that is.
N-channel High-side Switch

It would be better if you gave an exact description (link) of your soldering iron.

I am using an arduino UNO. I also tried with a nano.

i have a IRFZ44N mosfet would that be suitable? if not i would be grateful if you could suggest one i can get. I spent so much time on this project i am willing to try anything except buying a soldering station or controller :slight_smile:

regarding the iron, it's one i bought from ali express. it is a clone of the jbc. 5 wires with a glass mercury vibration sensor built-in.

yes that is correct, both heater and thermocouple share the same negative. I am able to read the temperature when the heater is not powered on and i use a flame to heat the tip.

No IRFZ44N does not fit, it is also an N-channel MOSFET.
You need a P-channel, for example IRF4905, IRF5305, there are a lot of them, see what your sellers have.

thanks Boffin. I have ordered an IRF9540 mosfet. Do i need to design the high-side switch as per your scematic?

Of course I would use a better MOSFET, but the IRF9540 can be used too. If it gets a little warm at the maximum power of the soldering iron (not the fact), put a small heatsink. The main parameter of MOSFET in switching circuits is the channel's on-state resistance Rds. For IRF9540 = 0.2Ω. For example, IRF4905 has Rds = 0.02 Ohm.
I found a couple of schematics for you on the internet.

Just do not experiment with 6V supply voltage, MOSFET will not fully open. Your circuit on the IRF520 was wrong, so the PWM didn't work and you could burn out the 24V soldering iron.
It is necessary to apply a voltage of 18-24V and a PWM signal with a duty cycle of 20-30%. This can be easily done in Arduino via analogWrite().

i will try this schematics. Seems simple enough. i suppose the load+ in this case would be the iron V- wire (black) and the load+ is the iron V+ wire (red). the first schematics shows an N-Channel mosfet and the second shows a transistor? The control pin being the digitalWrite(HIGH)? I am really trying to learn so please bear with me. cheers

Why are you doing the opposite again? Electrical engineering doesn't like mistakes.
I showed you the heater connection in post # 12.
The black wire is ground (GND or –) and should be connected to 'Load–'.
The red wire is the heater +, it needs to be connected to 'Load +'.
You shouldn't use digitalWrite (HIGH) at all because you will get maximum power at once and your soldering iron will burn out again.
You have to use PWM and analogWrite(value) function.
If value = 0 this is the minimum power (0%).
If value = 127 this is half the power (50%).
If value = 255 this is the maximum power (100%). Etc.
Read about PWM. For example, here Pulse Width Modulation