Changeset - 6fe1c15f9458
[Not reviewed]
default
0 2 0
kripperger@CL-SEC241-09.cedarville.edu - 12 years ago 2013-02-14 15:31:31
kripperger@CL-SEC241-09.cedarville.edu
Fixes for sensors
2 files changed with 5 insertions and 5 deletions:
0 comments (0 inline, 0 general)
slave/slave/lib/sensors.c
Show inline comments
 
@@ -173,26 +173,26 @@ void sensors_readPressure()
 
	}
 
	
 
	else
 
	{
 
		pressure = (b7 / b4) << 1;
 
	}
 
	
 
	x1 = (pressure >> 8) * (pressure >> 8);
 
	x1 = (x1 * 3038) >> 16;
 
	x2 = (-7357 * pressure) >> 16;
 
	pressure += (x1 + x2 + 3791) >> 4;				//This is the final value for our pressure
 
	
 
	altitude = 44330 * (1 - pow((pressure / 101325), (1 / 5.255)));
 
	//altitude = (float)44330 * (1 - pow(((float) pressure/101325), 0.190295));
 
	//altitude = 44330 * (1 - pow((pressure / 101325), (1 / 5.255)));
 
	altitude = (float)44330 * (1 - pow(((float) pressure/101325), 0.190295));
 
}
 
 
void sensors_readHumid()
 
{
 
	humid = i2c_read16(HUMID_ADDR);
 
	
 
	//calculations to relative humidity: humid = (humid/((2^14) - 1))*100%       >> is divide by power, << is multiply by power, 2^14-1 = 16383
 
	humid = (humid / 16383) * 100;
 
}
 
 
void sensors_readLight()
 
{
slave/slave/slave.c
Show inline comments
 
@@ -53,46 +53,46 @@ int main(void)
 
	i2c_init();				// Setup I2C
 
	serial0_setup();		// Config serial port
 
	
 
	io_readModuleId();
 
	modules_setup(io_getModuleId());				// Run setup functions for specific module
 

	
 
	
 
	//uint8_t test;		//Debug
 
	//uint8_t test2;	//Debug	
 
	
 
	
 
	// Serial output //DEBUG
 
	char buff[64];							//Buffer for serial output //DEBUG
 
	char buff[128];							//Buffer for serial output //DEBUG
 
	serial0_sendString("Starting Slave\r\n");
 
			
 
    while(1)
 
    {	
 
		
 
		// Master communication
 
		masterComm_checkParser();
 
			
 
		
 
		
 
		// Main slave operations
 
		if ((time_millis() % SENSOR_LOOP) == 0)	// Uses program timer to run every so often. Time interval defined in config.h
 
		{
 
			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,128,"|ModuleID: %u |BoardTemp: %i |Millis: %lu |Light: %u |Pressure: %u \r\n",io_getModuleId(),sensors_getBoardTemp(),time_millis(),sensors_getLight(),sensors_getPressure()); //DEBUG
 
			serial0_sendString(buff); //DEBUG
 
			//snprintf(buff,128,"|ModuleID: %u |BoardTemp: %i |Millis: %lu |Light: %u |Pressure: %lu |Altitude: %lu \r\n",io_getModuleId(),sensors_getBoardTemp(),time_millis(),sensors_getLight(),sensors_getPressure(),sensors_getAltitude()); //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);
 
		}
 

	
 
    }
 
	
 
	return 0;
 
}
 

	
 

	
0 comments (0 inline, 0 general)