Browse Source

Fan delay and advance timing

master
Barb 10 months ago
parent
commit
9dab0cb030
3 changed files with 101 additions and 15 deletions
  1. +42
    -13
      AulaStud_fridge_compressor_timer_controller.ino
  2. +53
    -0
      AulaStud_fridge_compressor_timer_controller.ino.tiny8.hex
  3. +6
    -2
      README.md

+ 42
- 13
AulaStud_fridge_compressor_timer_controller.ino View File

@ -1,29 +1,54 @@
int disable = 0;
int timer = 0;
int timerMAX = 900; //(countdown in seconds)
int fan = 0;
int relayPin = 0;
int fanPin = 1;
// Hi! Barb here: this is a quick and dirty implementation of a refrigeration compressor + evaporator fan(s) controller.
// I wrote this code to run it on an attiny45 that I was able to solder on the back of a 5V relay inside the refrigerator's
// control panel. This code relies on an external thermostat already doing its work and is not meant to manage internal
// temperature. It is written to make sure the compressor can get a minimum rest-time between cycles as to not overheat.
// This relay and attiny are connected in series with the main thermost's relay, so that they only function when it's calling.
// With this in mind, we assume the thermostat has just called for cooling every time the attiny is booted and leave the
// compressor running. After a set period of s (timerMAX) the compressor is switched off.
// In order to aid thermal transfer and maximize COP while using butane as refrigerant, the system needs to have a higher
// average temperature. Due to this reason, a fan is fitted between the fridge and freezer compartments to move air between
// the two. The fan is turned on after fanStartDelay to prevent rapid heating of the freezer and turned back on when the
// timer hits fanStopAdvance to allow for further freezer sub-cooling.
// Last updated: 05/03/24
bool disable = 0; // bool to store compressor disable status
int timer = 0; // active countdown timer, between timerMax and 0
const int timerMAX = 1500; // (countdown in seconds)
int relayPin = 0; // compressor relay output pin (active LOW)
int fanPin = 1; // fan MOSFET output pin (active HIGH)
const int fanStartDelay = 60; // fan turn-on delay in seconds
const int fanStopAdvance = 30; // fan turn-off advance in seconds (before the compressor stops, allows to sub-cool the freezer)
void setup() {
// put your setup code here, to run once:
// firstly, we initialize the needed outputs
pinMode(relayPin, OUTPUT);
pinMode(fanPin, OUTPUT);
// then we set them low to keep the compressor on and the fans off at boot
digitalWrite(relayPin, LOW);
digitalWrite(fanPin, LOW);
// lastly, we set the timer at maximum so that the loop starts counting down
timer = timerMAX;
}
void loop() {
// put your main code here, to run repeatedly:
// fan control logic:
// only enable fans after the compressor has been running for a while
if (timer < (timerMAX*4/5) && disable == 0) {
if (timer == (timerMAX - fanStartDelay) && disable == 0) {
// enable fan(s) after set delay if the compressor is not disabled
digitalWrite(fanPin, HIGH);
}
else if (timer == timerMAX) {
else if (timer == fanStopAdvance && disable == 0) {
// disable when we are about to stop the compressor
digitalWrite(fanPin, LOW);
}
else {
// do nothing
}
// compressor control logic
if (timer > 0 && disable == 0) {
@ -32,7 +57,7 @@ void loop() {
}
else if (timer > 0 && disable == 1) {
// when compressor is off, countdown moves at 5s/cycle
// when compressor is off, countdown moves at (1/5)s/cycle (5 times faster!)
timer = timer - 5;
}
@ -40,7 +65,7 @@ void loop() {
// reset countdown timer to max once 0 is reached
timer = timerMAX;
// realy control logic: warning! LOW = active!
// relay control logic: warning! LOW = active!
if (disable == 0) {
disable = 1;
digitalWrite(relayPin, HIGH);
@ -51,10 +76,14 @@ void loop() {
}
}
else { //protect against underflow or bitflip
else {
// protect against underflow or bitflip: if no condition applies, reset to safe values
timer = 0;
disable = 1;
disable = 0;
digitalWrite(fanPin, LOW);
}
// now wait 1s so that we can roughly count time using the timer variable
// this is a stopping delay, kinda bad, but we don't have any inputs, hence it shouldn't matter!
delay(1000);
}

+ 53
- 0
AulaStud_fridge_compressor_timer_controller.ino.tiny8.hex View File

@ -0,0 +1,53 @@
:1000000023C032C031C030C02FC0ACC02DC02CC006
:100010002BC02AC029C028C027C026C025C0010285
:100020000000040000000000000000003800000094
:100030000000370002020202020202020202010272
:10004000040810202004100811241FBECFE5D1E0C1
:10005000DEBFCDBF20E0A0E6B0E001C01D92AC360F
:10006000B207E1F7C9D065C1CBCF90E0FC01E25CFB
:10007000FF4F24918C5C9F4FFC018491882399F061
:1000800090E0880F991FFC01E25DFF4FA591B491AC
:10009000FC01E85DFF4F859194918FB7F894EC9146
:1000A000E22BEC938FBF089590E0FC01E25EFF4FDE
:1000B0003491FC01E25CFF4F2491FC01EC5CFF4FAA
:1000C000E491EE23B9F0332329F0323001F198F4B2
:1000D0003130C9F0F0E0EE0FFF1FE85DFF4FA59152
:1000E000B4918FB7F894EC91611114C020952E2330
:1000F0002C938FBF0895333011F0343059F78CB5FD
:100100008F7D8CBDE7CF8AB58F778ABDE3CF8AB567
:100110008F7DFBCF2E2BECCF3FB7F89480916500FD
:1001200090916600A0916700B091680022B708B670
:1001300001FE05C02F3F19F00196A11DB11D3FBF63
:10014000BA2FA92F982F8827BC01CD01620F711DEE
:10015000811D911D46E0660F771F881F991F4A95E4
:10016000D1F708951F920F920FB60F9211242F937B
:100170003F938F939F93AF93BF9380916100909132
:100180006200A0916300B09164003091600020E3B0
:10019000230F2D3758F54096A11DB11D2093600007
:1001A0008093610090936200A0936300B093640019
:1001B0008091650090916600A0916700B091680001
:1001C0000196A11DB11D8093650090936600A093D8
:1001D0006700B0936800BF91AF919F918F913F915D
:1001E0002F910F900FBE0F901F90189523EB230FA8
:1001F0004196A11DB11DD2CF78948AB582608ABD87
:100200008AB581608ABD83B7826083BF83B781600E
:1002100083BF89B7826089BF80B7826080BF329810
:10022000319A309A379A8CB580648CBD80E01DDF9E
:1002300081E01BDF60E080E037DF60E081E034DFF9
:100240008CED95E090936B0080936A0000E010E0E5
:100250009CEDE92E95E0F92EC0916A00D0916B00DB
:10026000C03A25E0D207B1F58091690061E08823AA
:10027000C9F18091690081114DC02197D0936B0025
:10028000C0936A0049DF4B015C0188EE482E83E091
:10029000582E612C712C40DF681979098A099B0955
:1002A000683E734081059105B0F381E0481A51081A
:1002B0006108710828EE820E23E0921EA11CB11C79
:1002C000411451046104710431F70115110521F243
:1002D00097DEC2CFCE31D10541F480916900811102
:1002E000C8CF60E081E0E0DEC4CF1C161D060CF430
:1002F000C0CFCD2BA9F4F0926B00E0926A00809100
:100300006900811109C081E08093690061E080E0AB
:10031000CBDEB8CF2597B2CF1092690060E0F7CF5F
:1003200010926B0010926A001092690060E081E008
:06033000EFCFF894FFCFAF
:00000001FF

+ 6
- 2
README.md View File

@ -1,3 +1,7 @@
Controller basato su attiny45, un relé e un FET per il frigorifero usato che abbiamo preso per l'aulastud nel '23.
Controller basato su attiny45 (bootloader flashato a 1 MHz), un relé e un FET per il frigorifero usato che abbiamo preso per l'aulastud nel '23.
Abbiamo dovuto sostituire il termostato e il design dell'evaporatore (parte fredda della serpentina) fa sì che ci sia rischio di trasporto di olio dal compressore e che si intasi il sistema se il compressore lavora per troppi minuti di fila (tipicamente dopo 30 minuti, a quel punto tocca staccare il frigo, riscaldarlo con un phon per sturare il blocco di olio, di solito nel reparto freezer, e poi riaccenderlo).
Questo controller è montato DOPO il termostato, in modo da impostare dei limiti di tempo massimo di accensione (15') e minimo di stand-by (3') del compressore. Inoltre, si occupa di accendere delle ventole nel compartimento freezer e frigo che aumentano il COP e permettono la completa evaporazione del refrigerante (butano).
Questo controller è montato DOPO il termostato, in modo da impostare dei limiti di tempo massimo di accensione (15') e minimo di stand-by (3') del compressore. Inoltre, si occupa di accendere delle ventole nel compartimento freezer e frigo che aumentano il COP e permettono la completa evaporazione del refrigerante (butano).
UPDATE 03/'24:
Ho aggiunto un delay di 60s all'accensione delle ventole per permettere al freezer di pre-raffreddarsi e poi uno spegnimento delle stesse 30s prima del compressore per far calare ulteriormente la temperatura nel comparto freezer.
Ho aumentato il tempo totale di accensione a 1500s (25'), portando il tempo di spegnimento forzato a 1/5 (5' con l'impostazione corrente)

Loading…
Cancel
Save