# HG changeset patch # User kripperger@CL-SEC241-09.cedarville.edu # Date 2013-04-03 19:02:24 # Node ID 0df60b3e84ea4ed58a427a81af41f43f87154e6d # Parent 231d04aebb09d28f111d1af0a951aa2dec8deff5 geiger work diff --git a/slave/slave/lib/geiger.c b/slave/slave/lib/geiger.c --- a/slave/slave/lib/geiger.c +++ b/slave/slave/lib/geiger.c @@ -47,14 +47,14 @@ uint8_t geiger_getCount() //DEBUG return counts; } -void geiger_on(); +void geiger_on() { // Turn the Flyback Transformer on PORTA |= (1 << PA1); //ON - } + } -void geiger_refresh(); +void geiger_refresh() { // Turn the Flyback Transformer off PORTA &= ~(1 << PA1); //OFF @@ -63,4 +63,3 @@ void geiger_refresh(); // Turn the Flyback Transformer on PORTA |= (1 << PA1); //ON } -} diff --git a/slave/slave/lib/geiger.h b/slave/slave/lib/geiger.h --- a/slave/slave/lib/geiger.h +++ b/slave/slave/lib/geiger.h @@ -11,6 +11,7 @@ uint16_t geiger_getCpm(); uint8_t geiger_getCount(); //DEBUG -void led_on(void); +void geiger_on(); +void geiger_refresh(); #endif /* GEIGER_H_ */ \ No newline at end of file diff --git a/slave/slave/lib/inputOutput.c b/slave/slave/lib/inputOutput.c --- a/slave/slave/lib/inputOutput.c +++ b/slave/slave/lib/inputOutput.c @@ -43,7 +43,7 @@ int8_t moduleID; // Slave Module ID from void io_readModuleId() { // Get ID from rotary dip and return it. - moduleID = 2; + moduleID = 0; /* // This method is temporary as the next release will read the module ID from EEPROM @@ -57,10 +57,10 @@ int8_t moduleID; // Slave Module ID from moduleID = (moduleID & 0b0111); //Mask bits */ -// while(moduleID==0) //UNCOMMENT ALL THIS -// { -// moduleID = i2c_read(EEPROM_ADDR, 0x05); -// } + while(moduleID==0) //UNCOMMENT ALL THIS + { + moduleID = i2c_read(EEPROM_ADDR, 0x05); + } } diff --git a/slave/slave/modules.c b/slave/slave/modules.c --- a/slave/slave/modules.c +++ b/slave/slave/modules.c @@ -19,6 +19,7 @@ uint32_t lastPicture; uint8_t pulseOn; + uint32_t lastRefresh; // Time in ms when last geiger refresh occurred void modules_setup(uint8_t id) { @@ -93,7 +94,8 @@ DDRA &= ~(1 << DDA0); // PA0 is an input DDRA |= (1 << DDA1); // PA1 is an output - + geiger_on(); // Turn on HV supply + // Setup for interrupt input on PA0 (PCINT0) PCMSK0 |= (1 << PCINT0); // Enable interrupt for PA0 PCICR |= (1 << PCIE0); // Enable ioc section PCIF0 @@ -101,7 +103,7 @@ // Setup for interrupt from Timer2 ASSR &= ~(1 << EXCLK); // Disable external clock input (enabling crystal use) ASSR |= (1 << AS2); // Enable timer2 async mode with an external crystal - _delay_ms(250); // Let external 32KHz crystal stabilize + _delay_ms(100); // Let external 32KHz crystal stabilize TCCR2B = 0x05; // Set the prescaler to 128: 32.768kHz / 128 = 1Hz overflow TIFR2 = 0x01; // Reset timer2 overflow interrupt flag TIMSK2 = 0x01; // Enable interrupt on overflow @@ -125,6 +127,7 @@ { // Gathers data and performs functions for generic daughter board + } void modules_sensors() @@ -142,6 +145,12 @@ { // No data gatering function needed for geiger daughter board // This is taken care of in interrupt (See geiger.c) + + lastRefresh = time_millis(); + if ((time_millis() - lastRefresh) > 1000000) + { + geiger_refresh(); //Refreshes every 1000sec (16min) + } } diff --git a/slave/slave/slave.c b/slave/slave/slave.c --- a/slave/slave/slave.c +++ b/slave/slave/slave.c @@ -104,33 +104,33 @@ int main(void) // Writes ID to EEPROM, change for all modules and delete after programming // 0 is for generic setup, 1 is for sensors, 2 is for Geiger, 3 is for cameras -//i2c_write(EEPROM_ADDR, 0x05, 0x03); +//i2c_write(EEPROM_ADDR, 0x05, 0x02); - } + } // IFloop - if (io_getModuleId() == 3); - { - if ((time_millis() - pulseOn) > CAMERA_PULSE) - { - PORTA &= ~(1 << PA0); // Pull pin on usb low - PORTA &= ~(1 << PA1); // Pull pin on usb low - PORTA &= ~(1 << PA2); // Pull pin on usb low - PORTA &= ~(1 << PA3); // Pull pin on usb low + //if (io_getModuleId() == 3) + //{ + // if ((time_millis() - pulseOn) > CAMERA_PULSE) + // { + // PORTA &= ~(1 << PA0); // Pull pin on usb low + // PORTA &= ~(1 << PA1); // Pull pin on usb low + // PORTA &= ~(1 << PA2); // Pull pin on usb low + // PORTA &= ~(1 << PA3); // Pull pin on usb low - if ((time_millis() - lastPicture) > CAMERA_FREQ) // Frequency of photos - { - cameras_sendPulse(); - lastPicture = time_millis(); - } + // if ((time_millis() - lastPicture) > CAMERA_FREQ) // Frequency of photos + // { + // cameras_sendPulse(); + // lastPicture = time_millis(); + // } - pulseOn = time_millis(); - } - } + // pulseOn = time_millis(); + // } + //} - } + } // While(1) return 0; -} +} // Main