4 ms·
We had issues with uneven heating and large temperature swings, so I fixed it with simple (though case-specific) logic: while True: if temperature < set_
by labawi 6y ago
We had issues with uneven heating and large temperature swings, so I fixed it with simple (though case-specific) logic:
while True:
if temperature < set_point:
heat for 15min
wait for 15min
Works wonders, consistently, even with differing types of radiators and no need for fancy PID/control loops. Measured temperature is a 5-min median, otherwise nothing fancy, except a bit of safeties¹.
Didn't bother with accessible controls - temperature adjustment of cca 2-3K can be made by raising/lowering the temperature probe.
¹ Contains a secondary probe, in a different room for safety. Doesn't heat if any probe above it's maximum setpoint, 50% duty cycle is not too bad and there usually is someone present. Median is considered valid only if data is available for each minute.
- MarkusWandel 6y agoHydronic heating systems (i.e. hot water and radiators) are a whole different ballgame from warm air - much slower to respond. But the beauty of homemade is that you can just come up with an algorithm that works for your house, by trial and error!
- war1025 6y agoIs the wait supposed to apply both to the if and else? Or does it really busy wait for the temperature to drop? Seems like that would be really inefficient, but maybe that's common practice in embedded software stuff.
- CyberDildonics 6y agoI don't think that's the actual program
- war1025 6y agoWell, yes. That seems obvious. I guess I was more wondering if running in a busy loop like that was a thing people did on embedded hardware since from my very minor experience with Arduino it is basically just a big while loop.
- CyberDildonics 6y agoAgain, you are assuming that the line that says 'wait' is a busy loop, but they are just saying that the program doesn't turn on the heat for 15 minutes after it has run for 15 minutes. That doesn't mean they are using a busy loop or not using one.
- war1025 6y ago> you are assuming that the line that says 'wait' is a busy loop I wasn't asking if the "wait" was a busy loop, I was asking if the "check whether the temperature dropped too far" was evaluated in a busy loop, and if not, how often that condition was checked. It doesn't really matter, and I imagine I won't get a response at this point, but it was just something I was curious about since I had never considered writing your own home thermostat software.
- labawi 6y agoI believe it uses sleep, and either threads or events / interrupts. I don't remember which. It's programmed in micropython. It calculates medians for each minute, and from those a 5-minute median (which is only considered valid if a majority of values are present) to filter out things like opening doors and missing values. Temperature readings are transported wirelessly from a different room. It supports multiple temperature clients for multiple rooms, each with a preset minimum (heat cycle activating) temperature, and also a maximum (safety-shutoff => don't activate heating) temperature.
- CyberDildonics 6y agoIt could be done with interrupts. With something like a raspberry pi it could be done with thread sleeps that yield non trivial amounts of process time so that the CPU usage is low.