| College of Engineering



Early Warning Detection for Solar Power12/9/2015Spencer KrugNate VargoTianhang SunQifan WangLiqing YaoExecutive SummaryMSU is in the process of acquiring a 10 MW solar array. This solar array is planned to go live in the summer of 2016. The idea of the solar array is to start the transition over to renewable and clean energy as well as create a portion of the total power MSU uses to purchase at a reduced cost. However, with this much electricity delivered by a renewable source, a sudden change in cloud cover will create a reduction in electricity. Since the weather is very dynamic and hard to predict for precise locations, this reduction of electric power will be very quick. With quick changes to the MSU grid, imported back up power will have high spikes that will go back down as other generators on campus power up. The power company calculates payments based on the height of the quick spikes. Since the solar panels could potentially create these spikes, the costs to import backup power go up greatly. If these high costs are common, building the array would counter effective. The present project constructs an early warning system based on remote sensors, which will enable users to anticipate changes in the output of the solar array and take appropriate action in the load profile such as powering up backup generators before the cloud front hits to reduce the spikes in imported back up power. MSU itself is the customer for the finished output of this project.AcknowledgmentsTeam 7’s acknowledgements go out to our sponsors, Wolfgang Bauer and Nate Verhanovitz. Throughout the entire design process, Wolfgang and Nate steered the team in the right direction as well as sharing ideas of the many possibilities for design solutions. The much experience from our sponsor allowed the team to create a good working prototype.Also, our thanks go out to our facilitator, Nelson Sepulveda. Nelson always made sure our plans were correct in theory and would be able to work in practice. He aided in very early algorithm concepts as well.Table of ContentsChapter 1: Introduction and Background51.1 Problem Statement51.2 Project Objective51.3 Other Methods51.4 Project Approach6Chapter 2: Solution Space and Approach62.1 Project Definition62.1.1 Project Breakdown72.2 Critical Customer Requirements72.3 Conceptual Designs82.4 Project Management102.5 Budget112.5.1 Conceptual Budget112.5.2 Implementation Budget11Chapter 3: Technical Description123.1 Hardware Design Efforts123.1.1 Pyranometer133.1.2 Light Sensor133.1.3 Electric Imp 002 Microcontroller143.1.4 Power Supply163.2 Hardware Implementation173.2.1 Power Integration173.2.2 Microcontroller Integration173.2.3 Scaling Up Design193.3 Software Design Efforts203.3.1 Detection Program203.4 Detection Program Implementation223.4.1 The Interface223.4.2 The Software223.4.3 The Algorithm25Chapter 4: Design Testing274.1 Fixture284.2 Cloud Simulation and Human Error294.3 Algorithm Testing29Chapter 5: Design Issues305.1 Security305.2 Nonresidential Solar Arrays31Chapter 6: Summary and Conclusion316.1 Summary316.2 Future Improvements326.2.1 Algorithm Refinement326.2.2 Noise Control326.2.3 Market Potential336.3 Final Costs336.4 Conclusion34Appendix 1: Technical roles and responsibilities35A Tianhang Sun35B Qifan Wang35C Liqing Yao36D Spencer Krug36E Nate Vargo36Appendix 2: References37Appendix 3: Technical Attachments37A Detection Software Program Code37B Electric Imp Device Code37C Electric Imp Agent Code38D Intermediate Matlab Code39E Tutorial of the Software Program40Chapter 1 - Introduction and Background1.1 Problem StatementMichigan State University, in an effort to go green, will be installing a solar panel array on campus. The problem is that Michigan State University is contracting a different company to install a solar panel array and MSU is going to buy power from said company. Now since the power output from the solar panel depends on how much sunlight is shining on it, the output power is going to fluctuate based on cloud movement and time of day. Michigan State will be buying power that the solar panels produce at a reduced cost to power operations on campus. The panels will produce around 10 MW of power, therefore, if there is a sudden change in power output of the solar panels, it will cause a shortage of power needed to supply campus operations. This will force Michigan State to purchase power from the power company at the peak hour rates. The peak hour rates are approximately $11 per kilowatt. This means that a 5MW mismatch would end up costing MSU $55,000. It can clearly be seen how expensive this can become if multiple events occur. This shows the necessity of the project.1.2 Project ObjectiveThe objective of this project is to design a system to detect cloud movement around the specific area of the solar panels, and to deliver an early warning to users when the clouds will pass over the solar panels. With enough of a warning to users at the power plant, power supplying non-essential items can start to be shut down, as well as turning on power supply units. This will ensure that the entire load profile of the campus will be accounted for at all times. Sensors placed at remote locations around campus, will record the amount of sunlight being received, and send the data to a software program which will monitor these values and produce a time simulation of cloud movement around the solar panels. 1.3 Other MethodsThere is another method to account for the quick power drop of solar panels. That method is using technology called a Tesla Powerwall. This device provides backup power when the load sensed is more than what is being generated. This is effective because it will keep spikes from the power companies at a lower height. However, they are simply lithium-ion batteries and are extremely expensive. The current cost for a 10kW backup Powerwall is over $3,000. Now a 1MW backup is desired, this would require 100 of these Powerwalls and would cost over $300,000. This is unreasonable because of the amount of Powerwalls required for a 10MW backup would be 1000 and they may not be able to function properly with that many together since they are designed for household power and energy requirements which are around 3.3kW and 7kWh, respectively. Also, the price would be around $3,000,000 assuming that everything would work as planned. This doesn’t include hook up and planning which would drive up costs more.So why not just use a website like to track the cloud movements? Well in this application, very specific cloud movement tracking is needed around the area of the solar panels. , while shows a simulation of cloud movement, is not specific enough for the small location that the solar panels are at. Also there is not a good way to tell if the clouds will pass over the solar panels. Therefore an early warning system that is location specific, can alert users of changing cloud conditions with much higher accuracy and without the need for constant monitoring.1.4 Project ApproachThe approach that our design will have is to place remote sensors in any pattern around the solar panel array. Any pattern is desired so that the sensors can effectively be placed anywhere as long as they are far enough away to give enough prediction time. These sensors will be connected to a web server online in order to upload light intensity data. The internet connection will be realized through a microcontroller with wireless capabilities. This means each sensor will be connected to the server and will constantly be putting in new solar irradiance data. Once the data is uploaded, a computer program is developed with an algorithm to process it. The program also has pop-up boxes to warn the user of incoming cloud fronts even if the software is running in the background. This approach can be very successful as long as consent can be obtained from the various owners whose homes will have these sensors. The difference that this project makes, is the ability to practically design powerful solar panel arrays that minimize or exclude the negative cost effects that could come with dynamic and sporadic weather. This is always a big limiting factor in implementing an array powerful enough to impact power usage away from the grid.Chapter 2 - Solution Space and Approach2.1 Project DefinitionThe development of the early warning system begins with outlining the function definition and critical design requirements to create a quality product. Before getting into the details of the breakdown of tasks, the project scope has to be clarified.The solar array warning system will require a software program to monitor cloud movement based on data from solar sensors placed remotely around the solar array site. The software program is required to show a real time simulation of the cloud cover around the solar array and prompt a warning when this cloud cover will cause a significant decrease in power output of the solar cells. The data is required to be extracted the sensors via a wireless connection.2.1.1 Project BreakdownNow that a general project scope is defined the project can be broken into implementable tasks. Figure 2.1.1 shows a breakdown of the project scope via a FAST diagram.Figure 2.1.1: FAST diagram of project scopeThis project is broken down into two major design phases, proof of concept and implementation. The focus of this semester's design project is to complete the proof of concept design phase, showing the project is feasible. Creating the proof of concept entails building a software/hardware package to detect cloud movement over the solar panels and alert users of these movements based on cloud coverage data in remote locations. This can be shown through an indoor tabletop experiment where clouds are simulated with an object casting a shadow over a scaled down array of sensors relating to the realized sensor array. This method results in a controlled simulation of which cloud movement can be simulated, allowing the team to build and test the software program. The technical details of completing this phase of the design can be seen in Chapter 3. After the proof of concept design phase is completed, and the software program is fully functional the project will be easily scaled to a full functioning early warning detection system in the implementation phase. 2.2 Critical Customer Requirements An optimal design of the early warning system stems from the voice of the customer and the critical customer requirements (CCRs). The customer of this project will be Michigan State University and the final deliverables will be presented to the Executive Vice President for Administrative Service, as well as the Director of Power and Water. Identification of the CCRs came through meeting with the sponsors, Wolfgang Bauer and Nathan Verhanovitz, where they identified their visions of the project. The highest priority customer requirement was to issue an early warning of cloud movements that will pass over the solar cells with ample time to power down non-essential campus operations. The load profile time constant is around 1 MW per minute, which means Michigan State's power control room needs a 1 minute warning to power down 1 MW of power. Since the maximum power output is 10 MW, and cloud coverage can drop the power output down to 15%, there will have to be a warning 10 minutes prior to the cloud front hitting the solar panels and dropping the load profile. An average cloud front moves at about 40 mph. This leads to a sensor critical radius of approximately seven miles. Since the area to protect is large, a cable connection between the sensors would be unrealistic, leading to the implementation of a wireless sensor network. A basic schematic of the functionality of the design is shown in Figure 2.2.1. This shows a sensor at a remote location sending a wireless signal to the web and then to a computer control station where the early detection software will be running. Figure 2.2.1: Simplified system diagramThe customers also identified specifics about the software program. The program should contain a user interface of the sensor locations as well as display the direction and speed of the clouds. Also the graphics on the program should visually appealing to promote expansion of the product to other customers. Other CCRs are the reduction of error in measurements of cloud movement, since every time the early warning system misses a detection it could potentially cost the university up to $110,000. 2.3 Conceptual DesignsThere are many potential solutions to the problem statement and requirements. Therefore a feasibility matrix was created to narrow the design options and start the project in the best direction. The major design issue for the project consists of creating a wireless ability to connect the sensor to the program, and building an efficient program for early warning detection. There are two potential directions for the wireless connectivity, Wi-Fi or radio frequency (RF). Using Wi-Fi, the sensors will be placed at residential buildings around the area and use the local Wi-Fi connection to transmit data. Using RF communication would allow the sensors to be placed at any position and could be implemented using an Arduino with RF transmit and receive components. There are also two main options when deciding which sensor type to use. A pyranometer is a sensor that detects solar irradiance. Therefore either a commercial pyranometer could be bought for a higher cost, or one could be built from a phototransistor and an attenuation material. The feasibility matrix can be seen in Table 2.3.1. 419960414605Table 2.3.1: Feasibility MatrixThe feasibility matrix is broken into two sections, hardware and software. The hardware section determines which sensor and wireless connection is best while the software section determines which language will best suit the project. From the feasibility matrix the most effective design for hardware would utilize a commercial pyranometer alongside a Wi-Fi connection. C++ is also determined to be the software language for this design. The team has the most experience in using C++ and for the application of the project, C++ can do all that is needed. Commercially there are no products that use a Wi-Fi connection at remote locations to create a wireless sensor network. Using this technique, a wireless sensor network can be easily implemented using the internet which makes it a simple and readily available solution. Also this design will be very robust allowing any amount of sensors to be added. Since the internet is a extremely simple and available at many locations it is a simple solution to a potentially complex network. Building a wireless sensor network in this manner gave the team evidence that this design procedure will work. 2.4 Project ManagementProject management is an essential part of this design project. The tasks that are broken down need to be distributed among the team. The Gantt chart seen in Figures 2.4.1 and 2.4.2 outlines the timeline of deliverables for this project. Figure 2.4.1: Gantt chart of project schedule part 1Figure 2.4.2: Gantt chart of project schedule part 22.5 BudgetThe budget for this project is broken down into two different phases corresponding to the design phases, concept, and implementation. The College of Engineering allocates $500 for the development of this project. This budget will cover the conceptual phase of design but the budget for the implementation phase will be much greater than $500. 2.5.1 Conceptual BudgetThe budget for the conceptual phase will be significantly smaller than the implementation phase. A table of the budget for the concept phase is shown in Table 2.5.1. This only consists of two microcontrollers (each microcontroller has eight ADC inputs). Only two microcontrollers will be needed because the tabletop experiment will consist of 16 light sensors and the sensors will be close enough that they can connect to the two microcontrollers. Simple phototransistor light sensors were used in the conceptual phase of the design, rather than pyranometers, due to the cost difference. Table 2.5.1: Concept phase budgetThe total budget for the project is approximately $160. Since the focus of this project is to complete the proof of concept phase of the design, this is the total budget for the project.2.5.2 Implementation BudgetWhen the project is taken to the implementation phase, a larger budget will be needed. The implementation phase consists of expanding the sensor array as well as using higher quality pyranometers. Also a microcontroller will be needed at each sensor location, as well as a power supply to power the sensor and microcontroller. The budget of this phase also depends on the number of sensors desired by the customer. Table 2.5.2 shows a prototype cost of a fully functioning early warning system with a 30 sensor array. Table 2.5.2: Implementation phase budgetAs seen in Table 2.5.2 the cost for implementation is much greater. The additional costs account for a higher quality product that is much more durable and sensors that are completely isolated from electrical connections. This cost could be reduced by building a cheaper pyranometer but that risks failure in the sensor due to the many seasons of weather patterns in Michigan, resulting in a greater error of detection and reduced sustainability. Also concessions may need to be made to the homeowners who are not willing to have a sensor placed on their roof, but have an essential location. The cost for these products however does not include mass discounts. When building a commercial early warning system with a large number of sensors being implemented, seeking contracts with suppliers for discount rates will be necessary. Chapter 3 - Technical Description This chapter will detail the technical work behind designing and implementing the early warning detection for solar power. As stated in Chapter 2, the early warning detection project shall have a big software component and a smaller hardware component. The main focus of this project was the software program of early warning detection. This is because the software will take longer and be revised much more than the complimenting hardware. The hardware component consists of a sensor, microcontroller, and a way to power both. After the hardware components are chosen, a good integration scheme is required for quick data transfer. The evolution of these processes and reasons for doing so will be explained in greater detail in the rest of the chapter..3.1 Hardware Design EffortsThe hardware design efforts for this project are fairly straightforward. The hardware consists of an ambient light sensor, a pyranometer, an electric imp microcontroller, and a voltage regulator power supply to power both items. The light sensor and pyranometer capture the incoming light available and output voltage values depending on light intensity. The electric imp microcontroller takes the output of the sensors as inputs and converts them to a digital value. It then sends the values, wirelessly, to a web server. The voltage regulator supply provides 3.3V and a max of 1.5A to the sensors and microcontroller. While these chapters describe the hardware efforts of this project, it also depicts the software needed to program the microcontroller. 3.1.1 Pyranometer The initial steps in determining the best project components was to find a solar irradiance sensor that fit the project description the best. A solar irradiance sensor is called a pyranometer and there a variety of models with different specifications for each one. The most essential specs for this project are the sensor must work year round, have the appropriate sensitivity to sunlight, and an efficient cost. Research into these products lead to one pyranometer, the apogee all weather pyranometer. This pyranometer has a 12V DC heater to keep it operating in the winter months and a sensitivity of 0.2 mV per W/m^2. Also this pyranometer outputs an analog voltage signal which will be input into the microcontroller. However this sensor costs $235, so in the build and test phases of the early warning system, a different sensor was used.Figure 3.1.1: Apogee all weather pyranometer (left) showing heating capability (right)3.1.2 Light SensorThe sparkfun ambient light sensor (Figure 3.1.2 left) was chosen as the sensor to simulate the pyranometer that will be physically implemented. This sensor was chosen due to its simplicity and its’ cost. Also since the supplier was sparkfun, a large electronic supplier, it was easy to order these parts. This light sensor is a very simple circuit with only one phototransistor and resistor to keep the transistor operating in the linear region. The schematic for the sensor is shown in Figure 3.1.2 (right). The input to the circuit is the ambient light and the output is an analog voltage signal that is sensitive to the amount of light incident on the phototransistor. Also the output signal of this circuit depends on the voltage input (VCC). The higher VCC is, the higher the voltage signal output, which will be essential in later chapters when the output is connected to an input pin of the microcontroller. Initially the input voltage was set to 5V but this was found to be too high. Figure 3.1.2: Sparkfun ambient light sensor breakout (left) and corresponding circuit (right)3.1.3 Electric Imp 002 MicrocontrollerThe microcontroller used for the project is the electric imp 002. The imp is a complete wireless network node in a module that works in conjunction with the imp service to allow easy connection of any device to the internet. Figure 3.1.3 shows a good visual of the process that takes place for the device to connect to the internet and the imp cloud.Figure 3.1.3: Flow diagram of electric impThe imp 002 was chosen because of the level of reference available online for connection of the device to a Wi-Fi signal as well as the simple configuration process. Also, the electric imp 002 comes with its own web server allowing data to be easily transferred to and taken from the internet. Therefore there will not need to be any allocation of space in Michigan State's servers for this project. The electric imp 002 costs $44.95 which is also relatively cheap for microcontrollers with Wi-Fi capabilities.Figure 3.1.4: Electric Imp 002 and breakout (left) with block diagram (right)The code for this microcontroller is based on the imp Integrated Development Environment (IDE), specific to the electric imp microcontroller. The unique part of this code composer is that it is a web based IDE. This allows easy integration between the web and the microcontroller as well as the ability to remotely program the microcontroller via Wi-Fi. This will be an essential part in the design, the microcontroller and therefore sensor, can be remotely reprogrammed if necessary, with the ability to run diagnostics on the sensor without having to physically travel to the location of the sensor. The programming language for the electric imp microcontroller is squirrel, which is a derivative of the language C. Therefore it was very easy to be picked up because of the team's experience with C. Getting started with programming of the microcontroller involved becoming familiar with the IDE of the electric imp. Fortunately, there are a lot of resources including instructions on the electric imp website. The IDE is formatted in a way where there are two Application Program Interfaces (API’s), the device and agent. These API’s serve the purpose of communication to and from the microcontroller (device) and communication to and from the web (agent). Therefore, all interfacing with the pins is controlled in the device API. The data read from the device API needs to be sent to the agent API where it can be managed and sent to the web. Detailed code will be described in later chapters about how this was achieved.The microcontroller can be easily connected to a Wi-Fi signal by following the electric imp BlinkUp procedure. The BlinkUp procedure simply consists of downloading the BlinkUp app, where the details of the Wi-Fi connection are entered. Once complete, the phone screen will flash black and white (blink) according to the Wi-Fi signal and a phototransistor on the microcontroller will watch this and attempt to test the connection with the signal received. Once the LEDs flash green and turn off with no other colors, set up is complete.The microcontroller has two main functions, those are to read an analog voltage value and send that data to a website where it will be available for the software program. There are eight pins that function as analog to digital converters (ADC) that can be used as input pins for the sensor values (‘SIG’ in Figure 3.1.2). This microcontroller does not require extensive set-up code to enable the ADC pins. The pins on the microcontroller can simply be used after programming one line of code, hardware.pinX.configure(ANALOG_IN), where X is the pin number desired. This contrasts many other microcontrollers, for example the one used in the lab section of this course where there was several lines of code to set-up the analog to digital converter. Using this code allows the analog value to be read from the pin. The detailed code of getting this to work is described in later chapters.3.1.4 Power SupplyThe power supply for this project was the same one used as in the lab section of this course. The input needed for this is 3.3V for the microcontroller and 5V for the light sensor. The circuit schematic for the power supply can be seen in Figure 3.1.5 and consists of a 9V wall wart that contains a full wave rectifier and smoothing capacitor to convert the 120V AC to a 9V DC signal. The 9V is then stepped down by a voltage regulator circuit to a 5V supply and a 3.3V supply. The components for the power supply were available from the lab section and therefore no money from the budget was spent to create this circuit. This power supply will be used to power each microcontroller and all of the light sensors. Therefore the current limitations of this circuit is very important. This issue became apparent when connecting all the components, and is detailed in later chapters. Figure 3.1.5: Power supply schematic3.2 Hardware ImplementationIntegration of the hardware components consists of powering the microcontroller and light sensor and sending the data from the light sensor to the web server where it will be accessed by the early warning software program. 3.2.1 Power IntegrationThe easier part of the integration of hardware was getting power to the light sensor and microcontroller. The power supply depicted in Figure 3.1.5 has three nodes, 9V, 5V, and 3.3V. 3.3V was the recommended voltage input to power the microcontroller which was taken from the imp 002 datasheet. Thus, the microcontroller is powered with the 3.3V node from the power supply. The light sensors were initially set to the 5V node. The light sensor output is simply a scale of the input, so the maximum output voltage was 5V. While an output of 5V would allow for more precision of the intensity of light, the pins of the microcontroller can only accept a maximum input of 3.3V or there is risk of damaging the microcontroller unit. Therefore, the rail voltage was changed to the 3.3V ensuring the pins of the microcontroller will not be damaged at any light intensity.3.2.2 Microcontroller IntegrationThe next step in the hardware integration is to program the microcontroller to output the data from the sensor to the web server provided by electric imp. In section 3.1.3, it is explained how the microcontroller pins are set-up and in section 3.2.1 it is explained that the power rails are the same for both sensor and microcontroller. The microcontroller with have pin headers soldered into the breakout. This allows the physical connection to be achieved with a protoboard. Figure 3.2.1: Hardware integrationAfter the physical connections are made with a protoboard, the wireless connection needs to be achieved via Wi-Fi. In section 3.1.3, the Blinkup procedure is explained for original configuration for Wi-Fi access. It also explains the two APIs that are used to program, the device and agent. Using the device API, the signals coming into the microcontroller can be sampled and processed at specified time intervals. The pins can also output various signals based on the code applied. Using the agent API, the signals and data stored can be uploaded to a designated server. Also, data from other servers can be obtained and brought into the agent. The way in which the hardware design uses the device and agent APIs is by taking input signals on the ADC configured pins and using the agent to upload data onto a server. In order for the information obtained in the device to be available in the agent, it must be sent using a specific command, agent.send. Once in the agent, the data can be sent and modified using the agent functions.Initially, the agent was programmed to output data to an Internet of Things (IoT) website called “Thingspeak”. This site has the ability to take incoming data and store it. This was completed by setting the agent to send data using an API key specific to the IoT website. The data could then be used to form a graph to show how the light values change over time. Similarly, another website called “Keen.io” could be used to do similar processing, but used a web based database in which a query could be implemented to access the data. This website would be convenient for scripting languages such as python or java script. However queries using C++ are rather difficult adding complexity to the program that is not necessary. These websites provide nice graphs and can obtain data easily, however, the C++ program that will be developed requires very intricate coding to obtain specific pieces of dynamic data from a website with so much information. It is noted that the simplest way to obtain data with C++ from a server is when the data and all other information are all in string format. IoT websites are rather complex websites which make it difficult to read the data from the using C++. Therefore other solutions were investigated. Even though the websites previously mentioned will not be used, it provided a good base code for web based data storage. Each microcontroller is provided with a specific website URL in which a single string of data can be written to or read from. Therefore with three lines of code seen in the appendix, data can be sent to the URL in string format. Once the data is sent to the provided server, the only information available at the URL is a single string containing the sensor data. This makes obtaining the data from a webpage with C++ much easier. The Squirrel code is provided in Appendix 3.Another simple way to import a string using C++ is through a .txt file. Therefore a possible solution to this was to use an intermediate matlab program to create a .txt file. This, however, involves the necessity of two programs which makes the design more costly and complex. The intermediate matlab step played its’ purpose which was to allow programming modification and testing while the single program method was determined.3.2.3 Scaling up DesignThe initial hardware design concept uses ten sensors. However, to have a good proof of concept, more sensors are required. This was determined by attempting to create an array that will be able to protect the solar panels with a distance of five to nine miles on a map. There are too many exposed spots when ten sensors were used. To be able to show adequate functionality from any direction, more sensors are required. To keep the team from purchasing another microcontroller, it is decided to get the max amount of light sensors as ADC inputs which is 16. This provides just enough coverage to adequately display proof of concept from many directions. One of these sensors will be placed at the solar panel region to get a real time value of the light intensity at the solar array site. The purpose for this will be explained in section 3.3. See Figure 3.2.2 for the arrangement of sensors on the map. The yellow area is the location of the solar panels. Figure 3.2.3 shows both microcontrollers with the maximum amount of sensors. This is what the hardware looks like under the map.Figure 3.2.2: Arrangement of sensors on mapFigure 3.2.3: Underside of map with 16 sensors3.3 Software Design EffortsThe software design efforts are based on the requirements established in chapter 2. The requirements for this software are to extract data from a server, to process the data to get an accurate time estimation of cloud coverage and associated power drop in solar panel output, and to have a user friendly UI (user interface). As can be seen in the feasibility matrix in Table 2.3.1, the best approach is to use C++ for this software program. 3.3.1 Detection Program The software design is based on Microsoft Foundation Classes (MFC), which is widely used to create Office-Style user interface with multiple controls. Since the design uses MFC, which is a Microsoft application, the software is developed using Microsoft Visual Studio and C++ programming language. The program also will be able to be packaged into an executable file so that the customer can easily access to the software as long as there is a Windows machine. The overall objective of the software consists of reading a data value for each sensor, and outputting the current value of solar power of which each sensor is associated. If the value sampled from the sensor is lower than a threshold, meaning the sensor is covered by a cloud, a warning will be prompted. From the data collected over each sample, the program is able to output an estimate of the time when the cloud will arrive to the solar panel, a direction of the cloud movement, a power drop percentage, a solar array output value, and a plot of a histogram for each sensor's output data. The user interface of the software will consist of a map of the area and a simulation of the cloud cover from the data. Initially, a google map satellite image of the area around the solar array will be loaded, which is the area around the Michigan State solar panel by default. In this user interface there will be two modes, editing mode and warning mode. In the editing mode, the user will be able to add an arbitrary number of sensors and a solar panel in the map. The location of these objects can be moved to their real locations on the map simply by clicking and dragging. In the warning mode, these locations will be fixed and the warning algorithm will be activated. An example of the user interface map with sensors can be seen in Figure 3.3.1. Figure 3.3.1 Map of detection area with populated sensorsThere are two sub-modes in the warning mode, a show map mode and a show plot mode. In the show map mode, the current value associated with each sensor will be shown under the sensor image, and the estimate arrival time will be shown under the solar panel (Figure 3.3.1). In the show plot mode, the map will be shown on the top left-hand side of the window, with the value under the map, and plots of sensor values on the right (Figure 3.3.2). Figure 3.3.2 Graph mode of detection softwareIn addition to the basic warning feature, the software will be able to save the position of the sensors and solar panels so that the user does not need to edit the location each time the software is started. However, all the algorithms and calculations will be performed based on the sensor and solar panel location in the software instead of the real location, so the prediction will be accurate as long as the map loaded is drawn to scale and the sensor and solar panel location in the software is correct. 3.4 Detection Program Implementation 3.4.1 The Interface There are two basic requirements for the interface between the hardware and software. The hardware needs to convert the analog value into a digital value, and output that value, with a specific name, to a server; the software needs to be able to connect to the server in order to read the data. Sending the sensor data to a web server is detailed in previous chapters. The interface of the web server and C++ program is completed using a reference code from the Microsoft Development Network (MSDN). MSDN provides a lot of information on visual C++ as well as MFC functionalities. This code constantly reads the webpage of the stored data into a text file. Therefore it is easy for the C++ program to import as a string type. 3.4.2 The Software The language C++ is an Object-Oriented Programming (OOP) language which has many benefits for this project. OOP is a programming paradigm based on the concept of "objects", which is widely used today as well as in the application of this project. In OOP, computer programs are designed by making things out of objects that interact with one another. While interacting with objects in software, one often uses design pattern which is a general reusable solution to a commonly occurring problem within a given context in software design. The most important reason OOP is used in the application is that it will be flexible. The sensors and solar panels are “objects” in the software, and we can create as many sensors or solar panels as needed, since it will be simply instantiate as a sensor or solar panel “object” in the code. Similar to many other OOP languages, C++ is “class” based. A class in C++ means an object type. This means there will be a sensor class and solar panel class in order to simulate the real situations. An example of the sensor class used in this project is seen in Figure 3.4.1. Figure 3.4.1 Example code of sensor classThere are several methods for a class when one is created. These are the “functionalities” of the object, and member variables which are the “properties” of the object. As seen in Figure 3.4.1, for example, the “enum Name”, which is the name of the sensor, is the member variable, and the void “CSensor::Draw();”, which will draw the sensor onto the screen, is the method. In this case, it will be very easy to extend the functionality of the software by simply adding methods for each class. Software is not as clever as humans, which makes the interaction between objects difficult. The object itself only knows the information of itself. The general solution is to add methods to take the information out. However, it is often the case that the objects are not linked together. For example, the sensor and solar panel in this application are different objects, no ownership relationship and no association. They are not responsible to know each other because there may be multiple sensors and solar panels. The map, which is the container of both sensor and solar panels, on the other hand, can gather the information of both items. This can be implemented with hard coding. By hard coding, Information in the map can be obtained and passed to other object. However, in this case, it will be very difficult to add functionality between different objects because methods will have to be added for each possible functionality. However, this can be bypassed by creating a visitor, which is able to go over one type of object and gather whatever information is needed. This is one kind of design pattern, called visitor pattern. By using a visitor pattern, a visitor can simply go over the sensors and pass the information to the solar panels using another visitor. Whatever information is needed, the functionality can be added in the visitor. The flowchart in Figure 3.4.2 is the class diagram generated by visual studio which shows the basic architecture of the software. The software consists of 11 classes and one additional class for an input dialog box. Figure 3.4.2 Class diagram for detection softwareFrom Figure 3.4.2, “CMainFrame” is the main program that is used for handling different events in MFC application. “CChildview” is responsible for handling the user interface, handling the buttons, and interacting with other objects. “CGoogleMap” serves as the container of all sensors and the solar panel, which loads the map, and the data from the microcontroller specific website, into the software and pasess them to the sensors. “CItem” is the base class for “CSolarPanel” and “CSensor” which contains the information that is common to both sensors and the solar panel in the software. This includes location information and the functionality of moving the item in the map. “CSolarPanel” is the class that simulates the solar panel together with our algorithm to predict all the information desired. “CSensor” is the class that simulates the sensor which includes functionality of processing the data and sending the signal to the solar panel. “CItemVisitor” is the base class of “CPanelVisitor” and “CSensorVisitor”. The three classes are used for collecting all locations, data, and flag information from the “CSensor” to “CSolarPanel” during warning mode. “CDoubleBufferDC” is a class that can eliminate flicker, which is created by Keith Rule. “CXmlNode” adds support for saving and loading the sensor network and solar panel, which is created by Dr. Charles Owen. When the software is in the warning mode, visitors will collect the information from sensors which stores the most information, to the solar panel, and the solar panel will process the collected data in order to predict all the needed information. A brief tutorial of how to use the software is available in the appendix section. 3.4.3 The AlgorithmThe algorithm is one of the most important aspects in this project since it will calculate the predictions and early warnings. It will base its calculations on sensor data that is located in a random array. The sensors location will not be known until the project is fully implemented because the sensors will have to be placed on willing residential participant’s homes. Therefore, the algorithm has to be built to work with any sensor array configuration.Initially, the team came up with an idea of a “two circles” algorithm. Figure 3.4.3 shows the outline of this algorithm, with the black cube being the Michigan State solar panels and the two circles being the sensor array. Once a cloud covers a sensor in the outer circle, a line can be drawn to the maximum edge of the campus area. This outlines the maximum area of incidence. When a sensor within this area of the second circle is triggered, the cloud can be predicted to move over the solar panels. However, even though this algorithm seems practical on paper, it would be very hard to implement with a software code. Also, the sensor array would have to be arranged in concentric circles which may not correspond to residential buildings to connect the sensors to Wi-Fi. Figure 3.4.3 Outline of initial algorithmThe second idea the team brainstormed, for a prediction algorithm, is based on vector math. The outline for this algorithm is shown in Figure 3.4.4. Assuming all the sensors are arranged arbitrarily, sensor A is the first activated sensor, B is the second, and C is the last activated sensor. Displacement vectors can then be created, vectors AB and AC. Using these distance vectors, velocity vectors can be created by dividing vectors AB and AC by the timestamp the sensor was triggered. Averaging AB and AC yields a velocity vector showing the speed and direction the cloud is moving. While in practice this method solves the prediction algorithm, a lot of space is required to implement in software since the amount of vectors created is non-linearly increasing. Also, there are situations of cloud movements that the algorithm will produce two possible directions of movement. To implement this without the two directions, a much more complex algorithm is needed to calculate angle and direction of cloud movement, then the speed of the cloud. This algorithm has been solved but is too complex for implementation in the short time period. Figure 3.4.4 Outline of vector algorithmThe prediction algorithm in the final design is based on the information of first three triggered sensors. The sensor array on the simulation board consists of 16 sensors. When placing sensors, there needs to be at least three sensors from each general direction to the campus. In this case, no matter what direction the cloud is coming from, the algorithm will give an estimate of needed information including wind speed, wind direction, power output drop, and time of arrival. When the first sensor is triggered, the software will store its’ value as well as the current value of all other sensors giving an estimate power drop percentage. Based on the percentage, the approximate maximum sampling value, and the MSU solar array output, the software will also provide an estimate power output of the solar panel array. When two sensors are triggered, the algorithm will calculate the radial distance between the sensors to the solar panel and time difference of the triggered sensors. From these two values, a speed can be calculated and, therefore, an estimated approaching time. Similarly, when a third sensor is triggered, an estimate approaching time will be refined based on third sensors radial difference and time stamp. Also, the software will calculate the three triggered sensors’ relative location to the solar panel and give an estimate of cloud direction. An outline of the algorithm is shown in Figure 3.4.5. Figure 3.4.5 Outline of final algorithmFrom Figure 3.4.5, the radial distance between the first triggered sensor and second triggered sensor is denoted “x1”. This distance divided by the time difference in the two triggered sensors gives an estimate of the speed of the cloud in the radial direction. The estimate is further refined when a third sensor is triggered. The value from the second sensor to the third sensor is denoted “x2”, and speed can be refined by dividing this time by the difference in time of sensor triggers. These two values are then averaged to give a better estimate of the arrival time. Therefore, this algorithm is capable of further refinement by contributing more sensor triggers to the average speed calculation. Chapter 4 - Design TestingDesign testing is an important aspect in every project, to confirm functionality. The way that this design is tested is by the idea of a tabletop experiment. The concept behind this is to scale down all the real world distances and elements to the size of a tabletop. This effectively shows the proof that given some incoming cloud front, the design will be able to accurately predict the time of overcast on the solar panels. This allows the testing phase to be done quickly and more often since waiting for specific weather patterns would be very cumbersome. A breakdown of the performance of the initial design requirements is shown in Table 4.1. A big part of the testing required building fixtures as well. In the following sections, the testing procedure will be explained in greater detail. ObjectivesDetailsPerformanceAccuracyThe warning system should give an accurate prediction.Works well for large infinite cloud.TimeAll predictions or warnings must be 10 min prior to the cloud front hitting the solar panels.Able to predict most time range as long as the cloud is not faster than the maximum case.Wireless connectionThe range of sensor array will be huge. The project needs to make all the sensors Wi-Fi accessible.Always connected correctly, almost no fault.UIThe program should contain a user interface of the sensor locations as well as display the direction and speed of the clouds.Good visualizations with all charts and maps. Very easy for user to operate.BudgetNo more than $500 for the prototype.Only use about ? of the total budget, well controlled.Table 4.1 Final prototype design requirement performance4.1 FixtureThe tabletop experiment requires a fixture to enclose the electronics and to place a scaled up version of MSU campus and its’ outskirts that is analogous with the map in the software. The fixture is created by using poster board which can be punctured relatively easily. Thanks to this material, the wires for the hardware can all be hidden for nice visual display. The top of the fixture can be seen in Figure 3.2.2. The rest of it can be seen in Figure 4.1.1Figure 4.1.1: Fixture for testing purposes4.2 Cloud Simulation and Human ErrorSimulating clouds is difficult in the scaled down map. This is because 10 miles now corresponds to less than two feet. This means that small speeds created by human hands are being calculated to be extremely high speeds. Also, there is a lot of human error when attempting to move an object at a steady slow speed. This will create some error in calculations. The difference in the prediction arrival time and the actual arrival time will be error from the algorithm as well as human error described here. 4.3 Algorithm TestingThe testing of this project was mainly broken down into testing of the detection algorithm created. The functionality and accuracy of the algorithm was tested in several different ways. The first way the design is tested is by looking at the difference in the prediction time the algorithm creates and actual time the cloud covers the sensor at the solar panel location. To display these two differences, a graph was created that would show both the prediction power output vs time and the actual sensor power output vs time. So long as the prediction graph and actual graph only vary by a reasonable amount, the first part of testing can be seen as a success. The tabletop experiment is a small scale version of cloud movement therefore a few second difference in time of the prediction versus actual is a relatively large error since the prediction is under a minute. However, in actual implementation, a few seconds of error is negligible since the prediction is 10 minutes. A cloud is simulated by bringing a piece of cardboard over the sensors. The largest error in difference of prediction time vs actual time was around ten seconds. This error can be explained by either an error in the prediction algorithm or human error while moving the cardboard. Since the worst error experimentally discovered was only a ten second difference it can be contributed significantly to human error. However the prediction algorithm could also be improved by adding more sensors to the array, and to add to the algorithm to factor in a greater number of sensors. This will be completed in the implementation phase of the project. Another aspect the prediction algorithm has to account for is the direction of the cloud movement. To test this part of the algorithm different directions of incoming fronts were simulated. In doing so, it was confirmed the all sides of an incoming cloud front would have a direction assigned with them in relation to north, south, east and west.Figure 4.3.1: Testing of the algorithm Chapter 5 - Design IssuesIt is inevitable that issues will come up with any design. The project discussed in this report is no exception. The following sections will detail the issues that come up in the design process that inhibit the appeal to more of the population or that would have negative effects when competing with other firms in the market.5.1 SecuritySecurity is always a concern when dealing with electronics. Especially more recently with the rise of cyber hackers. This is a serious issue that companies spend large amounts of money on trying to protect their intellectual property. The issue with the discussed design is that the microcontrollers use a Wi-Fi connection readily available in a person’s home. This person’s Wi-Fi may have security, or it may not. If there is no security, someone could potentially interrupt, easily, the connection the microcontroller has to the internet. Even if the homeowner has security, it may not be up to MSU standards to prevent such interference from outside interrupts. If this happens, the microcontroller will miss upcoming events. The user currently in control of the application will be able to see that the sensor is offline, but now a specific trip out to the sensor is required, and possibly replacement. This also is a potential point of attack for a hacker to access the Michigan State power control room. Since the program reads the webpage where the sensor is sending data to, someone could access the webpage and therefore the control room computers. From there Michigan State's power system is at risk. More research and time will be required to understand the extent of possibility from a cyber-attack. 5.2 Nonresidential Solar ArraysThe design discussed in this report covers the campus of MSU, which has plenty of homeowners in the area with Wi-Fi capabilities. This allows for many places to set-up sensors that can communicate to the main station with that has the program. However, large solar panel arrays will typically be found in areas with large amounts of sunlight such as a desert. Now this is great for solar panel output power capabilities, but it lacks the Wi-Fi connections that are required for this design. If an array exists in one of these areas, Various Wi-Fi access points would need to be set-up for the current solution to function properly. Or the hardware aspect of the project would need to be redesigned for communication in these types of areas.Chapter 6 - Summary and ConclusionTo reinstate the objective, this project goal is to design a system to detect cloud movement around the specific area of the solar panels, and to deliver an early warning to users when the clouds will pass over the solar panels. The goal is realized through the design process discussed in this report. After testing, the results and information delivered can be shown through sustainable demonstration. Also, this project very much stayed within the $500 budget given to the design group by MSU College of Engineering.6.1 SummaryThe final prototype of the early warning detection program detects the time of arrival, power output drop and direction of movement of a cloud incident upon the solar panels with minimal error. The detection program bases its calculation on the level of sunlight from a solar sensor array that covers a radius of ten miles from the solar panels. The data is collected by the detection program wirelessly using the internet as a communication device. The complete program gives users an alert of incident cloud patterns giving sufficient time to power down non-essential designs and power up generators. The implementation of this design project will save Michigan State thousands of dollars in power costs.Design Team 7 delivered a proof of concept of an early warning detection system that can be easily implemented using a remote sensor array and a data processing algorithm. Design Team 7 created a design that can be easily scaled when this program becomes a fully operational. 6.2 Future ImprovementsThere are a few ways the design can be improved if given more time and more resources. Four months was the timeline of the project, and that is a very small amount of time when compared to professional engineering projects. This short amount of time requires design teams to make smaller and more concept based designs rather than creating a prototype that has all the functionality of a production based design that is initially desired. Nevertheless, the prototype defined in this report attempts to capture as much of this functionality as possible even though there are a couple areas where it can be improved in the future as described below.6.2.1 Algorithm RefinementThe current algorithm calculates the time of the power drop by the difference in time and distance between three sensors. This can lead to a possible problem since two of the first three sensors have the potential to trigger at the same time since the program polls the website on a per second basis. This can lead to inaccurate results of the simulation and estimate. This issue, however, can be exposed of with some modifications for which there is no time left. An example of a solution would be to use just one of the sensors if two happen to be triggered at the same time. Also, as previously explained, the algorithm currently assumes an infinite length cloud with a smooth, flat, front. If it is desired to have the design function for small cloud fronts as well, again, the algorithm would need to be changed. A quick example for this solution would be to make a “cone” of impact after a sensor is triggered. If the cloud triggers another sensor that resides in the cone, then run the information through the rest of the estimation process. A solution to this issue would allow the program to have minimal false positives. The false positives also come up in the next improvement.6.2.2 Noise ControlNoise control can occasionally be an issue with this design as clouds are not the only thing in the sky! Various objects such as airplanes and birds can potentially cover the sensor for a moment and trigger it. Currently, the design has some control by requiring the first two sensors be triggered while waiting for a third to be triggered. However, if some noise triggers a third that is unrelated to the cloud front while it is approaching, the estimates may not be accurate, or it can produce a false positive. An example solution here would be two require the sensor be triggered for at least five seconds before passing information through to the rest of the algorithm. This code can be implemented in the main C++ program or in the microcontroller code as well if the implementation in the C++ program is complex.6.2.3 Market PotentialThe implementation of an early warning system for solar power can potentially have a market niche. With more renewables supplying power to commercial and residential buildings, fluctuation in the power output can occur with changing environmental conditions. Therefore power companies will have power supply issues when a sudden change in the environment causes power to decrease from the renewable sources. This will cause a power demand increase and increase the cost to generate. Therefore if a early warning detection system is implemented, it can alert power companies of potential power supply issues. 6.3 Final CostsThe tables 6.3.1 and 6.3.2 are the budget for proof of concept prototype and implementation phase, respectively. The total cost for the prototype is $169.10. But for the implementation phase, the budget will vary between $4274.25 and $11398.00 for the use of 15-40 sensors. This is for the reasons previously stated. In the implementation phase, each sensor will need a power supply and microcontroller for communication and data collection. Also, the recommended pyranometer costs more than the light sensors. The more sensors implemented, the more precise the prediction becomes. This budget is sizeable for implementation, however, recall from chapter 1 that one mismatch of power at 5 MW costs around $55,000 and implementing back-up with Tesla Powerwalls for 5 MW is over $1,500,000. This demonstrates the relative inexpensiveness of the design.Table 6.3.1: Estimated and actual budget for proof of concept phaseTable 6.3.2: Implementation phase budget6.4 ConclusionIn conclusion, the project has achieved the goals defined in chapter 1 which means it is able to gather the sunlight data and calculate the clouds movements for infinite straight long clouds. It is now a prototype that shows the concept on a piece of project board. The prototype was achieved by following the critical steps in the engineering design process. Team 7 is happy to confirm that this project adequately showed all members of the team the important aspects and factors of the proper engineering design process.Appendix 1 - Technical Roles and ResponsibilitiesFigure A.1: Picture from left to right: Liqing Yao, Qifan Wang, Spencer Krug, Nate Vargo, Tianhang SunATianhang SunThroughout the semester, Tianhang is mainly responsible for design, implement, and test the whole software, including the graphic user interface, data reading from the website, and the prediction algorithm in the software. Other technical tasks include give suggestion on the hardware output format, and the design of the algorithm. The non-technical role of Tianhang is the manager. Since we have an awesome team, this becomes easy to do and simply sending some messages.BQifan WangThroughout the fall semester, Qifan Wang assisted with many technical aspects of the project, in terms of software part, Qifan Wang aiding in the software program’s design concept & flow chart, finding method reading Data from web server, giving algorithm/UI concepts/ideas. In terms of Hardware, Qifan participated in optimizing the structure of our final demo map table, and built the platform table for the final demo. Also helping others integrate the microcontroller and sensors.Along with these technical contributions Qifan’s non-technical for this project was web page building. This include keeping update, maintaining and optimizing the team website as well as collect materials for team website.CLiqing YaoLiqing Yao had been working for problem solving during design process for the whole semester. As the lab coordinator, the basic job is helping the team to solve any hardware or other problem. Glad to have excellent teammates, the job is easier with others’ help. Thus solving design problem comes much more important. Because the project is much more like a software design, the whole team need to focus more on how to produce the system. For every week’s meeting, Liqing has contributed many thoughts and ideas to help push forward the design process.Also, Liqing has helped build the website. The non-technical role can be described as web page design helper. To build the website, Liqing learned a lot about how to use the tools adobe muse for web page optimization. DSpencer KrugSpencer Krug assisted with various technical aspects of the project throughout the semester including microcontroller programming as well as sensor integration. The main focus of Spencer’s technical role consisted of making the connection of the sensor data to a web server that can be accessed by the software program. This included aiding in programming the microcontroller and creating a sustainable design. Other technical tasks included aiding in the software program’s design concept and flowchart. Along with these technical contribution Spencer’s non-technical role for this project was document preparation. This consisted of managing and outlining critical project documents as well as dividing document tasks. ENate VargoThroughout the fall semester, Nate Vargo had many technical roles in the creation of the early warning system. Nate’s roles consisted of mostly hardware components and a few software components including: choosing the microcontroller for communication, aiding in microcontroller integration with web server, hardware integration with sensors and power supply, and algorithm/UI concepts/ideas.The non-technical role Nate contributed was presentation preparation. This includes outlining and overseeing important presentations for proper flow and necessary information for effective communication.Appendix 2 – References [10] 3 - Technical AttachmentsADetection Software Program CodeThe detection program which contains the data algorithm and user interface will not be shown in the report due to intellectual property protection. If you are interested in the program please contact the team. Imp Device Code// configure pin 9 to be an analog inputhardware.pin1.configure(ANALOG_IN);hardware.pin2.configure(ANALOG_IN);hardware.pin5.configure(ANALOG_IN);hardware.pin7.configure(ANALOG_IN);hardware.pin8.configure(ANALOG_IN);hardware.pin9.configure(ANALOG_IN);hardware.pinA.configure(ANALOG_IN);hardware.pinB.configure(ANALOG_IN);//read and send data to agent ide function sendAnalogInput(){local data = {};//initialize variable data arraydata.light0 <- hardware.pin1.read();//read value from pin 1data.light1 <- hardware.pin5.read();//read value from pin 5data.light2 <- hardware.pin7.read();//read value from pin 7data.light3 <- hardware.pin8.read();//read value from pin 8data.light4 <- hardware.pin9.read(); //read value from pin 9data.light10 <- hardware.pinA.read();//read value from pin Adata.light11 <- hardware.pinB.read();//read value from pin Bdata.light12 <- hardware.pin2.read();//read value from pin 2 data.ts <- date(); //take the time stamp server.log("Analog Input7: " + data.light4); //view value on device logagent.send("sendAnalogInput", data); //send analog value to agent in sendAnalogInputimp.wakeup(0.2, sendAnalogInput) //poll every 0.2 seconds }// Start the loopsendAnalogInput();CElectric Imp Agent Code// Establish HTTP request handler to persist settings changes device.on("sendAnalogInput" function(data) { local secondsF = format("%02d" , data.ts.sec);//format time secondslocal minutesF = format("%02d" , data.ts.min);//format time minuteslocal hoursF = format("%02d" , data.ts.hour-4);//format time hours local dataFiveF = format("%05d" , data.light5);//format pin 5 as decimallocal dataSixF = format("%05d" , data.light6);//format pin 6 as decimallocal dataSevenF = format("%05d" , data.light7);//format pin 7 as decimallocal dataEightF = format("%05d" , data.light8);//format pin 8 as decimallocal dataNineF = format("%05d" , data.light9);//format pin 9 decimallocal dataThirteenF = format("%05d" , data.light13);//format pin A decimallocal dataFourteenF = format("%05d" , data.light14);//format pin B decimal local dataFifteenF = format("%05d" , data.light15); //format pin 2 decimal //convert all decimals to a stringlocal seconds = secondsF.tostring();local minutes = minutesF.tostring();local hours = hoursF.tostring();local dataFive = dataFiveF.tostring();local dataSix = dataSixF.tostring();local dataSeven = dataSevenF.tostring();local dataEight = dataEightF.tostring();local dataNine = dataNineF.tostring();local dataThirteen = dataThirteenF.tostring();local dataFourteen = dataFourteenF.tostring();local dataFifteen = dataFifteenF.tostring(); //concatenate to single stringlocal total_string = format("sensor5: %s sensor6: %s sensor7: %s sensor8: %s sensor9: %s sensor13: %s sensor14: %s sensor15: %s " , dataFive , dataSix , dataSeven , dataEight , dataNine , dataThirteen , dataFourteen , dataFifteen); //send string to agent URLhttp.onrequest(function(request, response) { response.send(200, total_string);}); });DIntermediate Matlab CodeurlA = '';%read web page for micro AurlB = '';%read web page for micro B%allocate array for sensor datasensor0 = zeros(60, 1);sensor1 = zeros(60, 1);sensor2 = zeros(60, 1);sensor3 = zeros(60, 1);sensor4 = zeros(60, 1);sensor5 = zeros(60, 1);sensor6 = zeros(60, 1);sensor7 = zeros(60, 1);sensor8 = zeros(60, 1);sensor9 = zeros(60, 1);file = fopen('output.txt','w'); %open text filefor i = 1:60 strA = webread(urlA); %read data from website strB = webread(urlB); %read dat from website dataA = char(strA)';%format to characters sensor0(i) = str2num(dataA(23:27)); %take segment of characters to string sensor1(i) = str2num(dataA(37:41)); %take segment of characters to string sensor2(i) = str2num(dataA(51:55)); %take segment of characters to string sensor3(i) = str2num(dataA(65:69)); %take segment of characters to string sensor4(i) = str2num(dataA(79:83)); %take segment of characters to string dataB = char(strB)';%format to characters sensor5(i) = str2num(dataB(9:13)); %take segment of characters to string sensor6(i) = str2num(dataB(23:27)); %take segment of characters to string sensor7(i) = str2num(dataB(37:41)); %take segment of characters to string sensor8(i) = str2num(dataB(51:55)); %take segment of characters to string sensor9(i) = str2num(dataB(65:69)); %take segment of characters to string fprintf(file, '%s', dataA); %print string to file fprintf(file, '%s , ', dataB); %print string to file i = i + 1; pause(1); endfclose(file); %endETutorial of the Software ProgramThe overall objective of the software consists of reading a data value for each sensor, output the current value of solar power it is associated with. If the value sampled from the sensor is lower than a threshold, meaning the sensor is covered by a cloud, a warning will be prompted. From the data collected over each sample, the program is able to output an estimate time when the cloud will arrive to the solar panel, an estimate direction of the cloud movement, an estimate power drop percentage, an estimate solar array output value when they’re covered by cloud, and plots of histogram of all sensors’ data.The software requires user to load sensors and solar panels onto the pre-loaded campus map, move and match the location in the software to the real location, in order to perform the algorithm. The following is a brief tutorial of how to use the software.After double clicking on the executable file, or the run button is visual studio, a map of MSU campus and its’ surrounding area will be loaded. there are several menu options that you can choose, including a File, which allow user to save and load the items on the map, a Edit, which allows users to add sensors or solar panels, a View, which allows user to disable toolbar and status bar, a Mode, which allows users to switch between editing or warning mode, and a Show, which allows users to switch between the map and the plot.The first thing you probably want to do is to add sensors, click on edit, then Add Sensor.Then you’ll have a sensor on the map, you can move around the sensor in the map to anywhere you want, however, in order for the sensor network to work, it’s important to match the sensor location on the map to the real location. Also, you need to add one solar panel to the software, which is located in the yellow box in our case. Here is a loaded sensor network which matches our simulation board.Also, there’s a trash can on the right button corner so you can delete the item you don’t want. After finishing this, There’s a “Save As…” option which allow users to save these sensors and solar panels so you can load these location next time using the “Open…” button, both under the File. When programming the microcontroller, each sensor is required to set a specific name, in the format of “Sensor#”, while # is the number so you can select the name of the sensor in the software. The software currently support a maximum 16 sensors, from Sensor0 to Sensor15, which is the maximum number of input pins we have for the two microcontrollers. The next step is to set the sensor name in the software, which also require to match the name of the sensors set by the microcontroller. Double click on the sensor and a dialog box will appear which allows you to set the name for the sensors.The name of the sensor will be shown under the sensor image in short of “S#”, with its current reading from the microcontroller. The reading ranges from 0 to 65,000 while 0 is complete dark and 65,000 is a sunny day outside, the indoor condition ranges from 20,000 to 30,000. We set a trigger threshold at 10,000, and a warning sign will show up when the sensor is triggered.All the preparation steps are done till now, and you can active the algorithm by changing the Mode to Warning, in the warning mode, all functionalities like add sensor, solar panels, delete, move, save, load files will be disabled, otherwise, it’s very easy to crash the algorithm or the software by deleting something or load something else during simulation. The algorithm is based on the first two or three sensors triggered on the map. We’re using the radius distance of sensors, and the time difference to calculate the approximate speed, after two sensors are triggered, the calculation approaching time will be shown on the map, and the updated calculation will be shown together with a message box when the third sensor is triggered. However, there’re limited information shown on the map, if you want more information, you need to click on the Show, then Plot, in this case, all the real-time plot of sensors, cloud approaching time, estimate power drop percentage, estimate power plant output, and estimated direction will be shown on the screen, as well as a plot of current value of solar panel location and estimated value of solar panel location, which is shown here: ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download