Still nothing... the temperature is not increasing, and on pin 7 there is no wave form...
The yellow wave form is the one on pin 2.
The yellow wave form is the one on pin 2.
C:
int lowError=0;
int highError=20;
//PID constants
double Kp = 2;
double Ki = 0;
double Kd = 0;
void zero() {
counter++;
if ((counter == 24) || (counter>duty)) { //reach max count or duty cycle limit.
digitalWrite(triac, LOW);
}
else if (counter >= 25) {
counter = 0;
pottemperature = analogRead(potentiometer);
pottemperature = map(pottemperature, 0, 1023, 150, 400);
realTemperature = thermocouple.readCelsius();
temperature = int(0.779828 * realTemperature - 10.3427); // make temperature an integer
if (tempError || isnan(temperature) || temperature >= 432) { // on error kill power & set global error flag
digitalWrite(relay, LOW); // turn off power to iron
tempError = true; //set error flag. can only be unset outside ISR. Once set no further action taken till unset in main loop.
}
else { //reading valid
if (temperature <= pottemperature) { // not sure about = here, well if == then error = 0 so only rateError will have a value[S][/S]
error = pottemperature - temperature; // don't think you need abs() here as t cannot be > pt and get here...
cumError += error * elapsedTime;
rateError = (error - lastError) / elapsedTime;
output = Kp * error + Ki * cumError + Kd * rateError; //output error needs to be mapped to a number between 0 and 24 so...
duty = map(output, lowError, highError, 0, 24); // lowError is const >= 0, highError is const for fully on.
duty = constrain(duty, 0, 24); // keep duty between 0 and 24 (24 = 96%)
if(duty) { digitalWrite(triac, HIGH); }
lastError = error;
}
else {
duty = 0;
}//if (temperature
}//if (tempError
}//if(counter == 25...
}//zero
Attachments
-
32.5 KB Views: 3