hello everyone,i am trying to make closed loop a automatic temp controller to heat a thin metal plate using a buck converter,max6675 thermocouple module for temp sensing and a 250 watt halogen lamp.I am giving 10khz pwm signal from pin 9 to IRF540 mosfet and powering the max6675 using 5v and gnd available in arduino.My whole setup worked totally fine fews days ago but when i tried to run the same code again next day,it didn't worked.I am facing these issues now
1.For troubleshooting i first tried to run buck only at 50% duty cycle to check if its working properly or not,its working totally fine but whenever i insert gnd wire of max6675 into gnd pin of arduino brightness of bulb decreases suddenly and MOSFET in buck starts heating alot.I dont know why this is happening.
2.whenever i start serial monitor to see if anything is happening,it somehow starts interfering in the code of my closed loop.I have coded to print two things on serial monitor temp and pwm duty cycle.when it shows temp then duty cycle is zero and if it shows duty cycle then temp shows zero but most of the time both are zero.If bulb starts glowing and i open serial monitor then it switches off the bulb.
I am attaching my code for closed loop programme.I dont know why this is happening please help me!!!
#include <PID_v1.h>
#include "max6675.h"
#include <TimerOne.h>
double Setpoint, Input, Output;
int soPin = 4;
int csPin = 5;
int sckPin = 6;
MAX6675 robojax(sckPin, csPin, soPin);
double Kp=.5, Ki=.2, Kd=0;
PID myPID(&Input, &Output, &Setpoint, Kp, Ki, Kd, DIRECT);
void setup()
{pinMode(9,OUTPUT);
Timer1.initialize(100);
Serial.begin(9600);
Input =robojax.readCelsius() ;
Setpoint = 100;
myPID.SetMode(AUTOMATIC);
delay(500);
}
void loop()
{
Input = robojax.readCelsius();
myPID.Compute();
Output = map(Output, 0, 255, 0, 1024);
if( Output< 0)
{ Output = 0; }
if(Output > 950)
{ Output = 950; }
Timer1.pwm(9, Output);
Serial.print("c=");
Serial.print(robojax.readCelsius());
delay(500);
}
I am also attaching the schematic of my circuit.
pid_temp.ino (1.25 KB)
Use a logic level MOSFET. If it still doesn't work provide a circuit diagram and specs of your power supply, bulb and MOSFET.
hello everyone,i am trying to make closed loop a automatic temp controller to heat a thin metal plate using a buck converter,max6675 thermocouple module for temp sensing and a 250 watt halogen lamp.I am giving 10khz pwm signal from pin 9 to IRF540 mosfet and powering the max6675 using 5v and gnd available in arduino.My whole setup worked totally fine fews days ago but when i tried to run the same code again next day,it didn't worked.I am facing these issues now
1.For troubleshooting i first tried to run buck only at 50% duty cycle to check if its working properly or not,its working totally fine but whenever i insert gnd wire of max6675 into gnd pin of arduino brightness of bulb decreases suddenly and MOSFET in buck starts heating alot.I dont know why this is happening.
2.whenever i start serial monitor to see if anything is happening,it somehow starts interfering in the code of my closed loop.I have coded to print two things on serial monitor temp and pwm duty cycle.when it shows temp then duty cycle is zero and if it shows duty cycle then temp shows zero but most of the time both are zero.If bulb starts glowing and i open serial monitor then it switches off the bulb.
I am attaching my code for closed loop programme.I dont know why this is happening please help me!!!
pid_temp.ino (1.25 KB)
Opening the serial monitor resets the Arduino. The setup() code executes and execution continues with loop().
You probably have the serial baud rate at 9600 which requires approximately one millisecond per character sent. This may be the source of your timing issues but this is speculation as I cannot view your code on a mobile device.
Please post your code correctly per topic #7 of How to use this forum
First: double posting wastes everyone's time and yours included!
Second: better to post your schematic than the code.
Third: Did you allow for a cold halogen lamp with nearly zero resistance?
Paul
Hi,
Welcome to the forum.
Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html .
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
My whole setup worked totally fine fews days ago but when i tried to run the same code again next day,it didn't worked
What do you mean by "it didn't work"
- No power?
- No control of heater?
- No serial monitor response?
Thanks.. Tom.. 
I am giving 10khz pwm signal from pin 9 to IRF540 mosfet
Very bad choice, because the Arduino can't turn that device on completely, and it could burn out.
MOSFET in buck starts heating alot.I dont know why this is happening.
Perhaps it did burn out already.
Use a logic level MOSFET instead, like the IRL540 and post a wiring diagram (hand drawn, not Fritzing), because there are probably other problems.
jremington:
Very bad choice, because the Arduino can't turn that device on completely, and it could burn out.Perhaps it did burn out already.
Use a logic level MOSFET instead, like the IRL540 and post a wiring diagram (hand drawn, not Fritzing), because there are probably other problems.
No,mosfet is not burn i cheacked it.
I know IRL540 would have been better but i couldn't get it as it was unavailable and i read on different places and on this forum also that IRF540 can be used with arduino.MOSFET is heating only when i insert gnd wire of max6675 into gnd pin of arduino otherwise its totally working properly.
Can it be that having the same gnd of both Arduino Vgs signal and max6675 causing some issue?
TomGeorge:
Hi,
Welcome to the forum.
Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html .
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
What do you mean by "it didn't work"
- No power?
- No control of heater?
- No serial monitor response?
Thanks.. Tom.. 
I have attached a hand drawn schematic. Didn't work means No power and when ever I start serial monitor it starts giving nonsense value like 1.5 degree Celcius temp or 0% duty cycle of pwm.
Hi,
Ops circuit?
Please redraw it so the Arduino is bigger and all pins and MOSFET leads are labelled.
It looks like you are HIGH SIDE switching with an N-CH MOSFET.
Tom... 
PLEASE UPDATE with a new post, DO NOT GO BACK and edit an OLD POST......