Changeset - 6b25c240180b
[Not reviewed]
default
0 4 0
kripperger@CL-SEC241-09.cedarville.edu - 12 years ago 2013-01-21 19:39:31
kripperger@CL-SEC241-09.cedarville.edu
Heater configurations
4 files changed with 24 insertions and 6 deletions:
0 comments (0 inline, 0 general)
slave/slave/config.h
Show inline comments
 
@@ -7,23 +7,24 @@
 
 
 
 #ifndef CONFIG_H_
 
 #define CONFIG_H_
 
 
 #define F_CPU 11059200				// Clock frequency (used in calculations)
 
 
#define USART0_BAUDRATE 115200
 
#define USART1_BAUDRATE 115200 
 
 
#define SENSOR_LOOP 100				// Frequency of sensor reads (in ms)
 
 
#define HEATER_THRESHOLD 70			// Temperature threshold in Fahrenheit where heater is activated
 
#define HEATER_THRESHOLD 40			// Temperature threshold in Fahrenheit where heater is activated
 
 
 //I2C Addresses
 
 #define BOARDTEMP_ADDR 0x90		// Read 0x91 - Write 0x90
 
 #define PRESSURE_ADDR 0xA1		//THIS VALUE IS WRONG
 
 #define HUMID_ADDR 0xA4		//THIS VALUE IS WRONG
 
 #define RTC_ADDR 0xA2			//DEBUG [Used for testing]      // Read 0xA3 - Write 0xA2
 
 #define EEPROM_ADDR 0xA0		// Read 0xA1 - Write 0xA0
 
 #define BOARDTEMP_ADDR 0x90	// Read 0x91 - Write 0x90
 
 #define PRESSURE_ADDR 0xB1		//THIS VALUE IS WRONG
 
 #define HUMID_ADDR 0xB4		//THIS VALUE IS WRONG
 
 #define RTC_ADDR 0xB2			//DEBUG [Used for testing]      // Read 0xA3 - Write 0xA2
 
 
 
 
 #endif /* CONFIG_H_ */
 
\ No newline at end of file
slave/slave/lib/inputOutput.c
Show inline comments
 
@@ -18,47 +18,63 @@
 
	DDRC &= ~(1 << DDC3);		// Set PC3 to input for rotary dip    //TEMPORARY//
 
	DDRC &= ~(1 << DDC4);		// Set PC4 to input for rotary dip    //TEMPORARY//
 
	DDRC &= ~(1 << DDC5);		// Set PC5 to input for rotary dip    //TEMPORARY//
 
 }
 
 
 
 
 
 uint8_t io_getModuleId()
 
 {
 
	// Get ID from rotary dip and return it. 
 
	uint8_t id;
 
	id = 0;
 
	
 
	
 
	
 
	
 
	// This method is temporary as the next release will read the module ID from EEPROM
 
	PORTC |= (1 << PC2);	// Pull pins on rotary dip high
 
	PORTC |= (1 << PC3);	// Pull pins on rotary dip high
 
	PORTC |= (1 << PC4);	// Pull pins on rotary dip high
 
	PORTC |= (1 << PC5);	// Pull pins on rotary dip high
 
	
 
	id = ((PINC & 0b00011100) >> 2);	// Read Dip Encoder
 
	id = ~id;							//Invert Dip reading
 
	id = (id & 0b0111);					//Mask bits
 
 
 
	//id = i2c_read(EEPROM_ADDR, 0x04);
 
 
 
	return id;
 
 }
 
 
 
 void io_heaterOn()
 
 {		
 
	PORTB |= (1 << PB4);	//ON
 
 }
 
 
 
 void io_heaterOff()
 
 {
 
	PORTB &= ~(1 << PB4);	//OFF
 
 }
 
 
 
 uint8_t io_heaterStatus()
 
 {
 
	 uint8_t state;
 
	 state = 0;
 
	 
 
	 state = ((PORTB & 0b00010000) >> 4);
 
	 
 
	 return state;
 
 }
 
 
 
  void io_regulateTemp()
 
  {
 
	  // Gets board temperature and enables heater if below threshold
 
	  if (sensors_getBoardTemp() <= HEATER_THRESHOLD)
 
	  {
 
		  io_heaterOn();
 
		  led_on(1);
 
	  } 
 
	  else if (sensors_getBoardTemp() > (HEATER_THRESHOLD + 5))
 
	  {
 
		  io_heaterOff();
slave/slave/lib/inputOutput.h
Show inline comments
 
@@ -5,16 +5,17 @@
 
 *  Author: kripperger
 
 */ 
 
 
 
#ifndef IO_H_
 
#define IO_H_
 
 
 
void io_configure();
 
uint8_t io_getModuleId();	// Get ID from rotary dip and return it.
 
 
 
void io_heaterOn();
 
void io_heaterOff();
 
uint8_t io_heaterStatus();
 
 
void io_regulateTemp();		// Gets board temperature and enables heater if below threshold
 
 
#endif /* IO_H_ */
 
\ No newline at end of file
slave/slave/slave.c
Show inline comments
 
@@ -62,25 +62,25 @@ int main(void)
 
	serial0_sendString("Starting\r\n");
 
	
 
	
 
    while(1)
 
    {		
 
		if ((time_millis() % SENSOR_LOOP) == 0)	// Uses program timer to run every so often. Time interval defined in config.h
 
		{
 
			sensors_readBoardTemp();	// Read board temperature sensor (Common on all slaves) (Data Read)
 
			modules_run(moduleID);		// Runs specific module functions (like data reading)
 
			
 
			io_regulateTemp();			// Gets board temperature and enables heater if below threshold
 
			
 
			snprintf(buff,64,"|ModuleID: %u |BoardTemp: %i |Millis: %lu\r\n",moduleID,sensors_getBoardTemp(),time_millis()); //DEBUG
 
			snprintf(buff,64,"|ModuleID: %u |BoardTemp: %i |Millis: %lu |Heater: %u\r\n",moduleID,sensors_getBoardTemp(),time_millis(),io_heaterStatus()); //DEBUG
 
			serial0_sendString(buff); //DEBUG
 
			
 
			led_toggle(0);		// Toggle LED0(Blue) to show loop running	
 
		}
 
		
 
 
    }
 
	
 
	return 0;
 
}
 
 
0 comments (0 inline, 0 general)