diff --git a/uc/Makefile b/uc/Makefile index 639daa8..38a527a 100755 --- a/uc/Makefile +++ b/uc/Makefile @@ -44,11 +44,12 @@ TARGET = main # # Predefine the TYPE and SENSORx C macros in main.h via this Makefile. # Override the defaults on the command line by typing: -# make TYPE=xxxx SENSOR0=yyyy ... +# make PHASE=x METERCONST=y SENSOR0=z ... # DBG = 0 # TYPE = 2300501 +PHASE = 1 METERCONST= 5508 # SENSOR0 = 0123456789abcdef0123456789abcde0 @@ -56,7 +57,7 @@ SENSOR1 = 0123456789abcdef0123456789abcde1 SENSOR2 = 0123456789abcdef0123456789abcde2 SENSOR3 = 0123456789abcdef0123456789abcde3 # -CEXTRA = -D DBG=$(DBG) -D METERCONST=$(METERCONST) -D 'SENSOR0="$(SENSOR0)"' -D 'SENSOR1="$(SENSOR1)"' -D 'SENSOR2="$(SENSOR2)"' -D 'SENSOR3="$(SENSOR3)"' +CEXTRA = -D DBG=$(DBG) -D PHASE=$(PHASE) -D METERCONST=$(METERCONST) -D 'SENSOR0="$(SENSOR0)"' -D 'SENSOR1="$(SENSOR1)"' -D 'SENSOR2="$(SENSOR2)"' -D 'SENSOR3="$(SENSOR3)"' ############################################################################### diff --git a/uc/main.c b/uc/main.c index 7ebbd6e..8114edb 100644 --- a/uc/main.c +++ b/uc/main.c @@ -79,8 +79,11 @@ ISR(TIMER2_COMPA_vect) { #endif // read ADC result // add to nano(Wh) counter +#if PHASE == 2 + MacU16X16to32(aux[0].nano, METERCONST, ADC); +#else MacU16X16to32(aux[muxn].nano, METERCONST, ADC); - +#endif if (aux[muxn].nano > WATT) { measurements[muxn].value++; aux[muxn].pulse = true; diff --git a/uc/main.h b/uc/main.h index 7eede99..1596d88 100644 --- a/uc/main.h +++ b/uc/main.h @@ -42,6 +42,10 @@ #error "SENSOR3 not defined" #endif +#ifndef PHASE + #error "PHASE not defined" +#endif + #ifndef METERCONST #error "METERCONST not defined" #endif