Changeset - 0df60b3e84ea
[Not reviewed]
default
0 5 0
kripperger@CL-SEC241-09.cedarville.edu - 12 years ago 2013-04-03 19:02:24
kripperger@CL-SEC241-09.cedarville.edu
geiger work
5 files changed with 40 insertions and 31 deletions:
0 comments (0 inline, 0 general)
slave/slave/lib/geiger.c
Show inline comments
 
@@ -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
 
}
 
}
slave/slave/lib/geiger.h
Show inline comments
 
@@ -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
slave/slave/lib/inputOutput.c
Show inline comments
 
@@ -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);
 
	}
 
 }
 
 
 
 
slave/slave/modules.c
Show inline comments
 
@@ -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,6 +94,7 @@
 
	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
 
@@ -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()
 
@@ -143,6 +146,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)
 
		}			
 
	  
 
 }
 
  
 
 void modules_cameras()
slave/slave/slave.c
Show inline comments
 
@@ -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
 

	
 

	
 

	
0 comments (0 inline, 0 general)