Hello,
I am working on a project using cartridge heaters to heat an aluminium mold to 90 C where it will stay for two minutes and then turn off. To do this I plan on wiring the heaters to an SSR which can be activated by an Arduino UNO. To control the temperature increase I am using the Arduino PID Library where my input will be given by a thermocouple. I am familiar with how PID controllers work but this is my first time using one in actual application.
My first question is regarding tuning parameters, How do I initially find these values? I have seen in many projects people using the Autotune Library but everything I've read about this says you should reach your set point before you use this to get good results, but what tuning parameters do you use to initially reach that set point. Is it worth using autotune if you will always have the same set point?
Secondly, because everything I read about projects like this tells me I need a heatsink for my relay does anyone have suggestions for choosing a heatsink. The SSR is rated for 40A 230Vac, so I imagine I want a big one, the electronic shop I use has a huge selection and classifies their heatsinks by Rth (K/W) so what Rth should my heatsink have.
Finally, I have attached my code and schematic of the system if anyone sees any red flags in the coding or in the design of the circuit please let me know, I really don't want to get electrocuted or burn the building down...
Thanks,
Chris
/* Heat Cartdridge Control:
* The Purpose of this program is to have cartridge heaters heat a mold to 90d Celsius
* hold there for 2 minutes and then turn off. To do this I will use the Max6675 K type
* thermocouple and its acompanying library along with the PID library
*
* Still in progress: Finding PID tuning parameters and autotune library
*/
// inlude libraries
#include <max6675.h>
#include <PID_v1.h>
//#include <PID_AutoTune_v0.h>
#define RelayPin 6
//Define PID Variables we'll be connecting to
double Setpoint;
double Input;
double Output;
double Kp;
double Ki;
double Kd;
//Specify the links and initial tuning parameters
PID myPID(&Input, &Output, &Setpoint, Kp, Ki, Kd, DIRECT);
// 10 second Time Proportional Output window
int maxDutyCycle = 1000;
int count = 0;
// ThermoCouple
int thermo_gnd_pin = 45;
int thermo_vcc_pin = 47;
int thermo_so_pin = 49;
int thermo_cs_pin = 51;
int thermo_sck_pin = 53;
MAX6675 thermocouple(thermo_sck_pin, thermo_cs_pin, thermo_so_pin);
void setup() {
Serial.begin(9600);
//initialize the variables we're linked to
Setpoint = 90;
//tell our PID to give us an output as a duty cycle out of 1 second
myPID.SetOutputLimits(0, maxDutyCycle);
//turn the PID on
myPID.SetMode(AUTOMATIC);
//Assign pins for thermocouple
pinMode(thermo_vcc_pin, OUTPUT);
pinMode(thermo_gnd_pin, OUTPUT);
digitalWrite(thermo_vcc_pin, HIGH);
digitalWrite(thermo_gnd_pin, LOW);
}
void loop() {
digitalWrite(RelayPin,LOW); // Make sure relay is off to start
while (count < 120) {
Serial.print("Temp: ");
Serial.println(thermocouple.readCelsius());
Input = thermocouple.readCelsius();
myPID.Compute();
int now = millis();
while (Output < now) digitalWrite(RelayPin,HIGH); // Turn relay on for the portion of a second given by PID Controller
digitalWrite(RelayPin,LOW);
if (thermocouple.readCelsius() > 85) count++;
delay(1000-Output);
}
Serial.print("Heating Complete");
}
new doc 2017-09-12 13.37.58.pdf (273 KB)
Heat_Cartridge_Control.ino (1.97 KB)

