* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Project-SW
History of electric power transmission wikipedia , lookup
Pulse-width modulation wikipedia , lookup
Electrical substation wikipedia , lookup
Current source wikipedia , lookup
Control system wikipedia , lookup
Stray voltage wikipedia , lookup
Resistive opto-isolator wikipedia , lookup
Voltage regulator wikipedia , lookup
Two-port network wikipedia , lookup
Distribution management system wikipedia , lookup
Power electronics wikipedia , lookup
Voltage optimisation wikipedia , lookup
Power MOSFET wikipedia , lookup
Alternating current wikipedia , lookup
Immunity-aware programming wikipedia , lookup
Switched-mode power supply wikipedia , lookup
Mains electricity wikipedia , lookup
2 Contents 1.0 ABSTRACT (MB) .......................................................................................7 2.0 STATEMENT OF NEED (MB) ..................................................................7 3.0 OBJECTIVE (MB) ......................................................................................8 4.0 RESEARCH SURVEY (MB) ......................................................................8 5.0 MARKETING REQUIREMENTS (MB) ..................................................10 6.0 OBJECTIVE TREE (MB) .........................................................................11 7.0 DESIGN SPECIFICATION (MB) ............................................................11 8.0 CALCULATIONS (MB, DP) ....................................................................14 9.0 DESIGN SPECIFICATIONS (MB, DP) ...................................................15 9.1 Mechanical Design...............................................................................15 9.2 Material Design ....................................................................................15 9.3 Control Design .....................................................................................16 9.4 Electrical Design ..................................................................................16 9.5 Computing Requirements ....................................................................17 9.6 Economic and Ergonomic Design .......................................................18 10.0 ACCEPTED TECHNICAL DESIGN........................................................19 10.1 Hardware Theory of Operation (SW) ..................................................19 10.2 Level I – Hardware (DP)......................................................................20 10.3 Level II – Hardware (DP) ....................................................................23 10.4 Schematics (DP)...................................................................................30 10.5 PCB Artwork .......................................................................................42 10.6 Probe ....................................................................................................44 10.7 Weather Station ....................................................................................51 10.8 Home CPU ...........................................................................................53 10.9 Complete Lawn Probe..........................................................................54 10.10 Testing Procedures ...............................................................................55 10.11 Software (DP,MB,TM) ........................................................................60 10.12 Functionality – Home PC Interative Software (TM) ...........................75 10.13 Software Events ...................................................................................81 10.14 Timer Events ........................................................................................83 10.15 Conversion Functions ..........................................................................84 10.16 xBee Coding.........................................................................................85 10.17 File Structure For Code ........................................................................89 11.0 OPERATION, MAINTENANCE, AND REPAIR INSTRUCTIONS (DP,TM) .....................................................................................................91 12.0 FINANCIAL BUDGET (DP) ....................................................................97 13.0 GANTT CHARTS (DP) ..........................................................................100 3 List of figures Figure 1 Figure 2 Figure 3 Figure 4 Figure 5 Figure 6 Figure 7 Figure 8 Figure 9 Figure 10 Figure 11 Figure 12 Figure 13 Figure 14 Figure 15 Figure 16 Figure 17 Figure 18 Figure 19 Figure 20 Figure 21 Figure 22 Figure 23 Figure 24 Figure 25 Figure 26 Figure 27 Figure 28 Figure 29 Figure 30 Figure 31 Figure 32 Figure 33 Figure 34 Figure 35 Figure 36 Figure 37 Figure 38 Figure 39 Figure 40 Figure 41 Figure 42 Figure 43 Figure 44 - Super Sprinkler Objective Tree.................................................... 11 Level I Hardware ......................................................................... 21 Level II Hardware – Lawn Probe ................................................ 23 Level II Hardware – Weather Station.......................................... 26 Level II Hardware – Central Hub ................................................ 28 Level II Hardware – Control ....................................................... 29 Schematic – Probe Charging Circuit ........................................... 30 Schematic – Probe DC/DC Converter ......................................... 32 Schematic – Probe PIC ................................................................ 34 Schematic – Probe XBee ........................................................... 35 Schematic – Weather Station Power Supply .............................. 37 Schematic – Weather Station Temperature Amplifier ............... 38 Schematic – Weather Station Pressure Amplifier...................... 39 Schematic – Weather Station XBee ........................................... 39 Schematic – Central Hub Power Supply.................................... 40 Schematic – Central Hub XBee and Driving Circuit ................. 41 PCB Layout................................................................................ 42 Populated PCB ........................................................................... 43 Flat Model .................................................................................. 44 Charging Circuit ........................................................................ 45 Probe Battery ............................................................................. 46 DC/DC Converter Subsystem ................................................... 47 Lawn Probe xBee Subsystem .................................................... 47 PIC16 Subsystem ...................................................................... 48 Complete Central Hub System, Flat Model .............................. 49 Central Hub Subsystem ............................................................. 50 Driving Circuit Subsystem ........................................................ 50 Complete Weather Station, Flat Model ..................................... 51 Weather Sensor and Temperature Sensor Amplifier Subsystem 52 Pressure Sensor Amplification and Filtering Subsystem .......... 52 Complete Home CPU System.................................................... 53 Complete Lawn Probe ............................................................... 54 Moisture Sensor Graph ............................................................. 56 Pressure Test Results................................................................. 57 Temperature Sensor Test........................................................... 58 Central Hub Information ........................................................... 60 Lawn Probe Information ........................................................... 63 Main Function Flowchart .......................................................... 67 Timer 2 Interrupt Flowchart ...................................................... 68 Pin Change Interrupt ................................................................. 69 Timer 1 Interrupt Flowchart ...................................................... 70 Timer 0 Interrupt Flowchart ...................................................... 71 Probe Shutdown, Not Charging ................................................ 72 Probe Shutdown, Not Charging ................................................ 73 4 Figure 45 Figure 46 Figure 47 Figure 48 Figure 49 Figure 50 Figure 51 Figure 52 Figure 53 - Probe Not Shutdown and Charging........................................... 73 Probe Shutdown and Charging.................................................. 74 Battery Charged ........................................................................ 74 Probe in Wake Up State ............................................................ 75 Watering decision flow chart. ................................................... 76 Weather tests flow chart. ........................................................... 77 Rain prediction flow chart. ........................................................ 78 Manual turn on flow chart. ........................................................ 80 Manual turn off flow chart. ....................................................... 80 5 List of tables Table 1 Table 2 Table 3 Table 4 Table 5 Table 6 Table 7 Table 8 Table 9 Table 10 Table 11 Table 12 Table 13 Table 14 Table 15 Table 16 Table 17 Table 18 Table 19 Table 20 Table 21 Table 22 Table 23 Table 24 Table 25 Table 26 Table 27 Table 28 - Engineering Requirements and Justification ................................... 12 Power Calculations ......................................................................... 15 Level I Hardware FR Tables ........................................................... 22 Level II Hardware FR Tables – Lawn Probe .................................. 24 Level II Hardware FR Tables – Weather Station ............................ 27 Level II Hardware FR Tables – Central Hub .................................. 28 Level II Hardware FR Tables – Central Hub .................................. 29 Schematic FR Tables – Probe Charging Circuit ............................. 31 Schematic FR Tables – Probe DC/DC Converter ........................... 32 Schematic FR Tables – Probe PIC ................................................ 34 Schematic FR Tables – Probe XBee .............................................. 36 Schematic FR Tables – Weather Station Power Supply ............... 37 Graphics Table 1 ........................................................................... 61 Graphics Table 2 ........................................................................... 61 Barometric Pressure Graphics ....................................................... 62 Connections Graphics.................................................................... 64 PIC Pin Layout .............................................................................. 66 Encoding packet structure. ............................................................ 85 Decoding echo response packet structure. .................................... 87 Remote ADC packet structure. ..................................................... 88 Frame ID list used ......................................................................... 89 GUI File Structure ........................................................................ 90 Initial Budget ................................................................................ 97 Current and Final Budget.............................................................. 98 Donated Parts ................................................................................ 99 Design ......................................................................................... 100 Implementation ........................................................................... 101 Revised Implementation ............................................................. 102 List of appendices Appendix – Data Sheets, PIC Code, GUI Code (DP,TM) .................................. 103 6 1.0 ABSTRACT (MB) A lawn sprinkler controller was designed and built. The system is comprised of the moisture probe, the central hub, weather station, and the home CPU. The moisture probe monitors soil moisture content of a specified area of lawn, or zone, and wirelessly transmits data to the home computer station. The central hub is responsible for activating the sprinkler valves for each respective watering zone. The home computer station interprets the collected environmental data, and the embedded logic determines which lawn zones need watered. The system is initially configured to monitor four lawn zones, but the system is expandable to eight zones. Key Features: 2.0 Soil moisture, temperature, and barometric pressure sensors Solar recharging capability of wireless moisture probes Rechargeable nickel metal hydride (NiMH) batteries in each moisture probe Point to point minimum communication range of 132 feet for system components Graphical User Interface for user adjustment STATEMENT OF NEED (MB) In-ground lawn sprinklers are a common piece of equipment for many modern homes. A lawn sprinkler provides a home-owner with a constant source of water to keep their lawn green and healthy. There is, however, a drawback to the common lawn sprinkler system. At a specified time, the sprinkler will dispense water across the entire lawn, regardless of the ground‟s moisture content or the current state of the weather. A 7 new sprinkler design capable of monitoring current environmental conditions and ground moisture solves reduces the chances of unnecessary or excessive watering. 3.0 OBJECTIVE (MB) The objective is to create a soil moisture and weather monitoring system that is easily implemented into the existing sprinkler hardware. The system will utilize weather data from sensors and compare that with soil moisture levels via sensors in the ground. Individual sprinkler zones will be activated based on this information. 4.0 RESEARCH SURVEY (MB) Proper irrigation is critical to maintaining a healthy landscape, and it is a surprisingly complex process because many factors must be accounted for to ensure a proper watering schedule. One of the first factors to be considered is when to water. Many cities nationwide prohibit excess water usage during peak demand hours. Furthermore, it is not beneficial to water during the afternoon as water is wasted through evaporation and scalding the lawn is more likely to occur. Fungus is likely to grow if watering routinely occurs during excessively cool and damp hours of the day. It is also advantageous for a user to include weather as a factor when constructing a watering schedule. Water, and ultimately money, is wasted if current weather conditions are not taken into account. Temperature and barometric pressure are two of the most important factors to consider for proper watering. The temperature can negatively affect watering if too high or too low. As previously stated, watering during periods of extreme temperature can compromise the health of a lawn. The barometric pressure must be monitored to detect changes in the weather. The highest atmospheric 8 pressure ever recorded is 1,094 mbar (15.87 psi), and the lowest atmospheric pressure ever recorded is 870 mbar (12.62 psi) [5]. Higher pressure correlates with fair weather and low pressure correlates with precipitation. For this reason, monitoring the drop in barometric pressure will alert system when precipitation may be approaching. In this case, an intelligent system could increase the frequency of soil moisture readings to ensure watering does not occur during a rainstorm. Another factor to be considered is how long to water the landscape. Overwatering causes runoff, which contributes to a significant amount of water wasted over time as well as damage to the overall appearance of the lawn. However, the watering period must be long enough to ensure that the water penetrates the surface and reaches the roots within the soil. Short watering periods may contribute to a shallow root system, which are more vulnerable to disease and pests capable of compromising the lawn‟s overall health. These factors have influenced the creation of intelligent watering systems. While manually operated watering systems allow for physical control over the watering schedule, technological advancements allow for more complex, autonomous systems. One of the more basic systems that are implemented today is a timer on the master valve. The user can set the time that the valve is opened and closed. This allows for hands off operation every day. Many companies have taken the automated irrigation system a step further. Companies such as Cyber Rain [2], Hydro Earth [3] and Rain Bird [4] offer intelligent systems that water based on weather forecast data downloaded via the internet, and allow for independent control of each sprinkler head. This market also includes peripherals that can be integrated within systems to monitor soil moisture, barometric pressure, and temperature. However, many of these systems require existing 9 landscape to be physically altered in order to install the system underground. A need exists for a wireless control system that minimizes alterations to the existing landscape. 5.0 MARKETING REQUIREMENTS (MB) The following list is the set of the marketing requirements around which this project will be based. These are the foundation of the project, from which our engineering and design specifications stem. 1. The system shall be easy to use. 2. The device shall be durable. 3. The system shall not significantly disturb the existing lawn. 4. The system shall be capable of operating during a long period of time. 5. The system shall provide accurate measurement of soil moisture. 6. The system shall provide accurate measurements of current weather conditions (barometric pressure and temperature). 7. The system shall be priced competitively. 10 6.0 OBJECTIVE TREE (MB) The objective tree seen in Figure 1 specifies facets of the design to be considered. A hierarchy of important features is listed for each facet. These aspects are as follows: Easy to Use, Durability, Unobtrusive Installation, Long Term Operation, Soil Moisture Accuracy, and Weather Condition. Figure 1 - Super Sprinkler Objective Tree 7.0 DESIGN SPECIFICATION (MB) 11 Table 1 displays the engineering requirements and their justification. The engineering requirements are linked directly to the marketing requirements for clarity. The accepted design shall meet all of the requirements and constraints. Table 1 Marketing Requirements 1, 2, 3 2 1, 4 4 4 5, 6 5 5 Engineering Requirements and Justification Engineering Justification Requirements The dimensions of the The probe must be unobtrusive prototype moisture and cause minimal damage to the probe shall not exceed 2 existing landscape. × 3.3 × 1.5 inches. The moisture probe Only the soil moisture sensor face housing shall be should remain outside of the resistant to moisture and protective housing; remaining elements. hardware must be isolated from the elements. The moisture probe shall The XBee module operates at a be able to operate from a low voltage. A current draw low voltage source and budget estimate was developed will draw a maximum of with potential components and 250 mA. 250 mA was an upper limit of current estimated. Sleepmode shall be Power must be conserved because incorporated into the supply may be limited with moisture probe. the solar recharging circuit. The barometric pressure sensor and temperature sensor will be supplied by 120 AC. The barometric pressure sensor and temperature sensor should be accurate up to 1% of their respective range. Data rate for communication shall be 9600 bps. These sensors must be supplied with a continuous power supply in order to monitor real time weather conditions. Accurate weather data must be measured to ensure that watering during rainstorms is avoided. This is the default set data rate, and it is ideal for serial communication. Communication range These dimensions are based on must be average yard the tabulated data of an average size of 93 × 93 square lawn size study. feet [1]. 12 1, 5, 6 1, 4 1, 5 7 System shall operate autonomously and also offer user ability to alter weather parameters (temperature and barometric pressure thresholds) and blackout time periods. The system GUI shall be designed for keyboard and mouse inputs and allow users to set their own watering parameters. System shall include three (3) monitoring zones, with the ability to expand to eight (8) zones. Product cost (excluding labor) shall not exceed $400. The controller must have a “hands-off” mode that gives owners the freedom to let the controller decide watering needs. However, it must also provide the user with the ability to adjust the system operation based on their restrictions. The system msut be intuitive to users, and it must allow user flexibility ensure an optimal watering schedule can be manually created. Monitoring system should be capable of adapting to sprinkler systems of variable size. This is based on competitive market analysis and previous system designs. Marketing Requirements 1: The system and its components shall be easy to use. 2: The system and its components shall be durable. 3: The system components shall not significantly disturb the existing lawn. 4: The system shall be capable of operating for an extended period of time. 5: The system shall provide quick and accurate measurements of soil moisture. 6: The system shall provide accurate measurements of current weather conditions (barometric pressure and temperature). 7: System should be priced competitively. 13 8.0 CALCULATIONS (MB, DP) Power consumption was calculated within the soil moisture sensor. The power consumption at the central hub and the weather station were neglected as these components will be continuously supplied with their respective DC or AC supplies. The Nickel Metal Hydride (NiMH) batteries only have a capacity of 2300mAh. Table 2 includes power calculations for hardware necessary to complete the design. The following should be noted on the power calculations: 1. One minute (60 seconds) was used as the duration for all components except for the solar cells. This interval was used because the internal components of the probe are only powered for one minute every four hours. 2. The soil cell power calculation is to be taken as a very rough estimate. As previously mentioned, the solar cells were mounted at 23.5 degrees. The cells will not see direct sunlight the entire duration from sunrise to sunset. A time of six hours was used at the cells maximum voltage and current ratings of 8.4 volts (series connection of two cells) at 22 milliamps. 3. An example calculation set is shown for the soil sensors (form followed for all moisture probe components): Instantaneous Power = Power = kWh mAh 14 Table 2 - Power Calculations Power Calculations Part Part # VG400 PRO (TX) Voltage (V) 3.3 3.3 Current (mA) <0.8 270 PRO (RX) 3.3 55 2.0 5.0 × 10-5 2.0 220 × 10- Voltage Regulator PIC16F684 (Sleep) PIC16F684 (Norm Op) LP2950 917.0 × 10-3 2.0 × 10-4 3.3 DC/DC Converter Solar Cells (2x) LM2954 - 3.3 8.4 Soil Sensor (mAh) 13.0 × 10-3 4.5 XBee Module Microcontroller 9.0 Instantaneous (kWh) Power (kW) 2.64 × 10-6 4.4 × 10-8 891.0 × 10-6 15.0 × 10-6 -6 181.5 × 10 3.0 × 10-6 10 × 10-3 4.0 × 10-8 4.0 × 10-3 4.4 × 10-7 4 66.7 × 10-3 13.0 × 10-6 11 22 183 × 10-3 132 36.0 × 10-6 185 × 10-6 7.33 × 10-9 2.16 × 10-7 6.0 × 10-7 1.11 3 DESIGN SPECIFICATIONS (MB, DP) The following provides a brief summer summary of the system design including, but not limited to mechanical design, power, and control design. 9.1 Mechanical Design 9.1.1 Static Design and Structural Consideration No static considerations needed to be accounted for within this system. The housing consists of a 3‟‟ by 3‟‟ by 2‟‟ plastic project box. Holes were drilled to mount the XBee antenna, push button, power led, and soil moisture sensor. Two solar cells, measuring approximately 3.5‟‟ by 1.5‟‟, were mounted at approximately a 23° angle atop the project box. These panels were sealed within plexi-glass to ensure isolation from the weather. 9.2 Material Design 9.2.1 Material Properties 15 The moisture sensor itself has a plastic extension that measures the dielectric constant of the soil. This extension is brittle and with some effort can be broken. The housing of the moisture probe, as initially stated, consists of a black, opaque, plastic project box that shields the internal components (PCB, batteries) from the elements. Holes in the project box were filled with silicone sealant to protect all internal components. 9.3 Control Design 9.3.1 Control System The digital control system that exists within the home CPU will make determinations about current moisture levels and current weather patterns to see if lawn sprinklers, specifically which zones, should be turned on. The moisture, temperature, and barometric pressure sensors all output analog information that must be converted to digital for use by the microcontroller. 9.3.2 Sensors Three sensors will be implemented in this system. Parameters measured include soil moisture, barometric pressure, and ambient temperature. The data from these sensors will be analyzed to determine proper run/soak times for each respective lawn zone. 9.3.3 Actuators The existing controller should contain an override mechanism for manual control. A driving circuit will be responsible for generating a signal which will be capable of activating each of the respective valves. This circuit is not responsible for providing power to the valves; it is merely for opening the valves. 9.4 Electrical Design 16 9.4.1 Communication Requirements The system shall communicate wirelessly to each part (probes, central hub, weather sensing unit, home CPU). The average yard size of 93 ft. by 93 ft. has been named the range constraint on wireless communication between the respective modules. The bit rate for wireless communication will be set at 9600 bps. This is the standard rate for XBee wireless modules. 9.4.2 Bandwidth The bandwidth shall be big enough to hold information for the instance every part is communicating at once. Each packet of data from the analog to digital converter comes in at twenty (20) bytes at each probe, plus twenty (20) bytes from the weather sensor, as well as a sixteen (16) byte echo response from the central hub. This comes to [36 + 20n] bytes, where n is the number of probes used in the system. 9.5 Computing Requirements 9.5.1 Coding The main executed file on the system shall be coded in C#. The microcontroller on each probe shall be coded in C++. 9.5.2 Storage The user PC shall provide enough storage to keep parameters saved and logs of the system usage. 9.5.3 I/O Lines There shall be enough I/O lines on the central hub to control each sprinkler zone. The weather sensing unit shall provide three (3) I/O lines for ADC. The probe shall provide two (2) I/O lines for ADC. 17 9.5.4 Interrupts The main program shall provide interrupt routines for receiving wireless data to be processed. The GUI shall provide interrupt routines for each button that is selected. 9.5.5 Electrical and Electronic Design Connections and external components for DC/DC converters shall be connected for maximum efficiency and minimal interference. Amplifiers shall be used on all sensors to adjust the voltage range to 0V – 3.3V. Low pass filters shall be used on all power lines to reduce interference. Proper wiring gauges shall be used to carry rated current. 9.6 Economic and Ergonomic Design 9.6.1 Cycle Life and Reliability Reliability will be based on the physical condition of the system components. Physical damage to system will obviously compromise the integrity of system operation. The rechargeable probe batteries are the only part that would need to be replaced. Assuming no damage to the batteries, replacement would be recommended every two to three years. 9.6.2 Maintainability This system will be easily maintainable. The lawn unit requires zero maintenance once it is in the ground. The system shall be capable of year round operation. However, wireless probes are easily removed from the ground to protect the components during the winter season. 9.6.3 Testability 18 This system can be tested on request. Once the probe is inserted into the ground, the weather sensors are supplied power, and the main program executed, the system is immediately testable. 9.6.4 Human Factors, User Interfaces The user interface for this system will be placed on a home CPU. It will provide data on barometric pressure, temperature, and moisture levels as well as current weather conditions. The GUI will be capable of taking in keyboard and mouse inputs. This full control is one user intuitive than older, primitive controllers. 9.6.5 Economics For complete system and one lawn probe, the system will be approximately $300.00. Each additional probe will be roughly $80.00. 9.6.6 Safety Considerations No high voltages or currents will be established within this system. Appropriate insulating material will provide will provide proper grounding isolation of the probe electronics. The weather sensors and the home computer will be supplied by standard 120VAC outlets, and the pre-existing grounding techniques will be more than adequate for the system. 10.0 ACCEPTED TECHNICAL DESIGN 10.1 Hardware Theory of Operation (SW) The hardware necessary for the sprinkler monitoring system to behave as desired is as follows. The moisture sensor will be powered by a series of rechargeable batteries, which will be recharged by way of a solar cell. In addition to moisture data, the system will also record temperature and pressure data and these three pieces of information will 19 be sent to a home computer. At the computer, the system logic will decide if it‟s necessary to turn on the lawn sprinklers. If watering is necessary, the system will power a driving circuit that will actuate the lawn sprinklers. The process then repeats at a designated interval of four hours. 10.2 Level I – Hardware (DP) The level I diagram gives a generic overview of the complete super sprinkler system. This begins with the lawn probe. This unit is placed in the soil and has the ability to relay soil moisture data wirelessly to the control module. The weather station contains the pressure and temperature sensors. Like the lawn probe, information is sent wirelessly to the control on current temperature and pressure. The ideal location for the weather station is in the home garage, to ensure weather readings are as accurate as possible to outside conditions, without the unit being exposed to the environment. The central hub receives all watering information from the control unit. This should be placed next to the existing sprinkler controls as it provides the actuating signal to turn on specific valves to water the lawn. As for the control block, this is the home computer. It contains logic to make decisions on watering and when to take in information pertaining to soil moisture. Along with this logic, a GUI is included to allow for user inputs and adjustments for the watering decisions. 20 Figure 2 - Level I Hardware Figure 2 shown above provides a graphical representation of the level I system. To further describe the functionality of these blocks, functional requirements have been provided for each below Table 3. 21 Table 3 - Level I Hardware FR Tables Module Lawn Probe Inputs Outputs Functionality Sunlight (recharging); Command Signals (from control unit) Soil Moisture, 0-3VDC This block‟s sole function is to take soil moisture readings at increments as determined by the control and the end user. Because it must be a completely wireless unit, it is powered by a rechargeable battery. This is where sunlight is required, to keep the batteries at a necessary voltage level. Module Weather Station Inputs Outputs Functionality Current Weather Conditions (temperature and pressure) Temperature and Pressure Readings, 0-3.3VDC each The role of the weather station is to continuously monitor temperature and pressure conditions. These will be used as determining factors where watering is concerned. Like the lawn probe this is a completely wireless unit with the exception of its power source. Because of the need for continuous monitoring, a 120VAC source will be used to provide power. Module Central Hub Inputs Outputs Functionality Watering Decision from Control Unit Current Status of Zones being Watered The central hub sends the actuating signal to the sprinkler valves. Similar to the weather station, it needs to be continuously powered; therefore a constant 120VAC source will be used. Module Control Inputs Outputs Functionality All Weather and Soil Moisture Data Watering Decision; Commands to Lawn Probe The control unit is the brains of the whole system. It contains the logic to determine whether or not to water and, specifically, which areas to water. The user can also set certain parameters, such as how long to water and weather restrictions, and the control unit will send these commands accordingly to the lawn probes. The level I description gives a broad overview of the super sprinkler system. In the level II system each of the blocks from level I are broken down into more detail. 22 10.3 Level II – Hardware (DP) Lawn Probe A deeper look into the Lawn Probe can be seen in figure 3. Starting at the solar cell; sunlight is used to charge the battery. The charging circuit contains components to regulate this charging. The battery is a 6V NiMH pack and is used to power the whole probe. The PIC, XBee, and Moisture Sensor all run off 3.3V, therefore a switching DC/DC converter is used for its higher efficiency compared to a linear regulator. The moisture sensor is physically connected to the XBee, which relays the moisture readings to the control. The PIC is the control center of the probe. It turns the charging circuit and DC/DC converter on and off, and has the ability to put the probe in sleep mode when not taking readings. The PIC can also shut down the probe all together if the battery can no longer provide sufficient power. Figure 3 - Level II Hardware – Lawn Probe 23 A more detailed description of each block in figure 3 is shown in their respective functional requirements below in Table 4. Table 4 - Level II Hardware FR Tables – Lawn Probe Module Solar Cell Inputs Outputs Functionality Sunlight 8.4 VDC at 22mA (nominal) The solar cells will provide recharging power to the battery. This will help to ensure the lawn probe can remain a standalone unit. Module Charging Circuit Inputs Outputs Functionality Solar Power, 8.4VDC; Charge Signal (from PIC) Charge Power (approx 7.5VDC); Solar Voltage Level (to PIC) The charging circuit utilizes BJT‟s to turn on and off the charge power to the batteries. It also has a diode to prevent the solar cells from draining the battery when not charging. The current level of voltage provided by the solar cells is sent to the PIC to ensure the power is sufficient to charge the battery pack. Module Battery Inputs Outputs Functionality Charge Power (approx 7.5VDC); DC/DC Shutdown Signal (from PIC) 6VDC (to PIC); 6VDC (to DC/DC); DC/DC Shutdown Signal (from PIC) The battery pack provides 6VDC to the PIC and to the DC/DC converter. It also relays the shutdown signal from the PIC to the DC/DC converter. Lastly, the charge power coming from the charging circuit is used to charge the battery pack. Module DC/DC Inputs Outputs Functionality 6VDC (from battery); DC/DC Shutdown Signal 3.3VDC The purpose of the DC/DC converter is to provide a stepped down voltage of 3.3VDC to the XBee and the Moisture Sensor. This converter has a shutdown feature that will be utilized in the event that the probe needs to completely shutdown. Module PIC Inputs 6VDC (power source from battery); Solar Voltage Level; Transmit Signal (from XBee) Charge Signal; DC/DC Shutdown; Various Signals to XBee The PIC acts as the control unit for the Lawn Probe. It has the ability to turn the charging on and off, and the DC/DC converter on and off. It also sends signals to the XBee unit. These include a “wake-up” signal, the current battery voltage signal, and a reference voltage of 3.3VDC. The wake-up will be used to turn on the XBee unit when a moisture reading should be taken. The current battery voltage will be transmitted by the XBee back to the control module for reference by the user. Outputs Functionality 24 Finally, Vref is the reference voltage used by both the PIC and the XBee module. Module XBee Inputs 3.3VDC (power from DC/DC); Wake-up Signal (from PIC); Vref (from PIC); Battery Voltage (from PIC); Soil Moisture Level 0-3VDC 3.3VDC (power for moisture sensor); Transmit Signal (to PIC); The XBee is the communication transceiver for the lawn probe. It will take in data on soil moisture, as well as various diagnostics information about the probe itself and relay it to the control unit. When it is done transmitting, it sends a signal to the PIC, and in turn the PIC puts the XBee to sleep to conserve power. Outputs Functionality Module Moisture Sensor Inputs Outputs Functionality 3.3VDC (power from XBee module) 0-3VDC Moisture Level Signal The moisture sensor measures the dielectric constant of the surrounding soil to determine the soil‟s moisture content, as one of the parameters that change the dielectric constant is water content. This level is scaled as a 0-3VDC output and this voltage is sent to the XBee to be transmitted to the control unit. Weather Station Figure 4 displays a detailed look into the weather station block from figure 2. There is a power supply block that takes in 120VAC and separates this into 3.3, +5 and 5VDC depending on the component‟s need. Both the pressure and temperature sensors have wide output range. To make the ranges of the sensor outputs appropriate to the Super Sprinkler system, signal amplifier circuits are used. These are then sent to the control unit. 25 Figure 4 - Level II Hardware – Weather Station 26 The tables (Table 5) that follow go into greater detail about each block in the figure above. Table 5 - Level II Hardware FR Tables – Weather Station Module Power Supply Inputs Outputs Functionality 120 VAC (house supply) 3.3VDC; +5VDC; -5VDC The Power Supply has a DC/DC converter and a voltage regulator to provide the three voltages needed. The 3.3VDC level is used for the Pressure Sensor and the XBee. The +5VDC is used for the Temperature Sensor. The ±5VDC is used to power the Amplifier circuits. Module Temperature Sensor, LM335 Inputs Outputs Functionality +5VDC (power) 0-3.3VDC The Temperature Sensor measures the ambient temperature of the area around the sensor itself. While the overall range of the sensor is greater, for this application the range has been restricted to 0º to 120ºF. Module Pressure Sensor, SDX30A2 Inputs Outputs Functionality 3.3VDC (power) 0-3.3VDC The Pressure Sensor measures the absolute pressure of the area surrounding the sensor itself. Like the Temperature Sensor, the Pressure sensor output has been restricted to an approximate range of 14-17 psi, corresponding to a 0-3.3VDC voltage output. Module Temperature Amplifier Inputs Outputs Functionality 0-3.3VDC (temperature reading); ±5VDC (op-amp power rails) 0-3.3VDC While the input and output voltages are the same, the point of this amplifier is to offset and remove a portion of the range on both the high and low end range of the sensor. This will allow for greater accuracy between the temperatures of 0º to 120ºF. Module Pressure Amplifier Inputs Outputs Functionality 89-92mVDC (pressure reading); ±5VDC (op-amp power rails) 0-3.3VDC The purpose of this amplifier is to restrict the range of pressure measured to between 14 and 17 psi. It also amplifies the voltage to the 0-3.3VDC range to be transmitted by the XBee. This amplifier will ensure an enhanced accuracy of the sensor output. Module XBee Inputs 3.3VDC (power); Two 0-3.3VDC Signals (temperature and pressure data) Wireless Data Stream to Control Unit The XBee unit in the Weather station transmits the data received from Outputs Functionality 27 the temperature and pressure sensors to the control. Central Hub Figure 5 - Level II Hardware – Central Hub The Level II diagram for the Central hub is shown above in figure 5. The Power Supply provides a constant 3.3VDC source to the XBee module. It is connected to the house‟s 120VAC supply. The XBee in the central hub acts as receiver for watering decisions from the control. It also provides the driving signal for the sprinkler valves in different zones. The tables (Table 6) below go into greater detail about the two portions of the Central Hub. Table 6 - Level II Hardware FR Tables – Central Hub Module Power Supply Inputs Outputs Functionality 120VAC (house supply) 3.3VDC The sole purpose of the Power Supply is to provide a constant 3.3VDC power source to the XBee unit. This is accomplished by using a wall wart AC/DC converter that is then stepped down using a voltage regulator to obtain the necessary 3.3VDC. Module XBee Inputs Outputs Functionality 3.3VDC (power); Watering Decisions Current Status of Zones being Watered This XBee is directly connected to the home‟s existing sprinkler system and provides the actuating signal for the water valves. 28 Control Figure 6 - Level II Hardware – Control Figure 6 displays the Level II hardware diagram for the Control unit. This module receives all information regarding sensor data as well as probe vitals. All the logic for decision making is contained in the home CPU. This also houses the graphical user interface which allows the user to change parameters regarding watering decisions. The following tables (Table 7) provide more detail about the functionality of the XBee and home CPU. Table 7 - Level II Hardware FR Tables – Central Hub Module XBee Inputs All Sensor Data; Probe Vitals; Watering Decision (from home CPU); Commands for Lawn Probe (from home CPU) All Sensor Data (to home CPU); Probe Vitals (to home CPU); Watering Decision (to central hub); Commands for lawn probe The XBee in the control unit takes all the outside information including lawn probe vitals and all sensor data. This is then sent to the home CPU via the USB connection. Outputs Functionality Module Home CPU Inputs Outputs Functionality All Sensor Data; Probe Vitals Watering Decision; Commands for Lawn Probe The home CPU contains all the decision making logic and the GUI for the user to set personal parameters for how they want the system to operate. The end user is also able to see lawn probe vitals including current charge status and the most recent moisture reading. 29 10.4 Schematics (DP) This section could be considered as the Level III portion as it will provide a deeper look into many of the modules introduced in the Level II diagrams. Functional Requirement tables will also be included for each component in the schematic. Charging Circuit Referring back to figure 3, the charging circuit manages the power coming from the solar cells and provides a charge to the battery pack. There is a transistor switch used to turn the charging on and off based on the current battery charge. There is also a protection Schottky diode to prevent the solar cells from draining the battery when not charging. Vsolar U1 TIP32 D1 R9 Vbatt STPS10L25 1k R1 2.7k U2 R2 PIC16F684 (PIN 6) 2N2222 2.7k 0 Figure 7 - Schematic – Probe Charging Circuit Below, the tables (Table 8) take a deeper look into each component in figure 7. 30 Table 8 - Schematic FR Tables – Probe Charging Circuit Designation U1 Part Functionality TIP32, PNP BJT This transistor carries the charge signal from the solar cell and delivers it to the battery pack. It is turned on when the base is drawn to ground by the U2 transistor being turned on. This was chosen for its higher current carrying capabilities. Designation D1 Part Functionality Schottky diode D1 prevents the solar cell from draining the battery when not charging. It was selected to be a Schottky diode for the low forward voltage drop of 0.46V at 10 Amps. Because this application involves much lower current, a significantly lower voltage drop is present. Designation R9 Part Functionality 1kΩ resistor This resistor is used as a current limiter. In the event that the circuit would have a voltage source with much higher charging current capability, this resistor would restrict the current flow to prevent damaging the system. Designation R1 Part Functionality 2.7kΩ resistor This resistor restricts current at the base of the transistor U1. Its sole purpose is to save power in the system. Designation U2 Part Functionality 2N2222, NPN BJT This transistor is turned on by the signal from the PIC. It connects the base of U1 to ground and in turn activates U1 as a switch to allow charging. Designation R2 Part Functionality 2.7kΩ resistor Like R1, this resistor limits the current in the base branch of U2 in an effort to conserve overall power consumption. 31 The DC/DC converter is next. This is comprised of the LM2594 switching regulator. This part provides an ON/OFF feature being utilized by the PIC to cut power and put the lawn probe to sleep when necessary. As before, each of the components in figure 8 is described in detail in the tables (Table 9) below. D2 0 L1 1N5817 Vo 100uH Vbatt LM2594 C2 120u C1 68u DC/DC 0 0 0 R11 Vbatt 1k U3 243 A0 15 B0 3 A 4 1 5 B3 12 B2 13 B1 1 2 R3 PIC16F684 (PIN 8) 2N2222 2.2k 0 Figure 8 - Schematic – Probe DC/DC Converter Table 9 - Schematic FR Tables – Probe DC/DC Converter Designation DC/DC Part Functionality DC/DC switcher, LM2594 This device provides the necessary switching for the DC/DC converter. Coupled with the inductor and capacitor, this converts the battery input to 3.3VDC used by the lawn probe. Designation D2 Part Functionality Diode, 1N5817 This diode is an integral portion of a DC/DC buck converter. At moments when the switching is in the “open” state, this diode will conduct and allow current to flow, completing the source-load circuit. When the switching is in the closed state this diode will block current. Designation L1 Part Functionality Inductor, 100mH L1 is another necessary component in the DC/DC buck converter. It stores energy when the switch is closed and releases it to the load when the switch is open. The properties of an inductor ensure that the current output will not drop to zero since current cannot change in an inductor instantaneously. 32 Designation C2 Part Functionality Filtering capacitor, 120μF This capacitor is used to filter out any noise at the output generated by either the switching of the DC/DC converter, or any other outside noise that could be present. This will help guarantee a clean DC source of 3.3V. Designation C1 Part Functionality Filtering capacitor, 68μF The C1 capacitor filters out noise at the input side of the DC/DC switcher. Designation R11 Part Functionality Resistor, 1kΩ This resistor connects the ON/OFF pin (pin 5) of the DC/DC converter to Vbatt. When pin 5 is connected to battery terminal voltage, it will turn the DC/DC converter off. Normal operation will have the U3 transistor in the ON state, enabling the DC/DC converter. Designation U3 Part Functionality 2N2222, NPN BJT For the DC/DC converter to remain ON, pin 5 must be at ground potential. The PIC will enable this BJT to remain in the on state as long as necessary while taking soil moisture measurements and transmitting data. The benefit is being able to turn U3 off when it is desired to disable the DC/DC converter. Designation R3 Part Functionality Resistor, 2.2kΩ This resistor limits the current in the base of the U3 transistor to conserve power, while still ensuring enough current is available to turn on U3 when needed. The PIC module, seen in figure 3, is the control unit of the lawn probe. It is programmed to put the probe in sleep mode, or wake it up, when necessary. It also determines when to charge the battery, and can shut the probe down completely if the battery voltage dips too low. Below in figure 9 is a more detailed representation of this portion of the lawn probe. 33 OUT GND IN Vref Vbatt 1 2 3 SW1 1 C3 0 1u Xbee (PIN 19) R4 Xbee (PIN 11) Vbatt 4.7k R5 3.3k R2 Xbee (PIN 9) 1 2 3 4 5 6 7 0 a b c d g fe jih q trs PIC16F684 14 13 12 11 10 9 8 0 2 0 R10 0 10k R7 R3 Vsolar 10k R8 3.3k 0 Figure 9 - Schematic – Probe PIC Each component seen above is described in more detail in the tables (Table 10) that follow. Table 10 - Schematic FR Tables – Probe PIC Designation Vref Part Functionality 3.3VDC Voltage Regulator Vref utilizes power directly from the battery and regulates it down to 3.3VDC for use by the PIC. The PIC cannot use the DC/DC converter as a power source because one of the PIC‟s responsibilities is to shutdown the DC/DC converter. Vref provides a constant source of power for as long as there is charge in the battery. Designation PIC16F684 Part Functionality PIC Module The PIC is programmed to be the control center of the lawn probe. It has the ability to enable or disable charging, shutdown the DC/DC converter, and wake up the XBee module when it‟s necessary to take a moisture reading. Designation SW1 Part Functionality Momentary Push Button Switch (normally open) This switch is mounted on the outside of the lawn probe and is used to manually wake up the probe in the even the user wants to take an unscheduled moisture reading. The switch is connected to pin 11 of the PIC and when engaged, will supply a 3.3VDC signal to the PIC. Designation C3 Part Functionality Capacitor, 1μF This capacitor filters out unwanted noise to provide a clean 3.3VDC signal for the PIC. Designation R10 Part Resistor, 10kΩ 34 Functionality This resistor is for the manual wake up feature of the Lawn Probe. When SW1 is engaged, the PIC will see 3.3V across R10 to signify the probe to wake up and take a measurement. Designation R7, R8 Part Functionality Resistors, 10kΩ and 3.3kΩ respectively These resistors create a voltage divider. The values were chosen such that the voltage seen by pin 10 of the PIC would never be greater than 3.3VDC. This scaled solar voltage is used to ensure enough voltage is available from the solar cells to charge the battery. Designation R4, R5 Part Functionality Resistors, 4.7kΩ and 3.3kΩ respectively These resistors create a voltage divider. The values were chosen such that the voltage seen by pin 3 of the PIC would never be greater than 3.3VDC. This scaled battery voltage is used to ensure enough voltage is available from the battery to operate the probe. The final component in the lawn probe to be further detailed is the XBee module. This is the wireless transceiver which sends and receives information from the control unit. Vo LED1 R6 Vo 330 PIC16F684 (PIN 7) 1 2 3 4 5 6 7 8 9 10 0 20 19 18 17 16 15 14 13 12 11 a b c d g k o fe jih m q ls n trp Moisture Sensor Battery Voltage Div ider Vref PIC16F684 (PIN 2) XBee Pro Figure 10 - 35 Schematic – Probe XBee The following tables (Table 11) delve deeper into the functionality of each component in figure 10. Table 11 - Schematic FR Tables – Probe XBee Designation XBee Pro Part Functionality XBee Pro Transceiver The XBee is the communication center for the lawn probe. Any signals that need to be sent or received are passed through here. These include data on soil moisture, and probe vitals such as current battery charge. Designation LED1 Part Functionality LED This LED indicates when the XBee unit is on. It is position such that when PIN 9 on the XBee drops to a low state, indicating the XBee is ON, the LED will illuminate. Designation R6 Part Functionality Resistor, 330Ω R6 limits the current flowing into PIN 9 to ensure it does not exceed the maximum allowable by the XBee. Referring to figure 4, the following schematics represent each block for the weather station. While the pressure and temperature sensors have already been described in detail, they are still included in proceeding circuits. The first of these is the power supply. This unit provides the necessary 3.3VDC, +5VDC, and -5VDC to the weather station‟s circuits. Each component in the power supply is described by the functional requirements that follow in Table 12. 36 5.5V Wall Wart 1 2 3 IN GND OUT R12 SDX30A2 (PIN 5) LP2950 5.5V Wall Wart IN GND OUT R16 0 C4 4.7u 1 2 3 0 0 LF33CV 4.7u 4.7u C6 3 4 5 +Vin -Vin -Vout GND +Vout VASD1-S5-D5-SIP 0 Op-Amp (+) Power Op-Amp (-) Power Xbee (PIN 1) C5 Figure 11 - R24 1 2 Schematic – Weather Station Power Supply Table 12 - Schematic FR Tables – Weather Station Power Supply Designation LF33CV Part Functionality Fixed Output Voltage Regulator This regulator provides a constant 3.3VDC supply to the XBee module for the weather station. Designation LP2950 Part Functionality Precise Fixed Output Voltage Regulator The LP2950 supplies a constant 5VDC source to the rest of the weather station. A more precise regulator was required to achieve the exact offsets needed for the sensor amplifiers. Designation VASD1-S5-D5-SIP Part Functionality ±5V DC/DC Converter This DC/DC converter provides the ±5V to power the op-amps. Designation C4, C5, C6 Part Functionality 4.7μF Capacitor These filter the outputs of the DC/DC converter and the precision voltage regulator. Figures 12 and 13 represent the two amplifier cirucits used in the weather station. The first of these defines the range for measure of the temperature sensor. Stage one is meant to buffer the output from the sensor itself. While the LM335 temperature sensor has a range of -40º to 212º F, for greater accuracy, this has been 37 restricted to 0º - 120º F. This is done using the second stage op-amp. To restrict the maximum temperature to 120º F, the final stage op-amp is used to scale the value of the max temperature to 3.3VDC. R16 LP2950 (PIN3) 20k ADJ Vin GND LM335 1 2 3 R15 10k 0 1 1 R12 2k U4 + - uA741 1 OUT R13 2 OUT 2 U5 10k + R17 uA741 - U6 uA741 + Temperature Output OUT 2 - 22k LP2950 (PIN3) R14 20k R18 5.1k 0 0 Figure 12 - Schematic – Weather Station Temperature Amplifier The amplification of the pressure sensor required more op-amps to yield a precise, properly scaled measurement. The pressure sensor measures the absolute pressure referred to an internal vacuum. This measurement is taken as the voltage across a bridge circuit. For more details see attached datasheet on the SDX30A2. The differential voltage is then buffered through two separate op-amps and the difference is amplified by a factor of 100. This is done using op-amps U7-U9. Once this raw pressure reading is amplified to a more usable value, the full range output of the sensor, being 0-30 psi, is scaled between realistic pressures normal to the environment. This is done by first offsetting the output to the lowest pressure, and then amplifying that signal to make the maximum output of 3.3VDC to be the highest pressure of the determined range. 38 1 2 3 SDX30A2 6 5 4 -Out NC1 GND +Vs +OUT NC2 LP2950 (PIN3) LP2950 (PIN3) 0 1 R24 15k U7 R19 + R21 OUT 2 - 1k U9 1 1 100k - uA741 R23 OUT 1 + R20 R26 5.1k 1 OUT 2 1k 15k - 33k R27 4.7k 0 Figure 13 - Pressure Output uA741 R28 R22 100k uA741 + OUT 2 uA741 0 + U11 + uA741 OUT 2 U10 5.1k 2 U8 - R25 0 Schematic – Weather Station Pressure Amplifier The derivation of each stage found in both amplifier circuits can be found in the testing procedures for each sensor. These were omitted here to focus on the functionality of the amplifiers themselves. The final portion of the Weather Station is the XBee module. Like the other XBee‟s, this one transmits all data to the control. It‟s only two inputs are the amplified temperature and pressure readings. As for pins 18, 17 and 11, these are LEDs to indicate temperature being too hot, too cold, and a pressure reading low enough to predict rain is on the way, respectively. LF33CV (PIN3) 1 2 3 4 5 6 7 8 9 10 20 19 18 17 16 15 14 13 12 11 a b c d g k o fe jih m q ls n trp Temperature Output Pressure Output R29 LED2 330 R30 LED3 330 R31 LED4 0 0 0 0 330 XBee Pro Figure 14 - Schematic – Weather Station XBee 39 For the central hub, this consists of a power supply, XBee module, and a set of driving circuits. The power supply uses the LF33CV constant output voltage regulator. This will provide power to the XBee and the base current for the driving circuit. 5.5V Wall Wart 1 2 3 IN GND OUT 0 Xbee (PIN 1) LF33CV Figure 15 - Schematic – Central Hub Power Supply The XBee for the central hub takes in commands from control unit based on watering. This XBee is connected to four driving circuits to represent four different watering zones. These driving circuits can be configured in different ways depending on existing circuit hardware. In this example they are used to complete the DC circuit, by providing ground through a transistor operating in the switching region. Essentially, 5VDC is applied to the coil of a relay on the existing sprinkler system, while the ground is connected through transistors U12 through U15 for zones 1-4 respectively. When the zone in question is to be actuated, the switch will be turned on by the XBee, completing the circuit and enabling the relay, turning on the sprinklers for that zone. Indicator LEDs are also included for each zone to show when the zone is watering. 40 + Sprinkler Switch Ground (Zone 1) U12 R32 D3 2.7k R39 2N2222 LED5 0 330 Sprinkler Switch Ground (Zone 2) 0 LF33CV U13 R33 1 2 3 4 5 6 7 8 9 10 2.7k 20 19 18 17 16 15 14 13 12 11 a cb d kg o fe jih m lsq n trp R38 LED6 0 R37 LED7 0 0 330 Sprinkler Switch Ground (Zone 3) 330 U14 R34 2.7k 0 D4 2N2222 D5 2N2222 XBee Pro 0 R36 LED8 0 330 Sprinkler Switch Ground (Zone 4) U15 R35 2.7k D6 2N2222 0 Figure 16 - Schematic – Central Hub XBee and Driving Circuit 41 10.5 PCB Artwork Shown below in figure 17 is the schematic for the printed circuit board (PCB) that was used for the lawn probe. The program that was used to develop the PCB was a freeware program by the name of PCB123, which is developed by Sunstone. Figure 17 - PCB Layout Shown below in figure 18 is a picture of a populated PCB, based off of the design that can be seen above in figure 17. The PCB was designed in such a way that the several subsystems for the lawn probe are grouped in close vicinity of one another. 42 Figure 18 - Populated PCB It is worth noting that there were two changes that had to be made to the original PCB design, both of which were simple fixes. The first difference is obvious and that is that R9 has been jumpered and no physical resistor is placed here. This is due to the fact that the original design was done using breadboards and Agilent power supplies as opposed to actual batteries and sunlight. The Agilent supplies provide a great amount of consistent current so the R9 resistor was necessary to pull that current down slightly. The difference is that in the real world, the batteries don‟t generate nearly as high of a current so the inclusion of that resistor brought the current down to an unacceptable level, so it was not included. Additionally there should have been a jumper between the pin 11 of the PIC16 and R10. This jumper connects the push-button and allows the probe XBee to be woken up by the manual push-button. 43 10.6 Probe Figure 19 is the complete flat model for the entire probe circuit shown in figure 18. For demonstration purposes, the flat model of the probe has been split apart into each individual subsystem for convenience and understanding. Figure 19 - Flat Model Figure 19 showed an overview of the entire probe circuit. With this information in hand, the probe circuit subsystems will now be looked at individually so that they can be related back to previously presented information. The first of those systems can be seen below in Figure 20, the charging circuit. 44 Figure 20 - Charging Circuit The purpose of the charging circuit is to ensure that the probe batteries remain charged at an appropriate level, and do not get over charged. The connections shown in Figure 20 correlate exactly with what is shown in figure 3 of the Level II Hardware diagram. The input on the top of the charging circuit will be connected to the solar cells, with the bottom connection going off to the PIC16. The PIC16 will monitor the battery levels and determine whether or not it is necessary to charge the batteries. The charging circuit outputs to the battery, (right-most connection) and allows the battery to charge when necessary. The battery system itself can be found below in figure 21. The function of the battery is to power all of the various systems in the probe. 45 Figure 21 - Probe Battery The top input to this board is for the physical connection of the battery packs. The connector on the left goes to the charging circuit, which will dictate when the batteries are allowed to charge. The bottom connector feeds back to the PIC16 so that the battery‟s energy levels can be monitored at all times. The connector on the right connects to the DC/DC converter so that the voltage may be stepped down for use by the xBee. This relationship was also portrayed above in figure 3 of the Level II Hardware diagrams. Now that the battery subsystem has been covered, the batteries are used to power the DC/DC converter, which is shown below in figure 22. 46 Figure 22 - DC/DC Converter Subsystem For as complicated as the DC/DC converter looks, its only purpose is to take the voltage provided by the battery and step it down to 3.3VDC so that it can be used by the XBee. The XBee system can be seen below in Figure 23. The XBee is the device that allows for wireless communication between the lawn probe and the home CPU system, which will be discussed shortly. Figure 23 - Lawn Probe xBee Subsystem The xBee only has one output, which is to the PIC16. This is because when the lawn probe isn‟t taking moisture readings, the xBee will be turned off to conserve power. 47 For demonstration purposes the xBee is also connected to a switch and a potentiometer. It is worth noting that in the actual physical system, these two components will not be present. The switch allows for the users to alternate between taking actual physical readings from a moisture sensor, which would be connected to the bottom right hand pin, and between a user manipulated potentiometer. The switch and potentiometer will also not be found above in Figure 2 of the Level II Hardware diagrams, it is merely an addition that assists in demonstration and testing. The final probe subsystem can be found below in Figure 24 and that is the PIC16 microcontroller. The PIC16 allows the system to control the battery voltage, as well as when the xBee transmits moisture readings from the moisture sensor itself. Figure 24 - PIC16 Subsystem The PIC16 has been discussed at length aside from one small device, which is the push-button wake-up. As the super sprinkler system is designed, it will take moisture readings at user-defined intervals throughout the day. The purpose of the push-button is to provide an override to these user defined parameters. The user would simply press this 48 button, and the xBee would wake up and transmit current moisture levels back to the home CPU. Central Hub The central hub is a middle communication zone between the home CPU and the sprinkler driving circuit. The central hub‟s main purpose is to send the actuating signal to the sprinkler solenoids in the event that watering is necessary. The flat model for the central hub can be seen below in Figure 25. Figure 25 - Complete Central Hub System, Flat Model As was seen in Figure 4 of the Level II Hardware diagrams, this system aligns exactly with what was described there. The central hub xBee is powered by a dedicated 120VAC line that is obtained from the home. The central hub xBee is constantly running so that it will always be available to send an actuating signal in the event that it is necessary to water the lawn. The central hub itself is shown below in Figure 26. 49 Figure 26 - Central Hub Subsystem For the purpose of our demonstration, there were 4 zones that contained moisture probes. These four zones were monitored by the 4 LED lights shown in Figure 26. In the actual physical system, these lights would not be present. The last part of the central hub system is the driving circuit, which is shown below in Figure 27. Figure 27 - Driving Circuit Subsystem The driving circuit behaves as expected. Its purpose is to send out an actuating signal to the existing sprinkler system in the event that it is necessary to water. It is hard-wired to the central hub xBee in order to receive this information. 50 10.7 Weather Station A major feature of the super sprinkler system is that it has the capability to predict the weather based on two constantly running sensors, one of which measures temperature and the other measures barometric pressure. The complete weather station can be seen below in Figure 28. Figure 28 - Complete Weather Station, Flat Model The weather station shown above was modeled after the exact same systems that appear in Figure 3 of the Level II Hardware diagrams shown above. Both the temperature and pressure sensors are sent to an amplifier so that their values can be amplified and recorded. This is due to the fact that we are monitoring a very small range of temperatures and pressures and in order for the changes in those values to be measured, they must be amplified so that their changes are more pronounced. The board shown below in Figure 29 contains the pressure and temperature sensors, as well as the weather station xBee and the temperature sensor amplifier. 51 Figure 29 - Weather Sensor and Temperature Sensor Amplifier Subsystem Similar to the lawn probe board shown above in Figure &, the weather sensor board also has input pins for switches and potentiometers. Similar to the above system, these are included to assist in the demonstration of the system but would not be included in the final product. The switches and potentiometers are included so that it is possible to alternate between the actual sensor readings and user manipulated values. The board shown below in Figure 30 is the last remaining component and it is simply the amplification and filtering system used for the pressure sensor. Figure 30 - Pressure Sensor Amplification and Filtering Subsystem 52 It is worth noting that a finished super sprinkler product will not have the weather station setup as shown above. The same systems will be present, but they will be placed into a more compact system and housed in such a way that protects the electronics from the elements. This system is displayed as such due to the fact that the system must be demonstrated and this style of presentation allows for clear representations of the weather station as a whole. 10.8 Home CPU The final system, which also happens to be the one that contains all of the system logic, is located at the home CPU. The entirety of this system consists of an xBee connected to a computer by way of a USB cable. A potential configuration for this system can be found below in Figure 31. Figure 31 - Complete Home CPU System 53 The system as a whole does not include a personal computer, as that must be provided by the user. The software provided with the system is loaded onto the home computer and this system contains all of the logic that is used to make decisions about whether or not it is necessary to turn on the sprinklers. If watering is necessary, the home CPU xBee relays this information back to the central hub xBee to actuate the lawn sprinklers. This process repeats at a designated interval. 10.9 Complete Lawn Probe Shown below in Figure 32 is a photo of a complete probe circuit, which corresponds to the flat model that was shown above in Figure 19. Figure 32 - Complete Lawn Probe The manual wake up button can be seen on the right side of the probe. The antenna on the left side of the case was included so that the probe would be useful for 54 very long distances. The solar cells used to charge the batteries are placed on the top of the case and are angled in such a way as to provide optimum charging capabilities. The moisture sensor then sticks out of the bottom of the case so that it may be easily inserted into the ground for use. 10.10 Testing Procedures There were three sensors that were used to accomplish all of the challenged presented by this project. These three sensors, including their testing and calibration methods are discussed below. Moisture Sensor The first sensor used in this system is the moisture sensor. The moisture sensor can be found out in the lawn probe and its purpose is to measure the moisture content of the surrounding soil so that this information can be relayed to the home CPU for analysis. This sensor used was the Vegetronix VG400 series. In order to properly test the device the sensor was placed into a 12”x14” tub with 5” of dirt inside. Water was then added at regular intervals and the voltage measured by the sensor was recorded. Figure 33 is a graph of the the result of this test. 55 Figure 33 - Moisture Sensor Graph As can be seen, the sensor behaves in a linear fashion until a certain point is reached, at which point the sensor saturates and the output voltage doesn‟t change regardless of how much water is added to the system. The output voltage for the moisture sensor is from 0-3VDC. The reason why the sensor capped itself around 2.1VDC is because of the container that was used in the experiment. The version of moisture sensor that is used is one that operates at a low frequency. Since the operating frequency of the moisture sensor is so low it causes the size of the container to impact the sensor‟s output voltage. In order to achieve a maximum output voltage from the sensor the volume of the container must be large, such as a lawn. Also it is worth mentioning that as water was added to the soil, the output voltage changes nearly linearly as the amount of water increases. At a certain point, this linear relationship starts to break down and this is also a result of the version of sensor that was used. This also occurs because of the low operating frequency of the moisture sensor. These two shortcomings both result from the 56 fact that the sensor has a low operating frequency, and in spite of these shortcomings this sensor was used because the low operating frequency means that the power needed to operate this sensor is extremely low. This was advantageous to this design because of the fact that power management was essential for long term sustained operation and this low operating frequency version of the moisture sensor provided that capability. 10.10.1 Pressure Sensor The next sensor that needed to be tested was the pressure sensor. The pressure sensor that was used was the Honeywell SDX30A2. The pressure sensor is a main component of the weather station. Its purpose is to measure the barometric pressure levels outdoors to assist in making judgments about whether or not it is going to rain. In order to test the pressure sensor an air compressor was used. The air compressor was pressurized to a certain psi and then the nozzle was hooked onto the pressure sensor. At this point the air in the compressor was released and the pressure sensor‟s output voltage was measured. Figure 34 shows the results of this test. Figure 34 - 57 Pressure Test Results The pressure that is being applied in the graph above is applied on top of the already existing pressure in the room. This test was repeated five separate times to check the consistency of the sensor. As can be seen from the graph above, the pressure sensor behaves in a linear fashion throughout the entire operating range. This implies that the sensor will function properly through normal conditions. 10.10.2 Temperature Sensor The final sensor that needed to be tested was the temperature sensor. The temperature sensor that is used is the LM335. The temperature sensor is the other main component for the weather station. The purpose of the temperature sensor is to measure the outdoor temperature to assist in making judgments about whether or not it is going to rain. In order to test the temperature sensor, it was placed outside and allowed to settle at the surrounding temperature. From here, the sensor‟s output voltage was measured and the corresponding temperature to that voltage was recorded. This measured temperature was then compared with the actual outside temperature. Figure 35 displays the results of this test. Figure 35 - Temperature Sensor Test 58 This test was repeated once daily over a period of 10 days. As can be seen from the graph above, the temperature sensor that was used behaves in a linear fashion. The data sheet for this particular sensor claimed that the sensor responds at a rate of 10mV/K and this behavior was confirmed by testing. The only issue with the temperature sensor was that is measured roughly 4ºF less than the measured temperature. This was due to inaccuracies in the sensor which were known and specified in the data sheet. It is worth mentioning that the temperature sensor is designed such that it can have an output voltage of 2.3 to 3.7VDC for its full temperature range. For the super sprinkler system, this output range has been offset and scaled so that the output voltage will vary from 0 to 3.3VDC. This was accomplished by passing the temperature sensor output through an initial amplifier so that the signal is boosted and becomes more readable. The low end of the temperature range is then taken and converted into a voltage using the equation shown above in the Temperature Sensor Output Voltage vs. Temperature graph. This voltage will now become the offset that makes the low end temperature equal to 0VDC. This becomes the next amplifier stage for the offset. The next stage is first created by repeating the process with the high end temperature. From here, the difference between the high end temperature and low end temperature voltages is recorded and then 3.3 is divided by this difference. This becomes the value for the final gain stage amplifier. This circuit can be found above in Figure *** in the Level III Hardware diagrams. This process is repeated in an identical fashion for the pressure sensor. The circuit for this amplifier and offset is found above in Figure ### of the Level III Hardware diagrams. 59 10.11 Software (DP,MB,TM) 10.11.1 GUI The structure of the GUI is too complex to be explained with flow diagrams; therefore event states will be used accompanied by appropriate figures. The GUI displays information from the central hub, weather station, lawn probes, and the control XBee. It also allows the end user to modify parameters such as watering time, temperature limits, and the desired moisture level of the lawn. Though the system is designed to run on auto with limited user interaction, there is a manual feature included should one desire to control each zone at will. Figure 36 below is an example of what a typical GUI would look like for a Super Sprinkler system with four zones. Figure 36 - Central Hub Information The central hub portion of the GUI displays the current status of each zone configured for the system. The maximum number of zones is eight; however this particular example consists of four. For each zone, different graphics are used to notify 60 the user of various states the zones may be in. Two graphics are included for each zone. The left most is that of the watering condition, the right is the connection status. These are described in detail in the following two tables, Tables 13 and 14. Table 13 - Graphics Table 1 Graphic State of Zone Zone is not setup. This means the zone in question does not exist. Not connected. Zone has not taken a reading since the application (GUI) was last started. Auto disabled. This occurs when the control is not automatic. In other words, this zone is set to be manually turned on and off. Sleep mode. Probe in the zone is in sleep mode, previous readings have been taken since application was last started Reading. Lawn probe is currently taking a moisture reading. Timeout. At each time a moisture reading is taken, four are actually taken and averaged. While this normally takes approximately 30 seconds, the PIC in each probe will time out in two minutes. When this occurs, this image is displayed. Table 14 - Graphics Table 2 Graphic State of Zone Not watering. Zone is not currently watering Manual watering. Zone is being manually watered by user. Try to water. The actuating signal was sent to the driving circuit but watering is not occurring. Auto watering. Zone is set up for automatic watering and the zone in question is currently watering Force stop. User has manually forced the zone to cease watering. Watering still on. Zone is still watering even after the specified watering time has elapsed. This can occur when the application is shut down during a watering session. Weather Station Information The weather information displayed by the GUI is a combination of graphics and numerical data. The real time temperature is displayed at all times in ˚F, whereas the pressure will be displayed as a “graphical range.” Both pressure and temperature have accompanying graphics. Because pressure is used to help predict stormy weather the 61 measurement will be compared to four ranges of barometric pressure. The levels are sunny, fair, rainy, and stormy. These figures are shown below in table 15. Graphic Table 15 - Barometric Pressure Graphics State Sunny. Pressure is in the top 75% of the range. Fair. Pressure is between 50 and 74% of the range. Rainy. Pressure is between 25 and 49% of the range. Stormy. Pressure is between 0 and 24% of the range. Weather restrictions disabled. The user has selected to not incorporate weather information in the watering decision. Under temperature. Temperature is below the user specified limit. Over temperature. Temperature is above the user specified limit. Figure 37 below shows one of the two graphics for temperature. In this case the temperature has dropped below the minimum threshold. Thus the under temperature graphic appears. 62 Figure 37 - Lawn Probe Information The probe information section of the GUI shows the user details about each probe in operation. A selector menu allows toggling between the different probes. The GUI will display: The description of the probe in question (defined by user) When the specific zone was last watered When the last soil moisture reading was taken The soil moisture content, in percent, from the most recent reading The battery voltage level of the probe from the most recent reading Each of the three information sections, central hub, weather, and probe also has a connection display to show signal strength or loss of connection. At the very bottom of the GUI application, the connection between the control XBee and the home CPU is depicted using the following images shown in Table 16. 63 Table 16 - Connections Graphics Graphic State Connected. XBee is connected to CPU via USB cable. Not connected. XBee is not connected to CPU. The type of control and weather restrictions is also shown at the bottom of the interface. The control can either be automatic, meaning the logic will decide on watering decisions based on soil moisture, temperature and pressure, or manual, meaning the user decides directly when to water. The weather restrictions can also be enabled or disabled. When enabled, the system will again utilize the logic based on all three parameters, soil moisture, temperature, and pressure. When disabled, the decision to water will be solely based on soil moisture. The GUI has several drop-down menus to adjust settings and define user parameters. The first is system settings. To get to the system settings, select Settings>System Settings, in the upper left corner. The system settings allows the assignment of the default serial port, the central hub wireless address, network PAN ID, the pause between central hub network pings, and the weather and probe voltage reference values. These settings should generally not be adjusted by the average user. The user can also select which probes to be manually controlled, and which are controlled by the logic of the system. This can be done by selecting Settings>Probe Configuration>Online>Zone #. When selected a check mark will appear next to the zone in the drop down menu, and the watering decision for that zone will be based on the sensor logic. When un-selected, the watering for that zone can only be actuated by user control through the GUI. To define the settings for each zone individually, select Settings>Probe Configuration>Settings>Zone #. This will allow the user to specify a description of the 64 probe, the moisture threshold, as a percentage, the zone watering runtime, and the individual wireless address of the XBee in the probe. To toggle the weather restrictions on or off, select Settings>Weather>Restrictions. When the restrictions are enabled, a checkmark will appear next to the word restrictions. Likewise, when no checkmark is present, the watering decision will be based on soil moisture only. The user can also adjust maximum and minimum temperature settings. The minimum setting is the lowest temperature at which the zones can be watered. The maximum is just the opposite; the logic will not allow watering above this maximum temperature. To access these settings select Settings>Weather>Settings. The user can also specify the weather XBee‟s wireless address in this setting box. In the Settings drop down menu, the “Home Base” submenu is used to specify the port that is connected to the control XBee module. The GUI will search the computer‟s hardware to find the available COM ports and list them here. The Control menu allows the user to switch between automatic control and manual control. It also has sub menus to manually turn on and off different zones. Any zone can be manually turned off whether automatic control is selected or not. However, to manually turn on a zone, the automatic control must not be selected. Lastly, the System menu has selections to close, debug, disconnect, and reload app. The close option closes the application. The debug selection was used for testing purposes and troubleshooting by the programmer. When disconnect is selected, the connection between the CPU and the control XBee is severed. Finally, reload app reinitializes the program, the same effect as closing it down and re-opening. 65 10.11.2 Lawn Probe Embedded Software (MB) The PIC16F684 is the chosen microcontroller for probe battery management and probe sleep mode. This is done through the management of four interrupts. The pin layouts can be seen in Table 17 below. Pins 4, 9, and 13 remain unused. Table 17 - PIC Pin Layout Pin I/O Function 1 2 3 4 5 6 7 8 9 10 11 12 13 14 Vdd RA5 RA4 (AN3) RA3 RC5 RC4 RC3 RC2 RC1 RC0 (AN4) RA2 Vref (RA1) RA0 Vss Power: main power (battery input) Input: xBee done xmitting Input: Battery voltage ADC input *unused Output: Debug (TMR0 interupt signal) Output: Charge signal (enable/disable charge) Output: Wakeup signal for xBee module Output: Battery voltage shutdown *unused Input: Charging source ADC input Input: Manual wakeup (external wakeup button) Power: Reference voltage (RA0) {3.3V reference diode) *unused Power: Ground The probe sits idle in a low power sleep mode in four hour intervals. The probe will remain unless one of the following two actions occur: 1. The four hour sleep cycle is completed and the microcontroller automatically wakes up the XBee, which is denoted as the Timer 2 Interrupt. 2. The manual push button is activated to wake the probe up, which is denoted as the Pin Change Interrupt. Concerning the Timer 2 Interrupt, every four hours the microcontroller will check to ensure the batteries have been recharged to a high enough voltage to provide power to the probe circuit. When this voltage has been concerned, the XBee is awoken through setting RC3 low. The flow charts for the main function and the Timer 2 Interrupt can be seen in figures 38 and 39, respectively. 66 Figure 38 - Main Function Flowchart 67 Figure 39 - Timer 2 Interrupt Flowchart Concerning the Pin Change Interrupt, when the manual push button is engaged the microcontroller will first check to ensure the batteries have been recharged to a high enough voltage to provide power to the probe circuit. When this voltage has been confirmed, the XBee awakes through pin RC3 being pulled low. The flowchart can be seen in figure 40. 68 Figure 40 - Pin Change Interrupt When the probe circuit is turned on through Pin RC3, the microcontroller begins the Timer 1 interrupt. This interrupt is responsible for monitoring data transmission through the XBee through a transmission timeout counter. A time interval of 90 seconds has been specified for data transmission. If the XBee completes transmission pin RA5 will be set high, and the microcontroller will wait one sentence and turn off the probe circuit by setting pin RC3 high. Waiting allows the XBee to reset to its original state. If the XBee fails to complete transmission within the allotted time the microcontroller will put the probe back into sleep mode, and the timeout counter will be turned off. The Timer 1 Interrupt flowchart can be seen in figure 41. 69 Figure 41 - Timer 1 Interrupt Flowchart One final interrupt, Timer 0, has also been implemented to monitor the battery voltage and manage recharging. The battery voltage and so voltage are respectively assigned to the analog to digital converters on channels three and four, and both are initialized to zero. The voltage tests are synced to the clock through the debug pin RC5. This syncs state changes to occur on every other clock cycle. Figure 42 displays the Timer 0 Interrupt flowchart. 70 Figure 42 - Timer 0 Interrupt Flowchart A function designated checkCharge is responsible for managing the recharging function of the probe. If the battery voltage is less than 7.15 volts (constant defined in the header file), the voltage across the solar cells is compared to the battery voltage. Charging begins if the solar cell voltage is greater than the battery voltage. When the battery voltage reaches 7.6 volts (also defined in the header file), charging is stopped. When charging is stopped, the voltage will drop from 7.6 volts. Setting the charging 71 voltage to 7.15 provides a hysteresis which prevents the probe from getting stuck in a constant charging state. A function called checkShutdown is responsible for disengaging the DC/DC converter if the battery drops below 5.95 volts. This low threshold also governs whether or not the probe will energize when the four hour interval has ended or the manual push button has been engaged. The flowcharts for checkCharge and checkShutdown can be seen in Figure 41, the Timer 0 Interrupt Flowchart. The following five figures are simulation waveforms that visually explain the previously explained operation of the microcontroller. The following waveforms are defined as such: D0 – Interrupt Clock; D1 - !Shutdown; D2 – Charge; D3 – Sleep. Figure 43 shows that the battery voltage is less than 5.95 volts, and the probe is shut down and not charging. Figure 43 - Probe Shutdown, Not Charging 72 Figure 44 shows that the probe is not shutdown, but is also not charging. This case represents a scenario in which the battery is within the 7.3 to 7.6 volt range where charging does not occur. Figure 44 - Probe Shutdown, Not Charging Figure 45 shows the scenario in which the probe is shutdown and charging. In this case, the battery voltage is below 5.95 volts, and the solar cell voltage is greater than the battery voltage. Figure 45 - Probe Not Shutdown and Charging 73 Figure 46 displays the scenario when the probe is not shutdown but the batteries are charging. The battery voltage is at approximately 6 volts. The probe is asleep Figure 46 - Probe Shutdown and Charging Figure 47 shows the battery is charged (D2 shows not charging). Figure 47 - Battery Charged Figure 48 shows the XBee in its woken state. Signal D3 is low, signifying wake up. 74 Figure 48 - Probe in Wake Up State 10.12 Functionality – Home PC Interative Software (TM) 10.12.1 Watering Decision A watering decision is made each time a new moisture reading is recorded. This will happen every four hours (or when wireless probe is manually turned on) per zone. Figure 49 shows the flow chart for the watering decision. Once a moisture reading is received and recorded, the reading is compared to the user set threshold for that zone. If the moisture is below the threshold (the ground is dry), the watering decision continues to test more conditions. If the reading is above the threshold, the zone will not be watered and the probe will go back to sleep after three more readings (four total per a wake up). 75 Figure 49 - Watering decision flow chart. If testing is continued, the program makes sure that the zone is currently online. Also, if the zone is online, the system needs to be set to automatic. If either is disabled, watering will not take place. Next, weather conditions are tested if weather restrictions are enabled (see below for more information on weather testing). If there are no alerts, or restrictions are disabled, watering will take place if it has not already started. Once watering is started, the wireless probe will be informed to go back to sleep and the main GUI will be updated. 76 10.12.2 Weather Test The weather test is used to prevent watering at un-ideal times. The test is made up of three checks: over temperature, under temperature, and rain. As previously mentioned, hot air outside could scorch the grass when watering or the cold air may promote fungus growth or freeze. These two tests will make sure watering does not occur during the set temperature thresholds. The thresholds are determined by the user interface parameters located in the weather settings. The third test determines if it is raining or about to rain. In this situation, the system will save water and wait for the rain to moisturize the zone. Figure 50 shows the flow chart of the weather test at the top level. Figure 50 77 Weather tests flow chart. The temperature extreme test is a simple comparison of the current temperature versus the two thresholds. The rain test is a little more involved in the process. Figure 51 shows the flow chart for the rain prediction. Prediction is done using the recorded pressure. If the pressure is at the low extreme (29.50”Hg), it will most likely rain. Also, if the weather is fair (using 30.5”Hg) and has been dropping (at a rate of 0.30”Hg/20minutes) it may rain. To show if it is not likely to rain, pressure will be above the low extreme (29.50”Hg) or if the pressure has been increasing (at a rate of 0.30”Hg/20minutes) and is above 29.15”Hg. These are just predictions and do not confirm actual rain. Figure 51 - Rain prediction flow chart. 78 If any weather test shows an un-ideal condition, watering will not take place. Due to predictions being made, they may not always deliver the desired result based on an uncommon weather pattern. Disabling weather restrictions will skip all these test. The user will still be informed of the alert, but will not affect the watering choice. Another system bypass to ignore weather decisions is the last watered timestamp. If the system has needed water for more than 10 hours (3rd probe wake-up cycle) and has not watered due to a rain prediction, the prediction will be overthrown and watering will take place. Alerts are shown in two physical locations. The first is located on the GUI. As explained previously, the appropriate image and text warning will let the user see an issue with the weather. On the weather station itself is three LED‟s. Each LED represents an alert. The red shows an over temperature, the white shows an under temperature, and the blue shows possible rain. 10.12.3 Manual Control The GUI allows the user to manually control the sprinkler system. To turn on a specific zone, the system must be on manual or the zone must be offline. Otherwise, the zone will not water and the command will be ignored. Once watering has begun, the user is responsible for turning off the zone. No timer is set for manual control. Turning off a zone can occur at any time as long as the zone is currently enabled. This feature allows the user to stop manually started watering, or to override an automation decision. Figure 52 and Figure 53 shows the flow chart for the two cases. 79 Figure 52 - Manual turn on flow chart. Figure 53 - Manual turn off flow chart. While in manual control (per zone or whole system), the probe readings are still updated. No watering decision is made, however. When switching back to auto control, any manually turned on zones will be shut off. 10.12.4 External Files 80 External files are used to store various amounts of data. These are included in three text files: settings.txt, parameters.txt, and lastreadings.txt. The files are needed for the program to run correctly. Files should not be manually changed by the user due to the sensitivity of their formatting The „settings.txt‟ file holds all the setting information. When a setting is adjusted in the GUI, the file is updated. These settings are stored into internal variables in the program for startup. The „parameters.txt‟ file holds the different parameters used. These values are also stored in internal variables to be used in the program at initialization. Any adjustments to parameters are saved and written into the text file. The „lastreadings.txt‟ files holds data to initialize reading values at startup and remember important timestamps. Every ten central hub pins, the current values of all the readings are saved into the file. This allows the sprinkler program to restart seamlessly in case of an accidental shutdown. This auto save also occurs every time a new moisture reading is received. This file also keeps track of the last time each zone was watered. 10.13 Software Events Once the software starts up, it sits idle until an event occurs. An event will occur every time the user interacts with the GUI. These events control the functions described in the GUI. Other events occur internally based on data received from the serial port and timers within the code. 10.14 Wireless Data Received 81 Wireless data is sent and received through the connected serial port. Data is coming from a wireless probe, the weather station, or the central hub. By scanning the incoming wireless packet, the address is used to determine which location the data is coming from. When data is received from the wireless probe, the moisture reading and battery voltage is sent as a 10-bit ADC as well as the connection strength. The program converts these analog voltages into usable data based on voltage dividers, voltage reference, and any other scaling involved. Once data is recorded, the program calls for the watering test as described above. Probe readings are recorded up to four times. After four readings, a shut down signal is sent to put the probe back to sleep. If the zone is determined to water, the probe will go to sleep before four readings. Data is received from the weather stations every three seconds. Each reading updates the weather portion of the GUI. Temperature and pressure readings are retrieved from the weather station and converter to their proper units. Weather tests will be done to determine if any alerts need to be issued. Any found alerts will be displayed on the GUI and taken into account when a water decision is called for. No watering decision, however, is made during this event. The central hub is mainly used as an output station to control the sprinkler driving circuit. However, it also receives data to check the connectivity to the central hub as well as the states of the pins. This happens every time the central hub is pinged based on the timer event described below. The states of the pins are stored in variables internally to complete error checking tests against the logic state the pin should be in. The central hub also receives data to confirm that the driving pins are successfully being toggled. 82 10.15 Timer Events Different timer events run in the background while the program is running. Two timers are started when the application is ran and continue until the application is closed. The other is turned on and off when needed. The central hub timer is essential to the program to keep the user aware of any issues with the system. The event is a user defined setting that occurs from 60 seconds to 10 minutes. To use less timers, various timestamps are stored and checked during this event and are analyzed. The first check is for probe connectivity. If the program has not seen a reading within four hours (sleep cycle for the probe), the probe is then considered no longer connected to the system. If the probe was in the middle of taking readings and did not shut off within two minutes (the wireless probe auto sleeps in around 90 seconds if it was not told to sleep), the probe is considered to have timed out. The ping also checks on the status of the weather station. If the weather station has not seen a reading in five minutes, it is considered no longer connected to the system (a reading should be received every three seconds). After connectivity between components is determined, the ping calls for the program to send out various remote commands to check signal strength and the state of all the outputs on the central hub xBee. Once the states have all been received, they are compared to their logical value (the state the pin is supposed to be in). If any pin is enabled when it is supposed to be off, it is then shut off. This check is to safe guard against an accidental closure of the program during the middle of watering. The next timer is used for remember settings throughout the open time of the application. The timer event occurs after every five central hub pings. At this time, a list of all the current readings, last watering time for each zone, and settings is compiled. 83 This list is then saved in the „lastreadings.txt‟ file to be used the next time the program is opened. The last timer event is the sprinkler watering run time. Each zone has its user defined run time that watering will continue. Once a zone has been automatically turned on, this timer will start (manual events so not start the timer as previously mentioned). After the timer is expired, the program will find the zone which expired, and disable watering until next event is called. After disabling the watering, the timer is shut off. 10.16 Conversion Functions Different conversions are used to convert analog readings into usable data. Other conversions are used to convert units between each other. Conversions are also used to construct wireless packets and decode them. Construction and decoding is described below. Moisture readings are taken as percentage. The moisture sensor is on a scale of 03V. From this, the percentage is found by dividing the analog voltage found by 3V. No other scaling is done for this sensor. Battery readings are shown in voltage. The analog voltage read is a scaled version. The actual battery voltage goes through a voltage divider to get a scale of 0-8V. The actual voltage is found by multiplying the analog voltage by the ratio (2.42424). Temperature readings are scaled through two stages of operation amplifiers. To find temperature, the temperature sensor voltage needs to be found by going through the stages backwards. The analog voltage is divided by the gain stage (4.914) to get the pregain voltage. The previous stage offsets the voltage (-2.424V), so this voltage is added to the pre-gain voltage. The resulting voltage is the actual voltage at the temperature sensor. 84 The sensor‟s specification in the datasheet state 1 Kelvin / 10mV. Therefore, the voltage is multiplied by 100 to get Kelvin. Kelvin is finally converted into Fahrenheit. Pressure is found the same way temperature was found. However, different gains, offsets, and specifications are used. There is also an extra gain. The pre-gain stage has a gain of 8.09 and an offset of -1.7V. Finally, the differential voltage is found by dividing the first gain stage (103.017). From calibration, it was determined 0.825mV / PSI. Multiplying by 825 then results in PSI. Once PSI is found, it is converted into inches of mercury (“ Hg). 10.17 xBee Coding 10.17.1 Encoding There are essential parts of the xBee coding to successfully send a wireless packet to the network. Table 18 shows the packet structure to send a remote AT command. Table 18 - Encoding packet structure. Byte Meaning Comments 1 Start delimiter 0x7E 2-3 Packet length Length of the packet not including bytes 1-3 4 API ID 0x17 for remote AT commands 5 Frame ID Value used to identify command. See below for list of used frame IDs located in the echo response. 6-13 64 Bit address For short address on PAN ID, uses 0x000000FFFE 14-15 Short destination address Address of destination probe. Addresses of each system component are stored internally to be accessed. 16 Apply changes 0x00 will change value, 0x02 will change and apply. 17-18 AT Command Command being used. Refer to xBee manual for list. 85 Byte Meaning Comments 19-n Parameters Used for setting the command with the parameter n+1 Checksum Checksum to test integrity of packet (see below for calculation) 10.17.2 Decoding When receiving a packet, this program receives two types of responses: remote ADC reading and an acknowledgment response (echo). Echo responses confirm if a remote AT command was sent of returns a query response. Table 19 shows the packet structure for an echo response. As data is received through the input, it is stored into a temporary buffer. Once the packet length is found, data is read into buffer until the end of the packet is reached. This data in stored as a packet and processed. Data in the temporary buffer is then shifted over and repeated until no data is left to process. If a start delimiter is not found, the packet is trashed until 0x7E is received. 86 Table 19 - Decoding echo response packet structure. Byte Meaning Comments 1 Start Delimiter 0x7E 2-3 Packet length Length of packet being sent not including bytes 1-3 4 API ID 0x97 for remote command response 5 Frame ID Used to determine which command trigged the response. (see below for list of frame IDs) 6-13 64-bit Address Serial number of transmitting xBee 14-15 Short Address Address stored to determine which xBee is transmitting 16-17 AT Command Command that was sent 18 Command Response Status of command. 0x0 = successfully sent. Refer to manual for other responses. 19-n Query Response Only if AT command was used to query (n+1) or 19 if not queried Checksum Checksum of packet 87 ADC responses are sent differently. Table 20 shows the ADC packet structure. The table shows one sampled reading of two ADC inputs and a digital sample. Multiple samples loop through bytes 12-17. Table 20 - Remote ADC packet structure. Byt e Meaning Comment 1 Start delimiter 0x7E 2-3 Length Length of packet 4 API ID 0x83 - remote ADC reading 5-6 Short Address Address of transmitting xBee 7 RSSI Signal strength of transmission 8 Option byte Not used 9 Number of samples Number of samples inside of packet 10-11 Inputs Gets the enabled inputs 12-13 Digital Inputs Shows states of digital inputs 14-15 AD0 Shows 10bit ADC conversion on D0 16-17 AD1 Shows 10bit ADC conversion on D1 18 Check Sum Checksum Table 21 shows the different frame ID‟s used. The frame ID‟s keep commands sent by the program in order to determine what function was attempted. 88 Table 21 - Frame ID list used Frame ASCII Character Use ID 0x43 C Checking pin state on central hub 0x44 D Used for sending debugging commands 0x45 E Central hub echo response (for RSSI) 0x4D M Manual turn on / turn off 0x54 T Toggle pin event (for xBee sleep or weather alert) 0x57 W Automatic watering 10.18 File Structure For Code This program uses multiple files to better organize. All these files are included in the appendix. Table 22 shows the relation of each code file. Only the self created files are included in this table. 89 Table 22 - GUI File Structure File Purpose Call Program.cs Start of the code. File determines direction of code. Monitor.cs Main GUI. Initializing all serial port events, timer events, and loading variables Called from Program.cs initialize.cs Sets root directory for external files Called from Program.cs stringProcessing.cs probeConfig.cs GUI for changing prope settings Called from main GUI stringProcessing.cs systemSettings.cs GUI for changing system settings Called from main GUI stringProcessing.cs weatherSettings.cs GUI for changing weather settings Called from main GUI stringProcessing.cs constants.cs Initializes all needed -variables. Also loads in values from external files. stringProcessing.cs control.cs Hold all control commands for interpreting wireless commands, timers, tests, updating GUI, and handling events. -- stringProcessing.cs constants.cs stringProcessing.cs Constructs functions, holds conversions, and controls file I/O. -- -- 90 Uses - Opens Monitor.cs if not initializing, otherwise opens initialize.cs 11.0 OPERATION, MAINTENANCE, AND REPAIR INSTRUCTIONS (DP,TM) Warning: Probes should be removed from lawn prior to lawn maintenance (cutting grass, etc) and during cold/winter months. Operation: Setup Split up lawn into specific zones (average of 4 zones per lawn). Larger lawns may require more zones.* Gently place one Lawn Probe near the center of each zone. o Note: special care should be taken when placing probes into the soil as the moisture sensor is brittle.** Attach weather station in a non-environmentally controlled location, such as garage or screened porch, and connect to wall outlet. Place Central Hub unit in close proximity to existing sprinkler control box. Connect power cord to wall outlet. Connect actuator wires to electronic switches on existing sprinkler controller. o Note: This may require extensive knowledge of your existing sprinkler system. The Super Sprinkler System is expandable to as many as eight (8) zones. If there is only one main valve which operates all sprinkler heads, only one zone will be able to be used.*** Connect the Control Module to your home PC via the USB cable provided. Install the user software on your home PC. Open the Super Sprinkler software and set user defined parameters 91 o Temperature high and low points o Desired continuous moisture level of soil o Watering duration o Note: See GUI section below for more information on the user interface GUI (Graphical User Interface) Setting high and low temperature points o Select Settings>Weather>Settings o This will open up the weather settings dialog box 92 o Use the sliders to set max and min temperatures o Click Save to save the changes Setting desired moisture level of soil and watering duration o Select Settings>Probe Configuration>Settings>Zone# o This will open up the zone settings dialog box 93 o Use the sliders to set threshold and water runtime o Click Save to save the changes Toggle between automatic control and manual control. o Select Control o Ensure that Automatic has a checkmark next to it This will allow for the weather and soil moisture logic to make watering decisions without user interaction 94 o When Automatic does not have a checkmark next to it, the user has the ability to manually turn on sprinkler zones. To do this select Control>Turn on zone>Zone# Note: The manual turn on of the zones is only possible when the Automatic control is UNCHECKED o Unlike turning on zones, turning them off using the Control menu can be done whether Automatic control is checked or not. Maintenance System is self sustaining. The Lawn Probes are equipped with solar cells to ensure the battery can last throughout the watering season. However, because of the battery type, NiMH, they should be removed from the probes at the end of each season and fully charged before being put back into service.**** 95 For any connection issues, such as loss of connectivity, the system GUI will display the zone in question, and the error in question. This will help in the troubleshooting process. For testing, troubleshooting, or simply for personal desire, the user may, at any time, press the override button on the side of the probe to command a moisture reading at that particular time. Appendix * Zone sizes are strictly up to the user. Depending on how the previously installed sprinkler system is set up, there may be several zones already in use. In the event of only a single, “master valve,” several probes can still be used to keep record of moisture levels in different areas of the lawn. ** While the moisture sensor probe is made of a durable material, it is possible for this to snap or break in the event of improper handling or rough insertion into the ground. For this reason it is highly recommended to take extreme caution when inserting or removing the probes. *** When connecting the actuator wires from the Central Hub to the existing sprinkler system it is highly advisable to contact the system installer or obtain a detailed wiring diagram of the complete system. **** Nickel metal hydride (NiMH) batteries have a self discharge disadvantage; that is even while sitting idle they will begin to lose their charge. Note: Unfortunately, existing sprinkler systems without an accessible electronic switch interface are not compatible with the Super Sprinkler system. 96 12.0 FINANCIAL BUDGET (DP) The budget for this project has changed slightly since the original plan was set. Some of the components, upon testing, were deemed unfit for the design, and in some cases new ideas were added to the original concept. Table 23 below is the first budget set for the project. Table 23 - Initial Budget Qty. 2 3 2 2 2 2 2 5 1 2 4 2 2 4 3 3 4 5 5 Part Num. VG400 WRL-08690 2N2219A PIC16F684-I/P LM317T LM336Z-2.5/NOPB LF33CV SDX30A2 LM335Z/NOPB SolMaxx-Flex-4_2V22mA A24-HABUF-P5I XBP24-AUI-001 EVENH15BP4-NH15BP-4-4 PIC16F684-I/P LM2594N-3.3/NOPB 5800-101-RC UPW0J680MDD UPW0J121MDD Description Unit Cost Moisture Sensor XBee Communication Module NPN BJT for Charging Circuit 14 Pin PIC for Charging Circuit Adjustable Voltage Regulator Protection Diode Fixed Output Voltage Regulator Linear Regulator 3.3V, for Probe Power Absolute Pressure Sensor Temperature Sensor Solar Cell, 4.2V, 22mA XBee Pro external antenna XBee Pro Tranceiver Nimh batteries 14 Pin PIC for Charging Circuit 3.3 V DC/DC converter 100uH inductor for DC/DC converter input cap for DC/DC converter output cap for DC/DC converter Total Cost 29.95 37.95 59.90 113.85 1.96 0.72 0.96 1.35 3.92 1.44 1.92 2.70 31.66 1.19 2.65 5.00 32.00 11.99 1.96 3.42 1.33 0.34 0.35 Total 31.66 2.38 10.60 10.00 64.00 47.96 5.88 10.26 5.32 1.70 1.75 $398.36 This budget included enough material for testing and implementing two lawn probes. Several changes were necessary to meet power and size stipulations. For instance, the linear regulator was too inefficient, and was replaced by a switching regulator. Also, the design was adjusted to accommodate three lawn probes. Table 24 below is the revised budget for the Super Sprinkler system. Many of the major components, sensors, communication devices, and the PIC did not change. One significant addition was that of the NiMH batteries. Originally, a lithium ion battery was considered, however sufficient voltage was unattainable to meet size and cost needs. The 97 unfortunate downside to these is the self discharge characteristics. This will be overcome by the solar charging and the low power capabilities of the lawn probes themselves. Table 24 - Current and Final Budget Qty. 3 6 3 1 1 4 3 4 3 3 3 3 3 2 1 1 Part Num. VG400 XBP24-AUI-001 PIC16F684-I/P SDX30A2 LM335Z/NOPB SolMaxx-Flex-4_2V22mA A24-HABUF-P5I EVENH15BP4-NH15BP-4-4 LM2594N-3.3/NOPB LP2950ACZ-3.3 STPS10L25 TIP32C 5800-101-RC LF33CV LP2950ACZ-5.0 VASD1-S5-D5-SIP Description Moisture Sensor XBee Pro Tranceiver 14 Pin PIC for Charging Circuit Absolute Pressure Sensor Temperature Sensor Solar Cell, 4.2V, 22mA XBee Pro external antenna NiMH batteries 3.3 V DC/DC converter Precision 3.3VDC fixed output voltage regulator Schottky diode, charging circuit barrier PNP transistor, charging circuit 100uH inductor for DC/DC converter Fixed output voltage regulator 3.3VDC Precision 5VDC fixed output voltage regulator ±5VDC DC/DC converter, op-amp power Unit Cost Total Cost 29.95 32.00 1.96 31.66 1.19 2.65 5.00 11.99 3.42 1.12 1.61 0.55 1.33 1.35 1.12 5.58 Total 89.85 192.00 5.88 31.66 1.19 10.60 15.00 47.96 10.26 3.36 4.83 1.65 3.99 2.70 1.12 5.58 $427.63 The budget comes in just higher than the $400 allowed for the design. The majority of this price is taken up by the weather station and central hub portions. As the number of probes increase, however, the system becomes more cost effective. Table 25 below is a list of the parts used in the design that were donated by the university. 98 Table 25 Qty. 1 5 10 3 9 9 8 3 10 6 4 3 8 2 2 1 1 2 3 3 3 3 Part Num. LM348 UA741 2N2222A 1N5817 LED Resistor Resistor Resistor Resistor Resistor Resistor Resistor Resistor Resistor Resistor Resistor Resistor Resistor Capacitor Capacitor Capacitor Capacitor Donated Parts Description UA741 op-amp, quad package Op-amp NPN transistor, 40V, 0.625W Schottky diode, DC/DC converter LEDs (various colors) 330Ω Resistor 1kΩ Resistor 2.2kΩ Resistor 2.7kΩ Resistor 3.3kΩ Resistor 4.7kΩ Resistor 5.1kΩ Resistor 10kΩ Resistor 15kΩ Resistor 20kΩ Resistor 22kΩ Resistor 33kΩ Resistor 100kΩ Resistor 1μF, 50V 4.7μF, 50V 68μF, 6.3V 120μF, 6.3V 99 13.0 GANTT CHARTS (DP) Table 26 - 100 Design Table 27 - 101 Implementation Table 28 - Revised Implementation 102 Appendix – Data Sheets, PIC Code, GUI Code (DP,TM) 103 Datasheets Datasheet Part Used In Ref ID Diode Driving Circuit D3, D4, D5, D6 Quad Op-amp Weather Station U7, U8, U9 Single Op-amp Weather Station U4, U5, U6, U10, U11 PIC16F684 Probe Microcontroller Lawn Probes PIC16F684 LP2950-D Precision 3.3 and 5VDC Regulators Lawn Probes and Weather Station Vref, LP2950 NPN Transistor Driving Circuit, Lawn Probes U2, U3, U12, U13, U14, U15 Solar Cell, 4.2V @ 22mA Lawn probe PNP Transistor Lawn Probe U1 Schottky Diode Lawn Probe D1 Schottky Diode Lawn Probe D2 DC/DC Converter Switcher Lawn Probe LM2594 DC Regulator Central Hub, Weather Station LF33CV 1N4001 LM348 UA741 2N2222A Solar Cell TIP32C STPS10L25 1N5817 LM2594 LF33CV 104 SDX30A2 LM335 +- 5VDC DC/DC Converter Absolute Pressure Sensor Weather Station SDX30A2 Temperature Sensor Weather Station LM335 ±5VDC DC/DC Converter Weather Station VASD1-S5-D5-SIP 105