Step 9: Test it with code

Picture of Test it with code
You can take a look at the project code here. You will probably also need the max6675 library. The basic idea is that you pulse current across the resistors to heat up (by setting Arduino pin 7 to high); and turn on the fan to cool down (by setting Arduino pin 9 to high). You can check the temperature by polling the thermocouple.

The main thing is to not overheat (or even blow up) the resistors and sample. ***You never want to leave current running through the resistors for long periods of time!!!*** The thermocouple will not instantly respond to changes in temperature. Our 'heat up' code runs current through the resistors for about half a second and then checks the thermocouple. Every 15 seconds, the system times out and waits for a constant temperature to be reached. This ensures that we catch thermocouple delays, and also let the aluminum block heat evenly. Our heat-up code also has a few checks to make sure the thermocouple is properly connected, not heating up too fast, not overheating, etc.

Also, safety first, ***you don't want to leave this on running without watching it!!***

When cooling down, remember that the fan will continue moving for a few seconds after it's shut off, so it's best to shut off the fan 1 or 2 degrees before ideal temperature is reached.

The temperature is held constant by pulsing the resistors on for a tiny fraction of a second and constantly checking the temperature values. Given the limitations of the thermocouple and Arduino, you can get accuracy to +/-0.5C. However, since the Adafruit website reports a precision or +-2°C, you may also need to calibrate your thermocouple with an actual thermometer first.

The full 32 cycles take about 3 hours (depending on how the case is set up).
sunone2 years ago
Cool project, but I have a question. There is no mention of any Vcc for the arduino in this project, only the power of the relay and the fan. how is supposed to work the arduino? Using the current flowing from the fan?
This sounds like a perfect candidate for a PID control loop. http://en.wikipedia.org/wiki/PID_controller