I am using the beginner PID provided in the Arduino Library and the Relay Output example with modifications.
I have commented out transmitter.sendUnit(0, true);and transmitter.sendUnit(0, false); because it stops the if/else statement from switching to the else statements when the output is rising/high
I suspect this is because of the 257ms transmit time set up
I am printing "tempOutput" from the PID to the serial so I can monitor the changes and as "tempOutput" rises or falls the if/else statement is executed correctly, if the temperature is constantly under the set point the output will hold on 0.00 and if its constantly over it will hold on 500.00
int WindowSize = 500;
When the "tempInput" is below the "tempSetpoint" or falling it executes everything under the if
and when the "tempInput" is above the "tempSetpoint" or rising it executes everything under the else
else{
//transmitter.sendUnit(0,true);
Serial.print("Fans, On ");
digitalWrite(RelayPin,HIGH);
}
This works fine but I would also like to add the lines transmitter.sendUnit(0,true); and transmitter.sendUnit(0,false);.
When I add these lines to the code the "tempOutput" continues to rise and fall the PID reacts to temperature changes but only the if statement will run.
Even if the temperature is kept above "tempSetpoint" and the output holds at 500 I the else statement wont run
Are these tempXXX as in temperatureXXX or as in temporaryXXX?
If tempOutput is a temperature, then comparing it to time doesn't make sense. If tempOutput is temporary, then making it a global variable doesn't make sense. If tempOutput is neither a temperature or temporary, then perhaps it should be renamed to George.
What is temp_c for? It's sole purpose seems to be to have something to print later. Move the print() call to just after the read, and get rid of temp_c.
I thought I should just begin by naming the PID that controls the temperature tempPID instead of having to rename it later when the extra PID's are added into the code. Sorry for the confusion.