Changeset - a52064f7981f
[Not reviewed]
default
0 6 0
mkroening@CL-ENS241-07.cedarville.edu - 12 years ago 2013-02-07 20:11:48
mkroening@CL-ENS241-07.cedarville.edu
Merge
6 files changed with 32 insertions and 10 deletions:
0 comments (0 inline, 0 general)
slave/slave/config.h
Show inline comments
 
@@ -25,13 +25,13 @@
 
#define DATATYPES_GENERIC 3
 
#define DATATYPES_SENSOR 8
 
#define DATATYPES_GEIGER 4
 
#define DATATYPES_CAMERA 3
 
 
//Sensors and IO
 
#define SENSOR_LOOP 200				// Frequency of sensor reads (in ms)
 
#define SENSOR_LOOP 3000				// Frequency of sensor reads (in ms) (should be 200)
 
#define HEATER_THRESHOLD 40			// Temperature threshold in Fahrenheit where heater is activated
 
 
 //I2C Addresses
 
 #define EEPROM_ADDR 0xA0		// Read 0xA1 - Write 0xA0
 
 #define BOARDTEMP_ADDR 0x90	// Read 0x91 - Write 0x90
 
 #define PRESSURE_ADDR 0xEF		// Read 0xEF - Write 0xEE
slave/slave/lib/inputOutput.c
Show inline comments
 
@@ -20,16 +20,27 @@ int8_t	moduleID;	// Slave Module ID from
 
	
 
	DDRC &= ~(1 << DDC2);		// Set PC2 to input for rotary dip    //TEMPORARY//
 
	DDRC &= ~(1 << DDC3);		// Set PC3 to input for rotary dip    //TEMPORARY//
 
	DDRC &= ~(1 << DDC4);		// Set PC4 to input for rotary dip    //TEMPORARY//
 
	DDRC &= ~(1 << DDC5);		// Set PC5 to input for rotary dip    //TEMPORARY//
 
	
 
	
 
	DDRA &= ~(1 << DDA7);		// Set PA7 to input for battery voltage divider
 
	// I bit of SREG needs to be set?  Global interrupt.
 
	ADCSRA |= (1 << ADEN);									// Enable ADC
 
	
 
	ADCSRA |= (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0);
 
	ADMUX |= (1 << REFS0); 
 
	ADCSRA |= (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0);	// Set prescaler for ADC, 128 gives ADC freq of 125 KHz
 
	ADMUX |= (1 << REFS0);									// Set ADC reference voltage to AVCC
 
	ADMUX |= (1 << ADLAR);									// Sets 10 bit ADC to 8 bit
 
	ADMUX |= (1 << MUX2) | (1 << MUX1) | (1 << MUX0);		// Select ADC7 as the conversion channel
 
	ADCSRA |= (1 << ADATE);									// Enables auto trigger, determined in ADCSRB bits ADTS
 
	//ADCSRA |= (1 << ADIF);									// 
 
//ADCSRA |= (1 << ADIE);									// ADC interrupt enable set
 
	ADCSRB |= (0 << ADTS2) | (0 << ADTS1) | (0 << ADTS0);	// Set ADC auto trigger source to free running mode
 
	ADCSRA |= (1 << ADSC);									// Start ADC measurements.  ADC should now continuously run conversions, which are stored in ADCH 0x79
 
	
 
	
 
 }
 
 
 
 
 
 
   
slave/slave/lib/sensors.c
Show inline comments
 
@@ -19,12 +19,13 @@ int16_t	spiTemp;	// Thermocouple Tempera
 
int8_t	boardTemp;	// Board Temperature (from i2c)
 
//Should these two be int16_t?  CHANGED TO INT32 BASED ON DATASHEET
 
int32_t ut;			// Temperature from BMP085 (from i2c)
 
int32_t up;			// Pressure from BMP085 (from i2c)
 
uint16_t humid;		// Humidity (from i2c)
 
uint8_t light;		// Lux reading (from i2c)
 
int8_t batt;		// Read battery voltage from ADC
 
 
int16_t ac1;		// The following 11 variables are the calibration values for the BMP085
 
int16_t ac2;
 
int16_t ac3;
 
uint16_t ac4;
 
uint16_t ac5;
 
@@ -201,12 +202,17 @@ void sensors_readLight()
 
	// light = light | (0x0F & i2c_read(LIGHT_ADDR, 0x04));  //  This can be used to read in the 4 LSBs from the second register
 
	// exponent = 8xE3 + 4xE2 + 2xE1 + E0
 
	// mantissa = 128xM7 + 64xM6 + 32xM5 + 16xM4 + 8xM3 + 4xM2 + 2xM1 + M0
 
	// light = 2^(exponent)*mantissa*0.045
 
}
 
 
void sensors_readBatt()
 
{
 
	batt = ADCH;					// Read battery level from ADC
 
}
 
 
int16_t sensors_getSpiTemp(void)	// Gets spi temperature from variable
 
{
 
	return spiTemp;
 
}
 
 
int8_t sensors_getBoardTemp(void)	// Gets board temperature from variable
 
@@ -224,7 +230,13 @@ uint16_t sensors_getHumid(void)			// Get
 
	return humid;
 
}
 
 
uint8_t sensors_getLight(void)		// Gets light from variable
 
{
 
	return light;
 
}
 
 
//possibly uint8_t
 
int8_t sensors_getBatt(void)		// Gets battery voltage from variable
 
{
 
	return batt;
 
}
 
\ No newline at end of file
slave/slave/lib/sensors.h
Show inline comments
 
@@ -13,16 +13,16 @@
 
void sensors_setupPressure(void);	// Reads pressure calibration values
 
void sensors_readSpiTemp(void);		// Reads spi temperature
 
void sensors_readBoardTemp(void);	// Reads board temperature
 
void sensors_readPressure(void);	// Reads pressure
 
void sensors_readHumid(void);		// Reads humidity
 
void sensors_readLight(void);		// Reads lux
 
//void sensors_readBatt(void);
 
void sensors_readBatt(void);
 
 
int16_t sensors_getSpiTemp(void);	// Gets spi temperature from variable
 
int8_t sensors_getBoardTemp(void);	// Gets board temperature from variable
 
int32_t sensors_getPressure(void);	// Gets pressure from variable
 
uint16_t sensors_getHumid(void);	// Gets humidity from variable
 
uint8_t sensors_getLight(void);		// Gets lux from variable
 
//int_t sensors_getBatt(void);
 
int8_t sensors_getBatt(void);		// Gets battery voltage from variable
 
 
#endif /* SENSORS_H_ */
 
\ No newline at end of file
slave/slave/modules.c
Show inline comments
 
@@ -76,13 +76,13 @@
 
 }
 
  
 
 void modules_sensors_setup()
 
 {
 
	DESELECT_TEMP;
 
	setup_spi();
 
	//sensors_setupPressure();
 
	sensors_setupPressure();
 
 }
 
  
 
 void modules_geiger_setup()
 
 {
 
	// Pin setup
 
	DDRA &= ~(1 << DDA0);	// PA0 is an input
 
@@ -123,13 +123,13 @@
 
	// Gathers data and performs functions for sensor daughter board
 
	sensors_readBoardTemp();		//Data Read
 
	//sensors_readSpiTemp();			//Data Read
 
	//sensors_readPressure();			//Data Read
 
	//sensors_readHumid();				//Data Read
 
	//sensors_readLight();				//Data Read
 
	//sensors_readBatt();
 
	sensors_readBatt();
 
	 
 
 }
 
  
 
 void modules_geiger()
 
 {
 
	// No data gatering function needed for geiger daughter board
slave/slave/slave.c
Show inline comments
 
@@ -62,13 +62,12 @@ int main(void)
 
	
 
	
 
	// Serial output //DEBUG
 
	char buff[64];							//Buffer for serial output //DEBUG
 
	serial0_sendString("Starting Slave\r\n");
 
	
 
			
 
    while(1)
 
    {	
 
		
 
		// Master communication
 
		masterComm_checkParser();
 
			
 
@@ -80,14 +79,14 @@ int main(void)
 
			led_on(0);
 
			sensors_readBoardTemp();	// Read board temperature sensor (Common on all slaves) (Data Read)
 
			modules_run(io_getModuleId());		// Runs specific module functions (like data reading)
 
			
 
			io_regulateTemp();			// Gets board temperature and enables heater if below threshold
 

	
 
			//snprintf(buff,64,"|ModuleID: %u |BoardTemp: %i |Millis: %lu |Heater: %u\r\n",io_getModuleId(),sensors_getBoardTemp(),time_millis(),io_heaterStatus()); //DEBUG
 
			//serial0_sendString(buff); //DEBUG
 
			snprintf(buff,64,"|ModuleID: %u |BoardTemp: %i |Millis: %lu |Batt: %u\r\n",io_getModuleId(),sensors_getBoardTemp(),time_millis(),sensors_getBatt()); //DEBUG
 
			serial0_sendString(buff); //DEBUG
 

	
 
			_delay_ms(2);		// Delay to prevent the sensor loop from running again before time_millis changes
 
			led_off(0);
 
			led_off(2);
 
		}
 
0 comments (0 inline, 0 general)