User Tools

Site Tools

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
istatrol [2016/03/25 13:15] – Two more sections about basic operations. Traumflugistatrol [2018/05/27 16:10] (current) – external edit (unknown user)
Line 67: Line 67:
 on the command line. It should connect to the ISTAtrol and give a temperature readout every minute. That's how one makes visible how the ISTAtrol works. on the command line. It should connect to the ISTAtrol and give a temperature readout every minute. That's how one makes visible how the ISTAtrol works.
  
 +**Note**: if the ISTAtrol was just started, it'll take some time until temperature readouts pick up, so be a bit patient.
 ===== Valve Actuator ===== ===== Valve Actuator =====
  
Line 81: Line 82:
 Type of the thermistor isn't crucial. Design was made with a 10\_kOhms type in mind. Lower ohms ones will give smaller temperature readouts, larger ohms ones will give a higher readout. This can be adjusted in the configuration by TARGET_TEMPERATURE. Simply attach the thermistor, fire up terminal.py and look what the readings are. Then adjust configuration and upload firmware again. Type of the thermistor isn't crucial. Design was made with a 10\_kOhms type in mind. Lower ohms ones will give smaller temperature readouts, larger ohms ones will give a higher readout. This can be adjusted in the configuration by TARGET_TEMPERATURE. Simply attach the thermistor, fire up terminal.py and look what the readings are. Then adjust configuration and upload firmware again.
  
-If readouts happen to be above 32'000, firmware has to be adjusted. Prescaling in temp_init() should be changed to a higher value. For readouts < 1000, doing the opposite is likely a good idea to get better precision.+If readouts happen to be above 32'000, firmware has to be adjusted. Prescaling in temp_init() should be changed to a higher value. For readouts < 1000, doing the opposite is likely a good idea to get better precision.
  
 {{ :istatrol:istatrol_thermistor_readout.png?direct&300|Very coarsely measured readout of the developers thermistor.}} {{ :istatrol:istatrol_thermistor_readout.png?direct&300|Very coarsely measured readout of the developers thermistor.}}
  
-For the technical: ATtinys feature no Analog Digital Converter (ADC). But there is [[https://github.com/Traumflug/ISTAtrol/raw/master/data%20sheets/AVR400.pdf|Atmel Application Note AVR400]], outlining how to get analog readouts by using the Analog Comparator (ACO) anyways. Essentially, a capacitor is loaded starting at time zero, then the time measured (with 16-bit Timer 1) how long it takes to reach a constant comparison voltage. As the loading current goes through the thermistor, higher thermistor resistance ( = lower temperature) leads to a longer loading time and vice versa. This implementation is actually simpler than one using an ADC.+For the technical: ATtinys feature no Analog Digital Converter (ADC). But there is [[https://github.com/Traumflug/ISTAtrol/raw/master/data%20sheets/AVR400.pdf|Atmel Application Note AVR400]], outlining how to get analog readouts by using the Analog Comparator (ACO) anyways. Essentially, a capacitor is loaded starting at time zero, then the time this capacitor takes to reach the same voltage as a constant comparison voltage measured (with 16-bit Timer 1). As the capacitor loading current goes through the thermistor, higher thermistor resistance ( = lower temperature) leads to a longer loading time and vice versa. This implementation is actually simpler than one using an ADC.
  
 As one can see by the coarse measurements done, this is linear enough for our purposes. The recorded pretty hefty hysteresis isn't a property of the thermistor or the ISTAtrol, it's an artefact of the measurement procedure. As one can see by the coarse measurements done, this is linear enough for our purposes. The recorded pretty hefty hysteresis isn't a property of the thermistor or the ISTAtrol, it's an artefact of the measurement procedure.
 +
 +===== Configuration =====
 +
 +Here's a description of the configuration values meant to be user-adjustable. They're at the top of //main.c// and get in effect by re-uploading the firmware. Runtime ajustments are planned for after the upgrade to an ATtiny4313.
 +
 +All the values described here are also described in a comment in main.c.
 +
 +==== TARGET_TEMPERATURE ====
 +
 +This is our main goal, here one sets which temperature the ISTAtrol should try to keep. The actual value largely depends on the thermistor in use. Use [[#Controlling Terminal|terminal.py]] to see current readout, then adjust gently. On the developers thermistor, a change of 100 resulted in roughly a change of 1\_degree Celsius.
 +
 +==== THERMISTOR_HYSTERESIS ====
 +
 +This is, also in thermistor ticks, temperature is allowed to deviate from TARGET_TEMPERATURE. Too small values result in constant valve movements (more than 20 per hour), a too large value doesn't harm, but may result in unwanted temperature changes.
 +
 +==== RADIATOR_RESPONSE_TIME ====
 +
 +{{ :istatrol:istatrol_radiator_response.png?direct&300|Temperature response of the developers heating radiator.}}
 +
 +This is a bit a tricker one. Moving the radiator valve usually doesn't lead to an immediate change in temperature on the sensor. There is some //dead time// in between. Checking temperature and/or moving the valve too often makes no sense within this dead time.
 +
 +To get an idea about this dead time, connect ISTAtrol, run [[#Controlling Terminal|terminal.py]], without mounting and connecting the valve actuator, yet. Adjust //terminal.py// to give readouts more often by changing ''time.sleep(60)'' to ''time.sleep(1)'' in the last line of //terminal.py// and RADIATOR_RESPONSE_TIME in main.c also to 1. Then open the valve with the former thermostat and watch when temperature starts to raise. This is the value which should be entered here. The developers radiator response can be seen in the picture. According to this, a value of 120 was choosen and found to be choosen well.
 +
 +==== PREDICTION_STEEPNESS ====
 +
 +This value says how "sharp" the controlling algorithm responds to temperature changes. Too low and temperature will occasionally drop out of the given hysteresis width. Too high and the valve will be actuated too often. 4 has been found to be a good value in conjunction with a hysteresis of 50.
 +
 +==== MOT_OPEN_TIME ====
 +
 +The radiator valve is moved in increments, absolute position is actually ignored. Such an increment means to run the actuator motor for a short while. This value says how long this short time is when opening the valve, in milliseconds.
 +
 +==== MOT_CLOSE_TIME ====
 +
 +The same when closing the valve. Both values can be adjusted individually, because in some scenarios exceeding temperature to the top harms more than having it too low for a short while, so close time is usually bigger than open time.
 +
 +===== Practical Experience =====
 +
 +Quality of temperature regulation was recorded during days of firmware development, simply by running //terminal.py// and copying its output into a spreadsheet (GNUmeric). These graphs show not only how different algorithms behave, they also give some hints on a sane configuration.
 +
 +==== Early Days ====
 +
 +{{ :istatrol:istatrol_experience_1.png?direct&300|First ISTAtrol performance measurements.}}
 +
 +As one can see in the first set of graphs, regulation was really jerky in the early days. With a simple Bang-Bang-algorithm ("Temp too low? Open valve. Temp too high? Close valve."), temperature moved up and down funnily, sometimes more than 10\_degC. Part of the reason for this behaviour was certainly not only the algorithm, but also valve close time being 10 times higher than valve open time. Apparently the developer feared a lot to exceed target temperature.
 +
 +Next step was to add kind of a mild prediction into the algorithm. "If temperature raises already, don't open the valve further. And vice versa". Eventually, precision became better when distance between valve open and close time was reduced.
 +
 +==== Full Predictive ====
 +
 +{{ :istatrol:istatrol_experience_2.png?direct&300|Much better! So much better the temperature axis scale had to be changed. The larger spikes mark room temperature changes, like opening the window.}}
 +
 +As the Bang-Bang thing had turned out to be not very helpful, it was removed entirely. Instead, prediction now scales the last temperature change by factor PREDICTION_STEEPNESS into the future and looks wether this future value is within target bandgap. As one can see, results were much better, a precision of +-\_0.5\_°C could be kept almost all of the time. This is usable!
 +
 +But still occasionally an erratic temperature measurement slipped in, exploiting the prediction formula. Readouts aren't exactly noise-free, likely due to all the long unshielded wires. So an exponential moving average was introduced, each new measurement now counts in only 12% of the existing value. Regulation response is still quick, because some 100 averaged temperature readings happen between two evaluations of the regulation algorithm.
 +
 +And then a hardware issue was found. The temperature sensor was connected directly to the radiator, more precisely to the ISTA consumption counter. But when a blow hushed through the air, the sensor would change a lot more than the radiator. So the sensor was thermally insulated against air with some foam, still tightly connected to the radiator, problem solved.
 +
 +Now we get away with about 11% valve movements, which is one movement about every 9\_minutes. Looks like a good compromise between precision and valve actuator wear.
 +
 +===== These ISTA Devices ====
 +
 +{{ :istatrol:istatrol_ista_consumption_counting_device.jpeg?direct&200|An ISTA consumption counter mounted to a heating radiator.}}
 +
 +Remember these ISTA things mounted to the radiator? They mean to measure heating consumption. But they can also count erratic, because:
 +
 +  * They measure radiator temperature in one point only, so water flowing back to the central heating system hot is counted as consumed energy, too.
 +  * They ignore room temperature. A 30\_°C warm radiator in a 25\_°C warm room certainly consumes less heating energy than the same in a 15\_°C warm room.
 +  * They ignore effective size of the radiator. While the physical size is part of their bookkeeping, covering part of the radiator with e.g. a cabinet or a table reduces its effectivity, leading to higher radiator temperatures at the same energy consumption, leading to higher consumption counts, to higher consumption bills.
 +  * They count radiator temperatures above 28\_°C, only.
 +
 +To get at least an idea about what's happening at the counter, applying a temperature sensor directly to the aluminium back of this device is a good idea. Then you can see what's happening and optimise accordingly.
 +
 +Such erratic behavior was actually the reason why ISTAtrol was developed. Consumption grew by 50% from one year to another, without visible reason. After optimisation (e.g. removing the table), bills are now not 50% up, but 60% down. Yikes!
 +
 +===== TODO =====
 +
 +Let's collect possible improvements here.
 +
 +==== Bugs ====
 +
 +  * Replacing the ATtiny2313 with an ATtiny4313. Program memory is so constrained that this is considered to be a bug.
 +  * C3, 1.0 uF, should have a 200\_mil wide footprint. Many suppliers don't have 100\_mil types at this capacity.
 +  * Key //Menu// should go to INT1 to allow triggering an interrupt. Crucial for allowing the MCU to go to sleep.
 +  * These three thermistor connectors actually don't work this way. Connecting to means that current flows partially not to the measuring capacitor, but to the other ATtiny pin. Can likely solved with diodes, but note that a capacitor fills reasonably linear in the lower 20%, only.
 +
 +==== Wishlist ====
 +
 +  * There is an internal voltage reference, which can be connected to the Analog Comparator. Does this work? Does the Brown Out Detector still work then, too? This could save a pair of resistors. See page\_149, "Analog Comparator Bandgap Select", bit ACBG, of the ATtiny2313 data sheet.
 +  * Voltage dividers for the 5\_V programmer should go into a separate cable adapter.
 +  * Maybe it's a good idea to lift this whole thing to 5\_volts. Zener-diodes needed for D+ and D- then. ATtiny can run at 20\_MHz with quartz or 16.5\_MHz without quartz, then, both featuring considerably [[Notes on V-USB|smaller V-USB code]]. Voltage regulator can be dropped, but then the valve actuator motor needs some sort of voltage reduction.
 +  * A display for allowing USB-less operations, of course. Could be done with SPI via the ISP connector.
 +
istatrol.1458908159.txt.gz · Last modified: 2018/05/27 16:10 (external edit)