# HG changeset patch # User ethanzonca@CL-ENS241-08.cedarville.edu # Date 2013-03-14 16:48:00 # Node ID a5d9aa0655fca87d6e1ee1c0f2990b7da9578d6b # Parent 156fa380821ccc6d80e39222876fe0f49b2772d3 Added battery voltage, documentation, refactoring, etc. diff --git a/master/master/config.h b/master/master/config.h --- a/master/master/config.h +++ b/master/master/config.h @@ -16,29 +16,36 @@ #include // -------------------------------------------------------------------------- +// Hardware settings +// -------------------------------------------------------------------------- + +#define F_CPU 11059200 +#define BOARDTEMP_ADDR 0x90 + + +// -------------------------------------------------------------------------- // Module config (master.c) // -------------------------------------------------------------------------- +// Debug Output //#define DEBUG_OUTPUT +// Blackout (turn off all but power LEDs) #define BLACKOUT_ENABLE +#define BLACKOUT_TIMEOUT 300000 // Blackout after 5 minutes (hopefully after fix) -#define F_CPU 11059200 -#define MODULE_ID '1' -#define BOARDTEMP_ADDR 0x90 - +// Board heater setpoint #define HEATER_THRESHOLD 60 -// Touchdown buzzer settings +// Touchdown buzzer #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) +// Error Codes config (logger.c) // -------------------------------------------------------------------------- // SD Card @@ -46,29 +53,25 @@ #define ERROR_SD_INIT 1 #define ERROR_SD_PARTITION 2 #define ERROR_SD_FILE 3 - #define ERROR_XBEETIMEOUT 4 - - #define ERROR_FATAL 5 - #define ERROR_ATFAIL 6 #define ERROR_EXITAT 7 - #define ERROR_INFOTEXT 8 - -// !!! Please specify detailed messages for these error codes in logger.c +// !!! Please specify/update detailed messages for these error codes in logger.c // -------------------------------------------------------------------------- // Slave Sensors config (slavesensors.c) // -------------------------------------------------------------------------- -#define MAX_NUM_SLAVES 5 // Maximum number of nodes in the system -#define MAX_NUM_SENSORS 10 // Maximum number of unique types of sensors in the system +// Slave data structure size +#define MAX_NUM_SLAVES 5 // Maximum number of nodes in the system +#define MAX_NUM_SENSORS 10 // Maximum number of unique types of sensors in the system // Node identifier of log destination xbee #define XBEE_LOGDEST_NAME "HAB-LOGGER" +// Rate to request data from slaves. Must be greater than AT delay * number slaves #define DATAREQUEST_RATE 3000 // Timeouts @@ -77,9 +80,10 @@ #define TIMEOUT_EXITAT 2000 #define TIMEOUT_XBEERESPONSE 2000 -// Retries +// Slave data request max retries (for retry upon corrupt data reception) #define MAX_SLAVEREQUEST_RETRIES 2 + // -------------------------------------------------------------------------- // Command Parser config (serparser.c) // -------------------------------------------------------------------------- @@ -90,19 +94,20 @@ // Circular serial buffer size. Must be at least MAX_CMD_LEN + 5 #define BUFFER_SIZE 128 -// Public broadcast address -#define BROADCAST_ADDR 0 - // -------------------------------------------------------------------------- // GPS config (xxx.c) // -------------------------------------------------------------------------- + +// NMEA circular buffer size. Must be large enough to hold all received sentences #define NMEABUFFER_SIZE 150 + // -------------------------------------------------------------------------- // USART config (serial.c) // -------------------------------------------------------------------------- +// Baud rates for XBEE and GPS serial ports #define USART0_BAUDRATE 115200 #define USART1_BAUDRATE 115200 @@ -151,6 +156,7 @@ // Logger config (logger.c) // -------------------------------------------------------------------------- +// Log number EEPROM address (this number is incremented on boot, used for filenames) #define LOGGER_ID_EEPROM_ADDR 0x10 // Written to the beginning of every log file @@ -162,4 +168,5 @@ // LED cycle indicator speed #define LEDCYCLE_RATE 100 + #endif /* CONFIG_H_ */ \ No newline at end of file diff --git a/master/master/lib/boardtemp.c b/master/master/lib/boardtemp.c deleted file mode 100644 --- a/master/master/lib/boardtemp.c +++ /dev/null @@ -1,29 +0,0 @@ -/* - * sensors.c - * - * Created: 11/19/2012 9:25:01 PM - * Author: kripperger - */ - - -#include -#include -#include -#include "../config.h" -#include -#include "boardtemp.h" -#include "i2c.h" - -int8_t boardTemp = 255; // Board Temperature (from i2c) - -void sensors_readBoardTemp() -{ - boardTemp = i2c_read(BOARDTEMP_ADDR, 0x00); // Read only the first byte of data (we don't need the resolution here) - boardTemp = ((boardTemp*18)/10) + (32); // Converting Celsius to Fahrenheit - boardTemp = boardTemp - 3; // Linear offset -} - -int8_t sensors_getBoardTemp(void) -{ - return boardTemp; -} diff --git a/master/master/lib/boardtemp.h b/master/master/lib/boardtemp.h deleted file mode 100644 --- a/master/master/lib/boardtemp.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * sensors.h - * - * Created: 11/19/2012 9:24:50 PM - * Author: kripperger - */ - - -#ifndef BOARDTEMP_H_ -#define BOARDTEMP_H_ - -void sensors_readBoardTemp(void); // Reads board temperature -int8_t sensors_getBoardTemp(void); // Gets board temperature from variable - -#endif /* BOARDTEMP_H_ */ \ No newline at end of file diff --git a/master/master/lib/heater.c b/master/master/lib/heater.c --- a/master/master/lib/heater.c +++ b/master/master/lib/heater.c @@ -12,7 +12,7 @@ #include "../config.h" #include "led.h" -#include "boardtemp.h" +#include "sensors.h" void heater_regulateTemp() { diff --git a/master/master/lib/led.c b/master/master/lib/led.c --- a/master/master/lib/led.c +++ b/master/master/lib/led.c @@ -79,6 +79,11 @@ void led_blackout() { } } +bool led_isBlackout() +{ + return blackout; +} + // Flashes error LED a set amount of times, then leaves it on void led_errorcode(uint8_t code) { diff --git a/master/master/lib/led.h b/master/master/lib/led.h --- a/master/master/lib/led.h +++ b/master/master/lib/led.h @@ -15,6 +15,7 @@ #define LED_H_ #include +#include enum leds { LED_ACT0 = 0, @@ -61,6 +62,7 @@ void led_on(uint8_t led); void led_off(uint8_t led); void led_toggle(uint8_t led); void led_blackout(); +bool led_isBlackout(); void led_errorcode(uint8_t code); void led_spin(); void led_alert(); diff --git a/master/master/lib/logger.c b/master/master/lib/logger.c --- a/master/master/lib/logger.c +++ b/master/master/lib/logger.c @@ -71,10 +71,7 @@ void logger_setup() error_log(ERROR_SD_INIT, true); return; } - - // TODO: Check SD card switch to see if inserted. - // this was included in the library, but is commented out right now - + // Open first partition partition = partition_open(sd_raw_read, sd_raw_read_interval, sd_raw_write, sd_raw_write_interval, 0); diff --git a/master/master/lib/sdcard/sd_raw.c b/master/master/lib/sdcard/sd_raw.c --- a/master/master/lib/sdcard/sd_raw.c +++ b/master/master/lib/sdcard/sd_raw.c @@ -12,6 +12,8 @@ #include #include "sd_raw.h" #include "sd_raw_config.h" +#include "../led.h" +#include /** * \addtogroup sd_raw MMC/SD/SDHC card raw access @@ -319,6 +321,8 @@ uint8_t sd_raw_init() SPCR &= ~((1 << SPR1) | (1 << SPR0)); /* Clock Frequency: f_OSC / 4 */ SPSR |= (1 << SPI2X); /* Doubled Clock Frequency: f_OSC / 2 */ + + #if !SD_RAW_SAVE_RAM /* the first block is likely to be accessed first, so precache it here */ raw_block_address = (offset_t) -1; @@ -327,9 +331,10 @@ uint8_t sd_raw_init() #endif if(!sd_raw_read(0, raw_block, sizeof(raw_block))) { return 0; - } + } + #endif - + return 1; } diff --git a/master/master/lib/sensordata.c b/master/master/lib/sensordata.c --- a/master/master/lib/sensordata.c +++ b/master/master/lib/sensordata.c @@ -16,7 +16,7 @@ #include #include "sensordata.h" #include "slavesensors.h" -#include "boardtemp.h" +#include "sensors.h" #include "looptime.h" #include "gps.h" #include "logger.h" @@ -150,7 +150,7 @@ void sensordata_logvalues() csvHeader[0] = 0x00; // Add master data headers - logger_log("Time,BoardTemp,GPSTime,GPSLat,GPSLon,GPSSpeed,GPSHDOP,GPSCourse,GPSSV,"); + logger_log("Time,BoardTemp,VBatt,GPSTime,GPSLat,GPSLon,GPSSpeed,GPSHDOP,GPSCourse,GPSSV,"); // Add slave data headers for(uint8_t i=0; i BLACKOUT_TIMEOUT) + { + // LED blackout + led_blackout(); + black = true; + } + #endif // Parse any serial data in the XBee software buffer parseResult = serparser_parse(); diff --git a/master/master/master.cproj b/master/master/master.cproj --- a/master/master/master.cproj +++ b/master/master/master.cproj @@ -48,7 +48,7 @@ 127.0.0.1 - 49512 + 55130 False @@ -56,7 +56,7 @@ 249000 1000000 - 2010000 + 1970000 false false 0 @@ -132,10 +132,10 @@ compile - + compile - + compile