Hi . I'm trying to make a machine and I need to control stepper motor , heater and thermistor ať the same time. I use mega 2560 and Shield ramps 1.4 and as power supply I use 12v and 30 amps DC.
I can't find aby informations or tutorials about how to control heater and thermistor.
Any advice?
(I don't want to use marlin firmware)
To see the pin mapping between the Mega2560 board and the Ramps 1.4 board, look at the Marlin pins_RAMPS.h file.
// Temperature Sensors
//
#ifndef TEMP_0_PIN
#define TEMP_0_PIN 13 // Analog Input
#endif
#ifndef TEMP_1_PIN
#define TEMP_1_PIN 15 // Analog Input
#endif
#ifndef TEMP_BED_PIN
#define TEMP_BED_PIN 14 // Analog Input
#endif
// Heaters / Fans
//
#ifndef MOSFET_A_PIN
#define MOSFET_A_PIN 10
#endif
#ifndef MOSFET_B_PIN
#define MOSFET_B_PIN 9
#endif
#ifndef MOSFET_C_PIN
#define MOSFET_C_PIN 8
#endif
The thermistor changes resistance with temperature. A google search for 'thermistor Arduino' should turn up lots of examples and tutorials. The RAMPS board has a fixed resistor that is used to measure the thermistor resistance and you will need that value for the calculations.
If you want a STABLE temperature, you will probably want a PID control loop to adjust the intensity of the heater based on how far the current temperature is from the desired temperature.
I've been looking for some tutorials and codes whole day and I couldn't find anything that would be useful for me. Thank you for advice and I will find a way.
You don't have to use Marlin, but reading it should give you some hints about how they do it and you can derive your own custom version either directly or using what you learn.
There are a couple of types of temperature control. One is called band-bang and the other is PID.
Bang-bang is just on-off. When the temperature falls below the setpoint, the heater is turned on fully and when the temperature rises above the setpoint the heater turns off.
PID senses the difference between the setpoint and the actual temperature (input) and will turn supply a varying amount of current to the heater to try to keep the temperature relatively constant. That means that PID is more complex than bang-bang.
Can you justify the added complexity? How steady must the temperature be kept?
I will need constant temperature so I will find information about PID.
I know and I´ve tried but Marlin I've downloaded had tons and tons of information and I couldn't find part with heating and controling heater. Any ideas?
I would not use Marlin for what you want to do. Martlin has so much more capabilities that it could just be in the way.
I don't know how useful it would be to dig through Marlin to see how they measure and control temperature. There is so much information on those subjects on the net that it may be easier to look there for the information. For instance, I get 108,000 results for a search for "arduino thermistor tutorial" or "arduino temperature pid" gets 1.7 million hits.
I mentioned Marlin files in my first post only because the pins files have the relationship between the Mega pins and the pins on the Ramps shield. You need that information to be able to write your own code to measure and control using the Ramps and Mega.
I found the page " Improving the Beginner’s PID" to be very informative.
And the Arduino PID library by the same author is a good PID library. Install using the IDE library manager. It is the PID library by Brett Beauregard.
I have that PID library, I've found information about PID and how to read temperature and control heater ,but where can I found How is ramps 1.4 connected to the mega 2560?
Because thermistor has to be connected to "T0" on ramps board but I don´t know how to read information from there (like I don´t know in which pins is "T0" connected on mega 2560).
Any ideas where to find informations about how is shield connected to board?
Thanks for every advice.
Hi, @scorpio21
Welcome to the forum.
Can you tell us what your project is please?
Can you please tell us your electronics, programming, arduino, hardware experience?
Have you looked at this site showing you how to wire your shield?
https://reprap.org/wiki/RAMPS_1.4
Thanks.. Tom...

That information is in the pins file. Or you can look at the Ramps board schematic and find that.
Look at post #2. T0 is connected to Mega pin 13 (A13), T1 to 15 (A15) and bed to 14 (A14). The heater and fan MOSFETs connect to digital (PWM) pins 8, 9, 10.
I'm building machine that will have one stepper motor and heater with thermistor. Machine will be something simple in the begining and it will heat watter to 200°C and I will build sterling motor using arduino.
Thank you . This is amazing . Where can I find these schematics ?
I have another problem . I connected thermistor to ramps and I tried to measure temperature (I found how to change input to celsius) and I have some weird numbers like , here is 30 celsius degrees and thermistor says that there is only 4.
Sounds like the temperature measuring code is not using the right parameters for your thermistor and the RAMPS load resistor. Do you have the Steinhart-Hart equation parameters for your thermistor?
Hi,
Can you post some code that JUST reads the thermistor and outputs it to the serial monitor in the IDE.
No other code or hardware, just the thermistor.
Also a circuit diagram of how you have connected the thermistor?
Thanks.. Tom...
