temp: Increase filter time
Increase the filter constant to 100s to smoothen the signal a lot. For online viewing, this is quite nice, but for acquisition, we should probably look at the raw data...
This commit is contained in:
		
							parent
							
								
									12753d93fb
								
							
						
					
					
						commit
						670576abf8
					
				
					 1 changed files with 7 additions and 3 deletions
				
			
		| 
						 | 
					@ -19,11 +19,12 @@ THERMISTOR_R25 = 10e3
 | 
				
			||||||
THERMISTOR_RINF = THERMISTOR_R25 * math.exp(-THERMISTOR_BETA / 298.15)
 | 
					THERMISTOR_RINF = THERMISTOR_R25 * math.exp(-THERMISTOR_BETA / 298.15)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Filter constant in seconds
 | 
					# Filter constant in seconds
 | 
				
			||||||
FILTER_RC = 1
 | 
					FILTER_RC = 100
 | 
				
			||||||
FILTER_A = 1 / ADC_RATE / (FILTER_RC / 1 / ADC_RATE)
 | 
					FILTER_A = 1 / ADC_RATE / (FILTER_RC / 1 / ADC_RATE)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
temperature_filtered = 25
 | 
					temperature_filtered = -1
 | 
				
			||||||
last_report = time.ticks_ms()
 | 
					# Ignore the first 5 seconds
 | 
				
			||||||
 | 
					last_report = time.ticks_ms() + 5000
 | 
				
			||||||
while True:
 | 
					while True:
 | 
				
			||||||
    raw_value = cs1237.read()
 | 
					    raw_value = cs1237.read()
 | 
				
			||||||
    value = float(raw_value) / (2**24 - 1)
 | 
					    value = float(raw_value) / (2**24 - 1)
 | 
				
			||||||
| 
						 | 
					@ -35,6 +36,9 @@ while True:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    temperature = THERMISTOR_BETA / math.log(value / THERMISTOR_RINF) - 273.15
 | 
					    temperature = THERMISTOR_BETA / math.log(value / THERMISTOR_RINF) - 273.15
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if temperature_filtered == -1:
 | 
				
			||||||
 | 
					        temperature_filtered = temperature
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    temperature_filtered = (
 | 
					    temperature_filtered = (
 | 
				
			||||||
        temperature_filtered * (1 - FILTER_A) + temperature * FILTER_A
 | 
					        temperature_filtered * (1 - FILTER_A) + temperature * FILTER_A
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue