Changeset - e159e0fa6e70
[Not reviewed]
default
0 6 0
kripperger@CL-SEC241-09.cedarville.edu - 12 years ago 2013-04-29 19:40:00
kripperger@CL-SEC241-09.cedarville.edu
Added generic cases for daughterboard expansion
6 files changed with 123 insertions and 14 deletions:
0 comments (0 inline, 0 general)
slave/slave/config.h
Show inline comments
 
@@ -23,12 +23,15 @@
 
 
// Number of datatypes to transmit per module type. This should match what is being sent in masterComm.c
 
#define DATATYPES_GENERIC 3
 
#define DATATYPES_SENSOR 8
 
#define DATATYPES_GEIGER 4
 
#define DATATYPES_CAMERA 3
 
#define DATATYPES_CUSTOM1 3		// Modules already automatically send 3 values (temp, batt, and heater status.)
 
#define DATATYPES_CUSTOM2 3		//    Additional sensor readings should be added onto the 3
 
#define DATATYPES_CUSTOM3 3		//    For example a daughterboard with two sensors would be 3+2=5
 
 
//Sensors and IO
 
#define SENSOR_LOOP 200				// Frequency of sensor reads (in ms) (should be 200)
 
#define HEATER_THRESHOLD 0			// Temperature threshold in Fahrenheit where heater is activated
 
#define CAMERA_FREQ 30000		// Camera pulse frequency (Should be 30000 for 30 Secs)
 
#define CAMERA_PULSE 400 			// Camera pulse duration
slave/slave/lib/masterComm.c
Show inline comments
 
@@ -57,12 +57,27 @@ void masterComm_types()
 
			
 
		case 3:
 
			// Camera
 
			dataTypes = DATATYPES_CAMERA;
 
			break;
 
			
 
		case 4:
 
			// Custom Daughterboard 1
 
			dataTypes = DATATYPES_CUSTOM1;
 
			break;
 
			
 
		case 5:
 
			// Custom Daughterboard 2
 
			dataTypes = DATATYPES_CUSTOM2;
 
			break;
 
		
 
		case 6:
 
			// Custom Daughterboard 3
 
			dataTypes = DATATYPES_CUSTOM3;
 
			break;
 
			
 
		default:
 
			dataTypes = DATATYPES_GENERIC;
 
			break;
 
	}
 
}
 
 
@@ -133,14 +148,29 @@ void masterComm_modules()
 
			masterComm_packetSend_unsigned(8,geiger_getCpm());
 
			break;
 
		
 
		case 3:
 
			// Camera
 
			
 
			break;
 
 
		case 4:
 
			// Custom Daughterboard 1
 
			
 
			break;
 
			break;			
 
 
		case 5:
 
			// Custom Daughterboard 2
 
			
 
			break;	
 
			
 
		case 6:
 
			// Custom Daughterboard 3
 
			
 
			break;	
 
		
 
		
 
		default:
 
			
 
			break;
 
	}
 
}
slave/slave/lib/sensors.c
Show inline comments
 
@@ -28,13 +28,15 @@ uint8_t mantissa;	// Mantissa for Lux
 
uint32_t lux;		// Calculated Lux value
 
uint8_t battL;		// Low byte of ADC
 
uint16_t batt;		// Read battery voltage from ADC
 
uint16_t vBatt;		// battery voltage
 
 
int8_t analogL;		// Low byte of ADC
 
int16_t analog;		// Read analog voltage from ADC
 
int16_t analog[8];		// Read analog voltage from ADC
 
 
uint8_t digital;	// Byte that contains the digital inputs from PORTA
 
 
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;
 
@@ -239,24 +241,27 @@ void sensors_readAnalog(uint8_t pin)
 
	DDRA &= ~(1 << pin);		// Set pin to input
 
	
 
	ADMUX &= 0xF8;
 
	ADMUX |= pin;
 
	
 
	analogL = ADCL;				// Read low battery byte from ADC (all 8 bits)
 
	analog = ADCH;				// Read high battery byte from ADC (only two LSBs)
 
	analog[pin] = ADCH;				// Read high battery byte from ADC (only two LSBs)
 
	
 
	analogL = ADCL;				// Second Read low battery byte from ADC (all 8 bits)
 
	analog = ADCH;				// Second Read high battery byte from ADC (only two LSBs)
 
	analog[pin] = ADCH;				// Second Read high battery byte from ADC (only two LSBs)
 
	
 
	analog = analog << 8;
 
	analog |= analogL;
 
	analog = (analog * 10.0) / 67.4;
 
	analog[pin] = analog[pin] << 8;
 
	analog[pin] |= analogL;
 
	analog[pin] = (analog[pin] * 10.0) / 67.4;
 
}
 
 
 
 
void sensors_readDigital(uint8_t pin)
 
{
 
	DDRA &= ~(1 << pin);		// Set pin to input
 
	digital = PINA;
 
}
 
 
 
int16_t sensors_getSpiTemp(void)	// Gets spi temperature from variable
 
{
 
	return spiTemp;
 
}
 
@@ -283,15 +288,20 @@ uint32_t sensors_getLux(void)		// Gets l
 
 
uint16_t sensors_getBatt(void)		// Gets battery voltage from variable
 
{
 
	return vBatt;
 
}
 
 
int16_t sensors_getAnalog(void)		// Gets battery voltage from variable
 
int16_t sensors_getAnalog(uint8_t pin)		// Gets battery voltage from variable
 
{
 
	return analog;
 
	return analog[pin];
 
}
 
 
uint8_t sensors_getDigital(uint8_t pin)		// Gets battery voltage from variable
 
{
 
	return ((digital >> pin) & 1);
 
}
 
 
uint32_t sensors_getAltitude(void)
 
{
 
	return altitude;
 
}
 
\ No newline at end of file
slave/slave/lib/sensors.h
Show inline comments
 
@@ -15,17 +15,19 @@ void sensors_readSpiTemp(void);		// Read
 
void sensors_readBoardTemp(void);	// Reads board temperature
 
void sensors_readPressure(void);	// Reads pressure
 
void sensors_readHumid(void);		// Reads humidity
 
void sensors_readLux(void);			// Reads lux
 
void sensors_readBatt(void);		// Reads battery voltage from ADC
 
void sensors_readAnalog(uint8_t pin);	// Reads generic analog voltage from ADC
 
void sensors_readDigital(uint8_t pin);	// Reads generic analog voltage from ADC
 
 
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
 
uint32_t sensors_getLux(void);		// Gets lux from variable
 
uint16_t sensors_getBatt(void);		// Gets battery voltage from variable
 
int16_t sensors_getAnalog(void);		// Gets battery voltage from variable
 
uint32_t sensors_getAltitude(void);	// Gets altitude from variable
 
int16_t sensors_getAnalog(uint8_t pin);		// Gets battery voltage from variable
 
uint8_t sensors_getDigital(uint8_t pin);		// Gets battery voltage from variable
 
 
#endif /* SENSORS_H_ */
 
\ No newline at end of file
slave/slave/modules.c
Show inline comments
 
@@ -38,12 +38,24 @@
 
			break;
 
			
 
		case 3:
 
			modules_cameras_setup();
 
			break;
 
			
 
		case 4:
 
			modules_custom1_setup();
 
			break;
 
		
 
		case 5:
 
			modules_custom2_setup();
 
			break;
 
			
 
		case 6:
 
			modules_custom3_setup();
 
			break;
 
			
 
		default:
 
			modules_generic_setup();
 
			break;
 
	}
 
	  
 
 }
 
@@ -64,13 +76,25 @@
 
			modules_geiger();
 
			break;
 
		  
 
		case 3:
 
			modules_cameras();
 
			break;
 
		  
 
			
 
		case 4:
 
			modules_custom1();
 
			break;
 
		
 
		case 5:
 
			modules_custom2();
 
			break;
 
		
 
		case 6:
 
			modules_custom3();
 
			break;
 
			  
 
		default:
 
			modules_generic();
 
			break;
 
	}
 
	  
 
 }
 
@@ -120,12 +144,32 @@
 
	 DDRA |= (1 << DDA1);	// Set PA1 to Output for Camera
 
	 DDRA |= (1 << DDA2);	// Set PA2 to Output for Camera
 
	 DDRA |= (1 << DDA3);	// Set PA3 to Output for Camera
 
 }
 
  
 
 
 void modules_custom1_setup()
 
 {
 
	 
 
 }
 
 
 void modules_custom2_setup()
 
 {
 
	 
 
 }
 
 
 void modules_custom3_setup()
 
 {
 
	 
 
 }
 
 
 
 
 
 
 
 void modules_generic()
 
 {
 
	// Gathers data and performs functions for generic daughter board
 
	
 
	
 
 }
 
@@ -179,7 +223,21 @@
 
			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
 
		}		
 
 } 
 
  
 
\ No newline at end of file
 
  
 
  void modules_custom1()
 
  {
 
	   
 
  }
 
 
  void modules_custom2()
 
  {
 
   
 
  }
 
 
  void modules_custom3()
 
  {
 
   
 
  }
 
\ No newline at end of file
slave/slave/modules.h
Show inline comments
 
@@ -14,15 +14,21 @@
 
 
 
 // Setup functions for microcontroller configuration per specific daughter board
 
 void modules_generic_setup();
 
 void modules_sensors_setup();
 
 void modules_geiger_setup();
 
 void modules_cameras_setup();
 
 void modules_custom1_setup();
 
 void modules_custom2_setup();
 
 void modules_custom3_setup();
 
 
 // Data acquisition for specific daughter board
 
 void modules_generic();
 
 void modules_sensors();
 
 void modules_geiger();
 
 void modules_cameras();
 
 void modules_custom1();
 
 void modules_custom2();
 
 void modules_custom3();
 
 
 
#endif /* MODULES_H_ */
 
\ No newline at end of file
0 comments (0 inline, 0 general)