Changeset - 2406c449316b
[Not reviewed]
default
0 5 0
ethanzonca@CL-ENS241-08.cedarville.edu - 12 years ago 2013-02-26 16:34:24
ethanzonca@CL-ENS241-08.cedarville.edu
Added buzzer on touchdown support with altitude and failsafe cutoff time. Failsafe is tested and functional, altitude is untested.
5 files changed with 67 insertions and 4 deletions:
0 comments (0 inline, 0 general)
master/master/config.h
Show inline comments
 
@@ -29,6 +29,13 @@
 
 
#define HEATER_THRESHOLD 60
 
 
// Touchdown buzzer settings
 
#define BUZZER_RATE 3000
 
#define BUZZER_DURATION 1
 
 
#define BUZZER_FAILSAFE_DURATION 600000
 
#define BUZZER_TRIGGER_MINDURATION 1
 
#define BUZZER_TRIGGER_MAXALTITUDE 1
 
 
// --------------------------------------------------------------------------
 
// Error Codes config (led.c, used throughout code)
master/master/lib/led.c
Show inline comments
 
@@ -43,7 +43,7 @@ void led_power_toggle()
 
// Turn the specified LED on
 
void led_on(uint8_t led) 
 
{
 
	if(blackout && led != LED_ERROR)
 
	if(blackout && led != LED_ERROR && led != LED_BUZZ)
 
	{
 
		return;
 
	}		
 
@@ -58,7 +58,7 @@ void led_off(uint8_t led)
 
 
void led_toggle(uint8_t led)
 
{
 
	if(blackout && led != LED_ERROR)
 
	if(blackout && led != LED_ERROR && led != LED_BUZZ)
 
	{
 
		return;
 
	}
master/master/lib/sensordata.c
Show inline comments
 
@@ -204,4 +204,45 @@ void sensordata_logvalues()
 
		snprintf(logbuf + strlen(logbuf),CSV_LOGLINE_SIZE-strlen(logbuf),"\r\n");
 
		logger_log(logbuf);
 
	}
 
}
 

	
 
bool isTouchdown = false;
 
bool sensordata_isTouchdown()
 
{
 
	return isTouchdown;
 
}
 

	
 
int32_t sensordata_getSensorValue(uint8_t sensorID) 
 
{
 
	// Loop through all slaves
 
	for(int i=0; i<MAX_NUM_SLAVES; i++)
 
	{
 
		uint32_t val = sensordata_get(i, sensorID);
 
		if(val != -2111111111) {
 
			return val;
 
		}
 
	}		
 
	return -2111111111;
 
}
 

	
 
void sensordata_checkTouchdown()
 
{
 
	// If we have reached touchdown, never get out of this state
 
	if(isTouchdown)
 
	{
 
		return;
 
	}
 
	
 
	if(time_millis() > BUZZER_FAILSAFE_DURATION)
 
	{
 
		isTouchdown = true;
 
	}
 
	else
 
	{
 
		int32_t altitude = sensordata_getSensorValue(SENSOR_ALTITUDE);
 
		if(altitude != -2111111111 && altitude < BUZZER_TRIGGER_MAXALTITUDE && time_millis() > BUZZER_TRIGGER_MINDURATION)
 
		{
 
			isTouchdown = true;
 
		}			
 
	}
 
}
 
\ No newline at end of file
master/master/lib/sensordata.h
Show inline comments
 
@@ -21,5 +21,7 @@ void sensordata_set(uint8_t nodeID, uint
 
int32_t sensordata_get(uint8_t nodeID, uint8_t type);
 
char* slavesensors_getAPRScomment();
 
void sensordata_logvalues();
 
bool sensordata_isTouchdown();
 
void sensordata_checkTouchdown();
 
 
#endif /* SENSORDATA_H_ */
 
\ No newline at end of file
master/master/master.c
Show inline comments
 
@@ -64,6 +64,7 @@ int main(void)
 
	uint32_t lastLog = 0;
 
	uint32_t lastLedCycle = 0;
 
	uint32_t lastDataReq = 0;
 
	uint32_t lastBuzz = 0;
 
	
 
	// Result of last parser run
 
	int parseResult = PARSERESULT_NODATA;
 
@@ -73,7 +74,6 @@ int main(void)
 
	
 
	while(1)
 
    {
 
		
 
		// Periodic: LED execution indicator
 
		if(time_millis() - lastLedCycle > LEDCYCLE_RATE) 
 
		{
 
@@ -113,11 +113,20 @@ int main(void)
 
			lastLog = time_millis();
 
		}		
 
		
 
		// Periodic: Buzzer
 
		if(time_millis() - lastBuzz > BUZZER_RATE) {
 
			if(sensordata_isTouchdown())
 
			{
 
				led_on(LED_BUZZ);
 
				_delay_ms(BUZZER_DURATION);
 
				led_off(LED_BUZZ);
 
			}			
 
			lastBuzz = time_millis();
 
		}
 
		
 
		// Periodic: Data Request
 
		if(time_millis() - lastDataReq > DATAREQUEST_RATE)  
 
		{
 
			
 
			// Start getting values for next transmission
 
			if(slavesensors_isrequesting())
 
			{
 
@@ -135,6 +144,10 @@ int main(void)
 
		// Periodic: APRS transmission
 
		if(time_millis() - lastAprsBroadcast > APRS_TRANSMIT_PERIOD) 
 
		{
 
			// Check for touchdown
 
			sensordata_checkTouchdown();
 
			
 
			// LED blackout
 
			#ifdef BLACKOUT_ENABLE
 
			led_blackout();
 
			#endif
0 comments (0 inline, 0 general)