PID Temperature Controller using MOSFET

Hello, my project is to design the extruder system of a 3D printer. I am now stuck on the temperature controlling part. I am using a Thermistor-100k to measure the temperature. I am okay with this now. I can read the temperature from serial monitor. I have to use a Cartridge Heater (12VDC, 40W) to heat my system up to 300C. Here, I am stuck now. I want to use one N-channel MOSFET (like IRLB8721, 30V/60A) to turn the heater (powered separately) on/off to maintain a set temperature. And PID algorithm needs to control the temperature at set value. I have learnt about the wiring. I have attached the possible wiring diagram. Please check and if anything wrong, please let me know.

I see, there are some PID algorithms written but they all used LCD to read the reading. But I don’t want to use external screen to monitor, rather I prefer serial monitor. For example, I found this (Control Software | Sous-vide controller powered by Arduino - The SousViduino! | Adafruit Learning System) from Adafruit. But they used LCD, So I can’t use that program. I need to modify the program to fit my case. Would you anyone help me in the coding part? I am not good at programming/coding, but I need it to be done. Thank you all for your time.

Sorry, the link is here

LCD's/Serial monitor has nothing to do with PID just drop/change any code that outputs to the LCD. Or look at the PID lib in the learning section.

Mark

not sure where to start…

the thermistor needs to be connected to an AI or analog IN-put, not an output.

typically, the thermistor is on the high side, connected to power, the companion resistor is to ground and AI is connected between,

not sure why you are using 3.3, unless your board is 3.3v

I like to put power at the top and ground at the bottom of my sketches. makes it easier for me to follow.

I did not touch the aref other than to remove the thermistor from that section.

holmes4:
LCD's/Serial monitor has nothing to do with PID just drop/change any code that outputs to the LCD. Or look at the PID lib in the learning section.

Mark

This is very true. however, since you do not have anything connected, you can either comment out that portion of the program or just leave it, making sure you are not using those pins for anything else. that way, if you ever do add an LCD, it will be there already.

JohnLincoln:
The gate of the MOSFET should be connected to a digital output (preferably one of the PWM outputs), and not to an analogue pin.

So, that means I have to connect MOSFET gate to PWM output (any one pin of 3, 5, 6, 9, 10 & 11). Right? Please confirm me my understanding. Thank you very much.

dave-in-nj:
typically, the thermistor is on the high side, connected to power, the companion resistor is to ground and AI is connected between,

Yes. You are right. Actually I meant A0 numbered (analogue input) pin in figure. Sorry for confusion.

dave-in-nj:
not sure why you are using 3.3, unless your board is 3.3v

I used 3.3v and AREF to minimize the noise. I got this idea from Adafruit learning file. They suggested to use 3.3v instead of 5v of Arduino. You can check here
I didn't get you what you wanted to say:

dave-in-nj:
I like to put power at the top and ground at the bottom of my sketches. makes it easier for me to follow.

Thanks a lot.

I am going to modify the sketch to avoid LCD part. If I face any problem, will seek suggestion / solution from you guys. Thanks all.