   pidUpdateTimeLeft = pidUpdateTime - millis();
   heaterOnTimeLeft = heaterOnTime - millis();
   heaterPeriodTimeLeft = heaterPeriodTime - millis();
+  turnOffTimeLeft = turnOffTime - millis();
 
   if (sampleTimeLeft < 0)
   {

  printTimeLeft = printTime - millis();
	heaterOnTimeLeft = heaterOnTime - millis();
	heaterPeriodTimeLeft = heaterPeriodTime - millis();

	if (sampleTimeLeft < 0)
	{

float tempRiseTarget, tempZero;
RollingAverage tempAvg(TEMP_AVERAGING_INITIAL_VALUE);
float heaterDutyCycle;
uint32_t timeZero, sampleTime, heaterOnTime, heaterPeriodTime, pidUpdateTime, printTime, turnOffTime, turnOnTime;
long sampleTimeLeft, heaterOnTimeLeft, heaterPeriodTimeLeft, pidUpdateTimeLeft, printTimeLeft, turnOffTimeLeft, turnOnTimeLeft;
SPid pid;
float pidDrive;
bool heaterIsOn;

float iStateLim[] = {1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 10, 10, 25, 25, 50, 50, 100, 100, 200, 200, 400, 400 };
int iStateLimIterator = -1; // increment before use!
const uint8_t iStateLimSize = 27;

float updatePID(SPid * pid, float err, float pos)
{
