Changeset - 381ec8b85cb2
[Not reviewed]
default
0 3 0
kripperger@CL-SEC241-09.cedarville.edu - 12 years ago 2013-04-10 21:20:17
kripperger@CL-SEC241-09.cedarville.edu
Geiger moving avg filter improvements
3 files changed with 15 insertions and 13 deletions:
0 comments (0 inline, 0 general)
slave/slave/lib/geiger.c
Show inline comments
 
@@ -18,7 +18,7 @@ volatile uint8_t seconds;		// Counts Sec
 
volatile uint16_t counts;		// Counts the pulses
 
volatile uint16_t CPM;			// Counts per Minuite
 
volatile uint32_t countStart = 0;
 
volatile uint8_t CPS[30];		// Counts per Second
 
volatile uint8_t CPS[60];		// Counts per Second
 
volatile uint8_t i;
 
 
ISR(TIMER2_OVF_vect)    // Timer 2 overflow interrupt handler
 
@@ -26,22 +26,24 @@ ISR(TIMER2_OVF_vect)    // Timer 2 overf
 
	// This executes every second.  Update real-time clocks.
 
	// Used only in Geiger module
 
	
 
	//	The following is a 30 second moving average of the CPS
 
	//	The following is a 60 second moving average of the CPS
 
	seconds++;
 
	if (seconds>=30)
 
	if (seconds>=60)
 
	{
 
		CPM = 0;
 
		for (i=0;i<30;i++)
 
		{
 
			CPM = CPM + CPS[i];
 
		}
 
		CPM = CPM * 2;
 
		seconds = 0;
 
	}
 
	
 
	CPS[seconds] = counts;
 
	counts = 0;
 
	
 
	CPM = 0;
 
	for (i=0;i<60;i++)
 
	{
 
		CPM = CPM + CPS[i];
 
	}
 
	//CPM = CPM * 2;	// For a 30 second moving average
 
	
 
	
 
}
 
 
ISR(PCINT0_vect)    // Interrupt on PA0
 
@@ -53,7 +55,7 @@ ISR(PCINT0_vect)    // Interrupt on PA0
 
		countStart = time_millis();
 
		
 
		led_on(1);
 
		io_piezoOn();
 
		io_piezoOff();
 
		
 
		_delay_us(50);
 
	}
slave/slave/modules.c
Show inline comments
 
@@ -151,10 +151,10 @@
 
	//	geiger_refresh();	//Refreshes every 1000sec (16min)
 
	//}
 
		
 
	if ((time_millis() - geiger_getCountStart()) > 50)
 
	if ((time_millis() - geiger_getCountStart()) > 20)
 
	{
 
		led_off(1);
 
		io_piezoOff();
 
		io_piezoOn();
 
	}		
 
					
 
	  
slave/slave/slave.c
Show inline comments
 
@@ -94,7 +94,7 @@ int main(void)
 
			
 
			io_regulateTemp();			// Gets board temperature and enables heater if below threshold
 

	
 
			snprintf(buff,128,"|ModuleID: %u |BoardTemp: %i |Millis: %lu |Lux: %lu |Press: %lu |Altitude: %lu |Batt: %u |spiTemp: %i |CPM: %u \r\n ",io_getModuleId(),sensors_getBoardTemp(),time_millis(),sensors_getLux(),sensors_getPressure(),sensors_getAltitude(),sensors_getBatt(),sensors_getSpiTemp(),geiger_getCount()); //DEBUG
 
			snprintf(buff,128,"|ModuleID: %u |BoardTemp: %i |Millis: %lu |Lux: %lu |Press: %lu |Altitude: %lu |Batt: %u |spiTemp: %i |CPM: %u \r\n ",io_getModuleId(),sensors_getBoardTemp(),time_millis(),sensors_getLux(),sensors_getPressure(),sensors_getAltitude(),sensors_getBatt(),sensors_getSpiTemp(),geiger_getCpm()); //DEBUG
 
			serial1_sendString(buff); //DEBUG
 
			
 
			led_off(0);
0 comments (0 inline, 0 general)