Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Home automation system

1,220 views

Published on

  • Be the first to comment

Home automation system

  1. 1. HOME AUTOMATIONSYSTEMEE-323 SEMESTER PROJECT
  2. 2. COURSE INSTRUCTOR:LAB INSTRUCTOR:
  3. 3. “”Heights that great men reached and keptWere not attained in sudden flightThey while their companions sleptWere toiling upwards in the night• 2010079• 2010105• 2010131• 2010279
  4. 4. FAN RPM CONTROLTHROUGHTEMPERATURESENSORSINDOOR LIGHTCONTROL USING IRSENSORSOUTDOOR LIGHTDIMMING USINGLDRsAUTOMATIC CONTROLMODULESMANUAL OVERWRITECONTROLCONCATINATIONBASIC PLAN
  5. 5. F A N R P M C O N T R O LT H R O U G HT E M P E R A T U R ES E N S O R S2010131
  6. 6. SCHEMATICS
  7. 7. LM-35ANALOG DATAADCCONVERSIONDIGITAL DATATEST VALUEFLOW-CHART SUMMARIZATION
  8. 8. CODE EXPLAINATIONADCINTERNALCLOCKTIMER2AN0CCP1-PWMNO UNIVERSALVARIABLEDECLARATIONS
  9. 9.  setup_adc_ports(AN0); setup_adc(ADC_CLOCK_INTERNAL); setup_psp(PSP_DISABLED); setup_spi(SPI_SS_DISABLED); setup_wdt(WDT_OFF); setup_timer_0(RTCC_INTERNAL); [SLEEP MODE] setup_timer_1(T1_DISABLED); setup_timer_2(T2_DIV_BY_16,155,1); setup_timer_3(T3_DISABLED|T3_DIV_BY_1); setup_ccp1(CCP_PWM); set_pwm1_duty(0); setup_comparator(NC_NC_NC_NC); setup_vref(FALSE); setup_low_volt_detect(FALSE); set_timer2(0);CODE EXPLAINATION
  10. 10.  while(1) { set_adc_channel(0); value=read_adc(); if (value <= 12) set_pwm1_duty(0); else if (value > 12 && value <= 15) set_pwm1_duty(25); else if (value > 15 && value <= 18) set_pwm1_duty(50); else if (value > 18 && value <= 20) set_pwm1_duty(75); else set_pwm1_duty(100);}CODE EXPLAINATION
  11. 11.  if (value <= 12) set_pwm1_duty(0);CODE EXPLAINATIONVALUE <=12
  12. 12.  else if (value > 12 && value <= 15) set_pwm1_duty(25);CODE EXPLAINATION12<VALUE <=15
  13. 13.  else if (value > 15 && value <= 18) set_pwm1_duty(50);CODE EXPLAINATION15<VALUE <=18
  14. 14.  else if (value > 18 && value <= 20) set_pwm1_duty(75);CODE EXPLAINATION18<VALUE <=20
  15. 15.  else set_pwm1_duty(100);}CODE EXPLAINATIONVALUE >=20
  16. 16. [SIMULATION]PROTEUS SIMULATION OF CIRCUIT
  17. 17. I N D O O R L I G H TC O N T R O L U S I N GI R S E N S O R S2010105
  18. 18. SCHEMATICS
  19. 19. FLOW-CHART SUMMARIZATIONSTARTINTERRUPT?INT-IN OR INTOUTINT INCHECK OUTFLAGDECREMENTPERSONCOUNTERCOUNTER=0?OFF LIGHTSSET LIGHTSSET ININT OUTCHECK INFLAGSET OUTINC COUNTER SET LIGHTS
  20. 20. CODE EXPLAINATIONGLOBALINTERRUPTINTERRUPTEXT1INTERRUPTEXT 0short IN, OUTint COUNT
  21. 21.  setup_adc_ports(NO_ANALOGS); setup_adc(ADC_OFF); setup_psp(PSP_DISABLED); setup_spi(SPI_SS_DISABLED); setup_wdt(WDT_OFF); setup_timer_0(RTCC_INTERNAL); setup_timer_1(T1_DISABLED); setup_timer_2(T2_DISABLED,0,1); setup_comparator(NC_NC_NC_NC); setup_vref(FALSE); enable_interrupts(INT_EXT); enable_interrupts(INT_EXT1); enable_interrupts(GLOBAL); setup_low_volt_detect(FALSE);CODE EXPLAINATION
  22. 22.  void EXT_isr(void) { if (OUT) {COUNT -= 1; if (COUNT == 0) {output_bit( PIN_E0, 0); } else {output_bit( PIN_E0, 1); } OUT = 0; IN = 0;} else {IN = 1;} }CODE EXPLAINATIONINTERRUPTEXTERNAL_0
  23. 23.  void EXT1_isr(void) { if (IN) { COUNT+=1; output_bit( PIN_E0, 1); OUT = 0; IN = 0; } else { OUT = 1; } }CODE EXPLAINATIONINTERRUPTEXTERNAL_1
  24. 24.  void main() { IN=0; OUT=0; while(1); }CODE EXPLAINATIONMAINPROGRAM
  25. 25. [SIMULATION]PROTEUS SIMULATION OF CIRCUIT
  26. 26. O U T D O O R L I G H TD I M M I N G U S I N GL D R s2010279
  27. 27. SCHEMATICS
  28. 28. CODE EXPLAINATIONlong high_timelong low_timeint valueint lst_valueshort highshort lowADCINTERNALCLOCKTIMER0GLOBALAN0
  29. 29.  setup_adc_ports(AN0); setup_adc(ADC_CLOCK_INTERNAL); setup_psp(PSP_DISABLED); setup_spi(SPI_SS_DISABLED); setup_wdt(WDT_OFF); setup_timer_0(RTCC_INTERNAL); setup_timer_1(T1_DISABLED); setup_timer_2(T2_DISABLED,0,1); setup_comparator(NC_NC_NC_NC); setup_vref(FALSE); enable_interrupts(INT_TIMER0); enable_interrupts(GLOBAL); set_timer0(0); lst_value = 0;CODE EXPLAINATION
  30. 30. CODE EXPLAINATIONFUNCTIONZERO DUTY void zero_duty() { output_low(PIN_C0); disable_interrupts(INT_TIMER0); }
  31. 31. CODE EXPLAINATIONFUNCTIONFULL DUTY void full_duty() { output_high(PIN_C0); disable_interrupts(INT_TIMER0); }
  32. 32. CODE EXPLAINATIONFUNCTIONX DUTY(25% / 75%) void x_duty(int pcnt_duty) { if (pcnt_duty == 25) { high_time = 0x0271; low_time = 0xFD8E; } else { high_time = 0xFD8E; low_time = 0x271; } output_high(PIN_C0); set_timer0(high_time); high = 1; low = 0;}
  33. 33. CODE EXPLAINATIONTIMER-0INTERRUPT #int_TIMER0 void TIMER0_isr(void) { if (high) { set_timer0(low_time); output_low(PIN_C0); high = 0; low = 1; } else { set_timer0(high_time); output_high(PIN_C0); high = 1; low = 0; }}
  34. 34. CODE EXPLAINATIONMAINPROGRAM while(1) { set_adc_channel(0); value=read_adc(); if(value != lst_value) { lst_value = value; if (value <= 20) full_duty(); else if (value > 20 && value <= 60) {enable_interrupts(INT_TIMER0); x_duty(75); } else if (value > 60 && value < 142) { enable_interrupts(INT_TIMER0); x_duty(25); } else zero_duty();}}
  35. 35. [SIMULATION]PROTEUS SIMULATION OF CIRCUIT
  36. 36. M A N U A LO V E R WR I T EC O N T R O L2010079
  37. 37. FLOW-CHART SUMMARIZATION
  38. 38.  EXTERNAL 0 - MODE SWITCHING EXTERNAL 1 - IR SENSORS (IN) EXTERNAL 2 - IR SENSORS (OUT)CODE EXPLAINATIONAUTO/MANUAL MODE SWITCHINGINTERRUPT
  39. 39. CODE EXPLAINATIONFlag bit= highManualModeDisableinterruptsFlag bit= low Auto ModeEnableinterrupts EXTERNAL 0 - MODE SWITCHING A bit is initialized with the value 0 (automode), every time the interrupt EXT_0occurs, the value of the bit is toggled.
  40. 40. C O N C A T I N A T I ON O F T H EM O D U L E S2010079
  41. 41. FLOW-CHART SUMMARIZATIONSTARTAUTO MODEMAINENABLE INTERRUPTSTEMP SENSORFUNCTIONDIMMER FUNCTIONRETURN TO MAIN
  42. 42. FLOW-CHART SUMMARIZATIONEXT 0SWITCHMODEAUTO TOMANUALDISABLE EXTINTERRUPTSMANUALTO AUTOENABLE EXTINTERRUPTS
  43. 43. T H E E N D !

×