diff --git a/slave/slave/config.h b/slave/slave/config.h --- a/slave/slave/config.h +++ b/slave/slave/config.h @@ -30,8 +30,8 @@ //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 5000 // Camera pulse frequency (Should be 30000 for 30 Secs) -#define CAMERA_PULSE 2500 // Camera pulse duration +#define CAMERA_FREQ 30000 // Camera pulse frequency (Should be 30000 for 30 Secs) +#define CAMERA_PULSE 500 // Camera pulse duration //I2C Addresses #define EEPROM_ADDR 0xA0 // Read 0xA1 - Write 0xA0 diff --git a/slave/slave/lib/i2c.c b/slave/slave/lib/i2c.c --- a/slave/slave/lib/i2c.c +++ b/slave/slave/lib/i2c.c @@ -46,7 +46,7 @@ unsigned char i2c_start(unsigned char ad // wait until transmission completed // startTime = time_millis(); - while(!(TWCR & (1< 10) // { @@ -64,7 +64,7 @@ unsigned char i2c_start(unsigned char ad // wail until transmission completed and ACK/NACK has been received // startTime = time_millis(); - while(!(TWCR & (1< 10) // { @@ -99,14 +99,14 @@ void i2c_start_wait(unsigned char addres TWCR = (1< 10) - { - break; // Timeout Reached! - } - } + //startTime = time_millis(); + while(!(TWCR & (1< 10) + //{ + //break; // Timeout Reached! + //} + //} // check value of TWI Status Register. Mask prescaler bits. twst = TW_STATUS & 0xF8; @@ -117,14 +117,14 @@ void i2c_start_wait(unsigned char addres TWCR = (1< 10) - { - break; // Timeout Reached! - } - } + //startTime = time_millis(); + while(!(TWCR & (1< 10) + //{ + //break; // Timeout Reached! + //} + //} // check value of TWI Status Register. Mask prescaler bits. twst = TW_STATUS & 0xF8; @@ -134,14 +134,14 @@ void i2c_start_wait(unsigned char addres TWCR = (1< 10) - { - break; // Timeout Reached! - } - } + //startTime = time_millis(); + while(TWCR & (1< 10) + //{ + //break; // Timeout Reached! + //} + //} continue; } @@ -179,7 +179,7 @@ void i2c_stop(void) // wait until stop condition is executed and bus released // startTime = time_millis(); - while(TWCR & (1< 10) // { @@ -207,14 +207,14 @@ unsigned char i2c_writeX( unsigned char TWCR = (1< 10) - { - break; // Timeout Reached! - } - } + //startTime = time_millis(); + while(!(TWCR & (1< 10) + //{ + //break; // Timeout Reached! + //} + //} // check value of TWI Status Register. Mask prescaler bits @@ -235,14 +235,14 @@ unsigned char i2c_readAck(void) { TWCR = (1< 10) - { - break; // Timeout Reached! - } - } + //startTime = time_millis(); + while(!(TWCR & (1< 10) + //{ + //break; // Timeout Reached! + //} + //} return TWDR; @@ -259,14 +259,14 @@ unsigned char i2c_readNak(void) { TWCR = (1< 10) - { - break; // Timeout Reached! - } - } + //startTime = time_millis(); + while(!(TWCR & (1< 10) + //{ + //break; // Timeout Reached! + //} + //} return TWDR; diff --git a/slave/slave/lib/sensors.c b/slave/slave/lib/sensors.c --- a/slave/slave/lib/sensors.c +++ b/slave/slave/lib/sensors.c @@ -186,8 +186,9 @@ void sensors_readPressure() x1 = (x1 * 3038) >> 16; x2 = (-7357 * pressure) >> 16; pressure += (x1 + x2 + 3791) >> 4; //This is the final value for our pressure + pressure = pressure - 21000; // Linear Offset (Debug?) - altitude = (float)44330 * (1 - pow(((float) pressure/101325), 0.190295)); + altitude = (float)44330 * (1 - pow(((float) pressure/101325), 0.190295)); // 101325 } void sensors_readHumid() diff --git a/slave/slave/modules.c b/slave/slave/modules.c --- a/slave/slave/modules.c +++ b/slave/slave/modules.c @@ -18,7 +18,6 @@ #include "lib/led.h" uint32_t lastPicture; - uint8_t pulseOn; uint32_t lastRefresh; // Time in ms when last geiger refresh occurred void modules_setup(uint8_t id) @@ -113,8 +112,7 @@ void modules_cameras_setup() { - lastPicture = time_millis(); - pulseOn = time_millis(); + lastPicture = time_millis(); DDRA |= (1 << DDA0); // Set PA0 to Output for Camera DDRA |= (1 << DDA1); // Set PA1 to Output for Camera @@ -156,25 +154,22 @@ void modules_cameras() { + // Gathers data and performs functions for cameras daughter board //cameras_readAccelXYZ(); - //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(); - // } - - // pulseOn = time_millis(); - //} - + if ((time_millis() - lastPicture) > CAMERA_FREQ) + { + cameras_sendPulse(); + lastPicture = time_millis(); + } + else if ((time_millis() - lastPicture) > 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 + } } \ No newline at end of file diff --git a/slave/slave/slave.c b/slave/slave/slave.c --- a/slave/slave/slave.c +++ b/slave/slave/slave.c @@ -37,8 +37,6 @@ #include "lib/watchdog.h" bool WDTreset = false; - uint32_t lastPicture; - uint8_t pulseOn; void micro_setup() { @@ -107,25 +105,6 @@ int main(void) //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 ((time_millis() - lastPicture) > CAMERA_FREQ) // Frequency of photos - // { - // cameras_sendPulse(); - // lastPicture = time_millis(); - // } - - // pulseOn = time_millis(); - // } - //} } // While(1)