Anda di halaman 1dari 31

Lab 5

Summer 2013

Learning the Development Environment The Final Step Lab Objectives:

This project is the final phase in the formal development life cycle of a portable data measurement and collection system. In the previous phases, we developed the full specification and design documentation for the initial portions of the system. The development process included the high-level system architecture, the ability to perform a subset of the necessary control functions, and portions of the display and annunciation components. We also built and worked a simple kernel, a hardware time base, and utilized a nonpreemptive schedule to manage the selection and e ecution of the series of tasks comprising the system. We then moved those tasks to a real-time operating system !"T#$% called &ree"T#$ that utilizes a preemptive, priority based scheduler to do that job. 'ost processors designed for embedded applications utilize just such a computing core. The operating system !#$% provides a number of built-in library functions as well as drivers for a wide variety of peripheral devices such as timers, digital input and output channels, telecommunications links, and analog to digital converters that can then be utilized in the application In an earlier phase of our project, we have worked with one such built-in device and its driver, the timer. We have also designed several others, one for the display, and other for a serial interface, and a third for the keypad, into our system. The goal of this phase of the project is to continue and to e tend our development of the environmental monitoring system. To that end, we(ll work with some of the other built-in capabilities on the $tellaris )*I-+',$-./0 1 2orte -', system and we will learn to design, develop, and debug drivers for such devices under &ree"T#$ The final subsystem must be capable collecting data from several different types of sensors, performing some local processing of the data from those sensors, displaying it locally, and transmitting to a remote station. In addition, low power consumption will be an important aspect of the final product. In the final phase of the design life cycle of such a system, we will, 3. 2ontinue work with a real real time operating system. 0. 4dd features and capabilities to an e isting product. 3. Incorporate several additional simple tasks to our system. 5. Incorporate bidirectional remote communication via a simple web server, handler, and network interface into the system. 6. Introduce and manage a formal communication protocol.

- 3 of ,3 -

/. Introduce and work with a hard real-time constraint. 7. Utilize an FF algorithm to further characterize the collected temperature data. -. Introduce additional peripheral devices and develop drivers for them. !. "onsider several optional tasks. 37. 4mend the formal specifications to reflect the new features. 33. 4mend e isting 8'+ diagrams to reflect the new features. 30. 2ontinue to improve skills with pointers, the passing of pointers to subroutines, and manipulating them in subroutines.
Prerequisites:

&amiliarity with 2 programming, the Te as Instruments $tellaris )*I-+',$-./0 implementation of the 4"' 2orte -', v9' microcomputer, and the I4" $ystems )mbedded Workbench integrated 2 1 4ssembler development environment. 4 wee bit of patience.
Background Information:

:id incredibly well on ;roject 5< tired and an ious to rela . =etting ready to go party in a few weeks>.but don(t want to go outside with the current temps and the rain. Real-time Operating System We are now moving our design to an "T#$ ? a real-time operating system called &ree"T#$. This is an operating system with an attitude>a pirate operating system >r..yeah, it(s got rr(s>and at least one nasty patch>rr>this ain(t freetos, matey>rrr. ;lease check out the &ree"T#$ web site. @ou can find this and related documentation at>. httpA11www.freertos.org1 2heck out the getting started and advanced information here or directly at httpA11www.freertos.org1&ree"T#$-Buick-start-guide.html httpA11www.freertos.org1"T#$Cports.html httpA11www.freertos.org1a777.7.htmlDTI In this project, we(re going to continue to improve on the capabilities in our previous designs>this is the real world and we(ll add more features to our system as well. We have to make money selling people things that we first convince them that they need>yes, we(ll make modifications to Eersion 0.7 of our earlier system>.and raise the price, of course. We have to support the continually flagging economy. "elevant chapters from the te tA 2hapters 6, -, ., 33, 30, and 3/.
Cautions and Warnings:

Fever ask a guide in the 8ffizi in &irenze who is carrying rare porcelain vases directions to the ;onte Eechio. Fever light up if you just purchased and donned paper pants and jacket from a street vendor to meet the Eatican(s dress code.

- 0 of ,3 -

Thoughts on traveling this summer. In the 8.$., always look to the left, make sure all traffic is stopped for , miles in each direction, and erect protective barricades before crossing the street then walk out without even looking to see if there is any traffic coming and register with the nearest lawyer on the other side of the street. In the 8.*., always look right>it(s generally safe e cept for the ta is in +ondon. In &rance, look both ways, because they really are aiming for you>.then look again, take a phasor disrupter, and run really fast, firing in all directions. This will stop les voitures aiming for you as well as the rampaging strikers protesting something>BuaG>je ne sais Bua. In Italy>well>.forget it, you(ll never get across the street ? don(t even try. In Eietnam, hmmm, there(s a challenge. 'oses parting the "ed $ea was an amateur compared to anyone crossing a major boulevard in $aigon with 677 million motorcycle drivers !even more than in Italy% who think a "ed light is an amusing diversion. Why are the night markets open during the day in TaiwanG He certain to check out the wiring in your hotel room where ever you go>and take along some black tape just in case. 4fter the climate change is over, will we still be able to get ice in IcelandG 4lways practice safe software engineering>don(t leave unused bits laying around the lab or as $cott 4dams writes in the :ilbert strip. I:ilbert by $cott 4dams ? 0/ January 073,

Laboratory:

We will use this project to continue working with the formal development life cycle of an embedded system. $pecifically, we will continue to move inside the system to implement the software modules !the how ? the system internal view% that was reflected in the use cases !the what ? the system e ternal view% of the environmental monitoring and analysis system. To this end, we will continue the development of a simple kernel and scheduler that will handle a number of new and legacy tasks and support dynamic task creation and deletion. We will now introduce and design a dynamic task Bueue. )ach task will continue to share data using pointers and data structs. In the initial phase, we modeled many of the subsystems as we focused on the flow of control through the system. In the second phase, we started to implement the detailed drivers for the various subsystems. In the third phase, our main focus was on porting the system to a real-time operating system !"T#$%. We will continue to work with the I4" I:)

- , of ,3 -

development tool to edit and build the software then download and debug the code in the target environment. In this final phase of project we will continue to work with &ree"T#$ and the I4" I:) development environment as we e plore more of its capabilities. We will also continue to work with interrupts as the underlying timing mechanism for a time base as well as to signal events from the e ternal world. We will develop drivers for additional peripheral devices that will interact with the outside world. We will support bidirectional communication over a simple local area network. 4s we continue the development of the system, we will>. 2ontinue working with a real time operating system, 2ontinue working with the local serial channel, 2ontinue working with interrupts, interrupt service routines, and hardware timing functions, Incorporate several new peripheral devices and develop the associated drivers, Incorporate a hard real-time task, 8tilize a fast &ourier transform !&&T% to process some of the collected data, Incorporate remote communication and a simple web server, handler, and network interface into the system. Implement a command and control interface, ) tend the warning and alarm subsystem, ;rovide support for several optional features.

This lab, lab report, and program are to be done as a team ? play nice, share the eBuipment, and no fighting.
Software Project !eve"o#ing Basic $asks

@ou have just been given a once in a lifetime opportunity to participate in the formation an e citing new start up. Hecause of the growing concerns over rising temperatures and the associated glacial melt, you and several colleagues have decided to set your own direction and to start a company to develop a multipurpose environmental monitoring and reporting system. Hased upon initial discussions with your colleagues, you decide to call the company MonitoringStuffRUs-UnLtd, and have put together a set of preliminary reBuirements for a small, portable, low power, product based on I;od and smart phone ideas and technologies. The product, CheckItOut, will have the ability to perform many of the basic environmental measurements that people studying and researching factors potentially affecting climate change need to make. @our team decides that the system must be portable, lightweight, low power, ine pensive, and Internet enabled. &urther, that the prototype unit must have the ability to make such basic

- 5 of ,3 -

measurements as temperature, flow rate, concentration of various pollutants or mi tures, etc., perform simple computations such as trending, and log historical data. The initial deliverables for the system will include the display and alarm portion of the monitoring system as well demonstrated ability to handle temperature, flow rate, and perform carbon and salinity measurements. #ther measurements and capabilities will follow in subseBuent phases. 4ll of the sensors that will provide input to the system and any of the peripheral devices with which the system will be able to interact will not be available at present, so, we will model those signals to test the system architecture, flow of control, infrastructure, and internal data sharing. The first three phases of the environmental monitoring system have been successfully completed. @our company has just beed awarded the development contract for the final stage of the project. $imilar to the earlier phases, the tasks during the current phase include modifications to the design to improve performance as well as to incorporate additional features and capabilities. The development will now enter the final phase. The ;hase IE features are given in the reBuirements and design specifications that follow. "eBuirements for earlier phases remain in the document for tracking purposes. ;hase IE reBuirements supersede specifications for ;hases I to III where ever there may be a conflict. The reBuirements for the final phase of the project development life cycle are specified below. System Requirements Specification
1 ! "eneral Description

4 state of the art environmental monitoring and analysis system is to be designed and developed. The following specification elaborates the reBuirements for the display and alarm portion of the system. The display and alarm management subsystem must accept inputs from a number of sensors that can be used to collect data from various points in a localized geographic area which may be either on land or in the ocean or a river then signal a warning if the data falls outside of pre-specified bounds. :etailed analysis of the data will be performed by other parts of the system to be added at a future time. The outputs of the sensors are measuring a variety of natural phenomenon the values of which comprise a number of different data types such as integers, strings or high precision numbers. The system must be designed to accommodate each of these different types.
#hase $% &o'ifications

&or clarity, the identification of most of the earlier modifications have been removed from this document. If information about these modifications is reBuired, refer the appropriate earlier version of this document.
#hase $% (''itions

3. Incorporate several new peripheral devices and develop the associated drivers, 0. Incorporate a hard real-time task,

- 6 of ,3 -

3. Utilize a fast Fourier transform #FF $ to process some of the collected data, %. Incorporate remote communication and a simple web server, handler, and network interface into the system. 6. 4mend the reBuirements and design specifications to reflect the new features.
) ! Display an' (larm &anagement System

The display and measurement component of the system in the first prototype must track and support the measurement and display of the following signalsA
&easurements

Temperature &low "ate 2oncentration of several different pollutants or other chemical elements The status, alarm, and warning management portion of the system must monitor and annunciate the following signalsA
Status

Hattery state
(larms

Temperature, flow rate or pollutant concentration out of range


#hase $% (''ition

;olar bear pro imity detection ? alarm on still too close


*arning

Temperature, flow rate, or pollutant concentration too high


#hase $% (''ition

;olar bear pro imity detection ? alarm on too close :isplayed messages comprise three major categoriesA annunciation, status, and warning / alarm. $uch information is to be presented on an #+): display and on a series of lights on the front panel. $ensor signals are to be continuously monitored against predetermined limits. If such limits are e ceeded, a visible and aural indication is to be given and shall continue until acknowledged. 4cknowledgement shall terminate the aural indication but the visible indication shall continue until the aberrant value has returned to its proper range. If the signal value remains out of range for a specified time, the aural annunciation shall recommence.
#hase $% (''itions

The system will incorporate bidirectional communication into the networked interface to support communications with and control of the system by a remote computer. Interaction at the remote site shall be accomplished through a web browser on the remote ;2. - / of ,3 -

The system will incorporate a protocol and messaging subsystem to support bidirectional communication with an e ternal computer. he system must accept, interpret, and respond to commands from a remote computer. 2ollect data from the temperature sensor, perform an &&T on that data then send the component freBuency values to the remote data collection system for later processing. :evelop a polar !not 2artesian% bear detection and management system. #ptional - :evelop and support power backup system. #ptional - :evelop and support a polluter management system. #verall system and monitoring conte t safety must be improved.

) 1 +se ,ases

The following use cases e press the e ternal view of the system !see 2hapter 6 in the te t%, !To be added ? by engineering > this would be you%
#hase $%

!To be updated as necessary%

Soft-are Design Specification


1 ! "eneral Description

4 prototype for a state of the art environmental monitoring and analysis system is to be designed and developed. The high-level architecture is to be modular, comprising a set of tasks that are e ecuted, in turn, forever. The second phase of the development cycle will focus on enhancing the system flow of control, developing I1# drivers for several of the sensors, and enhancing the display and alarm management subsystem. The display and alarm management subsystem which must accept inputs from a number of sensors that are used to collect data from various points in a localized geographic area which may be either on land or in the ocean or a river then signal a warning 1 alarm if the data falls outside of pre-specified bounds. :etailed analysis of the data will be performed by other parts of the system to be incorporated later. The outputs of the sensors are measuring a variety of natural phenomenon the values of which comprise a number of different data types such as integers, strings or high precision numbers. The system must be designed to accommodate each of these different types.

- 9 of ,3 -

The prototype will be implemented using the 4"' 2orte -', v9' microcomputer development board. The prototype software will schedule task e ecution, control the #+): on the board, and manage the peripheral +):s through the processor(s output ports.
In addition, each team member must determine the execution time of one of the tasks analytically - you examine the comprising instructions and add up their times. Each team member must do one task. #hase $% (''itions an' &o'ifications

To implement the reBuired additions to the product, the following ;hase , capabilities must be incorporated. a. Remote Communication TaskA Will provide the interface to a web browser based ;2 application. The application must support bidirectional communication between the remote system and the local environmental monitoring system. he task must receive commands from the user and support the display of the measurement and alarm data returned from the measurement system. b. Command Task: The task will receive and interpret commands from the remote communications task then direct the local subsystem!s% to perform the reBuested tasks. It will also format any reBuested data to be sent by the communications task over the network to the remote system. c. Thermal Image Capture TaskA The task will capture the output of an analogue scanner used to acBuire thermal image data from the surrounding environment. The system must then convert the signal to digital form, perform an &&T on the digital data, then send the component freBuency values to the remote data collection system. The freBuency content of signals often contains tell tale spectra that can foreshadow potential problems thermal hot spots suggestive of increasing contaminants. d. Polar ear !anagement Subs"stemA The task will obtain data from a pro imity sensor. When a polar bear is detected, the subsystem will first issue a terrifyingly horrific aural alarm in an attempt to frighten the wayward critter further wayward. $hould this fail, a limited thermonuclear device will be launched to provide somewhat stronger encouragement. e. Portable #enerator Control Subs"stemA #ptional task that will provide a signal to control a portable generator. 4s the battery voltage decreases, a generator will be switched on and then operate at an increasing rotational speed that is proportional to the decreasing battery voltage. f. Polluter !anagement Subs"stemA #ptional task that will provide the system with the capability to manage any e treme polluters. It will first release a blast of phasor fire then a barrage photon torpedoes thereby effectively gaining the attention of any offending polluters. The following elaborates the updated specifications for the display and alarm portion of the system.
) ! Functional Decomposition Tas. Diagrams

The system is to be decomposed into the major functional blocksA Measure, Compute, Displa , Data !ntr , "nnunciation, Status, and Schedule. These blocks decompose into the following task1class diagrams !see 2hapter 6 in the te t%,

- - of ,3 -

!To be supplied by engineering%

) 1 System Soft-are (rchitecture

The environmental monitoring and collection system is to be architected as a set of tasks based upon the functional decomposition given above and are specified in the following task1class diagrams !see 2hapter 6 in the te t%. !To be supplied by engineering and updated as necessary%

The set of tasks will e ecute continuously following power #F. They will all have designer assigned priority and will be pre-emptable. Information within the system will be e changed utilizing a number of shared variables.
) 1 1 Tas.s an' Tas. ,ontrol /loc.s

The design and implementation of the system software will comprise a number of tasks. )ach task will be e pressed as a T2H !Task 2ontrol Hlock% structure. T2H creation will be done under the &ree"T#$ #$ utilizing a task create wrapper function. :etails of the function are given in 4ppendi 4. The following function prototypes given for the tasks are defined for the application
#hase $%

! To be updated to reflect additions and modifications %

- . of ,3 -

) 1 ) $ntertas. Data E0change an' ,ontrol Data

4ll of the system(s shared variables will have global scope< the remainder will have local scope. Hased upon the "eBuirements $pecification, the following variables are defined to hold the status and alarm information and command and control information. The initial state of each of the variables is specified as followsA
&easurements

Type unsigned int temperature"awHufK-L


Display

flow"ate"awHufK-L carbon+evel"awHufK-L salinity+evel"awHufK-L

:eclare as a - measurement temperature buffer :eclare as a - measurement flow rate buffer :eclare as a - measurement carbon level buffer :eclare as a - measurement salinity level buffer

Type unsigned int temp2orrected flow"ate2orrected carbon+evel2orrected salinity+evel2orrected initial value 7 initial value 7 initial value 7 initial value 7

Type !To be supplied by engineering%


(larm

*eypad status and data +ocal 2omms status and data

initial values initial values

Type unsigned char temp#ut#f"ange flrt#ut#f"ange carbon+evel#utof"ange salinity+evel#utof"ange ;olar bear pro imity detection initial value 7 initial value 7 initial value 7 initial value 7 initial value 7

#hase $% (''ition

- 37 of ,3 -

*arning

Type Hool3
Status

tempMigh flrtMigh carbon+evelMigh salinity+evelMigh

initial value &4+$) initial value &4+$) initial value &4+$) initial value &4+$) initial value &4+$)

#hase $% (''ition

;olar bear pro imity detection

Type unsigned short battery$tate initial value 077

3. 4lthough an e plicit boolean datatype was added to the 4F$I standard in 'arch 0777, the compiler wePre using doesnPt recognize it as an intrinsic or native type. !$ee httpA11en.wikipedia.org1wiki12CprogrammingClanguageD2.. if interested% We can emulate the Hoolean datatype as followsA enum _myBool { FALSE = 0, TRUE = 1 }; typedef enum _myBool Bool; ;ut the code snippet in an include file and include it as necessary.

#hase $%

Eariables necessary to support ;hase III and ;hase IE tasks will be added and specified by engineering.
) 1 1 Data Structures

The T2H member, task:ata;tr, will reference a struct containing references to all data utilized by task. )ach data struct will contain pointers to data reBuired1modified by the target task as given in the following representative e ample,

where NdataO would be an integer reBuired by myTask.

- 33 of ,3 -

&easureData Molds pointers to the shared variablesA temperatureHuf flow"ateHuf carbon+evelHuf salinity+evelHuf ,omputeData Molds pointers to the shared variablesA temperatureHuf flow"ateHuf carbon+evelHuf salinity+evelHuf temp2orrected flow"ate2orrected carbon+evel2orrected salinity+evel2orrected DisplayData Molds pointers to the shared variablesA temp2orrected flow"ate2orrected carbon+evel2orrected salinity+evel2orrected battery$tate *arning(larmData Molds pointers to the shared variablesA temperatureHuf flow"ateHuf carbon+evelHuf salinity+evelHuf battery$tate Status Molds pointers to the shared variablesA battery$tate

2eypa',onsoleData Molds pointers to the variablesA *eypad status and data !To be supplied by engineering% - 30 of ,3 -

!To be updated as necessary% Local,omsData Molds pointers to the variablesA +ocal 2omms status and data !To be supplied by engineering% !To be updated as necessary%

The following data structs are defined for the application, !To be supplied by engineering%

#hases $%

:ata structures necessary to support ;hase IE tasks will be added and specified by engineering.
) 1 3 Tas. 4ueue

The tasks comprising the application will be held in a task Bueue and will be pre-emptable. The initial task Bueue will be created under the startup task in the &ree"T#$ #$. Thereafter, it will managed by the "T#$ scheduler. :etails of the #$, the startup task, and T2Hs are given in 4ppendi 4.
#hase $% Modif the task definition

)ight of the T2H elements in the Bueue correspond to tasks, Measure, Compute, #hermalImageCapture, Displa , $e padConsole, LocalComs, %arning-"larm, Status, and Remote Communications and three to the dynamically scheduled Startup, &olar'earMgmt, and Command( The tasks are identified and elaborated in $ection 0.0. The Schedule task is not in the Bueue. The ninth element provides space for future capabilities. The task function pointer in each T2H should be initialized to point to the proper task. &or e ample, T2H element zero should have its function pointer initialized to point to the task7 function. The data pointer of each T2H should be initialized to point to the proper data structure used by that task. &or e ample, if MeasureData is the data structure for the task Measure, then the data pointer of the T2H should point to MeasureData. )ote* %hen a conte+t switch is made ,ecause a running task ,locks or terminates or on return from interrupt, the highest priorit task that is read to run will ,e selected from the -ueue, started or resumed, and mo.ed to the run state( /or the case of an interrupt, the resumed task ma or ma not ,e the interrupted task(

- 3, of ,3 -

) ) Tas. Definitions an' /ehaviour

The dynamic behaviour of each task is given, as appropriate, in the following activity diagrams !see 2hapter 6 in the te t%. !To be supplied ? by engineering%
#hase $%

!To be updated as necessary%

Startup

The startup task shall run one time at startup and is to be the first task to run. It shall not be part of the task Bueue. The task shall, 2onfigure and activate the system time base that is to be the reference for timing all warning and alarm durations. 2onfigure and initialize all hardware subsystems. 2reate and initialize all statically scheduled tasks. )nable all necessary interrupts. $tart the system. ) it.

The static tasks are to be assigned the following prioritiesA !To be supplied by engineering%

Schedule

The schedule task, under the control of the &ree"T#$ scheduler, manages the e ecution order and period of the tasks in the system. Mowever, the task is not in the task Bueue. &ollowing each cycle major cycle through the task Bueue, the scheduler will cause the suspension of all task activity, e cept for the operation of the warning and error annunciation, for five seconds. In between major cycles, there shall be a number of minor cycles to support functionality that must e ecute on a shorter period. The following block diagram illustrates the design. The =lobal 2ounter is incremented every time the +ocal :elay e pires. If the +ocal :elay is 377 ms, for e ample, then 37 counts on the =lobal 2ounter represent 3 sec. 4ll tasks have access to the $ystem Time Hase and, thus, can utilize it as a reference upon which to base their timing.

- 35 of ,3 -

The $oftware :elay must be replaced by a Mardware Timer.

Fote, all timing in the system must be derived from the $ystem Time Hase. The individual tasks cannot implement their own delay functions. &urther, the system cannot block for five seconds. The following state chart gives the flow of control algorithm for the system !To be supplied ? by engineering%
!easure

The 'easure function shall accept a pointer of type voidQ with a return type of void. The pointer in the task argument will be re-cast as a pointer to the Measure task(s data structure type before it can be dereferenced. &or the prototype, the temperature and the carbon and salinity levels must be measured. These data are to be read as analog signals on input 2hannels 7, 3, and 0. The 41: convertor will return the value of the voltage on the corresponding input channel e pressed as a 37 bit binary number. The input voltage range supported by the 41: is 7.7 to ,., E. The system shall store the - most recent samples for each measurement, as 3/ bit binary numbers, into each of the corresponding buffers. The stored values shall be e pressed in millivolts.
temperatureRa-

Temperature is measured by a temperature transducer. The output of the transducer is an analog signal with a range of 7 to R 077 mE :2.

car5onLevelRa-

2arbon level is measured by a carbon level transducer. The output of the transducer is an analog signal with a range of 7 to R 377 mE :2.
salinityLevelRa-

$alinity level is measured by a carbon level transducer. The output of the transducer is an analog signal with a range of 7 to R 377 mE :2.

- 36 of ,3 -

flo-RateRa-

The flow"ate is measured by a flow rate transducer. The output of the transducer is a digital signal that appears as a series of successive negative transitions. $uch transitions can be detected using an e ternal event interrupt. The freBuency of the signal is thence proportional to the flow rate. The freBuency of the signal is determined by first measuring the time interval between successive transitions. The measured values are then stored in a circular - reading buffer as binary values. The values are only to be stored if the current reading differs by more than 36S from the previously stored reading ? note this is above or below the previously stored reading. The flow"ate transducers are currently under development. #ne of the objectives of the present phase is to obtain some field data on a beta version of the transducers. To this end, the upper freBuency limit !shortest interval between transitions% of the incoming signal must be empirically determined. The upper limit will correspond to 077 liters per second and the lower to 0 liters per second.
Compute

&easure' $nterval

The Compute function shall accept a pointer of type voidQ with a return type of void. The pointer in the task argument will be re-cast as a pointer to the Compute task(s data structure type before it can be dereferenced. When available, the Compute task will take the data acBuired by the Measure task and perform any necessary transformations or corrections. The following relationships are defined between the raw data and the converted values. 3. Temperature in 2elsiusA temp2orrected T 6 R 7.-temp"aw 0. 2arbon+evel in ppmA carbon+evel2orrected T 9 R 3.0 carbon+evel"aw ,. $alinity+evel in pptA salinity+evel2orrectedT / R 7.9 salinity+evel"aw 5. &low "ate in lpsA flow"ate2orrected T . R0.7flow"ate"aw
Phase IV Addition Thermal Image Capture Task

The thermal image capture function shall accept a pointer to void with a return of void. In the implementation of the function, this pointer will be re-cast as a pointer to the Thermal Image task(s data structure type. The task will capture the output of an analogue scanner used to collect thermal image data from the surrounding environment. The freBuency content of such signals often contains tell tale spectra that can foreshadow potential problems thermal hot spots suggestive of increasing contaminants.

- 3/ of ,3 -

&or the prototype, measurements will be taken from a single strategically placed thermal transducer and converted to digital form. 4n &&T will then be performed on the digital data and the component freBuency values sent, on command, to the remote data collection system. The sampled data shall be converted to the freBuency domain using an &&T algorithm provided by 'wang Software, Ltd. $ee 4ppendi J. $ignal freBuencies will be used offline to classify the input signal. ;lease see the class web page under get your code here. Mere you(ll find an integer &&T algorithm developed by Hrent ;lump and a floating point version developed by 4nh Fguyen. The signal characteristics and freBuency ranges are specified as followsA Thermal dataA ;eak 4mplitude $ignal ? sinusoid ,6 Mz &reBuency ,.96* Mz ,.7 volts

Eariable starting phase of signal

The 3/ most recent freBuency values shall be tagged !to identify the scan% and retained in a buffer for transmission and presentation on the remote web page.
$e"pad Console Task

The ke padConsole function shall accept a pointer of type voidQ with a return type of void. The pointer in the task argument will be re-cast as a pointer to the ke padConsole task(s data structure type before it can be dereferenced. The keypad shall enable the user to program the environmental monitoring system and shall be scanned for new key presses on a two-second cycle or as needed. *eypad input will override local2omms input. The ke padConsole task will support the following functionality in ;hase II.
a. 2eypa' 6 Local,omms Select 2ey (

*eypad 1 +ocal2omms $elect shall permit the user to choose the keypad or the serial communication !local2omms% channel to configure the system. The ( key on the keypad shall be used to select between the two choices.

b. OLED 6 Local,omms Select 2ey /

#+): 1 +ocal2omms $elect shall permit the user to choose between the #+): display or the serial communication !local2omms% channel to display system configuration or measurement information.
c. Function Select

The , F keys on the keypad shall be used to select the function to be programmed. &or ;hase II, the following functions will be supportedA
Scan ,onfigure 6 Display 2ey ,

- 39 of ,3 -

$can 2onfigure 1 :isplay $elect shall permit the user to choose between configuring a scan or displaying measurement data when the system is scanning. The display device will be specified by the #+): 1 +ocal2omms $elect function. 4 scan comprises a seBuence of measurements that are to be made. &or ;hase II, four measurement types are supported. Temperature 7 2arbon 3 $alinity 0 &low "ate , 4 measurement type can be repeated in a scan.
LocalComms

The localComms task shall accept a pointer of type voidQ with a return type of void. In the implementation of the function, this pointer will be re-cast as a pointer to the localComms task(s data structure type. The localComms task will manage a bidirectional local serial communication channel between the monitoring eBuipment and a local mobile device. The e change shall comprise specified commands from a mobile device as well as returned status, warning, and alarm information. Information returned from the monitoring device will be sent to the mobile device where it can be stored and also displayed using MypertermU or on the $erial ;ort 'onitor. The localComms driver shall enable the user to issue commands program the environmental monitoring system or display measurement data. *eypad input will override localComms input. The localComms task will support the following functionality in ;hase II.
a 2eypa' 6 Local,omms Select 2ey (

*eypad 1 +ocal2omms $elect shall permit the user to choose the keypad or the serial communication !local2omms% channel to configure the system. The two letter command (! shall select keypad input. The two letter command (1 shall select local2omms input.
5 OLED 6 Local,omms Select 2ey /

#+): 1 +ocal2omms $elect shall permit the user to choose between the #+): display or the serial communication !local2omms% channel to display system configuration or measurement information. The two letter command /! shall select #+):. The two letter command /1 shall select local2omms.
c Function Select

The , F keys on the keypad shall be used to select the function to be programmed. &or ;hase II, the following functions will be supported
Scan ,onfigure 6 Display 2ey ,

- 3- of ,3 -

$can 2onfigure 1 :isplay $elect shall permit the user to choose between configuring a scan or displaying measurement data when the system is scanning. The display device will be specified by the #+): 1 +ocal2omms $elect function. The two letter command ,! shall select scan configuration. The two letter command ,1 shall select display measurement data. 4 scan comprises a seBuence of measurements that are to be made. &or ;hase II, four measurement types are supported. Temperature 7 2arbon 3 $alinity 0 &low "ate , 4 measurement type can be repeated in a scan. In the display mode, the corrected measurement data presented on the local console must be e pressed as four strings as followsA Temperature V 41: 2hannel D readingW 2 2arbon +evel V 41: 2hannel D readingW ppm $alinity +evel V 41: 2hannel D readingW ppt &low "ate V &low rate reading W +;$ Hattery $tatus VTime remainingW Mours %L&'displa" The oledDispla function shall accept a pointer of type voidQ with a return type of void. In the implementation of the function this pointer will be re-cast as a pointer to oledDispla task(s data structure type before it can be dereferenced. The oledDispla task provides a driver for the local #+): display. The driver supports two major modesA ,onfigure and Run
,onfigure &o'e

In the ,onfigure &o'e, the oledDispla task presents the current configuration of the instrument by default and provides the display portion of the user interface when the user is programming the instrument.
Run &o'e

In the Run &o'e, the oledDispla task retrieves the measurement results of the Compute task. The task must convert the data into 4$2II, format it so that it may be displayed on the instrument front panel #+): display, and finally present the data. Temperature, flow rate, battery status, and carbon and salinity levels shall be presented as illustrated in the following front panel diagram,

- 3. of ,3 -

Temperature 2arbon +evel $alinity +evel &low "ate Hattery $tatus

V 41: 2hannel D readingW 2 V 41: 2hannel D readingW ppm V 41: 2hannel D readingW ppt V &low rate reading W +;$ VTime remainingW Mours

!To be supplied ? by engineering%


Phase IV odifications and Additions Remote Communications Task

The remote communication function shall accept a pointer to void with a return of void. In the implementation of the function, this pointer will be re-cast as a pointer to the "emote 2ommunication task(s data structure type. The "emote 2ommunications task shall be started following power #F thenA Initialize the network interface 2onnect to and configure a local area network !+4F% $et up a web server and handler to support bidirectional communication with a remote browser 4ccept commands from the user via the browser. &ormat received data such that it can be interpreted and acted upon by the 2ommand task. $ignal that the 2ommand task is to be scheduled. &ormat and send the data to be displayed over the network to the browser.

- 07 of ,3 -

The remote web page shall present the following informationA The name of the product The site where measurements are being taken 2urrent date The scientist(s name

The corrected environmental data presented at the remote site must be e pressed as followsA Temperature V 41: 2hannel D readingW 2 2arbon +evel V 41: 2hannel D readingW ppm $alinity +evel V 41: 2hannel D readingW ppt &low "ate V &low rate reading W +;$ Hattery $tatus VTime remainingW Mours Thermal Image V'agnitude &reBuencyW The measured value must flash whenever a warning occurs. 4nnotation must also accompany each displayed measurement indicating how many times during an eight hour interval that a new warning has occurred. The following diagram gives illustrates the layout of the remote web page. !To be supplied ? by engineering%
Command Task

The 2ommand function shall accept a pointer to void with a return of void. The pointer in the task argument will be re-cast as a pointer to the Command task(s data structure type before it can be dereferenced. The task shall be scheduled whenever a command has been received by the system or when an outgoing message must be formatted in preparation for transmission to the remote computer.
Receive

When a command has been received by the system, the task must verify that the received message is valid. If valid, it is acted upon< if invalid, an error response must be sent to the "emote 2ommunications task. The legal commands and their interpretation are specified in 4ppendi I.
Transmit

When a message is to be transmitted, the 2ommand task must build the message body. The message body is then sent to the "emote 2ommunications task for transmission. 4fter the message has been interpreted and verified as correct or an outgoing message has been built and forwarded to the "emote 2ommunications task, the 2ommand task shall be deleted.
(arning) *larm

The %arning-"larm function shall accept a pointer of type voidQ with a return type of void.

- 03 of ,3 -

The pointer in the task argument will be re-cast as a pointer to the %arning-"larm task(s data structure type before it can be dereferenced. The normal range for the measurements is specified as followsA 3. TemperatureA -36 2 to 67 2 0. &low "ateA 307 liters per second ,. 2arbon+evelA ,-7 ppm 5. $alinity+evelA ,7 ppt 6. HatteryA =reater than 07S charge remaining The normal state shall e ist under the following conditionsA 3. If all measurements and the state of the battery are within their specified range, all +):s on the front panel shall be #&&. 4 warning shall be issued under the following conditionsA 3. If any measurement is out of range, the "): +): on the front panel shall be illuminated and flashing with a one second period. 0. If the flow rate measurement is out of range, +):7 on the front panel shall be illuminated and flashing with a 0 second period. ,. If either the carbon or salinity level is out of range, +):3 on the front panel shall be illuminated 4n alarm shall be issued under the following conditions 3. If either pollutant level measurement is more than 07 percent above the specified limit, +):0 on the front panel shall be illuminated and solid. The aural alarm shall sound with a series of one second tones. 0. If "cknowledge key on the front panel is depressed, the aural alarm shall cease and +):, on the front panel shall flash with a one second period until the levels return to within .7S of normal. The state of the battery display shall flash with a one second period when the state of the battery drops below 07S remaining.

- 00 of ,3 -

Polar

ear !anagement Task

The polar bear management function shall accept a pointer to void with a return of void. The pointer in the task argument will be re-cast as a pointer to the &olar 'ear Management task(s data structure type before it can be dereferenced. The polar bear management task will provide the capability to manage distractions to the scientists while they are out checking or configuring the monitoring eBuipment. In response to the first incident, it shall issue a terrifyingly horrific sound from an aural annunciator. If the need persists, then a limited thermonuclear device shall be released thereby !hopefully% effectively discouraging any encroaching critters. The task shall acBuire distance data from a pro imity sensor. The output of the sensor is an analog signal with a range of 7 to R 5E :2. The relationship between the bear(s distance and the sensor output is given as followsA 377 meters ? 5.7 E :2 67 meters ? 0.7 E :2 3 meter ? V 7.6 E :2
Status

The Status function shall accept a pointer of type voidQ with a return type of void. The pointer in the task argument will be re-cast as a pointer to the Status task(s data structure type before it can be dereferenced. The battery state shall be decremented by 3 each time the Status task is entered.
Portable #enerator Control Task + %ptional ,eature

The portable generator control function shall accept a pointer to void with a return of void. The pointer in the task argument will need to be re-cast as a pointer to the task(s data structure type before it can be dereferenced. 4 variable duty cycle signal shall be produced to control a generator that provides backup power to the system. The duty cycle shall be programmable from 7-.7S. The period of the signal must remain fi ed. 4t a duty cycle of 7S, the generator is running at 6S of full speed< a duty cycle of .7S corresponds to .6S of full speed. The generator shall be switched #F to 37S of full speed when the battery voltage drops below -7S of full value. 4s the battery voltage decreases to 07S of full value, the generator speed shall increase to .7S of full speed. This task is scheduled on demand.
Polluter !anagement Task + %ptional ,eature

- 0, of ,3 -

The ;olluter 'anagement function shall accept a pointer to void with a return of void. The pointer in the task argument will be re-cast as a pointer to the &olluter Management task(s data structure type before it can be dereferenced. The ;olluter 'anagement $ystem will provide the capability to manage e treme polluters. In response to the first incident, it shall release a blast of phasor fire. If the need persists, then a barrage photon torpedoes shall be released thereby effectively gaining the attention of any offending polluters The management system shall operate as follows. If the contaminantDensity or either element increases beyond an acceptable level, the phasor subsystem is enabled and the local research team can use the capabilities of the environmental monitoring system to fire phasors at will or anyone else who is polluting. If the contaminantDensity or either element increases to a dangerous level, the photon subsystem is enabled and the local research team can use the capabilities of the environmental monitoring system to fire photons at will ? or any other polluter that might e ceed safe limits. The &olluter Management subsystem shall fire one phasor burst or one photon torpedo at a time in response to each command. This task is dynamically scheduled.
Phase IV ) 7 Data an' ,ontrol Flo-

The system inputs and outputs and the data and control flow through the system are specified as shown in the following data flow diagram. !To be supplied by engineering%
) 8 #erformance

#he following re-uirement has ,een modified The e ecution time of each task is to be determined analytically ? you must e amine the comprising instructions and add up their times. )ach person in the group is to select one task on which to perform the analysis.

- 05 of ,3 -

) 9 "eneral

#nce each cycle through the task Bueue, one of the =;I# lines must be toggled. 4ll the structures and variables are declared as globals although they must be accessed as locals. )ote* %e declare the .aria,les as glo,als to permit their access at run time( The flow of control for the system will be implemented using a construct of the form
-hile:1; < myStuff= >

The program should walk through the Bueue you defined above and call each of the functions in turn. He sure to implement your Bueue so that when it gets to the last element, it wraps back around to the head of the Bueue. In addition, you will add a timing delay to your loop so that you can associate real time with your annunciation counters. &or e ample, if the loop were to delay 6ms after each task was e ecuted, you would know that it takes 06ms for all tasks to be e ecuted once. We can use this fact to create task counters that implement the proper flashing rate for each of the annunciation indicators. &or e ample, imagine a task that counted to 67 and then started over. If each count lasted 07ms, !due to the previous e ample% then the task would wait 3 second !67 Q 07ms% between events. To accomplish this, we create the functionA NdelayCms!int timeCinCms%O. Thereafter, simply call this function with the delay in milliseconds as its argument. "emember +ab 3.
%&' (ecommended !esign )##roac*

This project involves designing, developing, and integrating a number of software components. #n any such project, the approach one takes can greatly affect the ease at which the project comes together and the Buality of the final product. To this end, we strongly encourage you to follow these guidelinesA 3. :evelop all of your 8'+ diagrams first. This will give you both the static and dynamic structure of the system. 0. Hlock out the functionality of each module. This analysis should be based upon your use cases. This will give you a chance think through how you want each module to work and what you want it to do. ,. :o a preliminary design of the tasks and associated data structures. This will give you a chance to look at the big picture and to think about how you want your design to work before writing any code. This analysis should be based upon your 8'+ class1task diagrams. 5. Write the pseudo code for the system and for each of the constituent modules.

- 06 of ,3 -

6. :evelop the high-level flow of control in your system. This analysis should be based upon your activity and seBuence diagrams. Then code the top-level structure of your system with the bodies of each module stubbed out. This will enable you to verify the flow of control within your system works and that you are able to invoke each of your procedures and have them return the e pected results in the e pected place. /. When you are ready to create the project in the I4" I:). It is strongly recommended that you follow these stepsA a. Huild your project. b. 8nderstand, and correct if necessary, any compiler warnings. c. 2orrect any compile errors and warnings. d. Test your code. e. "epeat steps a-d as necessary. f. Write your report g. :emo your project. h. =o have a beer. Caution( Interchanging step h with any other step can significantly affect the successful completion of your design ) pro*ect.
+&' Lab (e#ort

@ou are welcomed and encouraged to use any of the e ample code on the system either directly or as a guide. &or any such code you use, you must cite the source &you will be given a failing mark on the lab if you do not cite your sources in your listing ' this is not something to be hand written in after the fact, it must be included in your source code& This is an easy step that you should get in the habit of doing. 'o not -orget to use proper coding st"le. including proper comments/ Please see the coding standard on the class 0eb page under documentation/ ;lease include in your lab report an estimate of the number of hours you spent working on each of the followingA :esign 2oding Test 1 :ebug :ocumentation

- 0/ of ,3 -

;lease include the items listed below in your project reportA 3. Mard copy of your pseudo code 0. Mard copy of your source code. ,. )mpirically measured individual task e ecution time. 5. Include a high-level block diagram with your report. 6. He sure to include all of the items identified as Xto be provided by engineering.( /. If you were not able to get your design to work, include a contingency section describing the problem you are having, an e planation of possible causes, a discussion of what you did to try to solve the problem, and why such attempts failed. 9. The final report must be signed by team members attesting to the fact that the work contained therein is their own and each must identify which portion!s% of the project she or he worked on. -. If a stealth submersible sinks, how do they find itG .. :oes a helium filled balloon fall or rise south of the eBuatorG 37. If you fly faster than the speed of sound, do you have to slow down every now and then to let the sound catch upG 33. If you fly really really fast around the world, can you catch up to the sound before it catches up to you and answer a Buestion before you hear itG 30. If you don(t answer a cell phone call, where does it goG Is it just sitting there waiting for youG
!"#E: If any of the abo$e re%uirements is not clear, or you ha$e any concerns or %uestions about you&re re%uired to do, please do not hesitate to ask us.

- 09 of ,3 -

)##endi, ): $*e -etwork Connection

The network connection will comprise a local web server and client handler on the $tellaris board and a remote client on a ;2 connected to the lab(s local area network !+4F%. The I4" development I:) and $tellaris e amples provide a good place to begin. It is recommended that you start with the project enet0io and proceed from there. &rom the comments accompanying the file enet0io(c in that project, The example application demonstrates web-based I/O control using the Stellaris Ethernet controller and the lwIP TCP/IP Stack !"CP is used to obtain an Ethernet address If the :M2; finds an address, that address will be displayed on the #+):. 2onnect the browser on the ;2 to that address. If D1C& times out without o,taining an address, a static I& address will ,e chosen using "utoI&( #he address that is selected will ,e shown on the OL!D displa allowing ou to access the internal we, pages ser.ed , the application .ia our normal we, ,rowser( #wo different methods of controlling ,oard peripherals .ia we, pages are illustrated .ia pages la,eled 2IO Control Demo 32 and 2IO Control Demo 42 in the na.igation menu on the left of the application5s home page( 'odifying the e isting website or creating your own reBuires working with several tools that come with the $tellaris environment. 8nder the enet0io project directory, there is file called io0fsdata(h and a directory, fs. 4ll of the files that make up the website are stored as a file system image in the file io0fsdata(h that is linked into the application image in flash. The subdirectory, fs, contains all of the associated html files from which the image is built. It is recommended that you start with the files in the fs directory enet0io under the project. To build the application image, first, it(s recommended that you save a backup of the e isting io0fsdata(h file. Fe t, make your changes to the files in the fs directory by adding images or modifying one of the other .html files as necessary. 4fter making the appropriate changes, you must rebuild the file system image using commandA makefsfile -i fs -o io0fsdata(h -h 6r

This function is found in the C*7Stellaris%are7tools7,in directory. @ou must call the function from the 'icrosoft 2ommand +ine> #nce you have a new image file, io0fsdata(h, add it to the project directory, replacing the previous one. @ou should now have a new web site

- 0- of ,3 -

)##endi, B: Su##orted Commands and (es#onses

The 2ommands and "esponses for the embedded application task from earth are given as follows. $ The $ command indicates $T4"T mode. The command shall start the embedded tasks by directing the hardware to initiate all the measurement tasks. In doing so, the command shall enable all the interrupts. ; The ; command indicates $T#; mode. This command shall stop the embedded tasks by terminating any running measurement tasks. $uch an action shall disable any data collecting interrupts. : The : command enables or disables the #+): display. 2VpayloadW The 2 command transmits a scan configuration to the monitor. 'VpayloadW The ' command. The ' command reBuests the return of the most recent value!s% of the specified data. The ' response. The ' response returns of the most recent value!s% of the specified data. 4 Vsp commandW The 4 response acknowledges the receipt of the identified command. ) The ) error response is given for incorrect commands or non-e istent commands.

- 0. of ,3 -

)##endi, C: ..$ /e"#er ) (ea" 0 $ime 1mbedded )##"ication 'sing the (ortex ) icrocontroller 'in %ang

$ssues on (6D configuration for FFT application 3. FyBuist theoryA sampling freBuency must be greater than twice the highest freBuency in a signal !in order to recover the original signal without aliasing%. &s W0Q&n $amples from 41: must be eBually spaced in time. &&T generic function
n$ +K nL YKkLT % ) , F is seBuence length.
n= 7 ) 3

YKkL, YKnL are supposed to be comple . YKnL has real and imaginary parts. The samples you get from 41: are the real part of YKnL. The imaginary parts of YKnL are all zero. 0. YKkL has non-zero values of both real and imaginary parts. void fft!comple Q , comple Qw, unsigned int m% 4lso you need to typedefZint Qreal, Qimag[ comple < ,. Mere m is the &&T stage, FT0\m. 8sually we use 30-, 06/ as the length of the seBuence, then m will be 9,- correspondingly. The longer the seBuence, the more accurate the &&T. Hut we are constrained by the available memory space and the speed. 5. Mere w is computed inside the &&T function, we do not care and we are not supposed to pass things into it. 6. $ince the 41: samples the input signal from 7v-6v, you need shift all the samples by 0.6v to make the samples have positive and negative parts before doing &&T. $n #lace ,omputations Input array and output array share the same piece of memory space. FoteA each time you do the &&T, remember to initialize the input imaginary buffer to zero. :etermine freBuency from the inde A fTfs QmCinde 1F

- ,7 of ,3 -

fA freB of the measured signal fsA sample freB mCinde A inde which corresponds to the ma imum magnitude 'ag\0 T real\0 Rimag\0 FA seBuence length or FT0\m FoteA The range of &&T is K7,0L, and also symmetric about . K7,FL is mapped to this range. When you search for the ma imum magnitude, half range searching is desired.

- ,3 of ,3 -

Anda mungkin juga menyukai