uc: remapping of sensor inputs to meters

This commit is contained in:
Bart Van Der Meerssche 2009-10-28 21:05:24 +00:00
parent 36ceaf4790
commit 8367d43828
3 changed files with 18 additions and 39 deletions

View File

@ -174,17 +174,8 @@ all: bin_files build sizeafter
build: elf hex eep
bin_files: $(TARGET).c
# Here is the "preprocessing".
# It creates a .cpp file based with the same name as the .pde file.
# On top of the new .cpp file comes the WProgram.h header.
# At the end there is a generic main() function attached.
# Then the .cpp file will be compiled. Errors during compile will
# refer to this new, automatically generated, file.
# Not the original .pde file you actually edit...
test -d bin || mkdir bin
#echo '#include "WProgram.h"' > bin/$(TARGET).cpp
cp $(TARGET).c bin/$(TARGET).c
#cat main.cxx >> bin/$(TARGET).cpp
elf: bin/$(TARGET).elf
hex: bin/$(TARGET).hex

View File

@ -44,30 +44,18 @@ volatile struct sensor measurements[4];
// interrupt service routine for INT0
ISR(INT0_vect) {
measurements[0].value++;
aux[0].pulse = true;
}
// interrupt service routine for INT1
ISR(INT1_vect) {
measurements[1].value++;
aux[1].pulse = true;
}
// interrupt service routine for PCI2 (PCINT20 = pin4)
ISR(PCINT2_vect) {
if (aux[2].toggle == false) {
aux[2].toggle = true;
}
else {
measurements[2].value++;
aux[2].pulse = true;
aux[2].toggle = false;
}
// interrupt service routine for INT1
ISR(INT1_vect) {
measurements[2].value++;
aux[2].pulse = true;
}
// interrupt service routine for PCI0 (PCINT1 = pin9)
ISR(PCINT0_vect) {
// interrupt service routine for PCI2 (PCINT20)
ISR(PCINT2_vect) {
if (aux[3].toggle == false) {
aux[3].toggle = true;
}
@ -78,6 +66,7 @@ ISR(PCINT0_vect) {
}
}
// interrupt service routine for ADC
ISR(TIMER2_OVF_vect) {
// read ADC result
// add to nano(Wh) counter
@ -188,14 +177,6 @@ void setup()
//pin change interrupt enable 2
PCICR |= (1<<PCIE2);
// PB1=PCINT1 configuration
// set as input pin with 20k pull-up enabled
PORTB |= (1<<PB1);
//enable pin change interrupt on PCINT1
PCMSK0 |= (1<<PCINT1);
//pin change interrupt enable 0
PCICR |= (1<<PCIE0);
// analog comparator setup for brown-out detection
// PD7=AIN1 configured by default as input to obtain high impedance

View File

@ -26,14 +26,21 @@
#define TYPE 2301
#if TYPE = 2301 // 230V - 1-phase @ 488.28Hz sampling rate
#if TYPE == 2301 // 230V - 1-phase @ 488.28Hz sampling rate
#define METERCONST 7091
#elif TYPE = 2303 // 230V - 3-phase @ 488.28Hz sampling rate
#warning "230V - 1-phase selected. METERCONST set to 7091"
#elif TYPE == 2303 // 230V - 3-phase @ 488.28Hz sampling rate
#define METERCONST 7026
#elif TYPE = 2401 // 240V - 1-phase @ 488.28Hz sampling rate
#warning "230V - 3-phase selected. METERCONST set to 7026"
#elif TYPE == 2401 // 240V - 1-phase @ 488.28Hz sampling rate
#define METERCONST 7399
#elif TYPE = 2403 // 240V - 3-phase @ 488.28Hz sampling rate
#warning "240V - 1-phase selected. METERCONST set to 2401"
#elif TYPE == 2403 // 240V - 3-phase @ 488.28Hz sampling rate
#define METERCONST 7331
#warning "240V - 3-phase selected. METERCONST set to 7331"
#endif
#define START 0