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
moving_average_on_avrs [2016/03/21 01:45] – [Practical Code] Note code size for the 2-value version. Traumflugmoving_average_on_avrs [2018/05/27 16:10] (current) – external edit (unknown user)
Line 1: Line 1:
 ====== Moving Average on AVRs ====== ====== Moving Average on AVRs ======
  
-One problem with the controlling strategy on the [[ISTAtrol]] is thermistor readings jittering by about 1%, which is quite a lot if we want to keep the reading ( = target temperature) in a similar tight range. As a result of this, the radiator valve is often opened or closed a bit, just because such a jittered value comes in, just to be moved back on the next reading. Not good, mechanics is subject to wear and we want to preserve our mechanics.+One problem with the controlling strategy on the [[ISTAtrol]] is thermistor readings jittering by about 1%, which is quite a lot if we want to keep the reading ( = target temperature) in a similarly tight range. As a result of this, the radiator valve is often opened or closed a bit because such a jittered value comes in, just to be moved back on the next reading. Not good, mechanics is subject to wear and we want to preserve our mechanics.
  
 There are solutions. Building better hardware is neither trivial nor free of cost, so the typical approach is to implement a **moving average algorithm**. There are solutions. Building better hardware is neither trivial nor free of cost, so the typical approach is to implement a **moving average algorithm**.
Line 41: Line 41:
   static uint16_t temp_c = 0;  // Reading used for controlling.   static uint16_t temp_c = 0;  // Reading used for controlling.
   static uint16_t temp_temp = 0;  // Reading directly from ADC.   static uint16_t temp_temp = 0;  // Reading directly from ADC.
-  #if TARGET_TEMPERATURE < 7000  // Avoid a compiler warning.+  #if TARGET_TEMPERATURE < 7000
     // We can expect thermistor readings to be always below 8192, so it always     // We can expect thermistor readings to be always below 8192, so it always
     // fits into 12 bits and we can always keep a multiplication by 8.     // fits into 12 bits and we can always keep a multiplication by 8.
Line 62: Line 62:
 </code> </code>
  
-Code size on the ISTAtrol/ATtiny2313 firmware: (xxx) for the 8-value version, 26\_bytes Flash and 2\_bytes RAM for the 2-value version.+Code size on the ISTAtrol/ATtiny2313 firmware: 58\_bytes Flash and 2\_bytes RAM for the 8-value version, 26\_bytes Flash and 2\_bytes RAM for the 2-value version.
moving_average_on_avrs.1458521102.txt.gz · Last modified: 2018/05/27 16:10 (external edit)