I'm working on a climate control system to put in an experimental aircraft.
The aircraft interior is heated and cooled via air inlets that can be controlled with servos and butterfly valves.
Let's call them:
heatservo
coolservo
The heatservo controls air coming off a heat source on the engine.
The coolservo takes cold vent air from outside the aircraft.
It was pretty easy to open and close servos based on whether the temp was < or > the set temp, but I'm trying to figure out how to build a curve that can control how open the butterfly valves are based on the temperature spread.
So for example:
10-60 degrees warmer than settemp open the coolservo 180
5-9.99 degrees warmer open the coolservo 90
3-4.99 degrees warmer open the coolservo 25
1-2.99 degrees warmer open the coolservo 10
0-.99 degrees warmer open the coolservo 5
10-60 degrees colder open the heatservo 180
etc
etc
This is what I tried but it wasn't working.
if ((settemp >= cabintemp+10) && (settemp<= cabintemp+50)) {
heatservoval = 180; // degrees my servo opens
heatservo.write(heatservoval);
coolservoval = 0; // coolservo stays cosed
coolservo.write(coolservoval);
}
if ((settemp >= cabintemp+5) && (settemp<= cabintemp+9.99)) {
heatservoval = 90; // heat servo closes some since the temp spread is less
heatservo.write(heatservoval);
coolservoval = 0;
coolservo.write(coolservoval);
}
if ((settemp >= cabintemp+1) && (settemp<= cabintemp+4.99)) {
heatservoval = 10; // heat servo closes more since the temp spread is getting smaller
heatservo.write(heatservoval);
coolservoval = 0;
coolservo.write(coolservoval);
}
else {
heatservoval = 0;
heatservo.write(heatservoval);
coolservoval = 0;
coolservo.write(coolservoval);
}
I also thought something like this would be more elegant.
heatservoval = ((settemp - cabintemp) * 5);
heatservo.write(heatservoval);
Any ideas would be much appreciated. I've only been working with Arduino for a couple of days now.
Thanks!