Home
SENIOR DESIGN PROJECT REPORT
Contents
1. HR 18 6 SYSTEM FLOWCHAR E aia 19 T TECHNOLOGIES USED E 20 7 1 Software Technologies Used cree eee e eres crees ee eene seen sees sees ssseesssseessss 20 7 2 Hardware Technologies Used a sus atri did tho ene tke n eee ea estu a eden ae deb ane ne Tek e apes Mars eee pe 22 9 SYSTEM ARCHITECTURE E 24 9 DESIGN RATIONALE 2 ou o one Gne o tea cats a ede ras EE aia 25 MEIN ricum E 26 10 1 Unit Testi 26 1 Unit Testing 10 2 System I CSEITIO asas ETE 11 LESSONS LEARNED iii Gn UCAC da Deeg 27 T2 eg 28 121 Ethical ctas cada HYR ceu uc oes cuo nv kee save etes t cave ee 12 2 Social 28 BAISER RENTE RA 12 3 Political 28 a i AAA REENEN s KE Y EE 12 5 Healthand Safety ee EE 12 6 Diana ctra d 12 7 Sustainability iria carro M24 2 12 3 Environmental Mpactucsrnsm cai iZ i PA SADIIEY ZO 12 10 Lifelong E TA AUREOS 13 USER MANU AL Pe 31 13 1 Setting up the Room Monitoring System ceeeeeeee eere eene eene een eese seessecess l 13 2 Using the On Board Interface eerie eteseee ete esatta easet tin ivtip a caso ba eoe odia esae a to eoi dNO SDO 133 Usmo the Web Inter PAC osos Q O 13 4 Using Temperature Monitoring Device oooonoconononooonococanonocnnonocnnonccnccncanccoranonocanonno JS 13 5 Using Light Monitoring Device
2. eese cete eerte e eerte e eene seen ese sen eee essseessseese Y M APPEND oem dt 40 14 1 Source Code Web Technologies ceres eere esee e eene eren eren eee een ee eessseessscees s DO 14 2 Source Code C files scccsssscsscscccssscccssvcccsccccssscccnnsccssccossscccensccccsccosssccensccccscoossseo O List of Figures Figure 1 Figure 2 Figure 3 Figure 4 Figure 5 Figure 6 Figure 7 Figure 8 Figure 9 Projec RE 13 Project Development Timeline etuer dde tiende a 14 System Flowchart uote tiet tst is 19 KE EH 24 Overall Project tee a 32 Detailed Project Flowchart Main Options sesion ici 33 Detailed Project Flowchart Temperature Options eene 34 Detailed Project Flowchart Light Options ENEE 35 Web Interface Screen Shot E 36 1 Introduction 1 1 The Problem In the world of technology and computer automation monitoring systems have played a large role Monitoring systems such as alarms or thermostats are an effective way to secure and monitor the atmosphere of one s residence work automatically and or remotely Networked monitoring systems have become popular recently One example is a networked thermostat a device capable of hosting a web server so that the user can check or change the temperature setting on the thermostat via the Internet There also exist similar monitoring systems that connect with the Internet such as networked alarms and sensors However
3. Loop over the bytes of the image for the dot for ulLoop 0 ulLoop lt 26 ulLoop y Copy this byte of the dot image to the local frame buffer g pucFrame ulStart ulLoop 2 64 ulLoop 2 g pucDot ulLoop l Skip past the dot in the local frame buffer ulStart 2 4 Return the new frame buffer starting address so that further drawing occur after the number just drawn return ulStart kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk Get an IP address store it in a global variable display it on the LCD J CK koe ke ke che ke e e he ke ehe ke RRR KR che ke RRR ce che ke e KKK KKK ce che ke KERR ke ce ck 5 ko KER RK kc ck RR KK KEK void GetIPAddress unsigned long ulCount ulLoop ulAddr ulStart ulDigit ulAddr 0 int ipl ip2 ip3 ip4 char IPaddress 20 int IPlength 0 while ulAddr 0 59 be over it Get the current IP address of the Ethernet interface This will zero when the IP address has not been assigned yet f ulAddr EnetGetIPAddr See if the IP address has been assigned if ulAddr 0 displayText Acquiring Address 10 30 5 displayText Please Wait 10 40 5 else 1 Get the width of the digits in the IP address L ulDigit ulAddr gt gt 24 ulStart ulDigit 99 24 ulDigit 9 16 8 ulDigit
4. hw_memmap h include hw_types h include i i sro uart h include rit128x96x4 h include lt stdio h gt include enet h include get_ip h include globals h include images h include random h include keystroke h include graphics h J RRR RRR KK RRR RRR RRR KR RK RR KR RK RRR ERK KR KKK RR KERR ERR KK RK KERR KERR KER RK i kck KKK RK KEK Draws a single number to the LCD J RRR RRR KK RRR RRR RRR KR RK RR KR RK KERR e AS static unsigned long DrawNumber unsigned long ulStart unsigned long ulNumber unsigned long ulMask tBoolean bDot unsigned long ulLoop ulIdx ulDigit Loop through the three possible digits in this number for ulIdx 1000000000 ulIdx gt 0 ulldx 10 4 Continue if this digit should not be drawn i e the hundreds digit for a two digit number a if ulNumber lt ulIdx amp amp ulIdx gt ulMask continue L Extract this digit from the number if ulDigit ulNumber ulIdx 10 Loop over the bytes of the image for this digit for ulLoop 0 ulLoop lt 52 ulLoop 1 58 can Copy this byte of the image to the local frame buffer ZZ g pucFrame ulStart ulLoop 4 64 ulLoop 4 g ppucDigits ulDigit ulLoop E Skip past this digit in the local frame buffer ulStart 4 See if a trailing dot should be drawn M if bDot
5. gYEAR 4 0 55 LeapMonth 0 else LeapMonth 0 Now we can check for month length if gDAY gt MonthLength gMONTH LeapMonth 1 gDAY 1 gMONTH if gMONTH gt 12 gMONTH 1 gYEAR 56 RR RRR RRR RRR KR RR RRR KERR KR Y ke ce che ke ce RK ce che KK RK KR RK ce che ck KERR KERR KER RK kc ko kc ck kc ck KK RK KKK KR KK KEK File name clock h KOR RRR RRR RRR RRR RR RR RRR RRR RR RR RR RR RRR RRR RRR RRR RRR RRR RRR KR RRR RRR RRR KR RK KR RR RR KKK define define define define define define extern extern extern extern extern extern extern extern HOUR MINUTE SECOND AMPM AM PM int int rint int int FP OWNF O gSECOND gMINUTE gHOUR gDAY gMONTH unsigned int gYEAR int gAMorPM char gAMPMarray 2 Function declarations void RTC_init void operati void Time update void on void ShowClock int vertical void SetClock char input char SetClockFormat char input void ShowDate int vertical void SetDate char input char SetDateFormat char input void IncrementSecond void updates the time and date initialize the Timer Counter 2 in asynchron 57 A kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk File name get ip c ub k i dA i6 A k RRR RRR ce RR e che ke ce che ck I ce ck KR RRR RRR RRR KERR KR KR KR RRR DRA ck ckckck ko k include
6. Acquiring IP Address Temperature Left Select Select Light Main Temperature Options Options Options see next three pages for detailed flowchart for each option Figure 5 Overall Project Flowchart 32 13 2 Using the On Board Interface Continued Main Options Set Time Set Date Select Up Select E Up Hours Month Minutes Up i Down i Up i Down i Decrement Toggle Down Decrement Toggle Down Increment Toggle Up Increment Toggle Up Figure 6 Detailed Project Flowchart Main Options 33 13 2 Using the On Board Interface Continued Temperature Options Set Set Thermo Temperature Status 5 degrees R Up 5 degrees Li Down Figure 7 Detailed Project Flowchart Temperature Options 34 13 2 Using the On Board Interface Continued Switch Light On Off Light Options Right Right Switch Motion Set Motion On Off Ld Timeout ZEIT Right EEUU Left Figure 8 Detailed Project Flowchart Light Options 35 13 3 Using the Web Interface The web interface allows most of the same changes to the device as the on board interface The web interface uses a web client assuming the device has an IP address If the IP address was assigned for use within a local area network LAN or any other type of private network then the controller may only be accessible within the LAN The interface allows most of the same changes to the device as the on board
7. A set of flags used to track the state of the application Id J RRR RRR KR RRR RRR RRR KR RK i R Y_ Y i RK RRR KR RK KR KR RK KERR KR RRR RK KERR KERR RR KK RK KR RK KEK extern unsigned long g_ulFlags define FLAG CLOCK TICK define FLAG CLOCK COUNT LOW define FLAG CLOCK COUNT HIGH define FLAG UPDATE define FLAG BUTTON fdefine FLAG DEBOUNCE LOW fdefine FLAG DEBOUNCE HIGH fdefine FLAG BUTTON PRESS fdefine FLAG ENET RXPKT define FLAG ENET TXPKT A timer interrupt has occurred The low bit of the clock count The high bit of the clock count The display should be updated Debounced state of the button Low bit of the debounce clock High bit of the debounce clock The button was just pressed An Ethernet Packet received An Ethernet Packet transmitted VD 0 JO Us 0 N20 IH CO S J RRR koe che ke ke ce he ke U INL A RK KERR e ce che ke ce che ck e RR KERR KERR KERR ck RRR KERR KER RK KR KK RA e kx G The speed of the processor VERBAL RH extern unsigned long g ulSystemClock WAA ke che ke ke she he ke ehe ke RRR e ce che i I X X K KERR ke ce KK ce che KK RK ke ce ck kc ck RRR KR RRR kc ck KER RK KKK KR RA Storage for a local frame buffer J RRR RRR RRR RK RRR RRR RRR Y RR KR RR KR i L AO KKK RRR KERR KERR KK KKK RH extern unsigned char g_pucFrame 6144 J RRR RRR A RRR RRR KERR KR RK RRR KERR KR KK ce che KK
8. ulAddr gt gt 16 amp Oxff ulStart ulDigit gt 99 24 ulDigit gt 9 16 8 ulDigit ulAddr gt gt 8 amp Oxff ulStart ulDigit gt 99 24 ulDigit gt 9 16 8 ulDigit ulAddr amp Oxff ulStart ulDigit gt 99 24 ulDigit gt 9 16 8 ra Compute the starting address in the local frame buffer of the location for the IP lt addr gt string 4 ulStart 81 64 128 ulStart 30 4 Display the IP text on the bottom of the display Loop the bytes in the image E for ulLoop 0 ulLoop 9 13 ulLoop Copy this byte from the image to the local frame buffer g pucFrame ulStart ulLoop 9 64 ulLoop 9 g_pucIP ulLoop Ld Advance the frame buffer starting address ulStart 9 Td Draw the first byte of the IP address with a dot to separate from the next byte 4 60 it ulStart DrawNumber ulStart ulAddr amp Oxff 1 true ipl int ulAddr amp Oxff fM Draw the second byte of the IP address with a dot to separate it from the next byte ulStart DrawNumber ulStart ulAddr gt gt 8 amp Oxff 1 true ip2 int ulAddr gt gt 8 amp Oxff WM Draw the third byte of the IP address with a dot to separate from the next byte fil ulStart DrawNumber ulStart ulAddr gt gt 16 amp Oxff 1 true ip3 int ulA
9. Winter Quarter 3 week Revise Design Report Winter Quarter 4 week Initial Operational System Winter Quarter 10 week Design Conference Spring Quarter 1 week Project Report and implementation Spring Quarter 10 week Figure 1 Project Deliverables 13 3 2 Project Timeline Summer 08 Fall 08 Week 1 Research technology for project Week 2 Week 3 Week 4 Week 5 Week 6 Week 7 Develop a custom interface for processor Configure system to act as a web server Configure sensor ports for periodic reading Attach light and temp sensors and connect wiring Complete electrical wiring for device control Week 8 Week 9 Week 10 Winter Break Winter 09 Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Spring 09 Week 7 Week 8 Week 9 Week 10 Spring Break Figure 2 Project Development Timeline 14 4 Requirements Primary Requirements essential to the functioning of the system Secondary Requirements that may increase appeal but are not necessary Functional Requirements describing what must be done Non Functional Requirements describing the manner the functional requirement will be achieved 4 1 Primary Requirements Fun
10. div gt lt b gt lt body gt lt html gt 46 RRR he ke he eese ke ke e he ee he ke e he ke e ce che ke ce che ce he ke ke ce ck ke ke ck kc ck ke cse ke ke ke e File name styles css RRR RRR RRR RRR amp A RR RRR RRR KERR KE RRR RRR RRR A A A ke ke BODY font family Arial background color white margin 10px padding 0px BODY side font family Arial background color white margin 10px padding 0px H1 background color white color black font weight normal font family Arial font size 24pt text decoration none text align center 47 14 2 Source Code C files A kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk RA A File name clock c KR RK RRR RRR RRR RR RK RRR RRR ke ce RK RRR RRR ERK ERR KR RK KR RR ERK ERR KER RK KERR KERR KERR AR A AA Include files include clock h include keystroke h include graphics h include lt stdio h gt int gSECOND int gMINUTE int gHOUR int gDAY int gMONTH int gAMorPM char gAMPMarray 2 unsigned int gYEAR char gPowerSaveTimer 0 char dateformat 0 Lookup table holding the length of each mont The first element is a dummy int MonthLength 13 0 31 28 31 30 31 30 31 31 30 31 30 31 int TBL CLOCK 12 table used when displaying 12H clock 112 1 2 3 4 5 Be 7 By X2 10 1 42 1 2 3 4 By 6 7 Sy Ey 40 11 RRR RRR RRR R
11. int state HOME int option 0 int numOptions 0 int clear Li If running on Rev A2 silicon turn the LDO voltage up to 2 75V This 82 is a workaround to allow the PLL to operate reliably SysCtlPeripheralEnable SYSCTL PERIPH ADC if REVISION IS A2 SysCtlLDOSet SYSCTL LDO 2 75V Set the clocking to run at 50MHz from the PLL Ei SysCtlClockSet SYSCTL_SYSDIV_4 SYSCTL_USE_PLL SYSCTL_OSC_MAIN SYSCTL XTAL 8MHZ SysCtlPWMClockSet SYSCTL PWMDIV 8 tf Get the system clock speed d g ulSystemClock SysCtlClockGet Enable the peripherals used by the application SysCtlPeripheralEnable SYSCTL PERIPH GPIOA SysCtlPeripheralEnable SYSCTL PERIPH GPIOB SysCtlPeripheralEnable SYSCTL PERIPH GPIOC SysCtlPeripheralEnable SYSCTL PERIPH GPIOD SysCtlPeripheralEnable SYSCTL PERIPH GPIOE SysCtlPeripheralEnable SYSCTL PERIPH GPIOF SysCtlPeripheralEnable SYSCTL PERIPH PWM SysCtlPeripheralEnable SYSCTL PERIPH UARTO GPIOPinTypeGPIOOutput GPIO PORTD BASE GPIO PIN 4 GPIO PIN 5 GPIO PIN 7 GPIOPinWrite GPIO PORTD BASE GPIO PIN 4 GPIO PIN 4 GPIOPinWrite GPIO PORTD BASE GPIO PIN 5 GPIO PIN 5 GPIOPinWrite GPIO PORTD BASE GPIO PIN 7 GPIO PIN 7 GPIOPinTypeGPIOInput GPIO PORTD BASE GPIO PIN 2 4 Configure the GPIOs used to read the state of the on board push buttons a GPIOPinTypeGPIOInput GPIO PORTE BASE GPIO PIN 0 GPIO PIN 1
12. 0 GPIO PIN 0 4 Delay for a bit 4 for ulLoop 0 ulLoop 300000 ulLoop 1 Turn off the LED L GPIOPinWrite GPIO PORTF BASE GPIO PIN 0 0 Delay for a bit 4 for ulLoop 0 ulLoop 300000 ulLoop void updateSensorData unsigned long tempStorel 8 float ratio ADCSequenceDisable ADC BASE 0 ADCSequenceConfigure ADC BASE 0 ADC TRIGGER PROCESSOR 0 ADCSequenceStepConfigure ADC BASE 0 0 ADC CTL CHO ADCSequenceStepConfigure ADC BASE 0 1 ADC CTL CH1 ADC CTL IE ADC CTL END ADCIntEnable ADC BASE 0 ADCSequenceEnable ADC BASE 0 Trigger the sample sequence ADCProcessorTrigger ADC_BASE 0 Wait until the sample sequence has completed d while ADCIntStatus ADC BASE 0 false ADCSequenceDataGet ADC_BASE 0 tempStorel ratio float tempStorel 0 1024 0 ratio ratio 3 0 ratio ratio 100 setActualTemp int ratio convertAndSetCurrentLight int tempStorel 1 void showHome int device switch device case MAIN displayText Main 53 15 5 80 ShowClock 62 ShowDate 40 GetIPAddress break case TEMPERATURE displayText Temperature 30 15 5 mainShowTemp 40 mainShowSetTemp 60 mainShowThermoStatus 80 break case LIGHT displayText Light 50 15 5 mainShowCurrentLight 40 mainShowLightSwitch 60 mainShowMotionSwitch 80 break voi
13. 1 if Increment the screen update count g_ucScreenUpdateCount g ucSecondTick Z ONE SECOND HAS PASSED if g ucSecondTick CLOCK RATE char timeout 12 memset timeout X0 sizeof timeout if gettingIpAddress TRUE 4 gtimeout sprintf timeout Timeout d gtimeout displayText Timeout a0 60 5 displayText timeout 30 60 5 g ucSecondTick 0 g ucLCDOFFCount if getMotionPinRead TRUE 72 setMotionStat TRUE gMotionCount 0 else if gMotionCount gt getMotionTimeout setMotionStat FALSE else gMotionCount if gCLOCK SET TRUE IncrementSecond updateSensorData See if 1 30th of a second has passed since the last screen update if g ucScreenUpdateCount CLOCK RATE 30 1 1 Restart the screen update count g_ucScreenUpdateCount 0 Request a screen update L HWREGBITW amp g ulFlags FLAG UPDATE 1 4 Update the music sound effects 4 AudioHandler Increment the application update count g_ucAppUpdateCount See if 1 100th of a second has passed since the last application update if g ucAppUpdateCount CLOCK RATE 100 4 Return without doing any further processing return ff Restart the application update count g_ucAppUpdateCount 0 73 Z Run the Ethernet handler
14. RR Ae I AA O RK KR KERR KER RK KKK KR RH if The set of switches that are currently pressed f RRR RRR AA RR RRR RRR KR RK KERR KERR RRR KK RK KERR KERR O L X Y Y KERR KERR KERR KKK KK RH extern unsigned char g_ucSwitches endif GLOBALS H 63 A kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk File name graphics c KR KR che kc he ke KR ce che RR RR RRR ke ce che ke ce che ke e RK RRR RRR KR RK RRR KERR KERR b RR RRR ERR KERR KK RK KR ck ckck ck ko k include graphics h J RRR RRR RRR RRR RK RRR RRR RRR KR i A RRR RRR KR KK KER KR KERR KER RRR RK KER KK KKK KKK EK hf Display text on the LCD display J RRR RRR RRR RRR i iI KR RK RRR RRR RRR KK RK KE RK KERR KR RK KERR KERR KERR KERR RR RA int displayText char pucHello int x int y int intensity RIT128x96x4StringDraw amp pucHello 0 x y 15 return 1 64 A kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk File name graphics h kkkkkk kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk kk include include al hw types h Ti include ad mi src debug h src sysctl h sf utzls diaq h ritl28x96x4 h PRA sal sal include include int displayText char pucHello int x int y int intensity 65 RRR ke ke he ke che ke ke ce he ke
15. RRR RRR KR RRR RR KR RK RRR ke RK KR che ke e RRR RR KER RK KR KERR Y ER ck KR RH File name keystroke c KOR KR che ke he ke che RR RRR RRR RRR RRR ce RK ce che ck e che RR RK ck ce che RRR ck KERR KERR RRR KR RRR KERR KR RK IAAIL L _ AR AA include keystroke h static int gkeystroke int getKey See if only the up button is pressed if g ucSwitches amp 0x0f 0x0e return UP See if only the down button is pressed if g ucSwitches amp 0x0f Ox0d return DOWN See if only the left button is pressed if g ucSwitches amp 0x0f 0x0b return LEFT See if only the right button is pressed if g ucSwitches amp 0x0f 0x07 return RIGHT See if only Select button was pressed if HWREGBITW amp g ulFlags FLAG BUTTON PRESS HWREGBITW amp g ulFlags FLAG BUTTON PRESS 0 return SELECT return 0 int getKeyWait int key 0 int previous do previous key key getKey while key 0 return previous int lastKeyStroke return gkeystroke void setLastKeyStroke int key gkeystroke key 66 RRR RRR he ke che ke e RRR RRR RRR KKK KR RK RRR e che ke KR RK ke ce KKK RK KERR kc ck RRR KR KERR KERR KERR KER KK RR KKK KKK File name keystroke h RRR RRR RRR RR KR RRR RRR RRR RR KR RRR RRR RRR RRR RRR RRR KR RRR RRR KR RRR RRR RRR KR KR KR KR KR RRR KR KK include hw memmap h inc
16. interface The web interface uses a web client assuming the device has an IP address When the user navigates to the page with the IP address assigned the user will receive a page that resembles the image below Temperature Light Settings Current Temperature 73 Desired Temperature 80 Set Status Switch Toggle A C Figure 9 Web Interface Screen Shot The tabs at the top of the webpage see image above indicate which devices are attached and which device is currently selected In this case the two devices attached are temperature and light and the currently selected device is the temperature tab Each tab displays information similar to what you may find on the on board interface Similarly most of the options from the on board interface such as Set Temperature are easily accessible from the 36 web interface as well Most of the options appear as buttons next to the information for which they refer The typical format for how the information and options will be displayed is as follows Each row represents a different type of information In the first column of each row there will be a description of the data which exists in the second column The third column if one exists will contain the options for altering the data reading As an example looking at the first column of the second row of the above image indicates the data will be describing the Desired Temperature The
17. second column shows 80 degrees representing the actual data and the third column provides the setting to alter the temperature a and button to increment or decrement the temperature 37 13 4 Using Temperature Monitoring Device If monitoring locally then switch to the temperature monitoring screen using the directional buttons This screen will show you the current temperature in the room and the desired temperature in the room It will also show you the thermo status making this device similar to a thermostat The current temperature reading displays the current temperature of the room in degrees Fahrenheit The desired temperature reading displays the temperature for which you prefer The thermo status reads either Off Heat or Cool If the reading is Off then both the heater and air conditioner will be off If the thermo status reads Heat then the system will turn on the heater until the current temperature reaches the desired temperature If the thermo status reads Cool then the system will turn on the air conditioner until the current temperature reaches the desired temperature You can use the directional buttons to access the options to change each setting see flowcharts in section 12 2 for help understanding how to navigate through the interface If monitoring remotely then switch to the tab labeled Temperature on the system web page Simply click the buttons next to
18. the microcontroller into a 12V output powered by AA batteries These switches allow real life devices such as lights to be connected to the controller Although the 12V output is not enough to power actual heaters and air conditioners it is enough to turn on a few lights to provide a proof of concept demonstration Motion Sensor The motion sensor also purchased from Parallax com was hooked up to the microcontroller Because the motion sensor outputs a value either 0 or 1 based on whether or 22 not the motion sensor was activated a simple input port is used rather than an analog to digital converter to monitor the motion sensor The motion sensor is used to automatically turn the light on or off Batteries Wires Resistors and Breadboard Batteries wires resistors and the breadboard were used to put the entire project together and form the connections between the sensors the controller and the attached devices 23 8 System Architecture This system uses a two tiered architecture The microcontroller acts as the server and the user s web browser acts as the client There is no need for a data tier because most of the data is dynamic e g current temperature However for the little amount of data needed such as storing future set temperatures arrays are enough The arrays are allocated on the RAM of the controller when the controller starts up Web Server HTML and JavaScript sent to client Req
19. toggleLightSwitch break mainShowLightSwitch 40 void mainShowMotionSwitch int vertical switch GetMotionSwitch case OFF displayText Motion Enable OFF 15 vertical 5 break case ON 78 displayText Motion Enable ON 15 vertical 5 break void mainSetMotionSwitch mainShowMotionSwitch 40 switch lastKeyStroke case LEFT toggleMotionSwitch break case RIGHT toggleMotionSwitch break mainShowMotionSwitch 40 void mainShowMotionTimeout int vertical int changed char motionString 25 memset motionString 0 sizeof motionString if changed TRUE sprintf motionString Motion Timeout displayText motionString 15 vertical 5 else sprintf motionString Motion Timeout s mainIntToStr getMotionTimeout displayText motionString 15 vertical 5 void mainSetMotionTimeout mainShowMotionTimeout 40 FALSE switch lastKeyStroke case RIGHT if getMotionTimeout 21 setMotionTimeout getMotionTimeout 1 mainShowMotionTimeout 40 TRUE break case LEFT if getMotionTimeout 1 setMotionTimeout getMotionTimeout 1 mainShowMotionTimeout 40 TRUE break default mainShowMotionTimeout 40 FALSE break void blinkLED int blinks volatile unsigned long ulLoop int i for i20 i blinks i 1 79 Lei Turn on the LED ff GPIOPinWrite GPIO PORTF BASE GPIO PIN
20. 00 tempValue 100 else tempValue newTemp return current temperature in room int GetCurTemp return actualTemp return thermostat status int GetThermStat return thermoStatus toggle thermoStatus in the upward direction void toggleStatusUp thermoStatus thermoStatus 1 3 toggle thermoStatus in the downward direction void toggleStatusDown thermoStatus thermoStatus 1 89 if thermoStatus 1 thermoStatus 2 run enableHeatCool function to get current value of heatOrCool and then return heatOrCool int GetEnabled enableHeatCool return heatOrCool compare current temperature with desired temperature and check thermoStatus to determine whether heater or AC should be on Then turn either on or off according to those conditions void enableHeatCool if thermoStatus HEAT if GetSetTemp GetCurTemp heatOrCool 1 GPIOPinWrite GPIO PORTD BASE GPIO PIN 4 0 GPIOPinWrite GPIO PORTD BASE GPIO PIN 5 GPIO PIN 5 else if GetCurTemp GetSetTemp gt TEMPDELTA heatOrCool 0 GPIOPinWrite GPIO PORTD BASE GPIO PIN 4 GPIO PIN 4 GPIOPinWrite GPIO PORTD BASE GPIO PIN 5 GPIO PIN 5 else if thermoStatus COOL if GetSetTemp GetCurTemp heatOrCool 2 GPIOPinWrite GPIO PORTD BASE GPIO PIN 5 0 GPIOPinWrite GPIO PORTD BASE GPIO PIN 4 GPIO PIN 4 else if GetSetTemp GetCu
21. 9 time SECOND 0 if time SECOND lt 0 time SECOND 59 gHOUR time HOUR gMINUTE time MINUTE gSECOND time SECOND if time AMPM lt 0 time AMPM 1 else if time AMPM gt 1 time AMPM 0 gAMorPM time AMPM return A kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk XA E ok F x Function name ShowDate Returns none Parameters char input from joystick Purpose Shows the date on the LCD 51 KOR KR RRR RRR RR RR ce che ke RRR RRR e RR ke ce RK ce RR RRR RRR KR RK RRR KERR RRR KR RK RRR kc ck KERR RK ck ck ck k ck kc kk void ShowDate int vertical static char YH YL MH ML DH DL char date 9 YH gYEAR if YH gt 9 YH YH 10 YL gYEAR YH 10 else YL YH A oK T MH gMONTH if MH gt 9 MH MH 10 ML gMONTH MH 10 else ML MH os m DH gDAY if DH gt 9 DH DH 10 DL gDAY DH 10 else DL DH 0 A DH sprintf date d d d d d d 0 MH ML DH DL YH YL displayText date 40 vertical 15 define YEAR define MONTH define DAY 2 Ho RR RRR RRR KKK KR RK O AO A ke ce he ke ce RK ce he KR RR e ce che ke RA A kx Function name SetDate Returns none Parameters char input from joystick Purpose Adjusts the date KOR KR RRR che ke e ke ke RRR ce che ke he ke RRR ce c
22. AM EnetTick 10 ff Read the state of the push buttons ulData GPIOPinRead GPIO PORTE BASE GPIO PIN O GPIO PIN 1 GPIO PIN 2 GPIO PIN 3 GPIOPinRead GPIO PORTF BASE GPIO PIN 1 3 if gClearNeeded TRUE gClearNeeded FALSE if ulData 31 g_ucLCDOFFCount 0 if g_LCDOFF TRUE RIT128x96x4DisplayOn gClearNeeded TRUE g LCDOFF FALSE if g ucLCDOFFCount 300 amp amp g LCDOFF FALSE g_LCDOFF TRUE RIT128x96x4Clear RIT128x96x4DisplayOff Determine the switches that are at a different state than the debounced state 4 ulDelta ulData g ucSwitches Increment the clocks by one g ucSwitchClockA g ucSwitchClockB g ucSwitchClockB g ucSwitchClockB 4 Reset the clocks corresponding to switches that have not changed state g_ucSwitchClockA amp ulDelta g_ucSwitchClockB amp ulDelta Get the new debounced switch state hd g ucSwitches amp g ucSwitchClockA g ucSwitchClockB g ucSwitches g ucSwitchClockA g ucSwitchClockB amp ulData Determine the switches that just changed debounced state if 74 ulDelta g ucSwitchClockA g ucSwitchClockB L See if any switches just changed debounced state LE if ulDelta 1 47 Add the current tick count to the entropy pool RandomAddEntropy g ulTickCount MH See if the select button w
23. E SysTickIntEnable SysTickEnable Throw away any button presses that may have occurred while the screens were being displayed HWREGBITW amp g ulFlags FLAG BUTTON PRESS RTC init blinkLED 10 gettingIpAddress GetIPAddress gettingIpAddress TRUE 0 FALSE Splash 84 blinkLED 10 RIT128x96x4Clear clear LCD mainStartTime while 1 if gselect TRUE keystroke SELECT gselect FALSE else keystroke getKeyWait enableHeatCool enableLight clear TRUE switch state case HOME if keystroke RIGHT device device 1 NUM OF DEVICES else if keystroke LEFT device device 1 if device 1 device NUM OF DEVICES 1 else if keystroke UP state MENU else clear FALSE break case MENU if keystroke RIGHT option option 1 numOptions else if keystroke LEFT option option 1 if option 1 option numOptions 1 else if keystroke DOWN state HOME else if keystroke UP state OPTIONS else if keystroke SELECT state HOME else clear FALSE break case OPTIONS if keystroke SELECT state MENU if keystroke SELECT clear FALSE setLastKeyStroke keystroke break if clear TRUE 85 RIT128x96x4Clear switch state case HOME showHome device break case MENU switch device case MAIN numOp
24. GPIO PIN 2 GPIO PIN 3 GPIOPadConfigSet GPIO PORTE BASE GPIO PIN 0 GPIO PIN 1 GPIO PIN 2 GPIO PIN 3 GPIO STRENGTH 2MA GPIO PIN TYPE STD WPU GPIOPinTypeGPIOInput GPIO PORTF BASE GPIO PIN 1 GPIOPadConfigSet GPIO PORTF BASE GPIO PIN 1 GPIO STRENGTH 2MA GPIO PIN TYPE STD WPU Configure the LED speaker and UART GPIOs as required 4 83 GPIOPinTypeUART GPIO PORTA BASE GPIO PIN 0 GPIO PIN 1 GPIOPinTypePWM GPIO PORTD BASE GPIO PIN 1 GPIOPinTypeGPIOOutput GPIO PORTF BASE GPIO PIN 0 GPIOPinWrite GPIO PORTF BASE GPIO PIN 0 0 Intialize the Ethernet Controller and TCP IP Stack EnetInit Configure the first UART for 115 200 UARTConfigSetExpClk UARTO BASE SysCtlClockGet 8 N 1 operation 115200 UART_CONFIG_WLEN_8 UART_CONFIG_STOP_ONE UART CONFIG PAR NONE UARTEnable UARTO BASE H Send a welcome message to the UART UARTCharPut UARTO BASE UARTCharPut UARTO BASE UARTCharPut UARTO BASE UARTCharPut UARTO BASE UARTCharPut UARTO BASE UARTCharPut UARTO BASE UARTCharPut UARTO BASE UARTCharPut UARTO BASE UARTCharPut UARTO BASE 74 Initialize the OSRAM em H OO tom 5 OLED display RIT128x96x4Init 3500000 Initialize the PWM for generating music and sound effects 14 AudioOn VA Configure SysTick to Rd periodically interrupt SysTickPeriodSet g ulSystemClock CLOCK RAT
25. K KR RK RRR RRR KR RR KR RK RRR KERR KERR KR RK KR RK RRR KERR KR RK RRR KERR KERR Y D RR KEK Function name RTC init returns none parameters none Purpose Initialize the Real Time Clock ROR KR RRR ce che ke ii ke e ce che ke RRR RRR e ce che ce RK RRR RRR ERR KR RA void RTC init void 1 initial time and date setting gSECOND 0 gMINUTE 0 gHOUR 12 gDAY 1 gMONTH 1 gYEAR 3 gAMorPM 0 48 FERRARA ke ke e ke e EK ttt gAMPMarray 0 a gAMPMarray 1 p ne Il Kei Function name ShowClock Returns void Parameters char input from joystick Purpose Shows the clock on the LCD kkkkxkkkkxkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk kkkkkk kkkk kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk kk void ShowClock int vertical time d d d d d d cmMV0 HH HL MH ML SH SL gAMPMarray gAMOorPM displayText time 35 vertical 15 static int HH HL MH ML SH SL char time 9 HH TBL CLOCK 12 gHOUR if HH gt 9 HL HH 10 HH 1 else HL HH HH 0 MH gMINUTE if MH gt 9 MH MH 10 ML gMINUTE MH 10 else ML MH MH 0 SH gSECOND if SH gt 9 SH SH 10 SL gSECOND SH 10 else SL SH SH 0 A sprintf A kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
26. REMOTE HOME MONITORING SYSTEM by Nick Treat SENIOR DESIGN PROJECT REPORT Submitted in partial fulfillment of the requirements for the degree of Bachelor of Science in Computer Engineering School of Engineering Santa Clara University Santa Clara California June 18 2009 Santa Clara University DEPARTMENT of COMPUTER ENGINEERING Date June 18 2009 I HEREBY RECOMMEND THAT THE THESIS PREPARED UNDER MY SUPERVISION BY Nick Treat ENTITLED Remote Home Monitoring System BE ACCEPTED IN PARTIAL FULFILLMENT OF THE REQUIREMENTS FOR THE DEGREE OF BACHELOR OF SCIENCE IN COMPUTER ENGINEERING THESIS ADVISOR DEPARTMENTCHAIR Abstract Remote monitoring systems have become popular in recent years as users are capable of monitoring a surrounding remotely However most remote monitoring systems only monitor a single entity a networked thermostat only monitors temperature Remote monitoring systems require a network connection therefore multiple network connections are required for each system There is no reason for a remote monitoring system not to monitor several sensors and send all this data to a requesting client over a single connection My project aims to accomplish exactly this task This project the Home Monitoring System uses a multitude of sensors to send atmospheric data such as light intensity or temperature to a remote client In this paper I will provide a technical discussion on the architectur
27. as been connected to device user has access to the Internet and device has been switched on Sequence of Events 1 User loads a browser and navigates to the web server s home page 2 User selects new value of temperature using either the or buttons 17 5 2 Nice to Have Scope Room Monitoring System Actor User Goal Change temperature from iPhone Precondition User has iPhone connected to the same network as device and remote system has been switched on Sequence of Events 1 User loads iPhone s safari page and types in the system s IP address 2 When connection to device is complete user selects new temperature value using either the or buttons 18 6 System Flowchart Device S creen Previous Next Device Device Change Key Next Previous Setting Pressed Setting Figure 3 System Flowchart 19 7 Technologies Used Because this project uses an embedded system both software and hardware technologies were needed The software technologies will be described followed by the hardware technologies used 7 1 Software Technologies Used IAR Systems Embedded Workbench IAR systems workbench is a compiler that works well with the LMS6965 microcontroller I used this compiler for all of my programming debugging and loading of the object code onto the controller Furthermore this compiler is nice because it allows for onboard debugging where I can use the actual controlle
28. as just pressed fi if ulDelta amp 0x10 amp amp g_ucSwitches amp 0x10 M Set a flag to that the select button was just pressed indicate HWREGBITW amp g ulFlags FLAG BUTTON PRESS 1 Set the data according to the keystroke and show date on LCD void mainSetDate ShowDate 40 SetDate lastKeyStroke ShowDate 40 start the clock ticking void mainStartTime gCLOCK SET TRUE stop the clock ticking void mainStopTime gCLOCK SET FALSE Set the time according to the keystroke and show time on LCD void mainSetTime ShowClock 40 SetClock lastKeyStroke ShowClock 40 convert an int value 1000 into a string char mainIntToStr int value static char string 4 int tempvalue memset string 0 sizeof string if value lt 0 string 0 0 return string 75 else if value 10 string 0 value 0 return string else if value lt 100 string 0 int value 10 0 string 1 value int value 10 10 0 return string else if value lt 1000 string 0 int value 100 0 tempvalue value int value 100 100 string 1 int tempvalue 10 0 string 2 tempvalue int tempvalue 10 10 0 return string else string 0 9 string 1 9 string 2 9 return string void mainShowTemp int vertical char temperatureStr 4 int stati
29. best bet and a simple rectangular tabbed design box for user interactivity would ensure that it could fit on the tiny iPhone screens 27 12 Societal Issues 12 1 Ethical Many products on the market have sparked ethical controversy due to a products material list design or purpose This remote home monitoring system shall be subject to the same ethical standards as any other product However I am confident that this system will not generate major ethical controversies No dangerous materials were used in the making of the prototype and no dangerous materials shall be used in the making of the final product Similarly this system does not invent any brand new technologies which may be subject to controversies in the future Rather this product only combines current technologies home monitoring and network connections to produce a seemingly ethically sound concept 12 2 Social I believe that this system will fully help the general public and lead to positive social implications It acts just like a current digital thermostat or other monitoring system However this system is networked providing easy access to those in need Disabled people for instance can access the remote system with ease and from anywhere in their house 12 3 Political I do not believe this system will have significant political considerations as it provides benefits of personal safety energy conservation and convenience However all of these are polit
30. c previousTemp int static temperatureInt 0 displayText Current Temp 10 vertical 5 previousTemp temperatureInt temperatureInt GetCurTemp strcpy temperatureStr mainIntToStr temperatureInt if previousTemp temperatureInt displayText 85 vertical 5 if temperatureInt lt 10 displayText temperatureStr 95 vertical 5 else displayText temperatureStr 90 vertical 5 displayText F 110 vertical 5 void mainShowSetTemp int vertical char temperatureStr 4 int static previousTempSet int static temperatureIntSet 0 displayText Desired Temp 10 vertical 5 previousTempSet temperatureIntSet temperatureIntSet GetSetTemp strcpy temperatureStr mainIntToStr temperatureIntSet if previousTempSet temperatureIntSet displayText 85 vertical 5 if temperatureIntSet lt 10 displayText temperatureStr 95 vertical 5 else displayText temperatureStr 90 vertical 5 displayText F 110 vertical 5 int mainAdjustTemp int upOrDown int temp switch upOrDown case UP if temp lt 100 temp temp 5 break case DOWN if temp gt 50 temp temp 5 break return temp void mainSetCurrentTemp char tempbuffer 5 int sameValue memset tempbuffer 0 sizeof tempbuffer sameValue GetSetTemp if lastKeyStroke NONE SetTemp mainAdjustTemp lastKeyStroke GetSetTemp strcpy tempbuffer mai
31. clude lt stdio h gt include lt stdlib h gt define TRUE 1 define FALSE 0 define MAIN 0 define TEMPERATURE 1 define LIGHT 2 define HUMIDITY 3 define NUM OF DEVICES 3 define HOME 0 define MENU 1 define OPTIONS 2 unsigned long g ulFlags unsigned long g ulSystemClock unsigned char g pucFrame 6144 static unsigned long g ulTickCount 0 static unsigned char g ucScreenUpdateCount 0 unsigned char g ucSwitches Oxlf static unsigned long g ucSecondTick 0 71 static unsigned char g ucSwitchClockA static unsigned char g ucSwitchClockB static unsigned long g ucLCDOFFCount 0 static unsigned long gMotionCount 0 static int g LCDOFF FALSE static int gCLOCK SET FALSE static int gClearNeeded FALSE static int gselect FALSE static int gtimeout 45 static int gettingIpAddress FALSE oo void updateSensorData J CK koe ke e ce he ke che he ke che ke e ce ui d I che KR KERR ke ce ck ke ce che ck ce RK KERR RRR KEK RK KERR kc ko ERR ck ck ck KERR ck RA Handles the SysTick timeout interrupt f f CK koc ke ke ce he ke RRR RRR KKK i d G I ke KERR ke ce ck ck ce RK RRR KERR KR RRR KR RK KERR kc ko KERR KERR KR KERR KERR KKK void SysTickIntHandler void unsigned long ulData ulDelta 4 Increment the tick count if g ulTickCount Indicate that a timer interrupt has occurred HWREGBITW amp g ulFlags FLAG CLOCK TICK
32. cquire an IP address However after forty seconds it will timeout and return a default IP address of 169 254 19 63 if the Ethernet has not been connected yet Third to connect the Ethernet plug any male Ethernet terminal into the Ethernet port on the system with the other end of the Ethernet cable connected to your network most typically plugged directly into your router If you have already provided power to the system and the system has already returned its default IP address then press the reset button the button closest to the top and closest to the right of the board Pressing this button will tell the system to repeat the IP address search process Note The Room Monitoring System requires both a power and Ethernet connection in order to monitor a surrounding remotely If you would like to simply monitor the surrounding locally then an Ethernet connection is not needed 31 13 2 Using the On Board Interface The system can monitor the surrounding locally using the on board interface The on board interface allows for a person to directly change settings on the controller This is helpful when the network connection is unavailable or not configured The on board interface allows the user to switch between the attached devices in this case a temperature and light controller are attached The following flowcharts indicates how the user can navigate through the on board interface to access certain features Start
33. ct gt ClowLight CChighLight currentLight 3 if act gt lowLight CChighLight LowLight 5 3 currentLight 4 if Cact gt highLight currentLight 5 lowLight 5 1 lowLight 5 2 set the lowValue variable to the current light sensor value void setLightLow 4 LowLight adcvalue set the highValue variable to the current Light sensor value void setLightHigh O 4 highLight adcvalue returns the value stored in currentLight int GetCurrentLight return currentLight 68 returns the value stored in adcvalue int GetADCLightO 4 return adcvalue run enableLight function to get current value of lightStatus and then return lightStatus int GetLightStatO 4 enableLight return lightStatus toggle light on or off void toggleLightSwitch 4 lightStatus lightStatus 1 2 check actual value of lightStatus and turn the actual light on or off depending on the value void enableLight O 4 if ClightStatus 1 GetMotionSwitch ON amp amp GetMotionStat ON i y else if lightStatus 0 amp amp C GetMotionSwitch OFF GetMotionSwitch ON amp amp GetMotionStat OFF GPIOPinWriteCGPIO PORTD BASE GPIO PIN 7 GPIO PIN 7 GPIOPinWrite GPIO PORTD BASE GPIO PIN 7 0 69 A kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk File name light h KR KR RR ce
34. ctional Monitors surroundings using temperature Acts as a web server Settings can be modified remotely Non Functional System program is loaded on a microprocessor Monitors temperature using a temperature probe Modifies settings remotely using LWIP packets 4 2 Secondary Requirements Functional Monitors various other aspects of environment Implements hysteresis for controlling heat and A C together Allows users to monitor the system using an iPhone Non Functional Connects various types of sensors to system Provides a threshold so neither A C or heat are immediately activated Creates a user friendly and compact webpage which easily fits on iPhone screen 15 5 Use Cases The use cases in this section describe the interaction between the user and the functional elements of the system The scope is the room monitoring system as a whole The actor in the following use cases is the user of the application or anyone interested in monitoring their surroundings remotely The goals represent any action the user wishes to take using the application and each goal must be preceded by a precondition In order for the goal to be carried out the user must follow the sequence of events for the particular use case Most of the following use cases pertain only to the monitoring and altering of the temperature using the system 5 Required Scope Room Monitoring System Actor User Goal Switch between devices Precondi
35. d showMenu int device int option displayText Options 40 15 5 switch device case MAIN switch option case 0 displayText Set Time 37 40 5 break case 1 displayText Set Date 37 40 5 break break case TEMPERATURE switch option case 0 displayText Set Temperature 23 40 5 break case 1 displayText Set Thermo Status 20 40 5 break break case LIGHT switch option case 0 displayText Switch Light On Off 10 40 5 break case 1 displayText Switch Motion On Off 10 40 5 break case 2 displayText Set Motion Timeout 10 40 5 break break 81 void showOptions int device switch device case MAIN switch option case 0 displayText Set Time 37 15 5 mainSetTime break case 1 displayText Set Date 37 15 5 mainSetDate break break case TEMPERATURE switch option case 0 int option displayText Set Temperature 23 15 5 mainSetCurrentTemp break case 1 displayText Set Thermo Status 20 15 5 mainSetThermoStatus break break case LIGHT switch option case 0 displayText Switch Light On Off 10 15 5 mainSetLightSwitch break case 1 displayText Switch Motion On Off 2 15 5 mainSetMotionSwitch break case 2 displayText Set Motion Timeout 10 15 5 mainSetMotionTimeout break break Main Function int main void int keystroke int device MAIN
36. ddr gt gt 16 amp Oxff fM Draw the fourth bytes of the IP address AA DrawNumber ulStart ulAddr gt gt 24 1 false ip4 int ulAddr gt gt 24 IPlength sprintf IPaddress IP d d d d 0 ipl ip2 ip3 ip4 IPlength 18 IPlength RIT128x96x4Clear displayText IPaddress 10 IPlength 3 85 15 Display the updated image on the display RIT128x96x4ImageDraw g_pucFrame 0 0 128 96 61 RRR ck ke he ke che ke e RRR RRR RRR KR ce che ce che KR RK RRR ce KK ce RH File name get ip h KR KR RR RRR RR RR ce che ke che ce he i i i iU che ke ce RR ce che ck e che ck RRR RRR KR RR RRR KR RRR kc kc RRR RRR KERR KR KR RK ck RA Function prototypes extern void GetIPAddress void fendif 62 A kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk File name globals h KR KR RRR RRR RR ke ke ce che ke RRR RRR ke ce che ce RK ce che ke GG RK RRR KERR ERR KK ck RR ko k ifndef _ GLOBALS H define _ GLOBALS H kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk kkk if The clock rate for the SysTick interrupt All events in the application occur at some fraction of this clock rate J RRR RRR RRR RRR RRR RR KR RK RR KR RK RRR RRR KK A KERR RH define CLOCK RATE 300 J RRR RRR RRR RRR RRR RK RRR KERR KR RK RRR RRR RRR KR RR KR RK KERR KERR RRR KR KERR KERR ERR KERR RA
37. despite the benefits of networked monitoring systems there are several problems that may discourage potential customers First of all the majority of monitoring systems are intended for large scale use where it is inconvenient to manually make changes to the system As an example a large business building can be easily heated by a networked thermostat However even though these systems may be wireless or intended for remote access they are usually not worth the cost of monitoring small residences such as a single apartment unit The cost and complexity of implementing most networked monitoring systems in small residences is generally unattractive Secondly these systems are often specialized and may only monitor one specific aspect of the environment For example thermostats only monitor temperature and burglar systems may only monitor motion or activity Therefore one would need to implement multiple costly systems to monitor multiple aspects of the environment 1 2 The Solution The project I developed a Home Monitoring Controller resolved the problems discussed in the previous section My project uses an Ethernet enabled micro controller that hosts its own web server Data can be sent from remote hosts to the micro controller and visa versa Unlike large scale networked monitoring systems my Home Monitoring Controller is a small scale device capable of monitoring a single room or section Because of its small size and scope the de
38. e of this system design rational technologies used and testing as well as a user level discussion on use cases and flowcharts Acknowledgements This thesis and project is dedicated to my family They provided great support and guidance from the conception of the project to its completion I would also like to thank my advisor Silvia Figueira for offering advice when I was stumped and providing positive feedback and encouragement She also gave me the freedom to take my own direction on the project Lastly I would like to thank friends and those who helped in providing advice throughout the entire process whether for the presentation or the actual project Table of Contents ABSTRACT ee re es IPIE v Ue En ML OUR RII Dc ee eee ODIO LESSE D ee 3 ACKNOWLEDGEMENT 9 1 sacs eer uu sea en ti 4 TABLE OF CONTENTS EE 5 LIST e FIGURES ed 8 INTRODUC TON RE 9 il The Problemas Y TR A 9 A U TES DU Pr 10 Z THE PROJECT ia E CI ai 11 ZI BIO PIC a soii 11 2 2 Details of Implementation icc sicsscccsssecxedsessussesnssveasscssnssesesascdandsdsencsescsassseassesasscesdeseaunss 11 3 DEVELOPMENT TIMELINE 55 552 521575655 ee FERE Er p sp a ER Pa SEN Saee BEER eege 13 3 1 Project Deliverable Dates ec 13 3 2 Project Felin aa 14 4 REQUIREMENTS me 15 4 1 Primary Requirements usuais cesses caia incida RHAW aco ea aoa ERR YR osea ean oa caia 15 4 2 Secondary E VE EE 15 5 USE CASES ni den ME EMAIL PE REI 16 Serge eege 16 MA uri up
39. eb server allows a remote user to send requests for data such as temperature or light intensity When the user makes this request the response can be viewed in a web browser There are buttons on the web interface that allow the user to interact with the interface in the same way the user would interact with the local interface The sensors attached to the input ports of the microcontroller send a signal to the controller allowing the controller to make accurate estimates about the atmospheric conditions The temperature and light sensors are connected to an analog to digital converter whereas the motion sensor is connected directly to an input pin because its value is either 0 no motion detected or 1 motion detected Lastly the output devices are connected to output pins on the controller These devices would be heaters air conditioners lights etc However for proof of concept 11 purposes this project has 12 lamps with different colors connected to the outputs The devices hooked up to the output pins would be triggered on or off depending on the settings and atmospheric conditions For example if the temperature was too high an air conditioner may turn on Similarly if motion was detected in a room a light may turn on 12 3 Development Timeline 3 1 Project Deliverable Dates Deliverable Week Due Problem Statement Fall Quarter 3 Week Design Report Fall Quarter 10 Week Design Review
40. eq open GET url id Math random true req onreadystatechange dataComplete req send null catch e function temperatureUp datahandler temperatureUp y function temperatureDown datahandler temperatureDown function tempStatusToggle 1 datahandler tempStatusToggle function lightStatusToggle datahandler lightStatusToggle function motionStatusToggle 1 datahandler motionStatusToggle function autoRefreshToggle 42 if document getElementById refresh innerHTML ON document getElementById refresh innerHTML OFF else document getElementById refresh innerHTML ON function refreshLooper if document getElementById refresh innerHTML ON datahandler dataGet setTimeout refreshLooper 2000 function loadFunc tabberAutomatic tabberOptions refreshLooper function pausecomp millis 1 var date new Date var curDate null do curDate new Date while curDate date lt millis function setLowLight datahandler lightSetLow function setHighLight datahandler lightSetHigh function lightBar fl 2 3 4 5 if f1 gt 0 document getElementById lightl style background blue else document getElementById lightl style background white if f2 gt 0 document getElementById light2 style background blue else document getElementById
41. ght5 gt amp nbsp lt td gt lt table gt lt td gt lt td class regular style min width 30px gt H lt td gt lt tr gt lt table gt lt table gt lt tr gt lt td class regular gt Set low high lt td gt lt td class regular gt lt input type button id setLowButton value Set Low onClick setLowLight gt lt td gt td class regular gt lt input type button id setHighButton value Set High onClick setHighLight gt lt td gt lt tr gt lt tr gt lt td class regular gt Motion Detect lt td gt lt td class regular id motionTrigger gt OFF lt td gt lt td class regular gt lt input type button id toggleMotion value Toggle onClick motionStatusToggle gt lt td gt lt tr gt 45 tr lt td class regular gt Light On Off td lt td class regular id statusLight bgcolor red gt OFF lt td gt lt td class regular gt lt input type button id toggleLight value Toggle onClick lightStatusToggle gt lt td gt lt tr gt lt table gt lt td gt lt table gt lt br gt lt br gt lt div gt lt div class tabbertab title Settings id settings gt lt table gt lt tr gt lt td class regular gt Auto Refresh lt td gt lt td class regular id refresh gt ON lt td gt lt td gt lt input type button id refreshtoggle value Toggle onClick autoRefreshToggle td table div lt
42. he ke RRR KR RK ce che KR RK RRR KERR ck ck RK KR RK RRR RRR kc ck KK RK ck RK KR KK 52 void SetDate char input static char date 3 static char mode DAY static int YH YL MH ML DH DL char MonthLength_temp char LeapMonth table holding the date YEAR gYEAR date MONTH gMONTH date DAY gDAY if mode YEAR YH date YEAR if YH 9 YH YH 10 YL date YEAR YH 10 else YL YH YH 0 else if mode MONTH MH date MONTH if MH gt 9 MH MH 10 ML date MONTH MH 10 else ML MH MH 0 else if mode DAY DH date DAY if DH gt 9 DH DH 10 DL date DAY DH 10 else DL DH DH 0 Increment decrement years months or days if input UP date mode else if input DOWN date mode else if input LEFT 1 if mode YEAR temporary date setting 53 mode DAY else mode else if input RIGHT if mode DAY mode YEAR else mode else if input SELECT store the temporary adjusted values to the global variables mode YEAR OPTIMIZE Can be solved by using a modulo operation if date YEAR 255 date YEAR 99 if date YEAR gt 99 date YEAR 0 if date MONTH 0 date MONTH 12 if date MONTH gt 12 date MONTH 1 Check for leap year if month February if gMONTH 2 if gYEAR a
43. he ke che RR ce che ke RRR RR RR RRR RRR RRR e che ck RRR KR RR KR RK RRR KE RRR RRR RRR KERR KERR KK RK kck A This source file contains info for handling the light define TRUE 1 define FALSE 0 define OFF 0 define ON 1 void convertAndSetCurrentLight int act int GetCurrentLight void setLightLow void setLightHigh void enableLight int GetADCLight int GetLightStat void toggleLightSwitch 70 A kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk be File name main c RRR KR RRR RRR RRR ke ce RR RRR RRR ce che ce che ce che ke RRR KR RK RRR RRR RRR RRR KR RRR A L Y L L AIAL ck ck ck ck ck KR KK KKK include fasl eel hw ints h include hw memmap h include sf eal se hw sysctl h include hw_types h include ded s eYrc ado h include ssl sa 8ta debug h include ifs sel BECY gpio h include sd caf naj S C iAnbexrtupt lt h include leds BLE pim h include of sws BEC Bysetl h include fs Src systick h include fare timer h include Wood ond include rit128x96x4 h include audio h include enet h include get_ip h include globals h include images h include random h include screen_saver h include sounds h include graphics h include keystroke h include temperature h include light h include motion h include clock h include lt string h gt in
44. ically important 12 4 Economic This monitoring system should save the customer money because it combines many technologies into one Many corporations may rely on many monitoring systems to effectively monitor their surroundings property etc However this system uses the same networked technology to deliver the current information from a multitude of attached sensors Therefore many existing monitoring systems can effectively be replaced by one thus saving the customer money 12 5 Health and Safety As with any system that uses electricity appropriate safeguards need to be taken in the design and manufacture of the final product to ensure that it meets all appropriate product safety standards This would include for example insuring that all of the electrical components are 28 contained within a plastic box shielding the user of the product as well as children and small animals from the danger of electric shock 12 6 Manufacturability This system does not have a resource heavy design In fact the microcontroller was the extent of the advanced technology used for this project The actual designed system would not use a microcontroller but rather only the chip and the LCD This would greatly minimize the space taken up by the system thus decreasing the amount of materials and improving the systems manufacturability 12 7 Sustainability This system is engineered to be sustainable in the narrow sense that it is designed to las
45. ired Temperature lt td gt lt td class regular id tempSet gt 80 lt td gt lt td class regular gt Set amp nbsp lt input type button id down value onClick temperatureDown gt lt input type button id up value onClick temperatureUp gt lt td gt lt tr gt lt tr gt 44 lt td class regular gt Status Switch lt td gt lt td class regular id statusSet gt OFF lt td gt lt td class regular gt lt input type button id toggleTemp value Toggle onClick tempStatusToggle gt lt td gt lt tr gt lt tr gt lt td class regular gt Heater lt td class regular id heat bgcolor red gt OFF lt td gt lt tr gt lt td class regular gt A C lt td class regular id cool bgcolor red gt OFF lt td gt lt tr gt lt table gt lt br gt lt br gt lt div gt lt div class tabbertab title Light id Light gt lt br gt lt br gt lt table border 2px align center gt lt td gt lt table gt lt tr gt lt td class regular gt Current Light lt td gt lt td class regular style min width 30px gt L lt td gt td class regular gt lt table style border solid black gt td class embedded id lightl amp nbsp td td class embedded id light2 gt amp nbsp lt td gt td class embedded id light3 gt amp nbsp lt td gt td class embedded id light4 gt amp nbsp lt td gt td class embedded id li
46. ke ce ck ke ce ck RR ke e e ke e ke File name home html RRR RRR RRR RR ke L IL V Y ce L O ke RRR KERR ce check ce ce ck ke ce ck ce ck ke ke ke html head meta http equiv Content Type content text html charset ISO 8869 1 gt lt link href styles css rel stylesheet media screen gt lt link gt lt script type text javascript src tabber js gt lt script gt lt link rel stylesheet href example css TYPE text css MEDIA screen gt lt link rel stylesheet href exampleprint css TYPE text css MEDIA print gt lt title gt Remote Monitoring System Homepage lt title gt lt style type text css gt regular min width 120px padding 5px text align center border none switch min width 120px padding 5px text align center border 0px solid black embedded width 30px padding 0px text align center tabbertabinvis display none lt style gt lt script language JavaScript gt var state 1 function datahandler url var recv var req false 40 function dataComplete if req readyState 4 if req status 200 recv req responseText split document getElementById tempCurrent innerHTML recv 0 document getElementById tempSet innerHTML recv 1 document getElementById statusSet innerHTML recv 2 document getElementById statusLight innerHTML recv 5 document getElemen
47. kkkkkkkkkkkkkkkkkkk 49 ein d CM ook ook HF HF Function name SetClock Returns void Parameters char input from joystick Purpose Adjusts the clock kkkxkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk kkkkkkkkkkkxkkk oid SetClock char input static int time 4 table holding the temporary clock setting static char mode HOUR static int HH HL MH ML SH SL initialize once time HOUR gHOUR time MINUTE gMINUTE time SECOND gSECOND time AMPM gAMorPM HH TBL CLOCK 12 time HOUR if HH gt 9 4 HL HH 10 HH 1 else HL HH HH 0 MH time MINUTE if MH gt 9 MH MH 10 ML time MINUTE MH 10 else ML MH MH 0 SH time SECOND if SH gt 9 SH SH 10 SL time SECOND SH 10 else SL SH SH 0 A Increment decrement hours minutes or seconds if input UP time mode else if input DOWN time mode 50 else if input LEFT if mode HOUR mode AMPM else mode else if input RIGHT if mode AMPM mode HOUR else mode else if input SELECT mode HOUR OPTIMIZE Can be solved by using a modulo operation if time HOUR gt 12 time HOUR 1 if time HOUR lt 1 time HOUR 12 if time MINUTE gt 59 time MINUTE 0 if time MINUTE lt 0 time MINUTE 59 if time SECOND gt 5
48. kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk File name motion h KOR RRR ce he ke che ke e RRR RRR che ck i RRR RRR ce che ke e che KR RK KR RR RRR KERR KERR kc kc kc RRR KERR KR KKK KKK ck ARA define TRUE 1 define FALSE 0 int getMotionPinRead void setMotionStat int motionBool int GetMotionStat int GetMotionSwitch void toggleMotionSwitch int getMotionTimeout void setMotionTimeout int timeout 88 A kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk File name temperature c KR KR RRR ce he ke che ke e RRR RRR RR RR RRR RRR ce che ke ce che ck RRR RRR AN RK RRR RRR KERR KERR KR KKK i include hw_memmap h include hw_types h include src gpio h include sro adc h include temperature h int tempValue 8 0 Temperature to turn on AC degrees F int actualTemp 0 0 Current temperature in room degrees F 0 Status of thermostat OFF HEAT COOL 1 heater on 2 A C on O both off L D int thermoStatus int heatOrCool return value stored in tempValue int GetSetTemp return tempValue set actual temperature value using input from sensor call void setActualTemp int act actualTemp act Set desired temperature according to parameter temperature void SetTemp int newTemp if newTemp 50 tempValue 50 else if newTemp 1
49. light2 style background white if f3 gt 0 document getElementById light3 style background blue else document getElementById light3 style background white if f4 0 43 document getElementById light4 style background blue else document getElementById light4 style background white if 5 gt 0 document getElementById light5 style background blue else document getElementById light5 style background white document write lt style type text css gt tabber display none lt style gt var tabberOptions manualStartup true onClick function argsObj var t argsObj tabber Tabber object var id t id ID of the main tabber DIV var i argsObj index Which tab was clicked 0 is the first tab var e argsObj event Event object if i 3 list document getElementById Category2 sublist document getElementById SubCat2 populateInfo sublist addLinkId true ur script lt head gt lt body onLoad loadFunc gt lt div class tabber id tabl style width 500px gt lt b gt lt div class tabbertab title Temperature id Temperature tabbertabdefault table border 2px align center gt lt br gt lt br gt lt tr gt lt td class regular gt Current Temperature lt td gt lt td class regular id tempCurrent gt 80 lt td gt lt tr gt lt tr gt lt td class regular gt Des
50. lude hw types h include src uart h include ritl28x96x4 h include audio h include enet h include get ip h include globals h include images h include random h include sounds h Define Key Strokes define NONE 0 define UP 1 define DOWN 2 define LEFT 3 define RIGHT 4 define SELECT 5 int getKey int getKeyWait int lastKeyStroke void setLastKeyStroke 67 RRR ke ke he ke e ce he ke he ke RRR KR RR e ce RK ce he ke KERR i k AII Y A amp KR RRR KERR KERR RR RH File name light c KR RRR ce he ke RR RR RRR RRR ehe RR ce che ke ce che ke ce che ke ce che ck RRR KR RK RRR ERR KR RRR kc kc RRR KERR RR RK iOU IL I ko k Zinclude hw memmap bi finclude hw_types h tinclude src gpio h include src adc h Zinclude light h Zinclude motion h int currentLight 0 Light sensor scaled value int lightStatus 0 Light on or off int highLight 500 Intensity of light considered high int lowLight 80 Intensity of light considered low int adcvalue 0 Digital unscaled value of light sensor convert digital input into scaled value and store to currentLight void convertAndSetCurrentLight int act 1 currentLight 0 adcvalue act if act gt lowLight CChighLight lowLight 5 0 currentLight 1 if Cact gt ClowLight CChighLight currentLight 2 if Ca
51. mp 0x0003 if gYEAR 4 0 if gYEAR 100 0 if gYEAR 400 0 LeapMonth 1 else LeapMonth 0 else LeapMonth 1 else LeapMonth 0 else LeapMonth 0 if LeapMonth MonthLength_temp else MonthLength temp MonthLength date MONTH 29 if date DAY 0 date DAY MonthLength_temp if date DAY gt MonthLength_temp date DAY 1 gYEAR date YEAR gMONTH date MONTH gDAY date DAY 54 RRR RR RRR RRR ee i I RRR RRR KERR ke ce che ke ce he ke KERR e ce ke ke ce che ke e RK L KERR KR RRR RRR KERR KER RK KKK KR KKK KK KEK Function name IncrementSecond Returns none Parameters none Purpose increments the time by one second and adjusts hours mins days years etc accordingly void IncrementSecond void 1 static char LeapMonth gSECOND increment second if gSECOND 60 gSECOND 0 gMINUTE gPowerSaveTimer if gMINUTE gt 59 1 gMINUTE 0 gHOUR if gHOUR gt 11 1 if gHOUR 12 if gAMorPM AM gAMOrPM PM else gAMorPM AM gDAY else gHOUR 1 Check for leap year if month February if gMONTH 2 if gYEAR amp 0x0003 if gYEAR 100 0 if gYEAR 400 0 LeapMonth 1 else LeapMonth 0 else LeapMonth 1 else if TE KOR RR RRR RR RR RRR RRR RRR RRR X I RK RRR ERK RRR KR RK RRR RRR KERR KR RK RRR RRR KR RR KK RK A A
52. nIntToStr GetSetTemp if sameValue GetSetTemp displayText 45 45 5 sprintf tempbuffer s F tempbuffer displayText tempbuffer 45 45 5 void mainShowThermoStatus int vertical switch GetThermStat case OFF displayText Status OFF 25 vertical 5 break case HEAT displayText Status HEAT 25 vertical 5 break case COOL displayText Status COOL 25 vertical 5 break void mainSetThermoStatus mainShowThermoStatus 40 switch lastKeyStroke case LEFT toggleStatusDown break case RIGHT toggleStatusUp break mainShowThermoStatus 40 void mainShowCurrentLight int vertical switch GetCurrentLight case 0 displayText Light Intensity 0 5 4 vertical 5 break case 1 displayText Light Intensity 1 5 4 vertical 5 break case 2 displayText Light Intensity 2 5 4 vertical 5 break case 3 displayText Light Intensity 3 5 4 vertical 5 break case 4 displayText Light Intensity 4 5 4 vertical 5 break case D displayText Light Intensity 5 5 4 vertical 5 break void mainShowLightSwitch int vertical switch GetLightStat case OFF displayText Light Switch OFF 20 vertical 5 break case ON displayText Light Switch ON 20 vertical 5 break void mainSetLightSwitch mainShowLightSwitch 40 switch lastKeyStroke case LEFT toggleLightSwitch break case RIGHT
53. nce rather than for the project itself The IAR workbench is able to load the compiled binaries onto the system However because the HTML files are not compiled a Perl script was run which converts the web files into binaries which can then be loaded onto the system 21 7 2 Hardware Technologies Used Luminary Micro LMS6965 Microcontroller The LMS6965 microcontroller is the embedded device that will be running the source code This controller features a network link that can be connected to a local area network via Ethernet I used this feature for transferring data from the client to the web server and vice versa The microcontroller also features an LCD for enhancing the user interface and several input ports for monitoring attached sensors LM 34 Temperature Probe This temperature probe ordered from Parallax com is used to monitor the temperature The output voltage for this probe was connected to an Analog to Digital input port on the controller where the user can monitor this value from the controller or a remote client Light Sensitive Resistor The light sensitive resistor also ordered from Parallax com was hooked up to the microcontroller in the same fashion the temperature probe was connected The light sensitive resistor yields a value of light intensity which can be monitored either locally on the controller or remotely Reed Relay Switches The Reed Relay switches were simply used to convert the 3V output from
54. onitored at the same time without needing the added complexity of multiple monitoring systems Allowing users to monitor their surroundings with sensors and devices of their choice provides for a greatly increased monitoring and cost efficiency 10 2 The Project 2 1 Big Picture The architecture of this project being an embedded system was complex This section will give a brief introduction to the arrangement and implementation of the various components of the system This remote monitoring system used an embedded system microcontroller as stated in the previous section with various sensors and other devices connected to the input and output pins The main aspects of this project were the local interface web interface web server sensors and device outputs Each of these will be briefly described in section 2 2 below 2 2 Details of Implementation The local interface is the user interface on the controller itself This interface uses the LCD and pushbuttons to communicate with the user The local interface was written using the C programming language Section 13 provides more information on how the local user interface operates The web interface serves as the interface when the user is remote This interface can be viewed from a web browser The web interface was written in HTML JavaScript CSS and Ajax Section 7 1 and section 13 provide more information on the web technologies used as well as the web interface itself The w
55. r in the debugging process C programming language The majority of the project s source files are written in C This language is appropriate because the compiler allows for low level function calls to be written in C as opposed to Assembly Additionally because this is an embedded system timing can be rather important Using C is an efficient alternative to Java or any other high level language JavaScript HTML CSS and Ajax JavaScript is used for the web aspect of the project When the microcontroller receives a client request for the web page it sends the JavaScript HTML CSS etc to the client that displays the information and handles the user interaction respectively The web site stores information from the last page load including current temperature The page also includes a few buttons that will enable the user to change the temperature and send the new value back to the server where the controller turns a fan or heater on or off based on the set temperature Furthermore when the server connects to the device it uses Ajax so the page does not have to be refreshed Lightweight IP LWIP 20 LWIP is an Internet protocol which was used to transport the data across the network from the client to the server and visa versa LWIP is a slimmed down version of TCP because due to the limited memory of an embedded system full TCP would not fit on the system s memory space Perl Scripting Perl was used as project maintena
56. rTemp gt TEMPDELTA heatOrCool 0 GPIOPinWrite GPIO PORTD BASE GPIO PIN 4 GPIO PIN 4 GPIOPinWrite GPIO PORTD BASE GPIO PIN 5 GPIO PIN 5 else heatOrCool 0 GPIOPinWrite GPIO PORTD BASE GPIO PIN 4 GPIO PIN 4 GPIOPinWrite GPIO PORTD BASE GPIO PIN 5 GPIO PIN 5 90 RRR ke ke he ke che ke KR he ke ehe ce he ke ce he e RR KR RK e che KK RK KR RH File name temperature h kkkkk kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk kk Temperature h This source file contains info for handling the temperature define TRUE 1 define FALSE 0 define OFF 0 define HEAT 1 define COOL 2 define TEMPDELTA 2 int GetSetTemp void SetTemp int newTemp int GetCurTemp int GetEnabled void toggleStatusUp void toggleStatusDown int GetThermStat void enableHeatCool void setActualTemp 91
57. re sensor may return a proper voltage however the function that checks this sensor may not convert the value properly I also made sure to combine dependent aspects of the project together and system test them before combining all independent parts of the project for a complete comprehensive test 26 11 Lessons Learned After many months spent on the design and implementation of this project there are a few lessons that I have learned that may make my next experiences easier and smoother First I will make sure to have extra sensors and other inexpensive hardware items on hand as basic hardware components can simply stop working On occasion a broken component slowed my project to a standstill For example if the motion sensor broke the only way to test whether or not my motion sensing software handler was working was to temporarily change the code in order to simulate a motion detection Since such components are so inexpensive it is reasonable to stock up on extra components Another lesson I learned was to determine the functionality that I would like my system to support during the conception phase Several times I reworked my code to support a certain feature because the original course of action would create a problem down the line For example the web section underwent frequent changes as I could not decide on a set method to send receive process and display the data for the client Eventually I decided that Ajax would be the
58. t just as long as any current monitoring system such as a thermostat Its simple design provides robustness and dependability This system also provides sustainability in the broad sense that it 1s built to be upgradable and last even when other technologies change The primary manner in which this system accomplishes this task is due to the fact that the system 1s connected to a network at any given time Therefore if the time comes that the system must be upgraded it can simply download new software from a content server via the Internet 12 8 Environmental Impact This system can have a positive impact to the environment Because the system provides convenience it will encourage more people to turn their heat or A C off whenever possible For example many families may leave the heat on in their apartment or house while away for the day so that the house is not too cold upon their return However if a customer is able to change the temperature on the way home rather than leaving the temperature high the entire time this will save energy and help preserve the environment 12 9 Usability This system provides a simple and easy to use web interface The interface to set the temperature is similar to a digital thermostat Next to a display of the desired temperature there are and buttons to decrement or increment the temperature 12 10 Lifelong learning This project was an inspiration to lifelong learning in that it showed
59. tById motionTrigger innerHTML recv 6 switch recv 3 case OFF document getElementById heat style background document getElementById cool style background document getElementById heat innerHTML OFF document getElementById cool innerHTML OFF break case HEAT document getElementById heat style background 00FF00 document getElementById cool style background document getElementById heat innerHTML ON document getElementById cool innerHTML OFF break case COOL document getElementById heat style background document getElementById cool style background 00FF00 document getElementById heat innerHTML document getElementById cool innerHTML break switch recv 5 case OFF OFF ON red document getElementById statusLight style background break case ON document getElementById statusLight style background 00FF00 break if recv 4 0 lightBar 0 0 0 0 0 else if recv 4 1 lightBar 1 0 0 0 0 else if recv 4 2 lightBar 1 1 0 0 0 else if recv 4 d 41 lightBar 1 1 1 0 0 y else if recv 4 4 lightBar 1 1 1 1 0 else if recv 4 5 lightBar 1 1 1 1 1 y if window XMLHttpRequest 1 req new XMLHttpRequest else if window ActiveXObject req new ActiveXObject Microsoft XMLHTTP if req try r
60. that new technology such as web interfaces and a microcontroller can be used to provide new solutions for activities like setting the temperature on a thermostat 29 12 11 Compassion In addition to the convenience factor of being able to turn on lights and heating before returning home this system could also be used to provide disabled people for instance with remote access for controlling temperature and lights with ease from anywhere in their house 30 13 User Manual 13 1 Setting up the Room Monitoring System First before you apply power and connect Ethernet make sure you find an appropriate place for your system to reside The light and motion sensors located on the front of the box cannot be blocked or they will not monitor the light intensity and motion properly Similarly the box should not be placed next to sources of hot or cold air because it will affect the ability for this system to monitor the temperature properly You will also want to make sure you place this system near a router or other connection to your network so you can easily connect it via Ethernet Once you have found a proper location for the system you may move on to the next step Second apply power to the system by plugging the system into a nearby wall plug using the included USB power adapter When power is connected an LED on the board will blink several times and the LCD will read Acquiring Address At this point the system will attempt to a
61. the corresponding field to either increment decrement a temperature value or toggle the thermo status see section 12 3 for help using the web interface 38 13 5 Using Light Monitoring Device The light monitoring device operates similarly to the temperature device If monitoring the light locally then switch to the light monitoring screen using the directional buttons This screen will show you the current light intensity in the room whether or not motion detection is enabled and whether or not the light switch is on or off The light intensity will be between 0 and 5 with 0 being the dimmest and 5 being the brightest The motion status will read either Off or On If off then the light will not respond to motion activity If on the light will turn on if motion is detected and it will stay on for as long as the user specifies with the motion timeout option The last piece of information displayed is simply the light switch If off then the light is off assuming that the light is not turned on by another means such as motion detection If the switch says on then the light is turned on If monitoring remotely then switch to the tab labeled Light on the system web page Simply click the buttons next to the corresponding field to toggle various fields on or off such as the light switch or motion detection 39 14 Appendix 14 1 Source Code Web Technologies AAA ee he ke ee he ee he ke e he ke e R ke ce he ke
62. tion Multiple devices have been attached and programmed into the system Two or more sensors have been connected to the input ports and the source code contains handlers for these sensors Sequence of Events User turns system on 2 User arrives at home screen 3 User uses up and down arrows to switch between devices Scope Room Monitoring System Actor User Goal View Current temperature from device Precondition Temperature sensor has been connected to device Sequence of Events User turns system on 16 2 User arrives at home screen 3 User switches to temperature sensor and views temperature value on screen Scope Room Monitoring System Actor User Goal View Current temperature remotely Precondition Temperature sensor has been connected to device user has access to the Internet and device has been switched on Sequence of Events 1 User loads a browser and navigates to the web server s home page 2 User views current value of temperature on web page Scope Room Monitoring System Actor User Goal Set Temperature from device Precondition Temperature sensor has been connected to device Sequence of Events User turns system on 2 User arrives at home screen 3 User switches to temperature sensor 4 User selects the menu option to change temperature and uses the up down arrows to change value Scope Room Monitoring System Actor User Goal Set temperature remotely Precondition Temperature sensor h
63. tions 2 break case TEMPERATURE numOptions 2 case LIGHT numOptions 3 showMenu device option break case OPTIONS showOptions device option break break break 86 A kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk File name motion c KR KR RRR RRR RR ke ke RRR RRR RR RR RRR RRR RRR e ix KR RRR RR RRR RRR KR KR RK RRR RRR KER RK KR RK KR ck ckck ck ko include hw_memmap h include hw_types h finclude L srfro dpio h include motion h int motionStat 0 Motion detected yes or no 1 or 0 int motionSwitch 0 Motion switch on or off 1 or 0 int motionTimeout 5 read whether or not motion sensor has detected movement int getMotionPinRead if GPIOPinRead GPIO PORTD BASE GPIO PIN 2 GPIO PIN 2 return 1 return 0 sets the value for motionStat void setMotionStat int motionBool motionStat motionBool returns current value stored in motionStat int GetMotionStat return motionStat returns whether or not light is set to respond to motion int GetMotionSwitch return motionSwitch toggle motion detector setting on or off void toggleMotionSwitch motionSwitch motionSwitch 1 2 int getMotionTimeout return motionTimeout void setMotionTimeout int timeout motionTimeout timeout 87 A kkkkkkkkkkkkkkkkkk
64. uest for Page User Client Figure 4 System Architecture 24 9 Design Rationale Considering that a functional requirement for this project was that it needed to allow the user to use the system remotely I decided to choose a networked microprocessor the LM3S6965 model with a built in Ethernet port This microcontroller supported many inputs and outputs and it also had a few built in analog to digital converters which were necessary for the monitoring of the temperature and light sensors I chose to use the IAR systems compiler because it was highly compatible with the system and made debugging and development a little simpler In fact the compiler had an on board debugger which allowed me to debug the software using the actual microcontroller rather than a simulator JavaScript HTML and CSS were used for the web portion of the system because these web languages are needed for handling user interactivity The CSS was critical in making the web site user friendly and compact as the page would be displayed on both a computer s web browser as well as an iPhone s web browser The web page featured a tabbed design so that the amount of space taken up by the page was minimized thus being able to comfortably fit most of the page if not all on smaller screens such as that of the iPhone Lastly Ajax was used for the client server interaction because a real time system should not need to be refreshed every time the user wishes to
65. vice will be portable as it can easily be moved from one room to the other Thus this project will be beneficial to consumers who wish to remotely monitor a single room such as a greenhouse or child s bedroom without needing to install complex and costly monitoring systems The project also eliminates the problem of specialization affecting most monitoring systems The Home Monitoring Controller allows the user to attach custom devices to various ports on the hardware Input devices attached include sensors such as temperature or motion sensors Output devices can trigger on or off or be given an analog value based on the input values of these sensors For example a customer wishing to monitor a greenhouse may attach two sensors to this controller a temperature and humidity sensor The customer may then attach devices which trigger on off for a fan heater and small sprinkler depending on the value at the ports A main difference between this Home Monitoring Controller and a large Home Monitoring System relates to the output devices attached to the controller A large system will often incorporate permanent devices attached such as a large vent heater or a surveillance system In contrast my controller allows users to attach their own devices for example a portable fan or desk light as the output devices for a temperature and light sensor respectively Moreover because the controller is customizable several aspects of the surroundings can be m
66. view an update of the temperature or light This results in a much more user friendly and straight forward system For instance a simple click changes the temperature on the actual controller as well as the web page without a page reload 25 10 Testing This project was produced over a range of about thirty weeks from the end of Summer 08 to the final product Even though there was sufficient time to complete the product testing throughout the process was a critical aspect because embedded system design can make debugging difficult especially when problems could be caused by either software bugs or hardware failures I tested my product using the following methods 10 1 Unit Testing I tested every individual component by creating simulated events For example to test to make sure the LCD reports the correct temperature value without having to implement the temperature sensor handler I created a function that returns an arbitrary value which is then written to the LCD By checking the LCD s value against this value I concluded that the LCD was working properly Similarly I tested other aspects of the system such as the network connection To make sure the server knows how to handle client packets I wrote a program to send test packets to the IP address of the controller 10 2 System Testing After the unit testing was complete I put all components together to see how they synergize with one another For example the temperatu
Download Pdf Manuals
Related Search
Related Contents
PRATIC EI ON Red Comunitaria Remota Guía de Usuario 取扱説明書 - M Customer Service - Fresa Technologies Lot n°1 PCR en temps réel. Copyright © All rights reserved.
Failed to retrieve file