/* This programme uses the 85 degree low temperature curing cycle to programme the Atmega32U4 chip on the carbon ply carbon fibre curing oven. */ #include #include #ifdef U8X8_HAVE_HW_SPI #include #endif #ifdef U8X8_HAVE_HW_I2C #include #endif //constructor for the OLED screen U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE, 3, 2); //defining the constant variables for the pins const int relayPin = 12; const int powerledPin = 13; const int heaterledPin = 5; const int programmedledPin = 10; const int modebuttonPin = A5; const int downbuttonPin = A4; const int upbuttonPin = A3; const int ThermistorPin = A1; //turning on the power LED and programmed LED int powerled = HIGH ; int heaterled = LOW; int programmedled = HIGH; int timeMins = 0; //current time in minutes int timeLeft = 900; //amount of time left in programme. //set initial target temperature int setTemp = 0; //may need to be float in some programmes? //set initial variables used to calculate temperature int Vo; float R1 = 10000; float logR2, R2, T; float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07; float powervoltage=5;//define the power supply voltage. //SETUP void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); //Define pins to be used as output pinMode(relayPin,OUTPUT); pinMode(powerledPin,OUTPUT); pinMode(heaterledPin,OUTPUT); pinMode(programmedledPin,OUTPUT); //Define pins to be used as input pinMode(modebuttonPin,INPUT); pinMode(downbuttonPin,INPUT); pinMode(upbuttonPin,INPUT); pinMode(ThermistorPin, INPUT); //initialise the u8g2 OLED screen u8g2.begin(); //allow printing of variables on the screen u8g2.enableUTF8Print(); } // the loop routine runs over and over again forever: void loop() { digitalWrite(powerledPin,HIGH); digitalWrite(programmedledPin,HIGH); Vo = analogRead(ThermistorPin); R2 = R1 * (1023.0 / (float)Vo - 1.0); logR2 = log(R2); T = (1.0 / (c1 + c2*logR2 + c3*logR2*logR2*logR2)); T = T - 273.15; //T=45; //Just used for debugging Serial.print("Temperature: "); Serial.println(T); timeMins = millis()/1000/60; setTemp = 30; //enter first ramp up to 70degC at 1deg/min increments while (setTemp < 70){ setTemp = setTemp+1; timeLeft=900-setTemp; Serial.println(setTemp); int counter = 1; //begin thermostatic loop with 1.2 second cycle while (counter <= 50){ if(T