From f57588c761523e5be5516c6519c24bcccecd126e Mon Sep 17 00:00:00 2001 From: Jan Michel Date: Thu, 27 Aug 2015 20:20:36 +0200 Subject: [PATCH] adding configurable averaging, few bugfixes --- pt100/Makefile | 4 ++-- pt100/main.c | 18 +++++++++++------- pt100/main.h | 8 ++++++-- pt100/tempmeas.c | 40 ++++++++++++++++++++++++++++++++-------- pt100/uart.c | 2 ++ 5 files changed, 53 insertions(+), 19 deletions(-) diff --git a/pt100/Makefile b/pt100/Makefile index b246656..18dfd96 100644 --- a/pt100/Makefile +++ b/pt100/Makefile @@ -109,8 +109,8 @@ AVRDUDE_NO_VERIFY = -V #AVRDUDE_VERBOSE = -v -v AVRDUDE_BASIC = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) -AVRDUDE_FLAGS = $(AVRDUDE_BASIC) $(AVRDUDE_NO_VERIFY) $(AVRDUDE_VERBOSE) $(AVRDUDE_ERASE_COUNTER) - +AVRDUDE_FLAGS = $(AVRDUDE_BASIC) $(AVRDUDE_VERBOSE) $(AVRDUDE_ERASE_COUNTER) +#$(AVRDUDE_NO_VERIFY) CC = avr-gcc OBJCOPY = avr-objcopy diff --git a/pt100/main.c b/pt100/main.c index b192ea4..d9afba6 100644 --- a/pt100/main.c +++ b/pt100/main.c @@ -10,7 +10,9 @@ volatile uint8_t next_second = 0; volatile uint8_t measurement_active = 0; -uint32_t temperature[9]; +uint32_t temperature[17][9]; +uint8_t invalid[8]; +uint8_t make_update_lcd; color_t col_background; color_t col_font; @@ -41,6 +43,7 @@ void read_calib() { calib_settings.gain_current = eeprom_read(9); calib_settings.period = eeprom_read(10); calib_settings.uselcd = eeprom_read(11); + calib_settings.average = eeprom_read(12); } /****************** @@ -73,7 +76,7 @@ void lcd_update(void) { // send_answer_hex('I','I',DDRB); for(uint8_t i = 0; i<8; i++){ - int32_t x = temperature[i]; + int32_t x = temperature[16][i]; if (x < 0) {lcd_use_foreground(col_neg); x = -x;} else {lcd_use_foreground(col_font);} @@ -123,7 +126,7 @@ void init(void) { //Init ADC for presence measurement - ADMUX = (3 << REFS0) | (1 << ADLAR) | (3 << MUX0); // internal2.56V ADC3 + ADMUX = (1 << REFS0) | (1 << ADLAR) | (3 << MUX0); // internal2.56V ADC3 ADCSRA = (1 << ADEN) | (0 << ADIE) | (5 << ADPS0); //fcpu/32 DIDR0 = 0x08; //PA3 is analog only @@ -165,7 +168,6 @@ void init(void) { ISR(TIMER0_COMPA_vect) { if(++time == calib_settings.period) { time = 0; - send_information(); measurement_active = 1; } next_step = 1; @@ -176,7 +178,8 @@ ISR(TIMER0_COMPA_vect) { * Second ticks *********************/ ISR(TIMER1_COMPA_vect) { - next_second = 1; +// next_second = 1; +// send_information(); } @@ -188,10 +191,11 @@ int main(void) { while(next_step==0); next_step = 0; if (measurement_active) {do_measurement_step();} - if (next_second && !measurement_active) { + + if(make_update_lcd) { if(calib_settings.uselcd) lcd_update(); - next_second = 0; + make_update_lcd = 0; } if(key_was_pressed(1<