 	}
 };
 
+float temp, tempRiseTarget, tempZero;
+float heaterDutyCycle;
+uint32_t timeZero, sampleTime, heaterOnTime, heaterPeriodTime, pidUpdateTime;
+long sampleTimeLeft, heaterOnTimeLeft, heaterPeriodTimeLeft, pidUpdateTimeLeft;
+SPid pid;
+float pidDrive;
+bool heaterIsOn;
+
 float updatePID(SPid * pid, float err, float pos)
 {
 	float pTerm, dTerm, iTerm;

	if (heaterPeriodTimeLeft < 0)
	{
		heaterOn();
		heaterOnTime = millis() + (uint32_t)(heaterDutyCycle * HEATER_PERIOD);
		heaterPeriodTime = millis() + HEATER_PERIOD;
    
    DEBUG0(Serial.print(F("heaterOnTime - millis() = ")));
    DEBUG0(Serial.println(heaterOnTime - millis()));

	return pTerm + dTerm + iTerm;
}

#define TEMPERATURE_DATA_POINT_COUNT 100
float getTemperature()
{
  uint32_t sum = 0;
