/* G3P Kiln Controller This codes for the digital control adapter to Scutt Kilns glass melting kilns and controllers. Using two relays per kiln device (one solid state and one mechanical saftey relay) and one type K thermocouple per hot zone, the code allows for the instantanious user specification of temperature and responds by raising or lowering the kiln temeperature by activating or deactivationg the resistive heating elements through 2 n-mosfets connected to the commercial kiln unit's power supply. The custom board is also equipped with two LED circuits in parallel to the contoller mosfets identifying which relays are activated. When both relays are activated, the kiln elements are activated as well. A Type K thermocouple is wired through op amp on the side of the board opposite the LED circuits. It must be calibrated to read the temperature from between 0 and 5V (table found here http://www.omega.com/temperature/Z/pdf/z208-209.pdf). Finally, the RX and TX pins of the boards ATTiny can be used to communicate a desired action through the serial port. A second program written in Processing (java) is provided to interface with the board through an FTDI-USB connection once it has been programmed. */ #include const int rx = 0; const int tx = 1; SoftwareSerial mySerial(rx,tx); int cmd = 1; int CONTROL = 2; int SAFETY = 3; int TC = 7; // the setup function runs once when you press reset or power the board void setup() { mySerial.begin(9600); while (mySerial.available()) mySerial.read(); pinMode(CONTROL, OUTPUT); pinMode(SAFETY, OUTPUT); pinMode(TC, INPUT); } // the loop function runs over and over again forever void loop() { if (mySerial.available() > 0) { cmd = mySerial.read(); } int r = analogRead(TC) * 5 / 260; int temp = ((2 *r) -74)* 2 + 32; if (analogRead(TC) == 0){ mySerial.println("THERMOCOUPLE ERROR"); //If the thermocouple is not plugged in or broken, giving no reading it returns an error digitalWrite(SAFETY, LOW); // and closes both relays digitalWrite(CONTROL, LOW); delay(1000); // It also only waits one second before checking this again. } else if (analogRead(TC) < cmd) { //If the temperature is below the desired temperature, the program opens the safety relay, waits digitalWrite(SAFETY, HIGH); //and opens the control relay, leaving them on to check again in one minute. delay(1000); digitalWrite(CONTROL, HIGH); mySerial.println("actual temp is "); mySerial.print(temp); mySerial.println(" target temp is"); mySerial.print(cmd); delay(30000); } else if (analogRead(TC) > cmd){ //If the temperature is above the desired temperature, the program closes the control relay, waits digitalWrite(CONTROL, LOW); // and closes the safety relay after, leaving them to check again in a minute. delay(1000); digitalWrite(SAFETY, LOW); mySerial.println("actual temp is "); mySerial.print(temp); mySerial.println("target temp is"); mySerial.print(cmd); delay(30000); } }