uc: Quadruple the sampling rate to 488.28Hz, define distinct default sensor IDs, configure meterconstant through a TYPE setting.
This commit is contained in:
parent
f7697b700e
commit
36ceaf4790
|
@ -207,8 +207,8 @@ void setup()
|
|||
ACSR |= (1<<ACBG) | (1<<ACIE) | (1<<ACIS1) | (1<<ACIS0);
|
||||
|
||||
// Timer2 normal operation
|
||||
// Timer2 clock prescaler set to 32 => fTOV2 = 1000kHz / 256 / 32 = 122.07Hz
|
||||
TCCR2B |= (1<<CS21) | (1<<CS20);
|
||||
// Timer2 clock prescaler set to 8 => fTOV2 = 1000kHz / 256 / 8 = 488.28Hz (DS p.158)
|
||||
TCCR2B |= (1<<CS21);
|
||||
TIMSK2 |= (1<<TOIE2);
|
||||
|
||||
// disable digital input cicuitry on ADCx pins to reduce leakage current
|
||||
|
@ -217,7 +217,7 @@ void setup()
|
|||
// select VBG as reference for ADC
|
||||
ADMUX |= (1<<REFS1) | (1<<REFS0);
|
||||
// ADC0 selected by default
|
||||
// ADC prescaler set to 16 => 1000kHz / 8 = 125kHz
|
||||
// ADC prescaler set to 8 => 1000kHz / 8 = 125kHz (DS p.258)
|
||||
ADCSRA |= (1<<ADPS1) | (1<<ADPS0);
|
||||
|
||||
// enable ADC and start a first ADC conversion
|
||||
|
|
20
uc/main.h
20
uc/main.h
|
@ -19,12 +19,22 @@
|
|||
// $Id$
|
||||
//
|
||||
|
||||
#define SENSOR0 "0123456789abcdef0123456789abcdef"
|
||||
#define SENSOR1 "0123456789abcdef0123456789abcdef"
|
||||
#define SENSOR2 "0123456789abcdef0123456789abcdef"
|
||||
#define SENSOR3 "0123456789abcdef0123456789abcdef"
|
||||
#define SENSOR0 "0123456789abcdef0123456789abcde0"
|
||||
#define SENSOR1 "0123456789abcdef0123456789abcde1"
|
||||
#define SENSOR2 "0123456789abcdef0123456789abcde2"
|
||||
#define SENSOR3 "0123456789abcdef0123456789abcde3"
|
||||
|
||||
#define METERCONST 45205 // 29165 * 1.55
|
||||
#define TYPE 2301
|
||||
|
||||
#if TYPE = 2301 // 230V - 1-phase @ 488.28Hz sampling rate
|
||||
#define METERCONST 7091
|
||||
#elif TYPE = 2303 // 230V - 3-phase @ 488.28Hz sampling rate
|
||||
#define METERCONST 7026
|
||||
#elif TYPE = 2401 // 240V - 1-phase @ 488.28Hz sampling rate
|
||||
#define METERCONST 7399
|
||||
#elif TYPE = 2403 // 240V - 3-phase @ 488.28Hz sampling rate
|
||||
#define METERCONST 7331
|
||||
#endif
|
||||
|
||||
#define START 0
|
||||
#define END3 0xffffffff
|
||||
|
|
Loading…
Reference in New Issue