206
1 Satellite Communications Buoy Senior Design II Fall 2008

I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

  • Upload
    dangdan

  • View
    219

  • Download
    4

Embed Size (px)

Citation preview

Page 1: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

1

Satellite Communications BuoySenior Design II

Fall 2008

Members: Mentors:John DeBlanc Elias Ellsworth Nick PughPeter Bankole Luis Chinchilla Mark Fenstermaker

Page 2: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

2

Table of Contents

1. Introduction……………………………………………………………….71.1. What is a picosatellite?………………………………………………71.2. What is a buoy?……………………………………………...………71.3. What does it do?……………………………………………………..81.4. Functional Specs……………………………………………………..8

2. Overall Block Diagram……………………………………………..……102.1. PIC…………………………………………………………………..122.2. Power System………………………………………………………..122.3. Batteries……………………………………………………………..122.4. Solar Cells…………………………………………………………...122.5. Sensors………………………………………………………………122.6. GPS…………………………………………………………………..122.7. Flash memory………………………………………………………..132.8. TNC………………………………………………………………….132.9. Radio…………………………………………………………………132.10 Mechanical…………………………………………………………..13

3. Preliminary Design………………………………………………………..143.1. Creating Excel Model………………………………………………..14

3.1.1. DataTX time TX power Power Reg………………….143.1.2. Assumptions…………………………………………………..14

3.2. Sat Access Schemes…………………………………………………..153.2.1. Intelligent Buoy ……………………………………………….153.2.2. Beacon Buoy…………………………………………………..153.2.3. Waiting Buoy…………………………………………………..15

3.3. Conclusions……………………………………………………………173.3.1. Based on model predictions……………………………..……..26

4. Subsystems…………………………………………………………..……..264.1. Communications………………………………………………..……..26

4.1.1. Alternatives / Tradeoffs………………………………..……….264.1.1.1. Antenna Theory…………………………………..………..27 4.1.1.2. Radio……………………………………………..…………30

4.1.2. Feasibility……………………………………………..………..304.1.2.1. Testing ……………………………………………..………31

4.1.2.1.1. Procedure…………………………………..……….324.1.2.1.2. Hardware………………………………….………..32

4.1.2.2. Data……………………………………………….………..334.1.2.3. Conclusion……………………………………….…………33

4.1.3. Design Document…………………………………….…………354.1.3.1. Explanation…………………………………………………364.1.3.2. Schematic…………………………………………………..37

4.2. Power………………………………………………………………….374.2.1. Alternatives / Tradeoffs………………………………………..38

4.2.1.1. Batteries……………………………………………………39

Page 3: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

3

4.2.1.1.1. Capacity, size, weight………………………….....384.2.1.2. Panels + Batteries…………………………………………41

4.2.1.2.1. Theory……………………………………………..414.2.1.3. Conclusion………………………………………………...44

4.2.2. Feasibility…………………………………………………..…444.2.2.1. Testing……………………………………………..……...44

4.2.2.1.1. Battery Charging……………………………...…..444.2.2.1.2. Procedure / Hardware……………………………..464.2.2.1.3. Peak Power Point………………………………….47

4.2.2.2. Data………………………………………………………..484.2.2.3. Conclusions………………………………………………..49

4.2.3. Design Document……………………………………………..504.2.3.1. Explanation………………………………………………..504.2.3.2. Schematic………………………………………………….50

4.3. Sensors………………………………………………………………..51

4.3.1. Alternatives & Tradeoffs………………………………………51

4.3.1.1. Air Temperature…………………………………………..51

4.3.1.2. Water Temperature………………………………………..53

4.3.1.3. Pressure……………………………………………………54

4.3.1.4. Anemometer/Wind Vane ………………………………..54

4.3.1.4.1 Wind Speed Detector… …………………………..54

4.3.1.4.2 Wind Vane…………. … ………………………….62

4.3.1.5. Salinity…………………………………………………….64

4.3.1.6. Humidity…………………………………………………..65

4.3.2. Feasibility………………………………………………………67

4.3.2.1. Cost………………………………………………………..67

4.3.2.2. Timeline…………………………………………………...68

4.3.3. Design Documents……………………………………………..68

4.3.3.1. Explanation………………………………………………...68

4.3.3.2. Schematic…………………………………………………..70

4.4. Command & Data Handling…………………………………………..72

4.4.1. Alternatives & Tradeoffs………………………………………72

4.4.2. Feasibility………………………………………………………74

Page 4: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

4

4.4.2.1. Test Code…………………………………………………..74

4.4.2.2. Results…………………………………………………….74

4.4.2.3. Conclusion…………………………………………………75

4.4.3. Design Documents…………………………………………….75

4.4.3.1. Explanation………………………………………………..75

4.4.3.2. Schematic…………………………………………………76

4.4.3.3. Flowcharts………………………………………….……..77

4.4.3.4. State Machine Design……………………………………..87

4.4.3.5. External Timer…………………………………………….90

4.4.3.6. External Memory………………………………………….91

4.4.3.7. Watchdog Timer…………………………………………..91

4.4.3.8. I2C Bus……………………………………………………92

4.4.3.9. Software Structure………………………….……………..93

4.4.3.10.Key Subsystem Functions……………………………….94

4.4.3.11.Satellite Commands For The Buoy………………………95

4.4.3.12.Data Transmission Format……………………………….97

4.5. Mechanical…………………………………………………………...80

4.5.1. Alternatives & Tradeoffs……………………………………..80

4.5.1.1. Discus Buoy………………………………………………80

4.5.1.2. Spar Buoy………………………………………………...81

4.5.2. Feasibility…………………………………………………….82

4.5.2.1. Flotation ………………………………………………….82

4.5.3. Design Documents…………………………………………….82

4.5.3.1. CAD drawing……………………………………………..82

5. Prototype Construction……………………………………………………82

5.1. Electrical System…………………………………………………….83

5.1.1. PIC……………………………………………………………83

Page 5: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

5

5.1.2. GPS……………………………………………………………83

5.1.3. Radio / TNC Box……………………………………………..83

5.2. Buoy Structure………………………………………………………..83

5.2.1. PVC……………………………………………………………84

5.2.2. Mounting Solar Panels…………………………………………84

5.2.3. Antenna ½ Wave………………………………………………84

6. Future Plans………………………………………………………………..84

6.1. Communications………………………………………………………84

6.1.1. Switch from handheld Radio to 3V custom low power radio….85

6.1.2. Switch from pico packet TNC to TNC-X………………………85

6.2. Power…………………………………………………………………..85

6.2.1. More efficient solar panels……………………………………..85

6.2.2. Research possibility of an entire system running at 3 volts……85

6.3. C&DH…………………………………………………………………85

6.3.1. Upgrade to PIC18F6722……………………………………….85

6.3.2. Create interface for 3rd party devices…………………………..85

6.4. Mechanical…………………………………………………………….86

6.4.1. Improve stability……………………………………………….86

6.4.1.1. Static and dynamics calculations…………………………...86

6.4.1.2. Placement of sensors……………………………………….86

7. Appendix……………………………………………………………………94

7.1. Website Wiki…………………………………………………………...94

7.2. Source Code……………………………………………………………95

7.3. Data Sheets……………………………………………………………..116

7.4. Schematics……………………………………………………………..120

Page 6: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

6

1. Introduction

Scientists, meteorologists, mariners, offshore companies, and countless other groups depend on timely reports of current oceanic conditions. However, there are considerable challenges associated with gathering oceanic data. It is impractical and perhaps dangerous to station humans at remote offshore locations in potentially harsh weather conditions. Furthermore, unacceptable inefficiencies arise with manual data collection. Therefore, scientists and engineers prefer to design autonomous data collection devices with remote communication capabilities.

A remote data collection device possesses an inherent design challenge; namely, how to establish a reliable communication link. If an offshore device attempts to communicate with terrestrial stations, distance and line-of-sight limitations can pose significant obstacles to reliable communication.

To overcome these obstacles, engineers have chosen satellites for telecommunications that would be impractical or impossible with land-based solutions. Typically, for oceanic environmental data collection, scientists and engineers have designed floating or moored buoys which relay their data via satellites back to a ground station.

This design projects aims to create a similar satellite communications buoy with one main difference. This buoy will communicate with a Low Earth Orbiting (LEO) CubeSat; namely, the C.A.P.E. II (Cajun Advanced Picosatellite Experiment) satellite. With a LEO CubeSat, a constant communications link is impossible unlike geostationary satellites. However, as an advantage over geostationary satellites, a LEO CubeSat is much closer to Earth, which dramatically reduces the necessary signal strength for communications. Therefore, this project will combine the desirable features of satellite communications and low power requirements for future buoys and other remote applications.

1.1 What is a CubeSat?

A CubeSat is a miniaturized satellite with 10cm X 10cm X 10cm dimensions and a 1-kilogram weight. Generally, CubeSats are built with commercial off-the-shelf components for research purposes. CubeSats can be built and launched for approximately $60,000 to $80,000. Due to these satellites’ relative low costs, universities and companies find CubeSats to be an attractive means to enter the previously high-cost fields of space science and space exploration.

Page 7: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

7

1.2 What is a weather buoy?

A weather buoy is a floating device that gathers environmental data while positioned in a large body of water, usually the ocean. Weather buoys monitor atmospheric parameters such as temperature, pressure, humidity, rainfall, wind speed, and wind direction. However, they can also monitor oceanic parameters such as salinity, wave height, and wave period. Weather buoys normally link with weather stations via satellite communications with geostationary satellites.

1.3 What is the purpose of the C.A.P.E. II weather buoy?

This design will demonstrate the usefulness of CubeSats in the area of data collection and forwarding. The buoy will gather environmental data and then upload it to the C.A.P.E. II satellite as it passes over the buoy’s location. This design’s success will create a new arena for opportunities and applications within the CubeSat community. Futhermore, future University of Louisiana at Lafayette senior design teams could develop other terrestrial applications with satellite link functionality.

1.4 Functional Specifications

Description:

This project is to design and build an expendable weather buoy with satellite communication abilities. The weather buoy will collect environmental conditions, store them on onboard memory, and relay them to the CAPE II satellite. This buoy system will ether have batteries that will keep the buoy active for 3 years or have a combination of solar panels and batteries to achieve a three year life. The cost of this buoy should be less that $150 including a GPS receiver. This buoy will have a data interface such that other devices may store data and transmit data to the satellite.

Specifications:(1) Compatibility with the Naval Academy buoy. (2) Contain an on board GPS receiver.(3) Report its location.(4) Collect water temperature.(5) Time stamp all data samples.(6) Memory storage > 100 Meg bits.(7) Transmitter 144 MHz and or 435 MHz.(8) Transmitter power sufficient to close a link to CAPE II Cubesat.(9) Satellite access scheme TBD.(10) Life of the buoy three years.(11) Cost of the buoy $150.(12) Data interface TBD probably I2C.

Page 8: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

8

Deliverables:(1) Produce one operational and fully tested buoy.(2) Documents that the buoy has been tested with on an orbit satellites. (3) Likely to be the International Space Station.(4) A survey of likely originations that might want to collect data.(5) Software for the ground station to feed the data collected to the Internet.(6) Software that will organize the data in to a spreadsheet interface.

Page 9: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

9

Figure 1. Functional Specifications Diagram Power Options

Inputs Outputs Solar/Batteries

(1) Environmental Data

(2) Location

(3) Time (4) Sunlight

(5) Satellite Commands

Environment Large Body Of Water

Potentially Harsh Weather

Final Products1 Operational and Fully-Tested BuoyDocumentation On Testing With An Orbiting Satellite (e.g. International Space Station)Ground Station Software To Upload Buoy Data To InternetSoftware To Organize Buoy Data Into A Spreadsheet Format

BuoyCompatible

w/ Naval Academy Buoy

On-board GPS Receiver

Memory > 100 Megabits

Data Interface (I2C)

Cost: $1503 Year Lifespan

(1) 145MHz and/or 435MHz Transmission Frequency

(2) Sufficient Transmission Power To Close Link With CAPE2 (3) Transmit Location, Time, and

Environmental Data

Page 10: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

10

2. Overall Block Diagram

Our solution is to design a system which will utilize a microcontroller to manage the gathering and communication of environmental data. The system will awaken every hour and gather environmental data via a collection of sensors. Then, a GPS unit will provide time, date, and location information to accompany the environmental data. Next, the system will format and store the current batch of data. Following this, the system will broadcast its most recent data to the satellite when the satellite passes over its location. In order to broadcast data, a terminal node controller (TNC) will format the data into AX.25 packets and then modulate the packets into an analog signal. Finally, the radio will transmit the modulated signal.

See the overall block diagram in Figure 2.

Page 11: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

11

Figure 2. Buoy Functional Block Diagram

Sensors

GPS

PIC

External Memory

Solar Cells Batteries

Power System

TNC RadioTX TX

RX RX

Mechanical

PVC Structure

Page 12: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

12

2. Overall Block Diagram

2.1 PIC Block

This block represents the microcontroller. This microcontroller will most likely belong to the Microchip PIC18 family. The microcontroller will control all other buoy subsystems. The microcontroller will retrieve data from the sensor array and the GPS unit. After formatting and storing the data, the microcontroller will send the data to the communication subsystem for transmission. The microcontroller will also accept commands from the satellite which may alter its task schedule or task list.

2.2 Power System Block

The power system directs power from the batteries (and possibly solar cells) to the rest of the system. If solar cells are used, the power system will handle the recharging of the batteries. The power system will step down voltage to the appropriate level for each component. Also, the power system will protect against destructive currents.

2.3 Batteries Block

The batteries will store power for the system.

2.4 Solar Cells Block

Solar cells will absorb solar energy and convert it into electrical energy. Then, the power system will store that electrical energy in the batteries.

2.5 Sensors Block

Sensors will measure analog environmental values and convert these values into electrical signals which the microcontroller will read.

2.6 GPS Block

The GPS (Global Positioning System) receiver compares signals from several GPS satellites to determine its location, time, speed, and direction. The GPS receiver will forward this information to the microcontroller. Using this information, the microcontroller will associate data with specific time and location details.

Page 13: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

13

2.7 External Memory Block

External memory will provide long-term storage for environmental data.

2.8 TNC Block

As part of the communication subsystem, the TNC formats digital data and then converts the data into an analog signal. Likewise, when receiving a signal from the radio, the TNC will demodulate the signal and transmit the digital data to the microcontroller.

2.9 Radio Block

The radio and its antenna are key components of the communication subsystem. The radio will transmit a modulated signal from the TNC over its antenna. Also, the radio will receive signals from its antenna and direct them to the TNC.

2.10 Mechanical Block

This block represents the physical aspects of the buoy, such as its shape, size, and weight. We will address the buoy mechanical issues later in the design process.

Page 14: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

14

3. Preliminary Design

After the block diagram was created, the design process continued with a quantitative buoy system model which included a data budget, a power budget, and a link budget. Using Microsoft Excel, this system model was drafted as a spreadsheet with preset functions that expressed the mathematical relations between design parameters. As potential design choices were typed in, the spreadsheet buoy model would instantly calculate the system-wide consequences of those choices. Therefore, the spreadsheet model was a powerful development tool which informed the team on the interrelationships of system characteristics.

3.1 Creating The Buoy System Model

The buoy is essentially a data collection and transmission system. The buoy system model began as a link budget to ensure that the buoy could indeed successfully transmit its data to the satellite. Once the necessary transmission power was calculated from the link budget, the buoy system model’s development continued with the creation of a data budget.

The data budget started with an assumption about the quantity of data gathered during each collection period. Then, assuming one data collection every hour, a total data amount per day was calculated.

Next, the buoy system model was expanded to include the underlying calculations and system requirements of a satellite access scheme. A satellite access scheme is a means by which the buoy will establish a reliable communications link with the satellite. The satellite access scheme will be discussed in further detail in a later section.

With a data budget, a link budget, and a communications schedule, the buoy system model was ready to add a power budget. The power budget first calculated the total system power needed from the two major draws of power, the communications system and the command and data handling system. Next, given our power system design, the power budget calculated the power generated from the buoy’s solar panel array. Finally, the power budget demonstrated that the buoy harnessed more solar power than it consumed each day.

Before summarizing the buoy system model conclusions, this report will outline the design and choice of the satellite access scheme.

Page 15: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

15

3.2 Satellite Access Scheme Design

The satellite access scheme describes the algorithm for establishing contact between the buoy and the satellite. The satellite access scheme poses a crucial engineering challenge. With a drifting buoy and an orbiting satellite, when will a line-of-sight transmission opportunity become available? There are three major approaches to a satellite access solution:

(1) Intelligent Buoy: The buoy uses sophisticated software to predict satellite passes based on orbital data.

Advantages: The buoy will only transmit during actual satellite passes and thus will save power because it can power down until the predicted satellite pass.

Disadvantages: The buoy will require a more powerful microcontroller and a more complex operating system. These two features could drastically increase system power requirements. Also, the implementation of a complex operating system could introduce further engineering challenges and consequently delay project completion.

(2) Beacon Buoy: The buoy transmits on a set schedule such that, inevitably, it will establish a link with the satellite.

Advantages: A software implementation of this algorithm is relatively straightforward and therefore reliable.

Disadvantages: The buoy will consume more power as it broadcasts to “deaf ears” when the satellite is not in the line-of-sight.

(3) Waiting Buoy: The buoy remains in a receive mode as it waits for the satellite to make first contact. The satellite can then choose when it wishes to extract data from the buoy. The buoy functions as a passive data repository that the satellite can access at will.

Advantages: The software implementation of this algorithm is even simpler than the two previous algorithms. The buoy adopts a more passive, slave role with respect to the satellite. Perhaps more software development time could be spent adding programmable features to the buoy such that the satellite may program the buoy’s behavior. This would further designate the buoy as a slave device of the satellite.

Disadvantages: The buoy must provide power to its radio all the time. There is an appreciable current draw from a radio in receive mode. This constant current

Page 16: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

16

draw will grow the power requirements so large that batteries alone will not be sufficient for the buoy.

See Figure 3 for a table summarizing the Satellite Access Scheme comparison.

Figure 3. Satellite Access Scheme Comparison

Scheme Description Advantages DisadvantagesIntelligent Buoy Use software to

predict satellite passes.

1. Buoy only transmits when satellite is present.2. Uses less power for transmission.3. A more elegant design. The buoy is aware of the satellite’s current behavior.

1. Requires an operating system.2. Requires a more advanced processor which will demand more power.3. Power savings from transmission will be spent on computing power.

Waiting Buoy In constant receive mode while waiting for satellite to initiate communication.

1. Simple implementation.2. Buoy is always ready for communication.3. May allow for other parties to communicate with buoy.

1. Requires constant draw of current.2. The batteries will drain quickly. Many batteries will be needed.3. Our solar panels cannot timely replenish the power consumed.

Beacon Buoy Transmit an aloha according to a schedule. Listen for acknowledgement.

1. Straightforward implementation.2. Less power consumed.3. Commonly accepted scheme for buoys.

1. The buoy will beacon even when the satellite is not present.2. The beacon will consume power, but only for brief periods every 4 minutes.

Page 17: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

17

Although each scheme is capable of establishing a reliable and periodic link with the satellite, the schemes differ significantly in terms of their power consumption. Moreover, this project can be classified as an embedded system which must operate in the field. Typically, low-power consumption is essential for embedded system designs. Therefore, the decision process focused on power consumption as the criterion to select a satellite access scheme.

Therefore, this project will implement the Beacon Buoy scheme because it boasts the lowest power requirements. This conclusion is the result of inputting the quantitative equivalent of each scheme into the buoy system model. Ultimately, the buoy system model predicted that the Beacon Buoy scheme would require the least amount of power.

The Beacon Buoy satellite access scheme algorithm relies on an “aloha” method of establishing a satellite link. An “aloha” is a brief transmission which, if received, informs the satellite that it is in the line-of-sight of the buoy. If the satellite acknowledges the aloha, the buoy will begin transmitting its data.

The Beacon Buoy satellite access scheme algorithm is as follows:

(1) Every 4 minutes, broadcast aloha. (Assumption: aloha size = 100 bytes)(2) Listen for 30 seconds.(3) If aloha is acknowledged,(4) Then send current day’s data.(5) Else, stop, loop to #1.

3.3 Buoy System Model

This section will present, in its entirety, the buoy system model, which has served as the main instrument for assisting design decisions. The buoy system model features the theory, the assumptions, the data, and the decisions surrounding this project. This system model has been created from the contributions of each team member’s research and engineering judgment.

See Figure 4 for the Buoy System Model in spreadsheet form.

Page 18: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

18

Figure 4. Buoy System Quantitative Model

Page 19: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

19

Figure 4, Continued.

Page 20: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

20

Figure 4, Continued.

Page 21: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

21

Figure 4, Continued.

Page 22: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

22

Figure 4, Continued.

Page 23: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

23

Figure 4, Continued.

Page 24: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

24

Figure 4, Continued.

Figure 4, Continued.

Page 25: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

25

Figure 4, Continued.

Page 26: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

26

Figure 4, Continued.

Page 27: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

27

Figure 4, Continued.

Page 28: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

28

Figure 4, Continued.

Page 29: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

29

Page 30: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

30

3.4 Buoy System Model Conclusions

In summary, the buoy system model proves two main conclusions.

(1) The buoy’s link budget demonstrates that 6 watts of transmission power will produce the necessary signal strength to link with the satellite.

(2) Even with extremely conservative estimates of only 3.3 hours of sun per day, the buoy’s solar panels generate roughly 5.15 watt-hours of power per day. Yet, the buoy only consumes about 4.76 watt-hours of power per day. Therefore, the buoy has plenty of power to recharge its battery each day.

4. Subsystems

4.1 Communication Subsystem

4.1.1 Alternatives & Tradeoffs

To make a judgment on what antenna will be the most advantageous for our project it would be of importance to learn about antennas in general. The best place to start to comprehend antenna theory is with radio waves. Radio waves are waves of energy that resemble closely to light waves and in fact they travel through air at the speed of light. A radio wave is usually visualized to be a sine wave and the period of this wave or cycle is known as its wavelength. (See figure below)

Figure 5 Radio Wave

Page 31: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

31

To better follow antenna theory one be would be prudent to understand how an antenna radiates electromagnetic waves or radio waves. This radiation occurs due to the time varying properties of the current, or an acceleration or deceleration of charge. Radiation however will still take place in a bent wire with a uniform velocity of its charges. The intensity of the magnetic field can be calculated by

H (2I) R . The radiation that is produced can be shown using Figure 2.This magnetic field is the signal and when it strikes another antenna such as the satellite it induces a current on the antenna surface and the current produced is then converted into data.

Figure 6 Antenna Radiation

The ability of an antenna to increase the field strength is measure in decibels (dB) and is called the gain of an antenna. According to wikipedia “Antenna gain is the ratio of the power density of an antenna’s radiation pattern in the direction of strongest radiation to that of a reference antenna.” The reference antenna is usually either an isotropic antenna (dBi) or a dipole antenna (dBd).

Standing Wave Ratio is a complex subject needing you to comprehend a few other properties involved in antennas. On such factor is impedance when we think of impedance we think of something that impedes or acts as a force. Impedance in antennas refers to the ratio of voltage to current at any place on the antenna. This ratio is different throughout the antenna, which means that its impedance also differs along the antenna.

This talk of impedance has to refer to our 50-ohm coaxial cable used to connect our radio to its antenna. To achieve maximum power transfer so well taught to us by Dr. Kumar we need match our impedances, which is known as tuning your antenna. So what happens with mismatched

Page 32: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

32

impedances? Well the coax connection on the antenna causes some of our wave to be reflected back depending on how out of tune your antenna is. This combination of our original wave toward the antenna and the reflected wave is known as Standing Wave Ratio. This ratio is generally tried to keep low, preferably less then 2:1.

The last fundamental theory part to tackle is the theory of polarization. As mentioned above a radio wave is composed of two fields an electric field and a magnetic field. These fields are perpendicular to each other and their sum is called the electro-magnetic field (figure 3). The fields transfer energy back and forth to each other to what is called oscillations.

Our primary field of interest is the electric field. The position and direction in relation to the ground determines its wave polarization. So if the antenna is vertical then the polarization is vertical and the same goes for horizontal. This can affect radiation pattern and will be part of what we are testing.

Figure 7 Electromagnetic Wave

Quarter Wave

The type of antenna that was used on our test was a ¼ wave antenna, which has an omni directional pattern meaning it radiates equally well in all directions. This works well with the design of the buoy, as our bearing to the satellite is unknown and randomly changing. It does however have the least amount of gain (3dBi), which makes it poor for antenna reciprocity, which is a feature that allows an antenna to both transmit and receive signals. It also needs a ground plane, which can be either constructed or can be substituted by the ocean.

Page 33: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

33

Figure 8 1/4 & 1/2 Wave Antenna Radiation

The quarter wave antenna does however need a good ground plane to work properly. A ground plane is a flat surface usually made of metal that limits the downward radiation of the antenna and extends a minimum of one wavelength in each direction from the antenna.

If a quarter wave antenna is used without a ground plane or one that is not functioning properly then two things can happen. One is that the radiated power will tend to go out in every direction up / down as well as towards the horizon. The other problem is the antenna can become mismatched and a high Standing Wave Ratio will be seen. Which causes the power that the transmitter generates to “bounce” back into the transmitter and be lost as heat. This in turns reduces the signal that our satellite will see causing more problems.

Half Wave

A half wave antenna however does not need a ground plane, which makes it more conducive to our environment and contains all of the other positives and negatives that was mentioned above for the ¼ wave antenna. The only other difference is in length, which is a consideration that was addressed in the mechanical design of our buoy.

Five-Eighth’s Wave

Another antenna that was included in our design discussions was the 5/8-wave antenna, which has a greater gain then the ½ wave and ¼ wave antennas at 4.2 dBi. Like the 1/4 wave antenna a ground plane is needed.

Figure 9 5/8 Wave Antenna Radiation

Page 34: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

34

Conclusion:

These were the only antennas that were feasible as they are all omni directional antennas. Due to the constant moving of the buoy a directional antenna would not be feasible for our project such as a Yagi antenna. With this knowledge of antennas the team decided on a ¼ wave antenna to be used on the buoy to help with the mechanical structure stability.

Crystal Radio:

There were two types of radios discussed for use of transmitting, one using crystals as an electrical oscillator to transmit at certain frequencies. These are very low power radios, which made them very attractive for power budget considerations. However crystal radio are susceptible to aging and environmental factors like temperature and vibration. This will cause them to drift from there nominal frequency. They do however have low phase noise, which gives them extremely stable signals.

Synthesized Radio:

These radios are the most popular radios seen today. They can be used over a wide variety of frequencies unlike crystal radios but need a constant power source. Our transmission will be sent using the frequency of 145.825 MHz at 6 watts so this has limited the number of handheld radios that we could use. Looking at most companies data sheets we were able to select one that would both transmit and receive at a reasonable power budget. Most synthesized radios today are transceivers so the need for a crystal radio for receive was deemed unnecessary according to our power budget.

4.1.2 Feasibility

To validate our communications from our buoy to the CAPE II satellite one must see if it is possible to do so and at what power. This can be easily done by the use of a link budget. As per previous Cube Sat buoy projects we chose an uplink frequency of 145 MHz, which will be transmitted at a distance of roughly 2000 miles with a bandwidth of 30 KHz. In communication systems, channel noise is tied to bandwidth as all objects that have heat emit RF energy in the form of random noise. This can be calculated by:

N = kTB = 3 watts where:N = noise power (watts)k = Boltzman’s constant (1.38 x 1023 J/K)

T = system temperature, usually 290KB = channel bandwidth (Hz)

Page 35: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

35

Another key consideration is the issue of the range between our buoy and the satellite. This distance can cause a loss in signal strength of the electromagnetic wave that results from a line of sight path through free space, with no obstacles nearby to cause reflection or diffraction. This is called free space loss and can be calculated by:

FSL = 96.6 + 20log(F) + 20log(D) = 145.848 db where:F = uplink frequency (Hz)D = distance (miles)

So what is our received signal level (RSL)? Well first we have to know our transmission power, transmission gain, receiver gain, and the FSL to calculate. Our PTX = 37 dbm , GainTX = 0, GainRX = 0, FSL = 145.848 db.

RSL = Power + TX Gain + RX Gain – FSL = -108.848 dbm

So is this above our minimum detectable signal (MDS)? Is our link budget feasible? To do this we next calculate our MDS, by this equation:

MDS = 10*log[(k*B*T)/.001] + N = -126k = Boltzman’s constant (1.38 x 1023 J/K)

T = system temperature, usually 290KB = channel bandwidth (Hz)N = noise figure (db)

This shows that our RSL is greater then our MDS that makes our link budget feasible in terms of transmission strength.

However the most important aspect of link budget is the signal to noise ratio (Eb/No), which was given to us to be 8. Now with RSL, MDS, and Eb/No we still have to design an allowance that provides sufficient sensitivity to accommodate fading. Fading is the distortion of a signal over a certain propagation media. To calculate our fade margin all we need to do is another simple calculation:

Fade Margin = RSL – MDS - Eb/No = 9

Our last calculation will to calculate our transmission power (PTX) that will be needed. We were given a spec of 30% transmitter efficiency (Teff), so to calculate PTX all we need to do is:

PTX = 10^(P/10) * .001/Teff = 17 watts

Link Test

1.1 Description of Test

Page 36: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

36

The link budget test is a measure of the power needed on our buoys to perform reliable communications with the CAPE II satellite. It will also measure the effects of antenna angle from the ground plane on our transmission success.

1.2 Unit of Measure

The transmission success rate will be measured by our repeated signals viewed on HyperTerminal.

2.1 Equipment

The transmission to the satellite will be performed by a TinyTrak3 and sent out by a radio. Our Byonics GPS1 will send out the GPS location. All enclosed in a waterproof pelican case. We will be using a PVC pipe with an 18” copper wire as our ¼ wave antenna.

Test Setup

A. Verify battery is charged to 12.4 Volts DC or greater.

1. If battery voltage is < Volts DC refer to the battery charging procedure.

B. Place antenna and box (with radio, battery, and tiny tracker) on the roof of Madison hall

C. Connect the following leads inside the box.

1. Connect the male DB-9 to the Radio / Power end of the tiny tracker.2. Connect the female DB-9 to the GPS / Computer end of the tiny

tracker.3. Connect the BNC on the antenna to the box and situate antenna as

described for the days test.4. Connect the black lead to the negative terminal of the battery.5. Connect the red lead to the positive terminal of the battery.

D. Verify the power light on the tiny tracker illuminates.

E. Verify the radio’s frequency is selected to 145.825 MHz

F. Wait a few minutes to allow the GPS to “lock on” and then the transmit light should illuminate once every 30 seconds.

G. Verify inside CAPE lab that the radio is transmitting at prescribed frequency by the use of the ground station.

Page 37: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

37

1. To turn on the ground station first turn on the Elevation-Azimuth dual controller G-5500, mystery box, and the Astron RS-35M.

2. Verify the Kenwood TS-2000 is on the 145.825 MHz frequency.3. Every 30 seconds you should here a transmission over the radio.

Conclusion

With our calculations and testing we feel confident that we will be able to transmit our data using the equipment we have selected. We hope to continue testing to build a more efficient buoy that will not jeopardize our transmission success. Shown below in figure 10 is the data collected during our testing.

Figure 10

Day # of Transmission # of Successful

Transmission

% of Successful

Transmissions

Antenna Polarization

2/21/08 27 15 55.56% 90 Vertical2/22/08 48 30 62.50% 90 Vertical

DAY 2/21/08 OVERCAST

Transmission Time (AM)

Corresponding Successful

Transmission Time

Antenna Polarization

Azimuth Elevation Range Height

4:52:35 4:52:36 90 Vertical 62.1 8,5 2493 8014:54:04 4:54:05 90 Vertical 52.4 3.9 2913 8026:24:14 n/a 90 Vertical 217.8 0.6 3262 7966:24:44 6:24:44 90 Vertical 218.6 2.2 3073 7966:25:13 n/a 90 Vertical 219.6 4 2886 7966:25:43 6:25:44 90 Vertical 220.8 6 2699 7966:26:12 n/a 90 Vertical 222.1 8.1 2515 7966:26:42 6:26:43 90 Vertical 223.7 10.4 2332 7976:27:12 6:27:13 90 Vertical 225.5 13 2153 7976:27:42 6:27:42 90 Vertical 227.7 15.9 1978 7976:28:11 n/a 90 Vertical 230.4 19.1 1808 7976:28:41 6:28:42 90 Vertical 233.8 22.7 1645 7976:29:10 n/a 90 Vertical 238.2 26.8 1492 7986:29:40 6:29:41 90 Vertical 243.9 31.4 1353 7986:30:09 6:30:10 90 Vertical 251.5 36.3 1231 7986:30:39 6:30:39 90 Vertical 261.9 41.3 1134 7996:31:09 6:31:09 90 Vertical 275.6 45.5 1066 7996:31:38 6:31:39 90 Vertical 292.5 47.6 1036 7996:32:08 n/a 90 Vertical 310.2 47 1045 800

Page 38: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

38

6:32:38 n/a 90 Vertical 325.9 43.8 1093 8006:33:07 6:33:08 90 Vertical 338.1 39.2 1174 8006:33:37 6:33:37 90 Vertical 347.1 34.2 1283 801

DAY 2/22/08 OVERCAST

Transmission Time

Corresponding Successful

Transmission Time

Antenna Polarization

Azimuth Elevation Range Height

4:14:27 4:14:27 90 Vertical 143.9 4 2890 7964:14:57 n/a 90 Vertical 140.4 5.2 2772 7964:15:27 4:15:27 90 Vertical 136.5 6.4 2664 7964:15:56 4:15:57 90 Vertical 132.4 7.5 2567 7974:16:26 4:16:26 90 Vertical 127.9 8.5 2482 7974:16:56 n/a 90 Vertical 123.1 9.4 2411 7974:17:25 4:17:26 90 Vertical 118 10.2 2355 7974:17:55 4:17:55 90 Vertical 112.7 10.7 2315 7974:18:25 n/a 90 Vertical 107.2 11 2292 7984:18:55 n/a 90 Vertical 101.7 11.1 2288 7984:19:24 4:19:24 90 Vertical 96.1 10.9 2300 7984:19:54 n/a 90 Vertical 90.7 10.5 2331 7984:20:23 4:20:24 90 Vertical 85.5 9.9 2378 7994:20:53 n/a 90 Vertical 80.5 9.1 2441 7994:21:23 n/a 90 Vertical 75.9 8.2 2519 7994:21:53 n/a 90 Vertical 71.6 7.1 2610 8004:22:23 n/a 90 Vertical 67.6 5.9 2713 8004:22:53 n/a 90 Vertical 63.9 4.7 2827 8014:23:18 4:23:21 90 Vertical 60.6 3.5 2949 8014:23:48 4:23:52 90 Vertical 57.5 2.3 3080 801

5:54:33 5:54:48 90 Vertical 210 2.4 3048 7965:55:02 5:55:03 90 Vertical 210.5 4.3 2856 7965:55:32 5:55:03 90 Vertical 211.1 6.3 2565 7965:56:02 5:56:02 90 Vertical 211.7 8.6 2475 7965:56:31 5:56:32 90 Vertical 212.5 11.1 2286 7965:57:01 5:57:02 90 Vertical 213.4 13.8 2099 7975:57:31 n/a 90 Vertical 214.5 17 1915 7975:58:00 5:58:01 90 Vertical 215.9 20.6 1735 7975:58:30 n/a 90 Vertical 217.7 24.9 1561 7975:59:00 5:59:00 90 Vertical 220.1 29.9 1394 7975:59:29 5:59:30 90 Vertical 223.4 36 1239 7985:59:59 5:59:59 90 Vertical 228.4 53.2 1100 7986:00:29 6:00:29 90 Vertical 236.6 51.8 983 7986:00:59 n/a 90 Vertical 251.7 60.8 900 7996:01:27 6:01:28 90 Vertical 280.4 67.4 857 7996:01:57 n/a 90 Vertical 318 66.4 863 7996:02:27 6:02:27 90 Vertical 343.2 58.9 916 8006:02:57 n/a 90 Vertical 356.2 49.8 1008 8006:03:25 6:03:26 90 Vertical 3.5 41.6 1130 800

Page 39: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

39

6:03:55 n/a 90 Vertical 8.1 34.6 1274 8016:04:24 6:04:24 90 Vertical 11.2 28.9 1432 8016:04:53 6:04:54 90 Vertical 13.4 24 1600 8026:05:23 n/a 90 Vertical 15.2 19.9 1776 8026:05:53 n/a 90 Vertical 16.5 16.4 1956 8026:06:23 n/a 90 Vertical 17.6 13.4 2141 8036:06:53 n/a 90 Vertical 18.5 10.7 2327 8036:07:23 n/a 90 Vertical 19.3 8.3 2516 8036:07:53 n/a 90 Vertical 20 6.1 2706 8046:08:23 n/a 90 Vertical 20.6 4.1 2897 8046:08:53 n/a 90 Vertical 21.1 2.2 3089 8046:09:23 n/a 90 Vertical 21.6 0.6 3281 805

4.1.3 Design Documents

TNC – X

TNC-X is a new Terminal Node Controller design based on the Chepponis/Karn KISS protocol. It is implemented using a Microchip PIC 16F628 microcontroller, a CML MX614 Bell 202 modem chip, an 8K Ramtron FRAM, a Maxim MAX232A level converter chip, and a dual op-amp which provides active audio filtering for the modem. From the beginning, this TNC was designed to be small, have low power consumption, and, most importantly, be expandable.

Page 40: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

40

Page 41: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

41

Schematic

Page 42: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

42

3-Volt Radio

The 3-volt radio uses a crystal radio to decrease power consumption and an RF amplifier to increase the RF output of the radio to our tested and calculated transmission power level. It will also use the TNC-X we hope to develop to packetize and for digital to analog conversion.

Schematic

4.2 Power

The most important subsystem of the Buoy project is the Power Subsystem. The Power Subsystem will be in charge of providing energy to all of the other subsystems. Energy is always an important factor to consider since all of the components of the buoy will not function without it.

The Design project consists of implementing different subsystems together to create a buoy that will communicate with other systems. Since the buoy has a life expectancy of 1 year, the power subsystem will have to provide energy to all of the subsystems so that they can function for this lifetime. Therefore, in order to design a successful power subsystem, the power requirements of the other subsystems should be considered and studied.

After going through research our team was able to provide an approximate amount of energy that the buoy would require; also satisfying the Design Project’s requirements. The team realized that the communication subsystem would be using a large amount of energy when compared to

Page 43: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

43

other subsystems. This energy consumption occurs since the communication subsystem will need to communicate with other devices according to our access scheme. The buoy would send an “aloha” to the device every 4 minutes followed by 30 seconds of listening. If the aloha is acknowledged, the buoy would send data. If not acknowledged the buoy would try again by sending an “aloha”.

Our calculations showed that our buoy would consume 1382.0352 Watt/Hours or 115.1696 Amp/Hours in communication purposes. Therefore our team would have to design a power system capable of proving a minimum of the Watt/Hours needed. Our two major power schemes are: Powering the buoy by using of batteries and powering the buoy by using batteries that recharge with the help of solar panels.

4.2.1 Alternatives and Tradeoffs

Batteries

The first power scheme that could be implemented in our project was the use of batteries to power up the buoy. If this scheme would be followed, there are important factors to consider when choosing batteries. The first factor to consider is weight. Batteries that provide a high Amp/Hour rate tend to be heavier. Another factor to consider when choosing batteries is the cost. These two factors will affect the decisions made when choosing batteries since they have to fit to our power requirement.

After doing some research we were able to distinguish the main differences of batteries and their chemistries. The following are different types of batteries considered and their characteristics.

Types of Batteries:

Batteries work by generating an electrochemical reaction. This reaction moves electrons from one pole to the other. The actual metals and electrolytes used control the voltage of the battery. This means that each different reaction has a different characteristic voltage.

Zinc-carbon battery:These batteries are also known as a standard carbon battery. Zinc-carbon chemistry is used in all inexpensive AA, C and D dry-cell batteries. The electrodes are zinc and carbon, with an acidic paste between them that serves as the electrolyte.

Alkaline battery:Alkaline chemistry is used in common Duracell and Energizer batteries; the electrodes are zinc and manganese-oxide, with an alkaline electrolyte. These batteries are inexpensive and may give a lot of power if arranged in parallel. They may provide different voltages like 1.5, 3, 6, 9 or 12 volts.

Some disadvantages include the fact that alkaline batteries lose their voltage gradually as opposed to rechargeable batteries; which maintain most of their voltage over the whole charge

Page 44: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

44

and then suddenly plummet. Alkaline batteries might leak if they're used only lightly or not at all for a long period of time.

Lithium-iodide battery: Lithium-iodide chemistry is used in pacemakers and hearing aides because of there long life. These batteries are small and light weight. These are designed for very high-drain devices, like digital cameras, motorized toys, and portable CD players. They're more efficient than standard alkaline batteries for high-drain devices. These batteries are expensive and are not rechargeable.

Lead-acid battery:

Lead-acid chemistry is used in automobiles; the electrodes are made of lead and lead-oxide with a strong acidic electrolyte. These batteries are inexpensive and simple to manufacture. In terms of cost per watt-hours, the lead-acid battery is the least expensive when compared to others. Lead acid batteries are mature, reliable and well-understood technology; when used correctly the lead acid battery is durable and provides dependable service. Also these batteries have a low self-discharge, having among the lowest in rechargeable battery systems.

On the other hand, lead acid batteries cannot be stored in a discharged condition. These batteries have a low energy density. This means that they have a poor weight-to-energy density, which limits use to stationary and wheeled applications. Lastly lead acid batteries allow only a limited number of full discharge cycles.

Nickel-cadmium battery:The electrodes are nickel-hydroxide and cadmium, with potassium hydroxide as the electrolyte. These type of batteries do not last very long before needing a recharge. They typically have 50 to 67% less capacity than alkaline batteries and Nickel-Metal Hydride batteries. Another downside of both Nickel-Metal Hydride batteries is that they self-discharge quickly. This type of battery is rechargeable.

Conclusions

After going over the different types of batteries and their characteristics the team considered in using alkaline batteries to power up the design project. The team decided to use so-called “lantern” batteries for the buoy due to their shape and size. This type of battery would provide 6 volts and each would weight 885 grams. The idea is to arrange about 16 of these batteries in parallel to provide the amount of amp-hours needed for our project.

We know that 16 alkaline batteries would provide about 160 amp-hours, which will satisfy our minimum of 115.16 amp-hours. This battery can be purchased for about $10 to $15. Therefore our battery expenses may add up to $160 to $240. The only problem would be that once the batteries are completely discharged, the buoy and all of its components would not function. The following picture displays the dimensions of the alkaline battery.

Page 45: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

45

Figure 11 Lantern Battery Dimensions

Solar Panels and Batteries

The second power scheme that was considered by the team was using solar cells to charge up our batteries to satisfy our power needs. Solar cells are tools that will help us transform energy from light to electric energy. The idea is to absorb energy from the sun since the sun is an eternal source of energy. Solar cells make electricity without waste, noise or pollution. These are solid-state devices in which there are no moving parts; therefore nothing wears out.

When light strikes a substance it causes the surface of the material to emit electrons. Also, when light strikes other substance it causes the material to accept electrons. The combination of these two substances can be used to cause electrons to flow through a conductor. This is called the photoelectric effect. The process when sunlight is converted into a flow of electrons (or simply electricity) is called Photovoltaic.

The source of energy used in this system is photons. Photons are the particles generated by sunlight; they carry a large amount of energy to earth. Solar panels use this large amount of energy by using silicon crystals with impurities added. This process of mixing materials is called doping. When two doped materials are bonded against each other an electric current can be induced.

In short, photovoltaic cells are made of special materials called semiconductors. Basically, when light hits a cell a portion of it is absorbed within the semiconductor. This energy causes electrons to move freely in the semiconductor. As we all know, this flow of electrons will cause a current.

Page 46: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

46

Figure 12 Solar Cell Theory

Solar Panels Implementation

The use of solar panels will provide our system a good source of “eternal” energy. This is a good idea to consider since solar panels will let our power subsystem recharge when needed. This will provide the energy needed to other subsystems and avoid the change of batteries in the future. But in order to absorb photons correctly, the solar panels must be pointed in direction to the sun. There are a number of different variables to consider when figuring out the best direction.

First, we assume that the solar panels are fixed. Solar panels should always face south. If they are located in the southern hemisphere, solar panels should face north. In our case, the use of multiple solar panels will let them always face the appropriate direction. Next, we need to figure out the angle from the horizontal.

Since the winter season has always the least amount of sun, we will have to find an optimal angle that will let the solar panels collect as much energy as possible. This means that if our need for energy is evenly the same throughout the year, we will want to leave the tilt at the winter setting. This is because the angle of the solar panels will be fixed.

Page 47: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

47

Figure 13 Sun Path

To calculate the best angle from horizontal of tilt during winter season we will use the following formula:

Angle = (Current Latitude * 0.9) + 29

The following table will show some examples of different locations with their corresponding angle from horizontal. Notice that the Angle from Horizontal is directly proportional to the latitude from the location.

Location Latitude Angle from HorizontalGuatemala City 14 (14 * 0.9) + 29 = 41.6

Mexico City 19 (19 * 0.9) + 29 = 46.1La Havana, Cuba 23 (23 * 0.9) + 29 = 49.7

Houston, TX 29 (29 * 0.9) + 29 = 55.1Lafayette, LA 30 (30 * 0.9) + 29 = 56

These calculations are assumed to be true only if energy is collected from an unobstructed sky. Also, it assumed that the solar panels are located at an altitude near sea level. This is important since at higher altitudes there is little atmosphere to absorb light from.

Lead Acid Batteries

The team has planned to implement a lead acid battery in the power system due to several reasons. One of the main reasons is following the fact that lead-acid batteries have a poor weight-to-energy density. This is important because the battery will be used to stabilize the buoy in the water. By placing the battery in the bottom of the buoy the weight of the battery will be able to compensate the weight of the mechanical structure. The team is planning to use a battery with a capacity no less than 14 Amp-Hours.

The following picture shows the weight and dimensions of a 12V 14Amp-hour Lead Acid battery.

Page 48: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

48

Weight: 9.25 lbs (4.20 kg)Length: 5.95 in (151 mm)Width: 3.86 in (98 mm)Height: 3.70 in (94 mm)

Height to Terminals: 3.94 in (100mm)

Another reason is because lead-acid batteries have a low self-discharge. This is important because the team is planning to manufacture a buoy with a lifetime of 1 year. Therefore, we would want to prevent our batteries from self-discharging. Lastly, lead acid batteries are inexpensive when compared to the prices of other types of batteries; our task is to design a buoy that is relatively cheap.

Advantages

Some of the advantages when using solar panels correctly include provide power for long deployments. This means that our system will not be dependent on any number of batteries since it will have solar panels to recharge the batteries. We know that the weather is constantly changing; some days may be cloudier than others. This will decrease the effectiveness of the solar panels. On the other hand, recharging will not be required every day. This means that our solar panels will not be used constantly; they will be used only when needed. Panels are generally fully enclosed in glass, so that there is no problem surviving in marine applications where washed with waves. The lifetime of solar panels is really high. Manufacturer warranty generally says that after 10 years of use the solar panel will output >90% original power.

Page 49: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

49

Disadvantages

Some disadvantages of using solar panels include the fact that the batteries may be overcharged. Also panels can be damaged if not protected by a cover. More than one solar panel may be needed to satisfy our power needs. We know that the weather is constantly changing; some days may be cloudier than others. This will decrease the effectiveness of the solar panels. The solar panels have to be at a constant angle of incidence in order to charge the batteries correctly. The prices of solar panels may be high depending on the size and power. They can be purchased for about $50 - $200 depending on mostly on size. Rechargeable batteries may be needed to use the solar panels.

Conclusions

After working on research and experiments, the team was able to decide which would be the best power scheme for the design project. The team chose to implement solar panels on the power subsystem due to many reasons. Firstly, solar panels will expand the lifetime of the buoy since it will not need battery replacement due to battery discharge.

The prices of solar panels may be higher, but the team believes that paying extra will benefit the project as a whole. Weight may also increase when using solar panels since rechargeable batteries are needed. For example, lead-acid batteries may be really heavy when compared to alkaline batteries. Since our buoys are placed in water, weight is not an issue. The team will design individual power systems for all subsystems to make them independent in power terms.

The team plans to use lead acid batteries that will be charged by the solar panels. The battery will be positioned in the bottom part of the buoy. The idea is to compensate the weight of the battery with the weight of the rest of the buoy. The weight of the battery will be located underwater. In order to satisfy the needs of the design, the team has planned to use a lead acid battery that can provide a minimum of 14 Amp-Hours.

The solar panels may only work properly if they are fixed in the right angle of incidence with the sun. The team will use multiple solar panels to collect as much sunlight as possible. This is because the buoy may rotate on its y-axis, causing the fixed solar panels to move. By implementing multiple solar panels, the buoy will always receive sunlight.

4.2.2 - Feasibility

Battery Charging Procedures

A. Measure the voltage in order to calculate the time the battery will charge.a. Connect alligator clips to the battery according to positive (red) and negative

(black) poles.b. Set the digital meter to read DC voltage.

B. Refer to the following chart to approximate the voltage charge of the battery.

Page 50: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

50

State of Charge 12 V Battery Volts per cell

100% 12.7 2.1290% 12.5 2.0880% 12.42 2.0770% 12.32 2.0560% 12.20 2.0350% 12.06 2.0140% 11.9 1.9830% 11.75 1.9620% 11.58 1.9310% 11.31 1.89

0 10.5 1.75

a. These voltages are for batteries that have been at rest for 3 hours or more.b. Batteries that are being charged will be higher – the voltages while under

charge will not tell anything, therefore the battery must sit for a while.c. Chart Zones:

1. For better life, batteries should stay in the green zone of the chart.2. Occasional uses of battery during yellow zones are not harmful.

i. Continual discharges to yellow levels will shorten battery life.C. Set the DC source to deliver 14.6 volts.

a. Make sure to connect cables on the +25 ports of the DC source.b. Scroll voltage until 14.6 volts are being delivered.

D. Set the DC source to deliver a minimum of 3 mA.a. Create a short between the positive and negative ports +25 ports.

i. This will allow user to set the current to 3 mA.b. Scroll current until 3 mA are delivered.c. Disconnect cables to undo the short.

E. Connect cables with alligator clips to positive and negative terminals of the battery with the respective ports of the DC source.

a. Notice the voltage of the source will change from 14.6 volts to a lower voltage depending on the initial battery voltage.

F. Allow battery to charge for a couple of hours depending on the charge needed.a. Current * voltage * hours charged = Power measured in Watts/ hrs

G. After the battery is fully charge disconnect alligator clips and turn off equipment.H. Allow battery to rest a minimum of 3 hours before being used.

Solar Panel Experimentation

The team was able to run experiments on a solar panel to learn more about its functions. A solar panel was connected across a resistance box and a voltmeter to see how the change in resistance would affect our output voltage

Page 51: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

51

The following table shows the results of the experiment.

Resistance Voltage Current (mA)1 77 mV 64.8 10 0.56 V 64.60 100 5.15 V 63.50 1 K 18.10 V 17.95 10 K 19.06 V 1.896 100 K 19.17 V 0.1906 1 M 19.21 V 0.0191

Notice that as the resistance increases the voltage output will increase as well. During this experiment the team also tried changing the angle of incidence of the solar panels. The data was collected while using a constant angle of incidence. With this information the team was able to approximate the power delivered if 4 solar panels were used.

Experiment’s Conclusions

We know that the project will consume approximately 115 amp-hours / year, meaning that it will consume about 0.315 amp-hours / day or 3.78 watt-hours / day. Assuming that we will be using a 1000 resistance to regulate the voltage, the solar panels will collect 0.136 amp-hours /day. This is assuming that everyday has at least 8 hours of direct sunlight.

This means that each solar panel will be able to deliver 1.632 watt-hours / day. The team is planning to use four solar panels at a correct angle of incidence according to the buoy’s location.

Therefore, the buoy’s solar panels would be able to collect 6.52 watt-hours / day for 8 hours on 1 day. Notice that the amount of energy that can be collected from the sun is greater that the amount of energy that is presumed to be used by the communication subsystem (6.52 watt-hours / day > 3.78 watt-hours / day).

In cases when the weather is constantly sunny, the solar panels may accidentally overcharge the batteries. For this type of issue, the team is planning to design a circuit that will prevent the solar panels from overcharging the batteries.

Peak Power Point

When a solar panel is set across a resistance box voltage and current delivered may vary according to the resistance value. From our last experimentation the team was able to learn that when the solar panels are set across an increasing resistance voltage will also increase. As a result, the current flowing through the circuit will decrease.

This means that at a low operating voltage a solar panel output current will be high but the output power will be low. This is because power is the product of voltage times current; P = V * I. Also, at a high operating voltage the current will be low and so the output power will be low as well. Somewhere in the middle is the panel’s peak power point, which is where the product

Page 52: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

52

voltage time’s current is maximized. It is important to find the peak power point of out solar panels so that we can use these devices effectively.

To find the solar panel’s peak power point the team ran some experiments on a sunny day. Again, a solar panel was set across a resistance box and a voltmeter. In addition, an ammeter was implemented in the circuit to measure the values of current flowing.

Figure 14 Peak Power Point Test Circuit

The resistance was varied and values of voltage and current were recorded. The following chart shows the experiment’s results.

Note: The resistance column shows the varying resistances used. The Vout column shows the voltage delivered across the resistance box, measured by a voltmeter.

The measured current column shows the values current collected by using an ammeter.

Calculated current column were calculated by using I = Vout / Resistance, which helped us prove we were recording correct values.

Measured power column = Measured Current * Vout.

Calculated power column = Calculated Current * Vout, used to prove if we were on the right track when recording measured value

Page 53: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

53

Resistance Ohms Vout

Measured Current Amps

Calculated Current Amps

Measured Power Watts

Calculated Power Watts

1 0.077 0.0648 0.07700 0.0050 0.005910 0.56 0.0646 0.05600 0.0362 0.0314

100 5.66 0.05380 0.05660 0.3045 0.3204150 7.47 0.04780 0.04980 0.3571 0.3720200 9.29 0.04218 0.04645 0.3919 0.4315250 10.49 0.03950 0.04196 0.4144 0.4402

Page 54: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

54

300 11.40 0.03485 0.03800 0.3973 0.4332350 12.09 0.03289 0.03454 0.3976 0.4176400 12.79 0.02912 0.03198 0.3724 0.4090450 13.24 0.02870 0.02942 0.3800 0.3896500 12.66 0.02526 0.02532 0.3198 0.3206550 12.95 0.02420 0.02355 0.3134 0.3049600 14.36 0.02230 0.02393 0.3202 0.3437650 14.55 0.02128 0.02238 0.3096 0.3257700 14.82 0.01992 0.02117 0.2952 0.3138750 14.97 0.01908 0.01996 0.2856 0.2988800 15.21 0.01791 0.01901 0.2724 0.2892850 15.32 0.01726 0.01802 0.2644 0.2761900 15.50 0.01633 0.01722 0.2531 0.2669950 15.58 0.01577 0.01640 0.2457 0.2555

1000 15.73 0.01516 0.01573 0.2385 0.24741050 15.81 0.01461 0.01506 0.2310 0.23811100 15.88 0.01401 0.01444 0.2225 0.22921150 15.97 0.01352 0.01389 0.2159 0.22181200 16.07 0.01294 0.01339 0.2079 0.21521250 16.14 0.01254 0.01291 0.2024 0.20841300 16.22 0.01209 0.01248 0.1961 0.20241350 16.28 0.01173 0.01206 0.1910 0.19631400 16.36 0.01128 0.01169 0.1845 0.19121450 16.40 0.01098 0.01131 0.1801 0.18551500 16.48 0.01062 0.01099 0.1750 0.1811

10000 19.06 0.001896 0.00191 0.0361 0.0363100000 19.17 0.00019 0.00019 0.0036 0.00371000000 19.21 0.000019 0.00002 0.0004 0.0004

Experiment’s Conclusions:

From the results the team was able to learn that the peak power point was when:Voltage = 10.49 voltsCurrent = 0.03950 ampsPower = 0.4144 watts

Page 55: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

55

With this experiment the team also learned that previous conclusions on calculations of the value of watt-hours delivered by a single solar panel might be erroneous. This is because the previous calculations were made assuming solar panels would be across 1000-ohm resistances.

If a single solar panel is used across a 250-ohm resistance then it will deliver 0.316 amp-hrs. This is assuming that on average a day has 8 hours of sunlight. 0.316 amp-hrs = 0.03950 amp * 8 hrs.

Therefore this single solar panel will then deliver 3.3152 watt-hrs. This is assuming that on average a day has 8 hours of sunlight.3.3152 watt-hrs = 0.4144 watt * 8 hrs.

These results show that the rate of power generation is almost the same as the rate of power consumption. Since the task of solar panels is to charge the lead-acid batteries, the use of solar panels with its peak power point is still feasible.

4.2.3 - Design Document

Schematic

Page 56: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

56

Description

Solar Panels:

This basic schematic shows the different components of the power subsystem. The power system will feature four solar panels connected in parallel. The panels will be connected in parallel because we want the current to change and not the voltage. Therefore the voltage will stay constant when the panels are in parallel. To be able to control the amount of current flowing into the battery a resistance will be used as shown in the schematic. The value of this resistance is related with the value of the resistance that gives us the peak power point.

LM7805:

Next a voltage regulator is implemented in the circuit. The LM7805 is a voltage regulator that will change 12 volts into 5 volts. Port 1 represents the input of voltage, in our case 12 volts. Port 3 represents the output of voltage, in our case 5 volts. Lastly, port 2 is connected to the circuit’s ground. This 5-volt line will be used to power the GPS subsystem.

LM317:

Page 57: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

57

These components are another voltage regulators needed for our system to function properly. These regulators will have an input of 12 volts and will generate an output of 3 volts and 3.8 volts. The 3-volt line will be used to power the receive communications subsystem. The 3.8-volt line will be used to power the transfer communications subsystem. The two resistances connected to these devices are used to regulate the voltage and obtain the output voltage needed.

In operation, the LM317 will develop a nominal 1.25V reference voltage or VREF, between the output and adjustment terminal. Output voltage is determined by the values established on resistors R1 and R2. The output voltage can be approximated by using the following formula: Vout = 1.25 * [1 + (R2 / R1)]. The voltage across R1 is a constant 1.25 volts and the adjustment terminal current is less than 100uA. A minimum load of 10mA is needed to assure that the value for R1 can be selected to drop 1.25 volts at 10mA or 120 ohms.

When power is shut off to the regulator the output voltage should fall faster than the input voltage. In case this does not happen a diode will protect the regulator from possible reverse voltages. The 1uF capacitor placed across the output will improve transient response. Next, the 0.1uF capacitor is set across the input only if the regulator is located at distance from the power supply filter (more than 6 inches away).

12V Lead Acid Battery:

This battery will be in charge of storing all of the power collected by the solar panels. It will be able to deliver 12 volts to the system.

NPN Transistor

This transistor is charge of controlling the flow of current from the solar panels to the battery. The transistor will work as a switch, turning on when the battery needs current to charge and off when the battery does not need charge. This transistor is implemented in the circuit with the objective of preventing the battery to overcharge.

The collector will be connected to the solar panels positive end. The emitter will be connected to the resistance in series. The base will be connected directly to the PIC. The PIC will be in charge of sending a voltage to the base of the transistor in order to open or close the switch. The battery’s voltage will be sent directly to the PIC. This will tell the PIC the current battery voltage. When the voltage of the battery reaches a certain value, the PIC will send a signal to the base of the transistor.

4.3 Sensor Subsystem The oceanic and atmospheric environmental conditions, which can be categorized as physical quantities are converted into signals that an observer or an instrument can easily read and

Page 58: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

58

understand using environmental sensors. These analog data vary in a long range from the ocean’s substances, solutions and compositions to the atmospheric conditions such as wind speed, objects’ distance, wind direction and much more. These data are converted to digital outputs, which would be handled in the command & data handling subsystem. In this section six different sensors that contributes to the implementation of the buoy would be discusses. This section includes different design or device alternatives, the feasibility of the devices and an overall schematic of sensor subsystem.

4.3.1 Alternatives and Tradeoffs

Air Temperature

The title of this section explicitly describes the purpose of this sensor, however in general term the temperature sensor senses the temperature of the atmosphere in terms of the units, Celsius or Fahrenheit. The inputs of these temperatures would be some analog voltage, but essentially would be converted to a digital output. The temperature is interpreted from the digital output based on a voltage to temperature reference and a mathematical calculation or I2C interface, which would be discussed later. In other to discuss the alternatives and trade offs of the air temperature sensor, it is important to understand the different types of temperature sensors available. Thermocouple:

Thermocouple is pair of junctions from two dissimilar metals. One junction includes the measured voltage and the other junction includes a voltage from a known reference temperature. The voltage measurement would be determined by the SeeBack effect. The SeeBack effect describes the voltage or electromotive force (EMF) induced by the temperature difference along the copper wire shown in the diagram below. The voltage output would change with respect to the change in measured temperature from the tip of the thermocouple. It is normally advisable to make the reference temperature a constant 0 degree Celsius by making a reference junction in ice water, thereby there would be no slight change in the reference temperature.

Page 59: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

59

Figure 15 Thermocouple

NTC (Negative Temperature Coefficient) Thermistor

Thermistor basically stands for thermal and resistor and they are typically temperature dependent resistors. The resistance decreases has the temperature increases, in a nonlinear predefined way, due to the properties of the semiconductor materials used to make the thermistor. Most NTC thermistors are made from various compositions of metal oxides of manganese, nickel, cobalt, iron, copper and titanium.

RTD (Resistance Temperature Detectors)

The difference between NTC thermistors and RTDs is the material used to make them. The materials used for RTDs experience an increase in resistance when their temperature increases. Therefore, RTDs could be referred to have PTC (Positive Temperature Coefficient) thermistors. The higher the coefficient, the greater an increase in electrical resistance for a given temperature increase. Both the PTC and NTC thermistors have a high temperature coefficient. The most commonly used material for RTDs is platinum, because it has the best temperature range. They also have low system cost, they are very linear (analog), and can measure temperature over a useful range, from -55 C to 155 C.

Integrated Circuit (analog and digital output)

Analog Integrated Circuits(IC), output voltages or currents that are Proportional to the temperature and digital ICs converts analog signals to digital output, which are basically 1s and 0s. Some advantages of the ICs temperature sensors over thermocouples, NTC thermistors and RTDs Is that it requires no external circuit to connect to the microprocessor (microprocessors usually come with analog to digital converters to convert the analog signal to digital.)

There are a lot of different ICs temperature sensors, all ranging from a 1 to 3-wire interface of both analog and digital. For example, the DS60 is a 1-wire analog temperature sensor. It has three pins. One pin is used to power up the device, another is connected to ground, and there is a 1-wire output pin connected to the microcontroller. Most 1-wire temperature sensors are analog,

Page 60: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

60

except for a few like the DS18S20, which as a built-in ADC (Analog to digital Converter.) However the temperature sensor that would be used in this Project is the 2 wire I2C Interface, DS1621 temperature sensor because, the pins are easy to Solder, the availability at the time for testing, and because multiple I2C devices/sensors can be connected to an I2C bus. I2C stands for Inter-integrated circuits, and it used to communicate with two or more digital devices using addresses. I2C supports master mode, multi-master mode (two or more devices in mater mode.), and slave mode; where the microprocessor would act as the master and the sensor would act as the slave. From the18f4520 datasheet it says that the master can initiate the data transfer at any time. The master determines when the slave is to broadcast data by the software protocol. The two wire interfaces for I2C are SDA; for serial data input, and SCK (serial clock.), these are used to schedule and initiates the sending and reading of data.

Water Temperature. Sensing the temperature of the water can be done numerous ways, but two major ideas were considered.

Thermocouple

Remember that a thermocouple needs a reference temperature sensor in other to determine a gradient temperature output, so what if the reference Temperature is acquired from the sea. The main problem with this is that the temperature of the sea would change so often that a précised Temperature for both the water and the air temperature would not be determined. Also the output of the air temperature would depend on the input of the water temperature, so if there were any fault with the water temperature sensing wire that would affect the air temperature.

Digital Temperature Sensor

Most water temperature sensors used in the ocean are very expensive; costing hundreds of dollars. Therefore a suggestion was made to put an air temperature sensor inside a resin. The resin would then be put under the water, and wires would connect to the pins of the temperature sensor to read the data – the temperature of the resin would determine the temperature. By doing these, we could avoid water from destroying the temperature sensor and avoid the expensive cost of water temperature sensors.

. What is a Resin? A resin is a compound that hardens when mixed with a solution. It is not soluble in water, but soluble in alcohol. There are a number of different classes of resin; this depends on what is being used for the chemical composition. A DS1621 would be inserted inside a non-conductive epoxy (contains resin) which would be used to measure the temperature of the water.

Page 61: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

61

Pressure Sensor

Pressure sensor measures the force of fluid or air over an area. It is usually measured in Pascal (newton/meter2), bars or in pounds per square inch with respect to the type of pressure measurement. The three main pressure measurements are Differential, Gauge, and Absolute pressure, which were alternatives for the pressure sensor. Differential Pressure Sensor Differential Pressure Sensor measures the pressure difference between two measuring points therefore, there are two measuring ports on the device that would take the measurement; the output would then be determined by the difference in the measurement. The unit for differential pressure is pounds per square inch differential (psid). It measures in reference to a perfect vacuum, which should have zero psi output.

Gauge Pressure Sensor

There two types of gauge pressure measurement. The first type is the vented gauge pressure measurement, which compares the pressure from an opened vent gathering the ambient pressure, to the atmospheric pressure. The vented input pressure is positive if it exceeds the atmospheric pressure and it is negative if falls below. Essentially, by adding the vented gauge pressure with the atmosphere pressure input, an absolute pressure is retrieved. Now, if the atmospheric measuring point is sealed up, the type is called sealed gauge pressure measurement. Vented gauge pressure is measured in psivg, and sealed gauge pressure is measured in psisg.

Absolute Pressure Sensor This type of sensor would measure the atmospheric pressure with respect to pure vacuum which has 0 psig. Since our concentration in this project is gathering atmospheric data, it seemed like the perfect type of sensor to use because it is uniform. Measuring with the gauge and differential sensor could also give the desired output, but other considering needs taken into effect. Whether it is doing some addition with the gradient of the differential pressure or ignoring the ambient pressure from the gauge sensor.

Anemometer/Wind Vane

The anemometer involves using a 3 cup anemometer assembly and a digital device to measure the wind speed. The wind vane involves using a potentiometer and a compass to measure the wind direction.

Wind Speed Detector

We came up with three basic ideas to record the speed of the wind.

Page 62: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

62

Cups and Mouse Method / Using an Optical Encoder The general idea of the cups and mouse comes from a computer ball mouse. Under some computer ball mouse is a ball, which moves as an individual moves the mouse. The ball is connected to two rollers that detect the position of the ball; when the ball moves the roller moves as well. These rollers are then connected to a shaft that spins a disk with hole in it (essentially, an optical encoder). In front of the optical encoder are infrared LEDs and the back is an infrared sensor, which detects the motion. The beams of light emitted by the LEDs are broken by the rotation of the encoder, which create digital pulses and is sensed by the infrared sensor. The signal detected by the infrared sensor is then passed to chip, which transfers the pulses through the mouse cord. The pulses are related to the distance the mouse as traveled and the speed.

So essentially, what is needed is the optical encoder to produce digital pulses which is related to the speed at which the 3 cup assembly will move. The section below discusses more in detail of the optical encoder.

Optical Encoder and Velocity Calculation / Choosing an Optical Encoder

This section discusses about finding relationship between the frequency response and radius of the 3 cup assembly.

In this section, we are going to take a look at two optical encoders in order to determine a general calculation of the velocity of an encoder with respect to the anemometer cups.

Figure 16: EC202A075A-27D Figure 17: QD787-05/05-2048-01-010-S1

Based on the datasheet of the rotary encoder in Figure 16, it has a resolution of 75 pulses per revolution (PPR) and a maximum frequency response of 500Hz. The frequency response is a system’s response to an input signal at varying frequencies. So given the square wave below (Figure 18), the frequency response is F = 1/T Hz. T is the amount of time the encoder takes to generate another clock pulse after one full period. Therefore, ‘F’ symbolizes the frequency of one waveform at T periods.

Figure 18

Page 63: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

63

Analyzing this data,- The encoder has 75 PPR = 75pulse/Revolution- 1 Revolution = (2*pi*r) , where r = radius of the rotary encoder

Assuming it takes 1 second to complete on full resolution (1 revolution per second), knowing that 1 revolution is (2*pi*r), then

- (2*pi*r) = (2*pi*F) = w, where w is the angular frequency. Essentially, r equals F-

Figure 19

If we decide to plot the angular frequency against the frequency in relation to the pulses, we would have a linear relationship.

Angular Frequency Versus Pulse/Revolution Graph

0

5

10

15

20

25

30

35

40

Frequency(Pulse)

Angu

lar F

requ

ency

(w, 2

*pi i

ncre

men

t)

Series1

Series1 6.2832 13 18.85 25.133 31.416 37.699

75 150 225 300 375 450

Figure 20The formula for this graph comes out to be

Page 64: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

64

Now, Analyzing the Wind cups,

Figure 21Notice that in Figure 21, the radius of the circle is denoted as r. Circumference of a circle ( C ) = 2*pi*r = w - C = v*t, where v = velocity (meter/seconds), and t = time or period (seconds) - 2*pi*r = v*t - t = (2*pi*r)/v - w = (2*pi)/t if w = (2*pi)/t and t = (2*pi*r)/v, then w = v/r Recall, w also equals (2*pi*F)/75, therefore (2*pi*F)/75 = v/r Letting v = V,

The radius, r is given to be exactly 0.053 meters, and the maximum frequency response is 500Hz. Therefore, the velocity of the anemometer without any resistance is equal to 2.220058809 meter/second. If 1meter/second = 2.23693629 miles/hour, then the maximum speed the anemometer can go without damaging the optical encoder is equal to 4.966130115 miles/hour.

Analyzing the QD787-05/05-2048-01-010-S1 optical Encoder (Figure 17),Based on the datasheet, the encoder has a frequency response of 200kHz and a maximum shaft speed of 8000RPM; which is 133.333 Revolution per second. if 2*pi*F = v/r, then 837.758041 = v/r. We also know that r = 0.053meters, so v = 44.40117617meters/second = V2, which results to V2 = 99.326023 miles/hour; the maximum velocity the anemometer can rotate without damaging the optical encoder.

Clearly this shows that the second optical encoder is better than the first. Another advantage of the second encoder over the first in this project is that, the lead connected to the encoder’s shaft

Page 65: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

65

has a diameter of 0.1247 inches for the second encoder compare to the first which has a diameter of 0.2000 inches. Since this lead would be connected to opening that the center of the wind cups attachment (view Figure 21 at center, M) which is 0.1 inches wide, the second encoder is better. The only advantage of the EC202A075A-27D encoder other the QD787-05/05-2048-01-010-S1 is that it requires a maximum input current of 30mA, while the QD787-05/05-2048-01-010-S1 encoder requires a maximum input current of 100mA.

Finding Relationship between the Actual Wind Speed and Encoder’s frequency response

In the real world, there is no such thing as a perfect shaft encoder; therefore the encoder’s lead would always have a little resistance. So we have to find a relationship between the wind speed and the frequency response of the encoder. Figure 22 and Figure 23 basically explains what needs to be done.

Figure 22.

Figure 23

The use of a wind tunnel is to study the effect of air moving around a solid object. The wind coming through a wind tunnel would be calibrated to different wind speed. The wind would come through the tunnel then blow on the anemometer. As the anemometer rotates it produces

Page 66: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

66

different frequencies based on the calibration of the wind speed. These frequencies could be stored in the PIC. The data would then be plotted against the varying speed. The question is: Where can we find a wind tunnel? A wind tunnel is located in the mechanical engineering department in the fluids laboratory of the University of Louisiana.

Another way to find a relationship between the actual wind speed and encoder’s frequency response is to test if frequency matches the frequency of an already built and tested wind speed detector. This is very expensive to get.

Cups and Motor Method The idea of the motor is basically the same as with the mouse; the difference is that the motor would represent the ball and the rollers would touch the motors’ axles. The fault in this method is that the motor would produce fiction against the wind. In order to avoid this, one could loosen up the axle of the motor internally. But an advantage of the cups and mouse method over the cups and motor is that it is already structured; that is, numerous of frictionless optical encoder are been manufactured and it would take more time developing a basic structure for the cups and motor than using an optical encoder.)

Hall Effect Method: Hall Effect Sensor

A Hall Effect transistor is nothing more than a thin sheet of semiconductor material with a voltage supply used to create a closed circuit. When a current carrying conductor is placed into a magnetic field, a voltage will be generated perpendicular to both the current and the field (see figure 24). This principle is known as the Hall Effect. The magnetic field allows a Lorentz force to disturb the current and create a potential difference across the output. A magnetic field can be created by placing a magnetic perpendicular to the Hall Effect transistor. This magnetic field would now be referred to as magnetic flux density, B, in this section.

Figure 24: Hall Effect principle with magnetic field present. V = I X B. (Honeywell, Inc)

Page 67: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

67

Flux density is the total flux divided by the cross sectional area which current flows; it measures the strength of a magnetic field in an area. Flux simply means line of flow. The unit of magnetic flux density is known as Tesla (T). 1 Tesla equals 1 weber/m2. 1 Weber is equal to Volt-Second. Combining these units together, 1 Tesla would equal 1 Volt-Second/m2.

Characteristics

Hall Effect transistors come in both analog and digital ICs. The difference between the analog and the digital is that in digital Hall Effect transistors, there is a built in differential amplifier and a schmitt trigger circuit which converts an analog signal to a digital signal, thereby creating an ON and OFF state. If the magnetic flux density equal or exceed an operating point, the sensor is registered in a state of being ON. If the magnetic flux density is below a minimum release point, the level of magnetic field is very low; therefore the sensor would be in an OFF state. These bring into term, hysteresis, which is the differential of the ON and OFF state. (Since a Hall Effect transistor would be used in this project, the explanation of the digital Hall Effect transistor would continue to be discussed.)A characteristic of the digital Hall Effect transistors is that some come with a built in regulator to ensure a constant current in its circuit so that the output would reflect the intensity of the magnetic field. Regulated digital Hall Effect transistor range between 3.8V to 24 VDC. Unregulated range between 4.5V to 5.5V.

Calculations

Let us assume we have an operating magnetic flux density of 17.5mT and a circuit current of 20mA, neglecting the flow of current with respect to ground.V = I X B, therefore,

Doing the cross product this formula results to V = (17.5mT)(20mA)k = (.000175mGauss)(20mA)k = 350uV.The voltage produced by the sensor is usually very low. Therefore the internal differential amplifier would be used to amplifier the voltage difference. An external pull up resistor will also need to be connected to the Hall Effect transistor. With the Hall Effect sensor connected to the pull up resistor, the Hall Effect transistor will be in a high state. When a magnet pass through the transistor the voltage will drop to milli voltages (close to zero). Without the pull resistor the output will rise up from a lower voltage to higher voltage. Though, the voltage will not be large enough to be read by the PIC, which requires a minimum of 4mV input. View schematic in the Appendix.

Programming the Hall Effect transistor

Due to the fact that friction could be neglected when using the Hall Effect sensor, we decided to go with the transistor. Also it will be easier to prevent water from entering the buoy system if the transistor is used. The reason is because the Hall Effect sensor would communicate with the 3

Page 68: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

68

cups assembly using magnets, therefore the external physical structure will not be exposed to the electrical devices. The same calculations for wind velocity of the QD787-05/05-2048-01-010-S1 optical encoder still apply with this transistor, except that there would be one pulse per revolution. Below is a flow chart on how the Hall Effect transistor would be programmed using c18 libraries and PIC18F4520. View code in Appendix.

Figure 25

Page 69: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

69

Wind Vane

The wind vane is used to measure the direction of the wind. The wind vane would require a rotary potentiometer and compass to accurately determine the direction of the wind.

Rotary Potentiometer

A rotary potentiometer is essentially a variable resistor. A rotary potentiometer is usually connected to a flat metal fin to determine the wind’s direction. The wind will blow the fin to its direction and the fin will rotate the potentiometer to that direction. A potentiometer could be interpreted using voltages; that is, having a constant current and varying the resistance in a potentiometer will produce a variance of voltages. The 360 degree format and the 540 degree format are the two different formats of the potentiometer. By rotating a rotary potentiometer from 0 to 360 degrees, changes in the voltage output will occur from its minimum to its maximum. The 540 degree format requires two voltage outputs (dual wiper) which will have a phase difference of 180 degrees. When the resistance in one wiper is very low it switches to the other wiper, vice versa. The 540 degree format would be used in this project because it is usually cheaper than the 360 degree format. Below show a picture of the 5k dual wiper potentiometer from APRS world used in this project.

Figure 265k dual wiper potentiometer

Digital Compass

The purpose of the digital compass is to orient the wind direction to its true north. When the buoy is placed in the gulf, the position of the buoy will not always face north, so it is very important to include a digital compass to find the buoys true north. By knowing the direction of the wind vane with the potentiometer and knowing the direction of the compass with respect to north at 0 degrees, one could calculate the wind direction by adding or subtracting the two directions with respect to 0 degrees. For example, if the buoy is facing 35 degrees away from the north; between 0 and 180 degrees, and if the potentiometer indicates a direction of 170 degrees, subtract 170 degrees from 35 degrees to get the actual wind direction, 135 degrees (SW). The compass that will be used in this project is a 1 inch by 1inch OS5000 –T Solid Stat Tilt Compensated Nano Compass (TTL), which requires a minimum voltage of only 3.3V. The compass also comes with a software that can be used to simulate a three dimensional direction of

Page 70: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

70

the buoy, along with the depth. The compass can also connect to a host system using microsoft hyperterminal. The picture below shows a virtual representation of the software.

Figure 27

View Picture of Compass Below

Figure 28

Page 71: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

71

Magnetic North versus True North

In determining the actual wind direction, it is also very important to understand the different between magnetic north and true north/geographic north. The magnetic north is the reference north of the compass, and in most locations the magnetic north different from the true north. The wind direction is usually referenced with true north. To accurately determine the wind direction, one would need to know the magnetic declination of the Gulf of Mexico. This can be calculated at http://www.ngdc.noaa.gov/geomag/magfield.shtml .

Salinity Detector

What is Salinity? Salinity is the measurement of the concentration of dissolved salt in water. The concentration is the amount of salt in the water (weight) and could be expressed as parts per million (ppm), or in grams/milliliter(grams/mililiter = g/ml = milligrams/micro-liter = mg/ul. 1ug/ml = 1mg/l = 1 ppm.) Our interest with the salinity sensor is measuring the amount of salt in the water, but it important to note that the salt would also include the impurities in the gulf from factors like the dissolved substances like mud in the water. Salinity can be measured using a hydrometer or a refractometer but these devices are used for lab experiment only. Another method used to measure salinity is deeping two electrodes water, then connecting the electrodes to a voltage supply, and a multimeter in other to measure resistance across the electrode or the current that flows through the electrodes.

Figure 29 Salinity Measurement Diagram

In other to measure the resistance or current the fundamental idea that needs to be used is the idea of conductivity. Conductivity is usually measured in Siemens or in mho; it is also the reciprocal of resistivity. It is more ideal to measure the resistance in terms of the resistivity because of the length and the cross sectional area of the electrodes, R = (P*L)/A, which as a unit of ohm*cm (P stands for the resistivity, L stands for the length, and A is the cross sectional area.) The cross sectional area (A) = radius2*pi or (diameter2 * pi)/4.

When the electrodes are inserted in the water they create positively charged hydrogen ions and negatively charged oxygen ions. The positively charged ions migrate to the cathode electrode and collect electrons causing an addition of more electrons at that end. The negatively charged

Page 72: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

72

ions at the same time migrate to the anode electrode to drop off electrons and oxides (loss of electrodes, gain of holes.) The separation of these ions is called electrolysis. Salt that dissolves in water break into positively charged sodium ions that are attracted by the cathode electrode, and negatively changed chloride ions, which are attracted by the anode electrode. If the negative charged ions discover that there are excess holes by the anode, the chloride ions drop off their electrons into the holes. The movement of these electrons in and out of the electrodes creates the flow of current in and out.

Obviously, a very important instrument in this sensor is the electrode. Therefore, finding the right electrode as to be taken into consideration. Since electrodes are typically conductors, any material that conducts electricity can be used in this Measurement. Two important factors that needs to be known, when looking at Conductors are: 1. The amout of resistance (the smaller the resistance, the greater the condutivity.) 2. The temperature of the melting point, because the more the temperature, the slower the metal disintegrate over time because of the thermal conductivity of the material. Here are a list of three good conductors.

Copper:

Copper is part of the elements in the chemical element table. Its symbol is Cu and its atomic number is 29. The electrical resisitivy at 20 C is 16.78 nΩ·m. Its thermal conductivity is (300 K) 401 W·m−1·K−1 and its melting point is at 1,084.6 °C. Aluminum The atomic number of aluminum is 12. Its symbol is Al. The electrical resistivity at 20 C is 26.50 nΩ·m. Its thermal conductivity is (300 K) 237 W·m−1·K−1, and its melting point is at 660.32 °C

Pure Tungsten Pure tungsten is a steel-gray to tin-white metal. It atomic number is 74. It has the highest melting point of all the chemical elements. The electrical resistivity at 20 C is 52.8 nΩ·m, which is still quite good. Its thermal conductivity is (300K) 173 W·m−1·K−1, and its melting point is at 3,407 °C. This pure tungsten is chosen in this project because of its melting point and its availability at the time.

Humidity

Humidity measures the amount of water vapor in the air. There are two devices that will be used to determine the humidity. First of all, we shall discuss two most common terms used to describe humidity. Below explains the most common terms used for humidity.

Page 73: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

73

Absolute Humidity

This calculated the mass of water vapor over the volume of the air or Gas (Mass/Volume.) It is usually measure in terms of grams per cubic meter or grains per cubic foot. Absolute humidity could be calculated if the Relative humidity (RH) is known.

Relative Humidity These sensor measures how much water vapor is present in the air, over the amount of water vapor that would be in the air if the air were saturated. This is measure in percentage. Humidity is usually referred to In terms of percentage, therefore for the design we are using the HIH-3610 that could be measured percentage.

Analog Humidity Device

The analog humidity device will sense the humidity of the air and convert it to analog data. This analog data would then be converted to digital using the microprocessor’s analog to digital converter. The analog humidity device that was considered in this project is the HIH3610 because it easy to use and program. But because it is unrealiable due to fog, sea spray, wind driven rain, and salty air, an additional DS1621 temperature sensor would be used to determine the humidity using what is called ‘WET BULB’ temperature method.

Wet Bulb Temperature for humidity

The wet bulb is gotten from the moistened temperature of the air. Water evaporating from heating the moistened air cools the thermometer. The evaporation is gotten from heating a moistened wick. The cooling effect of the evaporation is inversely proportional to the amount of water vapor present in the air:  the more water vapor present, the less moisture will evaporate from the moistened wick, and the less cooling of the thermometer bulb will occur. From the actual temperature reading (dry bulb) and wet- bulb readings humidity values may be calculated. Below shows a nomograph used to determine the relative humidity when the dry and wet bulb temperature readings are known. For example, with a wet bulb temperature of 72 degree Fahrenheit and a dry bulb of 84 degree Fahrenheit the broken line below indicates the relative humidity to be 56%.

Page 74: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

74

Figure 30Sensing and Controlling Humidty (KAELE ASSOCIATES) 4.3.2 Feasibility Two main feasibilities that are very important in the construction of the buoy sensors are the cost and the timeline given to complete the project. Fortunately, most of the sensors were gotten at a price of $0 due to letters of requests, donations and availability.

The Cost Actual Cost = Actual Cost of the device Buoy Sensor Cost = Cost of device after discount A = Available in the labD = Donation from Mark FenstermakerLos = Letter of request for Ocean Server TechnologyLcd = Letter of request for Quantum Device S = Samples

Page 75: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

75

DEVICE ACTUAL COST BUOY SENSOR COST 1.) Temperature Sensor (x3) $4.50 each $0.00 (Maxim) 2.) Pressure Sensor (MXP4115AP) $15.00 $0.00 (A) 3.) Humidity Sensor (HIH3610) $45.00 $0.00 (A) 4.) 5k dual Wiper Potentiometer $18.00 $18.00 (APRS World) 5.) Pure Tungsten Electrode $3 - $20 $0.00 (D) 6.) OS5000 –T Solid Stat $200.00 $0.00 (Los) Tilt Compensated Nano Compass (TTL) 7.) QD787-2048-01-02-S1 Unknown $0.00 (Lcd) Optical Encoder (x2) 8) 3 cup anemometer assembly $29.95 $29.95 (Davis) 9) (0H090U) Hallogic Hall-effect $2.67 $2.67 (Digi-key) Transistor Total: $50.62

TimeLine The time for the completion of this project is one year. The timeline mainly depends on the testing of the sensors and the mechanical aspect/configuration of each sensor. (See testing section)

4.3.3 Design Documents This section discusses about the tests that were done during our timeline. The programmable devices codes can be viewed in the code section of the appendix.

Salinity Testing

A procedure had to be taken in other to find a relationship between the output voltage of the electrodes and the amount of salt in water. This procedure was applied using aluminum and copper but because of their thermal conductivity they started to disintegrate, therefore there was no constant reading of the Output voltage.

Procedure

1. Connect the circuit (see circuit below) . 2. Pour a 50,000uS/cm calibrated solution in a beaker up to 200ml (make sure the temperature is about 25C to avoid worry about specific conductivity.) 3. Record the DC output Voltage. 4. Pour the Solution out of the beaker until it reaches about 100ml in the beaker.

5. Add some distilled water in the beaker to reach 200ml. (This basically reduces the conductivity by half.)

Page 76: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

76

6. Measure the DC output voltage. 7. Repeat procedure (4 – 6) until 20 measurements are made. 8. Plot the Data: The concentration of Salt in the water, VS output voltage

Circuit for testing:

Figure 31

The purpose of the Operation amplifier is to give a cleaner and stable output. It was also used to Amplify the voltage.Result:

Figure 32

The graph above shows 17 measurements that were taking following the procedure. Notice that right between the voltage 5.85 and 5.9 there is a huge difference between the Graph data. The reason for this is because every measurement was given a minute delay before the next, except from the measurment between 5.85 and 5.9. This was given a 5 minute delay. If we were to assume that there was a minute delay between each measurment then, the graph gives a

Salinity Graph

5.75

5.8

5.85

5.9

50,0

00

6250

781.

25

97.6

56

24.4

14

3.05

18

COnductivity

V1-V

2

Series1

Page 77: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

77

mathematic formula of y = ln(x). However further testings were conducted but we could not achieve a consistant voltage output. Schematics (Sensors)

Page 78: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

78

Schematic (Continued)

Page 79: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

79

4.4 Command and Data Handling

The command and data handling (CDH) subsystem will control and coordinate all the tasks of the buoy. The CDH subsystem will schedule data collections, then store and catalog that data. The CDH subsystem also implements the satellite access scheme by handling all data transfers to the satellite. The CDH subsystem will also provide a standard interface for all third-party piggyback devices. These piggyback devices can avail themselves to the resources provided by the buoy; namely, power, memory, and satellite connectivity.

The CDH subsystem will also selectively power on components only when needed to conserve power. Moreover, the CDH subsystem will monitor the battery voltage and enable/disable the solar panel charging system.

The CDH subsystem comprises the onboard microcontroller, the external memory, and the system software. The microcontroller manages a collection of input and output signals that connect it with the other subsystems. The external memory provides extra storage for environmental data when it cannot be transmitted to the satellite. The system software constitutes the algorithms, which will guide the buoy data collection and transmission tasks.

4.4.1 Alternatives / Tradeoffs

Before choosing a microcontroller, the number of inputs and outputs was estimated. Considering both the Terminal Node Controller and the GPS, at least two USART ports were desirable. Next, to allow compatibility with I2C sensor integrated circuits, an I2C serial port was deemed necessary. To accommodate plenty of analog environmental sensors, the number of analog to digital channels was identified as a critical factor. Additionally, a suitable microcontroller would be a low-power device. Finally, the microcontroller should support a C language development environment rather than the more tedious assembly language programming.

The C.A.P.E. lab was already outfitted with Microchip PIC programmers and development software as well as plenty of experienced PIC users. Therefore, a Microchip PIC microcontroller was an obvious choice. However, PIC microcontrollers are divided into several families mainly organized into increasingly more feature-rich models.

The lower and midrange families, such as the PIC12 and PIC16 devices, did not offer enough I/O pins or serial ports. At the upper end of Microchip’s product line, the PIC24 devices required up to 300mA of current, which was unacceptable with respect to the power budget.

Ultimately, the PIC18 series provided an appealing balance between features and low power consumption. Starting with the arrival of the PIC18 series, the C language became the primary development language. The team’s programming experience focuses mainly on C and its successor, C++, so this was an attractive feature. Moreover, a PIC18 series processor controls the still operative C.A.P.E. satellite.

Page 80: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

80

Microcontroller

The PIC 18F4520 microcontroller was the first PIC18 series processor considered. Several of the team members were already familiar with the microcontroller from a previous project. Also, the 40 pin DIP package would facilitate the breadboarding of prototype circuits. However, the PIC 18F4520 has only one USART port and the buoy design called for multiple peripherals to interface via the USART port. Later, this limitation was circumvented by the use of multiplexing signals with TTL logic. The 18F4520 also features I2C and SPI capability which is shared by the same pins. So, this would force the choice of either I2C or SPI peripherals but not both. This was not a problem either because the team chose to use only an I2C bus which would support multiple clients with the microcontroller as the host. The 18F4520 offers 13 analog to digital channels which would be plenty for our sensors. Also, 36 I/O ports would provide enough lines for the microcontroller to individually control the power supply for each subsystem.

Next, the PIC 18F6722 was considered. Compared to the 18F4520, this microcontroller offers more features. In particular, the PIC 18F6722 provides 2 USART ports and 2 serial ports, which is ideal for this application. Both the GPS and TNC would have dedicated USART ports. Also, with 54 I/O pins and 12 analog to digital channels, the 18F6722 can handle plenty of analog sensors. The 18F6722 features almost 4MB of RAM and 1MB of data memory. This abundance of working memory will facilitate multi-tasking and allow for more complex programs if needed.

Despite the 18F6722’s enhanced feature set, the 18F4520 sufficiently met the design demands in practice. Originally, the 18F6722 was thought to be an advantageous choice. However, throughout prototyping, the 18F4520 was accomplished all tested system tasks. Futhermore, the 18F4520’s lean feature set translated to less power consumed, which was a very attractive characteristic for our low-power system.

Watchdog Timer

The watchdog timer is a fail-safe device that is external to the microcontroller. The watchdog timer requires that the microcontroller send it an acceptable signal within a certain time frame. This timely signal informs the watchdog that the processor is running fine. Otherwise, if the expected signal is not received, the watchdog will conclude that the processor has hanged, i.e. an infinite loop or some other unanticipated fault condition.

The inclusion of a watchdog timer is the admission that the mission code may not be perfect. But rather than allow a single, rare software bug derail the entire mission, the microcontroller can be rebooted and resume its tasks.

First the 18F4520’s internal watchdog timer was considered. However, this watchdog timer seemed too closely coupled with the device it is supervising. Furthermore, the watchdog timer and the microcontroller would share the same power source. This prevents more sophisticated watchdog functionality like disconnecting microcontroller or even total system power in the

Page 81: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

81

event of latchup, a dangerously high current condition. In conclusion, an external watchdog timer was deemed preferable.

Next, a simple external watchdog timer was considered. This watchdog timer requires a periodic pulse on one of its pins. The pulse must occur before a timer expires. This gives the microcontroller some flexibility for when it pulses the watchdog line. It may service the watchdog through quick pulses then less frequent pulses depending on its other activities. However, if rogue code would somehow randomly pulse the watchdog line, the software fault could go uncorrected.

Finally, the team examined the external windowed watchdog timer. The windowed watchdog requires the service pulses to be delivered only during certain valid periods. This restriction prevents random line pulses or noise from successfully servicing the watchdog. Although, now tending to the watchdog necessitates more time-sensitive care from an essentially non-deterministic system. At some points, the buoy is waiting an indeterminate amount of time for a satellite acknowledgement (up to 30 seconds). Also, high speed data transmission could make timely watchdog pulses somewhat troublesome.

Ultimately, the team concluded that a simple external watchdog timer would suffice for the buoy design. A watchdog such as this could be programmed for relatively long periods (in terms of seconds). This feature was appealing because the buoy loops in terms of seconds and minutes, not microseconds.

4.4.2 Feasibility

The team developed test code to explore how a PIC microcontroller would handle the fundamental tasks of the buoy. For this testing, the 40 pin DIP (Dual-Inline Pin) form factor 18F4520 microcontroller was inserted into a ZIF (Zero Insertion Force) socket which allowed the microcontroller to be tested on a standard breadboard.

Three test programs were developed: (1) a USART communications port test, (2) a GPS data receive and string parsing test, (3) a sensor data acquisition test, (4) an AX.25 packet and KISS protocol test, and (5) a system state machine test.

The source code for the above-mentioned programs can be found in Section 11.2 Appendix: Source Code.

The USART communications port test verifies that the USART port is opened at the correct baud rate and that data can be send via that port at will. The USART port transmits at TTL (Transistor-Transistor Logic) levels so a RS-232 level converter was utilized to change the signal levels to +5V and –5V before routing the signal lines into a DB-9 serial connector and then into a PC’s serial port. The PC listened to its serial port using HyperTerminal, which is a program that displays ASCII traffic on a PC’s serial port. The USART communications port test was successful and performed as expected.

Page 82: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

82

Next, a GPS data receive and string-parsing test was conducted to check that the microcontroller could read data from the GPS and extract the data fields of interest. Once the GPS and its antenna are provided with a +5V power source, there is an approximately 50-60 second delay before valid data is acquired from a satellite fix. Once valid data was present on the USART receive pin, the program successfully extracted the time, the longitude, and the latitude, and then sent this data to a laptop running HyperTerminal via the USART transmit pin. Because the test microcontroller, the 18F4520, only has one USART port, the GPS and PC serial cable were multiplexed into the transmit and receive pins with standard TTL logic gates. Then, the desired signals were enabled using output pins connected to AND gates which were configured as Enable lines. The GPS test proved successful. The test verified that (1) the GPS unit was accurate and (2) the code correctly handled the GPS data.

Also, a sensor code program was developed. This program was designed to test the humidity and pressure sensors. Also, the microcontroller’s analog-to-digital converter was tested. Both sensors output a voltage proportional to their environmental values. This program checked if those voltages could be converted to sensible values by the analog-to-digital converter. Then, this program checked that we could convert these ADC counts into familiar units. The test successfully reported the correct pressure and humidity values. This proved that our test code could serve as a basis for any other analog sensors in the design.

Next, an AX.25 packet test program was developed. This program formatted a message into an AX.25 packet and then wrapped that packet in KISS protocol. AX.25 is a common protocol used in packet radio networks. The KISS protocol allows for an AX.25 packet to be sent over a serial channel to a TNC for transmission. The KISS wrapper is not transmitted but it does guide the operation of the TNC. The AX.25 packet protocol and KISS protocol will be discussed further in the Command and Data Handling design documents section.

Finally, a state machine test program was developed. This program proves that the buoy can accomplish its mission by transitioning between system states via clearly defined events. The state machine program simulated the natural pattern of the buoy’s activities.

4.4.3 Design Documents

Explanation

The command and data handling subsystem will coordinate the operation of all the other subsystems. At the conceptual level, the command and data handling subsystem is the actual implementation of the satellite access scheme. More specifically, the command and data handling subsystem will schedule the cycle of data collection, data storage, and data transmission.

At a lower level, the command and data handling subsystem will convert and format sensor data into usable information. Next, the command and data handling subsystem will associate a date, time, and location stamp with this formatted sensor data. Following that, the data will be stored

Page 83: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

83

chronologically in non-volatile memory. Finally, once a satellite link is established, the data gathered since the last satellite transmission will be relayed to the satellite.

Microcontroller Schematic

Page 84: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

84

Flowcharts

Data Cycle

The buoy’s essential program cycle is pictured below.

Page 85: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

85

Satellite Access Scheme

The beacon buoy algorithm is pictured below.

Page 86: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

86

Data Collection

The below method aims to minimize power consumption by keeping peripherals active only when they are needed.

Page 87: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

87

OBC State Diagram

NOTES:Enter “Wait Long” state after successfully uploading a day’s worth of environmental

data.

Wait Short State – Gather data throughout the day while attempting to contact with satellite.

Wait Long State – Gather data for 24 hours without attempting to contact the satellite.

Page 88: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

88

Low Power State – Do nothing until batteries have recharged.

OBC State Descriptions

Wait Short State – The buoy idles until either three possible conditions become true. If four minutes passes, the buoy will transition to the Aloha state. If sixty minutes passes, the buoy will transition to the Data Gathering state. If there is a low voltage detected on the batteries, the buoy will transition to the Low Power state. Essentially, the buoy sits in the Wait Short state while alternating between attempts to contact the satellite and collections of environmental data.

Aloha State – In this state, the buoy is attempting to contact the satellite. The buoy transmits an AX.25 frame with an APRS-formatted data field with position information. If the satellite recognizes this message, it will reply with an acknowledgement. Upon reception of that acknowledgement, the buoy will transition to the Data Transmission state. If the buoy does not receive an acknowledgement within 30 seconds, the buoy will return to the Wait Short state.

Data Gathering State – Every hour, the buoy will transition to this state. The buoy will be coming from either the Wait Short state or the Wait Long state. In this state, the onboard computer will query the GPS and the environmental sensors for information about its current surroundings. First, the GPS and sensors are powered on. Then, environmental data is obtained from the sensors. Once 90 seconds pass, the GPS is checked for a location and time fix. The 90

Page 89: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

89

seconds should be able time for a GPS fix. The current environmental data is then stamped with location/time information before the data is stored. After the data collection is complete, the GPS and sensors will be powered down. Then, the buoy will transition to its previous state, either Wait Long state or Wait Short state.

Data Transmission State – Only the Aloha state may transition to this state. This ensures that the satellite is listening to the data transmission. The buoy will transmit 24 hours worth of environmental data in AX.25 packets. Each packet will correspond to one hour’s worth of data. The data packet will include date, time, latitude, longitude, air temperature, water temperature, humidity, atmospheric pressure, wind speed, wind direction, and salinity.

Wait Long State – In this state, the buoy refrains from trying to contact the satellite. Instead, the buoy continues to wait for the hourly data collections. That way, a significant amount of data is accumulated before transmitting to the satellite. Once 24 hours pass, the buoy transitions to the Wait Short state, which will eventually resume satellite alohas. Also, low battery voltage can trigger a state transition to Low Power state.

Low Power State – This state suspends all buoy activity until the buoy batteries are recharged. The microcontroller ensures that the solar charging FET is on to provide a channel between the solar panels and the batteries. The battery voltage is sampled until the voltage has reached an acceptable level. No data gathering or radio transmission is attempted. Any unnecessary power-draining task could further jeopardize the mission’s livelihood. This state is designed so that the buoy will never go completely dead due to insufficient power.

Core Software State Machine Implementation

while(1) { switch(nextState) { case WaitShortState: previousState = nextState; nextState = waitShort(); break; case WaitLongState: previousState = nextState; nextState = waitLong(); break; case AlohaState: previousState = nextState; nextState = aloha(); break; case DataGatheringState: dataGathering(); //Return to previous state

Page 90: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

90

nextState = previousState; break; case DataTransmissionState: previousState = nextState; nextState = dataTransmission(); break; case LowPowerState: lowPower(); //Return to previous state. nextState = previousState; break; }//end switch

}//end while

External Timer

State transitions governed by time passage are implemented via an external timer. The Maxim DS1371 timer was chosen because it counts in terms of seconds and it is an I2C device. Buoy time intervals of interest are either 30 seconds, 4 minutes, 60 minutes, and 24 hours. However, upon closer inspection, only two distinct intervals are needed: 30 seconds and 4 minutes. This is because 60 minutes can be divided into 15 four minute intervals. Likewise, 24 hours can be interpreted as 360 four minute intervals. Only two values need to be loaded into the timer, 30 seconds or 4 minutes. The 4 minutes could be further reduced to several 30 second intervals, but the 30 second interval is only pertinent in the Aloha state. On the other hand, minutes and hours are key to both of the waiting states.

Wait Short state loads the value 240 seconds (4 minutes) into the DS1371 timer. Then, an I/O pin is checked until a pulse from the timer is detected. Once the timer expires, a static 4 minute interval variable is updated and the buoy transitions to Aloha. Upon return from Aloha, if the static 4 minute interval variable equals 15 counts (60 minutes), the buoy transitions to Data Gathering state.

Likewise, the Wait Long state uses the DS1371 timer to track 60 minute and 24 hour intervals. Again, 60 minutes can be interpreted as 15 counts of 4 minute intervals. At each 60 minute interval, the buoy transitions to the Data Gathering state. Therefore, timer code can be shared across states. Furthermore, after 360 counts of 4 minute intervals, the Wait Long state transitions to the Wait Short state. From there, the buoy will resume attempts to contact the satellite.

The Aloha state uses the DS1371 timer as a signal to transition back to the Wait Short state. The timer is loaded with a 30 second value. Then, either two events will occur. The satellite will respond to the aloha within 30 seconds or the timer will expire in 30 seconds. If the satellite responds, the buoy will transition to the Data Transition state. If the timer expires, the buoy will cease listening for satellite acknowledgement and return to the Wait Short state.

Page 91: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

91

External Memory

The PIC 18F4520 features only 256 bytes of non-volatile EEPROM memory. This is insufficient given that a day’s worth of environmental data was calculated at 1440 bytes. Therefore, external memory was necessary. The team decided that the external memory should be interfaced via the I2C bus with the other external peripherals, such as the timer and temperature sensors. Also, EEPROM memory was selected instead of flash memory because memory writes would occur in smaller transfers rather than huge block writes. Also, EEPROM memory could be obtained for cheaper and with more smaller size options.

The amount of external memory needed was based on two assumptions. First, the team decided that the buoy should retain up to 6 months worth of data. This would allow the buoy to retain a significant amount of data even if satellite communication fails. Six months of data would provide ample environmental information in the scenario that the data was retrieved by other means. Second, aside from the ability to host 6 months of data, extra memory could be used for future expansions to the buoy design, such as extra sensors or more frequent data gathering.

Next, the desired memory size was calculated. At 1440 bytes of data per day, 30 days of data amounted to 43,200 bytes. Therefore, 6 months of data required 259,200 bytes of space. This memory space is just under the common 256 kilobyte EEPROM size. So, a 256K I2C EEPROM was selected, the Microchip 24AA256.

The 24AA256 supports input VCC from 1.8V to 5.5V with a maximum standby current of 400nA at 5.5V. The 24AA256’s CMOS technology translates to low power requirements such as a maximum current of 400uA reads and 3mA writes.

Watchdog Timer

Based on the alternatives and tradeoffs study, the team decided that the buoy needed a watchdog timer which required only a single pulse within a certain time period. The low-power TI UCC3946 watchdog timer was chosen for its typical 10uA current and programmable timer period and reset threshold. The UCC3946 is flexible such that it can function on VDD anywhere in the range of 2V to 5.5V.

The watchdog period is calculated as T = 25 x C, where T is time(milliseconds) and C is capacitance(nanofarads). With a 0.1uF capacitor, the watchdog period is 2.5 seconds, which seemed appropriate for our application. If our buoy locks up, 2.5 seconds lost makes virtually no impact on the mission. Also, with a 2.5 second period, servicing the watchdog is not as demanding as if the period was much shorter; for example, 2.5 milliseconds.

Next, the reset voltage threshold was calculated. If the system VDD drops below a certain voltage, the watchdog can assert a reset signal on the microcontroller until the supply voltage

Page 92: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

92

rises above the threshold for a user-programmed period. Using this feature, we can ensure that the microcontroller does not attempt to run code while its supply voltage is insufficient. During testing, we did notice that the microcontroller running on insufficient voltage would make noticeable errors related to its analog-to-digital converter. The reset threshold voltage is calculated by Vreset = 1.235x((R1+R2)/R2). Solving for a chosen voltage of 4.6V and assuming R2 is 1Mohm, we find that R1 should be 2.7Mohm. The resistors were picked in the Mohm range to limit quiescent currents.

Then, the reset period is calculated using T = 3.125 x C, where T is time(milliseconds) and C is capacitance(nanofarads). The reset period is how long the supply voltage must rise back above the reset voltage threshold before the watchdog releases the microcontroller reset, allowing the microcontroller to restart execution. Picking a capacitance value of 0.1uF, we find that the reset period is 312.5ms. So, about the system voltage must recover and stabilize for about one-third of a second until the watchdog will allow the microcontroller to reboot.

Finally, we decided to utilize the watchdog as a recovery method for latch-up conditions. Due to its CMOS technology, our microcontroller is susceptible to high current conditions known as latch-up. During latch-up, paired transistors conduct in such a way that a low resistance path is created between VDD and ground. For our application, a nearby lightning strike could create sudden transients on the VDD or ground lines that could cause latch-up. Therefore, if the watchdog is not serviced, the watchdog will disconnect DC power to the system such that a latch-up condition can hopefully reset itself. Naturally, the watchdog will not be cutting power to itself but rather the other system components; namely, the microcontroller.

I2C Bus

I2C (Inter-Integrated Circuit) is a serial bus which uses only two lines: SDA (data) and SCL (clock). Both lines are bidirectional and require pull-up resistors. Communication is accomplished by driving these lines low or letting them stay high with an open drain. The bus supports multiple masters and slaves but, in practice, there is usually only one master. The master initiates each I2C transfer, whether it is a read or write. Each slave is addressed via a combination of its standard part address and the configuration of its address lines. The configuration of the slave’s address pins allows duplicate devices on the same bus yet each with a unique address. I2C devices typically function by allowing the master to read and write the device’s internal registers. Usually, the master will write to a configuration register and then read from an output register.

The I2C bus was chosen for its two line simplicity and the resultant low pin count of I2C devices. A low device pin count usually translates to a smaller package size with less power consumption. Also, the team had previous experience with this bus on other projects. Simple I2C components also keep the overall cost down compared to components that are compatible with high speed buses. The team also weighed the disadvantages associated with I2C. However, relatively low speed data transfers are not detrimental to the buoy’s performance. Also, the bus limitation of only a few meters does not pertain to our self-contained buoy.

Page 93: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

93

Software Structure

- main.c - This file constitutes the program’s starting point and forms the basic structure of the buoy state machine. A switch statement is the primary agent of the state machine. Each case of the switch structure represents a buoy state. Inside each case, there is a function call which implements the actions of a buoy state. This function call then returns a value which indicates which state the buoy must transition to next. The variables nextState and previousState will track the last buoy state and the upcoming buoy state. Execution will continuously loop through this switch statement while the outcome of each case determines then next switch case chosen.

- state.h, state.c - These files contain the functions which correspond to each buoy state. These functions will call more subsystem specific functions to carryout the state’s duties.

- system.h - This file will consolidate many of the defines, macros, pin assignments, and system constants into one section. Therefore, all system-specific symbolic names are in one source file for easy reference.

- gps.h, gps.c - These files contain all functions pertinent to retrieving and parsing information from the buoy’s onboard GPS.

- timer.h, timer.c - These files contain the functions which will interface with the buoy’s external timer. These timer setting functions are important for scheduling state transitions.

- watchdog.h, watchdog.c - These files feature functions to service the watchdog.

- power.h, power.c - These files have functions which will affect the power system, such as solar charging enable/disable and battery sensing/testing. Transitions to the low power state will depend upon the battery testing functions within these files.

- sensors.h, sensors.c - These files contain functions which manage the buoy’s array of sensors that monitor atmospheric pressure, air temperature, water temperature, humidity, salinity, wind speed, and wind direction. Also, functions related to our digital compass will also be included here. The digital compass informs us on the buoy’s orientation so that we may determine wind direction using a wind vane.

- comm.h, comm.c - These files contain interface functions for the TNC-X as well as transmit and receive functions. The receive interrupt service routine is included here as well.

- data.h, data.c - These files feature functions which will organize the buoy environmental data into ASCII character arrays for transmission. Also, incoming satellite ASCII commands will be interpreted using functions in these files.

Page 94: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

94

- memory.h, memory.c - These files have functions to interface with the buoy’s external memory. EEPROM reads and writes are implemented here, along with any data formatting or compression for storage.

- satellite.h, satellite.c - These files contain functions which implement satellite commands. Once ASCII commands are interpreted in data.c, they are passed to the functions which will perform the desired actions, such as transmitting certain data or configuring buoy behavior.

Key Subsystem Functions

These functions provide the main interface between the Command & Data Handling subsystem and the other subsystems. Naturally, there are many more supplementary functions which are called by the below functions. However, to abstract the underlying complexity, the Command & Data Handling subsystem only calls these high-level functions.

Power Subsystem- float CheckBattVoltage();

Used for determining if (1) batteries need charging, (2) batteries are fully charged, or (3) batteries are critically low. If batteries are critically low, the buoy will transition to the Low Power state.

- void EnableSolarCharging();Turn on the FET which connects the solar panels to the batteries.

- void DisableSolarCharging();Turn off the FET which connects the solar panels to the batteries.

Sensors Subsystem- void PowerOnSensors();

Turn on the FET which connects the positive power rail to the sensor array.

- void PowerOffSensors();Turn off the FET which connects the positive power rail to the sensor array.

- struct ENVIRONS* GetEnvirons();Retrieve a struct variable whose members include integer values corresponding to

pressure(kPa), humidity(%), air temperature(degrees), water temperature(degrees), salinity(mg/L), wind speed(mph), and wind direction(N,S,W,E,NE,NW,SE,SW).

Communication Subsystem- void EnableRadio();

Page 95: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

95

Ensure multiplexing logic has the TNC-X connected to the USART.

- void PowerOnComm();Turn on the FET which connects the positive power rail to the comm system.

- void PowerOffComm();Turn off the FET which connects the positive power rail to the comm system.

- void Transmit(char* data);Accept a null-terminated ASCII string, wrap it in an AX.25 packet, and transmit

the data.

- char* Receive();Receive incoming AX.25 packet, extract ASCII data, and return in a null-

terminated ASCII string.

GPS Subsystem- void EnableGPS();

Ensure multiplexing logic has the GPS connected to the USART.

- void PowerOnGPS();Turn on the FET which connects the positive power rail to the GPS unit.

- void PowerOffGPS();Turn off the FET which connects the positive power rail to the GPS unit.

- struct GPS* GetGPS();Retrieve a struct variable whose members include ASCII char strings

corresponding to time, date, longitude, and latitude.

Source Code

Please consult the appendix for the source code.

Satellite Commands For The Buoy

If the satellite receives the buoy aloha, it will respond with a valid command. Commands are sent in ASCII with each command preceeded by a dollar sign ($) and the address number of the buoy. The address number of the buoy allows communication with a specific buoy if multiple buoys are present. Each buoy will have a designated number to respond to. For the following examples, assume the buoy address is 1.

$1Get24Data

Page 96: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

96

This command simply instructs the buoy to send the environmental data for the past 24 hours. This should be the most common satellite response to an aloha from the buoy.

Note: Please notice that the above buoy address is 1. This command will only cause buoy #1 to respond.

Also, the satellite may specify only the most current data using the following commands:

$1GetLastData

Upload only the last hourly data set to the satellite from buoy #1.

$1GetLastPosition

Upload only the last recorded position of buoy #1.

In addition, to further increase the data recovery flexibility, the satellite may specify only a certain metric of interest. For the following examples, the satellite wants only a certain environmental measure from buoy #3.

$3Get24Air

Upload the last 24 hours worth of air temperature measurements from buoy #3.

$3Get24Water

Upload the last 24 hours worth of water temperature measurements from buoy #3.

$3Get24Press

Upload the last 24 hours worth of atmospheric pressure measurements from buoy #3.

$3Get24Hum

Upload the last 24 hours worth of relative humidity measurements from buoy #3.

$3Get24WDir

Upload the last 24 hours worth of wind direction measurements from buoy #3.

$3Get24WSp

Upload the last 24 hours worth of wind speed measurements from buoy #3.

$3Get24Sal

Page 97: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

97

Upload the last 24 hours worth of water salinity measurements from buoy #3.

Depending on the future buoy development and needs, more commands and functionality may be added.

Data Transmission Format

The components of a buoy data string are as follows:

Buoy Address – This number distinguishes a particular buoy from the other buoys.

Date – The data is formated as mmddyy: mm is month, dd is day, yy is year. This time specifies when the data was collected.

Time – UTC (coordinated universal time) format: hhmmss.ss, where hh is hours, mm is minutes, ss.ss is seconds. This time specifies when the data was collected.

Latitude – Specified in ddmm.ss,direction, where dd is degrees, mm is minutes, and ss is seconds. Direction is N or S.

Longitude – Specified in ddmm.ss.direction, where dd is degrees, mm is minutes, and ss is seconds. Directions is W or E.

Air Temperature – Specified in degress Fahrenheit.

Water Temperature – Specified in degrees Fahrenheit.

Humidity – Specified as %.

Wind Speed – Specfied in miles per hour.

Wind Direction – Specified as either N, S, W, E, NW, NE, SW, or SE.

Salinity – Parts per thousand.

Buoy data string: (Data points separated by commas.)

[Buoy Address],[Date],[Time],[Latitude],[Longitude],A[Air Temperature],W[Water Temperature],H[Humidity],WS[Wind Speed],WD[Wind Direction],S[Salinity]

Example string

03,101809,053021.32,2501.23.N,9002.18.W,A088,W084,H060,WS015,WDNW,S32

Page 98: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

98

AX.25 Packet

The information field of an AX.25 packet will contain the buoy data string. The AX.25 protocol is a data link layer protocol commonly used in amateur packet radio communications. An AX.25 packet features seven fields:

(1) Flags – The hex value 7E is used to delimit the boundaries of the packet. (2) Address – This field specifies the destination and source call signs and their SSIDs (Secondary Station Ids).(3) Control – This field specifies the type of frame being passed: Information, Supervisory, or Unnumberd.(4) Protocol Identifier (PID) – This field defines what type of Layer 3 protocol is in use (if any).(5) Information – This field holds the transmitted data.(6) Frame Check Sequence – This field holds the Cyclic Redundancy Check value which is used to detect transmission errors.(7) Flags – The hex value 7E signals the end of the packet.

For our purposes, we are sending only Information frames with no layer 3 implemented, so our Control Field is always 03h and our Protocol Identifier is always F0.

To send an AX.25 packet, the buoy provides the TNC-X with the address field, the control field, the PID field, and the information field. The TNC-X automatically appends the flag fields and computes the Frame Check Sequence frame.

For the address field, each call sign is seven bytes. Six bytes for the call sign and one byte for the SSID. The destination call sign comes first and the source call sign follows. All bytes in the address field are bit shifted to the left by one. The bit in the zero position (furthest right bit) must always be zero until the last byte of the address field. The last byte of the address field will have a one as its least significant bit. This one will signal the end of the address field.

The information field contains the buoy data string as described above.

KISS Protocol

The buoy’s TNC-X requires all packets in the KISS format for transmission. KISS format specifies that each frame begins and ends with the hex value C0. After the first C0, a port number and command are specified. Our system has only one HDLC (High-level Data Link Control), so our port number is always 0. The commands are as follows:

Command Function Comments

0 Data frame The rest of the frame is data to

be sent on the HDLC channel.

Page 99: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

99

1 TXDELAY The next byte is the transmitter

keyup delay in 10 ms units.

The default start-up value is 50

(i.e., 500 ms).

2 P The next byte is the persistence

parameter, p, scaled to the range

0 - 255 with the following

formula:

P = p * 256 - 1

The default value is P = 63

(i.e., p = 0.25). 3 SlotTime The next byte is the slot interval

in 10 ms units.

The default is 10 (i.e., 100ms).

4 TXtail The next byte is the time to hold

up the TX after the FCS has been

sent, in 10 ms units.

5 FullDuplex The next byte is 0 for half duplex,

nonzero for full duplex.

The default is 0

(i.e., half duplex).

6 SetHardware Specific for each TNC.

Typically, we are using command 0 to send data out. Therefore, our data to the TNC-X will look like:

Page 100: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

100

C0 00 [AX.25 Packet w/ Buoy Data String in Information Field] C0

The TNC-X will strip off the C0 delimiters and the command code and then only transmit the AX.25 packet.

4.5 Mechanical

4.5.1 Alternatives & Tradeoffs

Discus Buoy

Woods Hole Oceanographic Institute originally developed discus buoys for our specific task. They consist of 3 major components, which include the hull, the superstructure, and the substructure. The discus design allows it to easily move with waves providing a more accurate platform for wave height, period and direction. They are typically constructed using aluminum with zinc anodes attached to mitigate corrosion.

The Hull is typically where they house the electronics and batteries. The superstructure is usually of a tripod design with cross braces that allows for the attachment of sensors, solar panels, and antennas. The substructure improves upon the stability of the buoy to minimize pitch and roll and is attached to the bottom of the hull. This is usually where the zinc anodes are attached for corrosion purposes.

Some advantages of discus buoys are there proven track record as they have been used by NOAA for many years, their ability to wave follow, and the ability to be modified easily by adding more sensors or solar panels to the superstructure.

The disadvantages however of discus buoys are the cost, due to the use of aluminum compared to PVC. They are also more susceptible to pitch and roll then that of a spar buoy, which can seriously effect communications shown by our testing.

Page 101: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

101

Figure 40 Typical Discus BuoySpar Buoy

Spar buoys are usually constructed with a wide variety of materials from polyurethane, to PVC (polyvinyl chloride), to aluminum. This was one of the key points for us selecting a spar buoy design to that of a discus buoy. PVC is easily available at many home improvement stores for relatively low cost and with no knowledge of welding needed it greatly simplified our construction

.

Page 102: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

102

Figure 41 Spar Buoy Design

4.5.2 Feasibility

To make sure that our buoy will be able to float we need to see how much water we have to displace. This can be easily done by using the weights of all of our components including the hull of our buoy to see how much displacement. To do this you need to find the total weight you will be housing inside the buoy.

Buoy Components Weight (grams)Structure or Hull 8470.1 gElectronics (GPS, PIC, board) 932.2 gSolar Panels (including mounts) 2727 gBatteries 4195.79 gTotal Weight = 16325.09 g

We know that one cubic foot of salt water weights approximately 64 pounds. Since our weights were originally measured in grams we can easily convert them over to pounds (1 pound = 453.59

Page 103: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

103

grams) so the total weight of the buoy in pounds is 35.99 pounds. This means we have to displace a half a cubic foot of water. This is easily achievable with a spar designed PVC buoy.

4.5.3 Design Documents

AutoCAD Drawing of Hull

5. Prototype Construction

Toward the end of the first semester, construction began on a proof of concept prototype. The prototype comprised an electrical system and a mechanical structure. The prototype was built from mostly components on hand in the C.A.P.E. lab. Consequently, the prototype is not an exact design implementation but rather a combination of substitute components. Nevertheless, the prototype serves as a trial implementation which can be incrementally improved upon and tested as development continues. Currently, the prototype’s electrical system can acquire GPS data and broadcast that data. However, further development was delayed due to technical difficulties with a PICStart Plus microcontroller programmer. Eventually, the team determined that the programmer’s firmware was outdated. Unfortunately, additional difficulties have prevented the necessary firmware upgrade. More time will be needed to rectify these problems.

On the other hand, the mechanical structure constitutes a fairly close approximation to the final buoy structural design. Moreover, the mechanical structure features an array of four solar panels mounted at its top. At the bottom, the mechanical structure provides a housing for the payload.

Page 104: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

104

5.1 Electrical System

The electrical system was built on a large breadboard. The electrical system featured an 18F4520 PIC 8-bit microcontroller, a GPS unit, a TNC/radio unit, a humidity sensor, a pressure sensor, a lead acid battery, and additional ICs and TTL logic.

5.1.1 Microcontroller

The microcontroller successfully ran test code that verified the functionality of the USART (Universal Synchronous Asynchronous Receive Transmit) port. This involved sending messages via the USART port to the TNC/radio unit for broadcast. Also, the test code managed the USART port to receive data strings from the GPS unit. Sensor test code was developed but was never actually tested on the microcontroller due to problems with the programmer.

5.1.2 GPS Unit

The GPS unit was a standard 5V device which would continuously stream NMEA (National Marine Electronics Association) strings once the receiver had acquired a sufficient signal. A NMEA string is an ASCII string that concatenates various position and time data fields. Typically, a NMEA string is parsed to extract certain data fields of interest.

5.1.3 TNC/Radio Unit

The TNC/Radio unit was an integrated unit that offered a serial port and power terminals. The unit required a 9V power source. Once powered on, the TNC/Radio unit would automatically transmit a 435MHz signal from incoming serial port data.

5.1.4 Lead Acid Battery

A 12V lead acid battery supplied the power to the prototype. The battery voltage was stepped down to 5V using a voltage regulator. This rudimentary power system made the prototype portable such that it could work outdoors. This was important because the GPS unit could not acquire a satellite signal inside the engineering building.

5.2 Buoy Structure

5.2.1 PVC Hull

The hull of the buoy is constructed out of off the shelf PVC parts that were purchased at a local hardware store. The enclosure for the electrical system is a t-pipe that has an outside diameter of

Page 105: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

105

6” and a length of 14” with a 4” opening on the top that was used for the mast. This 4” opening was converted over to a 1.5” buy a serious of converters so as to decrease its top weight.

5.2.2 Solar Panel Mounts

The solar power mounts were also made of PVC that was UV treated. The PVC was drilled out to decrease weight and bent so as to maximize sunlight. They were then mounted on top of the buoy and affixed with zip ties to prevent birds from landing on them.

5.2.3 Antenna

The antenna was constructed using non-braided copper wire and a SO-239 connector. This was joined by a BNC 50 ohm coaxial cable. The other end was then attached to the output of the radio.

6. Future Plans

6.1 Communications

6.1.1 Three-volt low power radio

As part of the teams specifications on building a buoy that will decrease design cost and increase sustainability the team has designed a low power radio that will help aid in decreasing the battery size and rating. It will cause no decrease in efficiency for transmitting or receiving either. It will be done using the schematic shown previously. We hope to construct and test this during our next semester so as to test our design.

6.1.2 TNC-X

The TNC-X will also be constructed next semester using the design of John Hansen the developer of the TNC-X. The parts are all accessible in the lab and should be constructed fairly easily. It will provide a lower power option over the TNC currently being used.

6.2 Power

6.2.1 - Solar Panel Efficiency.

The team is planning to run experiments to determine the efficiency of different solar panels used. Solar panel prices may increase accordingly with solar panel efficiency. The team plans to

Page 106: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

106

find a better efficient solar panel to be used on the final design. Currently generic solar panels are used in the project. These panels do not have a brand or a data sheet. This made it hard for the team to rely on this product. These cheap solar panels were used by the team with the objective of running some tests and getting a basic idea on how solar panels could be implemented on the project. Therefore further research will be done to implement a solar panel that will fit into the project’s needs and at the same time it will be efficient.

6.2.2 - Research Possibility of an entire system running at 3 volts.

The team is also planning to do some research in order to find a way of implementing a system that will run all on a same voltage. This idea was first introduced by one of the team’s mentors as a challenge. If this can be possible, the system will run on 3 volts, which alters the voltage of other subsystems. Currently the system runs on 12 volts and voltage regulators are used to power up subsystems like GPS that require only 5 volts. This will make our system consume less power. Regulators will still be needed since radio transmitters need more than 3 volts to function.

6.4 Command and Data Handling

6.4.1 Create Interface For 3rd Party Devices

Once the buoy’s core functionality is established, a standard port and interface will be designed for additional payload devices. These devices could range from extra sensors to science experiments to any sort of compatible peripheral. By plugging into a standard port, the device will be provided power, long-term memory storage, and satellite communication. The Data Gathering state will allow the device to schedule its tasks such that they will integrate into the buoy’s existing execution cycle. Through software, the device will designate which data it wants to upload to the satellite. Also, commands and data from the satellite can be forwarded to the device. Through this standard interface, new and creative functionality can easily be added to the buoy. This is similar to PCs that offer a standard interface for peripherals which can then expand and extend capabilities in unexpected ways.

6.5 Mechanical

6.5.1 Improve Buoy Stability

A key aspect to improving our communication reliability and success rate is to provide the most stable platform for the communication system. As our testing has shown antenna polarization has a major effect on our transmission success. With more testing and calculations we hope to improve upon our initial design.

6.5.2 Sensor Placement

Page 107: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

107

Currently our buoy is totally enclosed with no penetrations in the hull, this will have to change so as to take the environmental data that is needed. As our sensors are developed and tested we will have to discuss their placement and affect on stability. This will need more testing to make sure our hull has no water intrusion and that the sensors operate properly in there location and have no effect on stability.

7 Appendix

7.1 Wiki

As a way for the team to stay organized and the mentors to have access to our work the team created a wiki that allowed all users to upload there work. This allowed us to have a library of information each team member collected during our research phase and a place for our designs and schematics to be analyzed. This was of great help not only to the students working on the project but for our mentors who could easily access the work we have done so to ask questions or guide us.

Page 108: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

108

7.2 Source Code

// File: Main Function// Purpose: OBC State Machine// Created: 10/26/2008

#include <p18f4520.h>#include <stdlib.h>#include <usart.h>#include <delays.h>#include <string.h>

#pragma config OSC = HS /* Sets the oscillator mode to HS */#pragma config WDT = OFF /* Turns the watchdog timer off */#pragma config LVP = OFF /* Turns low voltage programming off */#pragma config DEBUG = OFF /* Compiles without extra debug code */

// OBC States#define WaitShortState 1#define WaitLongState 2#define AlohaState 3#define DataGatheringState 4#define DataTransmissionState 5#define LowPowerState 6

// Power States (Batteries)#define BattVoltageLow 0#define BattVoltageOK 1

// Time keeping#define hourComplete 15#define day24HoursComplete 24

void InitializeUSART();void InitializePorts();void LightLEDs();void EnableRadio();int powerOK();

Page 109: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

109

//Functions simulating each state.int waitShort();int waitLong();int aloha();void dataGathering();int dataTransmission();void lowPower();

void main(void){ int nextState; int previousState; //Start OBC state machine in "Data Gathering" state. nextState = DataGatheringState; previousState = WaitShortState;

InitializePorts(); EnableRadio(); InitializeUSART(); LightLEDs();

while(1) { switch(nextState) { case WaitShortState: previousState = nextState; nextState = waitShort(); break; case WaitLongState: previousState = nextState; nextState = waitLong(); break; case AlohaState: previousState = nextState; nextState = aloha(); break; case DataGatheringState: dataGathering(); //Return to previous state nextState = previousState; break; case DataTransmissionState: previousState = nextState; nextState = dataTransmission();

Page 110: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

110

break; case LowPowerState: lowPower(); //Return to previous state. nextState = previousState; break; }//end switch

}//end while

}//end main

void InitializeUSART(){

//Open USART for 1200 BaudOpenUSART ( USART_TX_INT_OFF &

USART_RX_INT_OFF &USART_ASYNCH_MODE &USART_EIGHT_BIT &USART_CONT_RX &USART_BRGH_LOW,129 );

}

void InitializePorts(){

LATD = 0x00;TRISD = 0x00;

}

void LightLEDs(){

LATDbits.LATD0 = 1;LATDbits.LATD1 = 1;

}

void EnableRadio(){

LATDbits.LATD6 = 1;}

int powerOK(){ //Sense battery voltage

Page 111: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

111

//if battery OK return BattVoltageOK; //else //return BattVoltageLow;}

int waitShort(){ static int countTill60Minutes = 0;

while(BusyUSART()); putrsUSART( "Wait Short State. \r\n" );

while(1) { if(!powerOK()) { return LowPowerState; }

//Wait "four minutes" Delay10KTCYx( 255 ); Delay10KTCYx( 255 ); Delay10KTCYx( 255 ); Delay10KTCYx( 255 );

countTill60Minutes++;

if(countTill60Minutes == hourComplete) { countTill60Minutes = 0; return DataGatheringState; } else { return AlohaState; }

}//end while}//end int waitShort()

int waitLong(){ static int countTill60Minutes = 0; static int countTill24Hours = 0;

Page 112: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

112

while(BusyUSART()); putrsUSART( "Wait Long State. \r\n" );

while(1) { if(!powerOK()) { return LowPowerState; }

//Wait "four minutes" Delay10KTCYx( 255 ); Delay10KTCYx( 255 ); Delay10KTCYx( 255 ); Delay10KTCYx( 255 );

countTill60Minutes++;

if(countTill60Minutes == hourComplete) { countTill60Minutes = 0; //Count every hour towards 24 hours. countTill24Hours++; return DataGatheringState; }

if(countTill24Hours == day24HoursComplete) { countTill24Hours = 0; return WaitShortState; }

}//end while

}//end int waitLong()

int aloha(){ int i; char incomingCharacter;

while(BusyUSART()); putrsUSART( "Aloha State. \r\n" );

//Send aloha.

Page 113: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

113

while(BusyUSART()); putrsUSART( "Aloha? \r\n" ); //Activate receive mode.

//Wait "thirty seconds" //Current loop and delay numbers //are just placeholders. for(i = 30; i > 0; i--) { if(DataRdyUSART()) { incomingCharacter = getcUSART(); //Check for arbitrary signal character //from satellite. if(incomingCharacter == '$') { return DataTransmissionState; } } Delay10KTCYx( 5 ); } // 30 seconds have expired and still no acknowledgement. return WaitShortState;}//end int aloha()

void dataGathering(){ while(BusyUSART()); putrsUSART( "Data Gathering State. \r\n" ); //Read GPS and Sensors. //Return to previous state.}//end void dataGathering()

int dataTransmission(){ while(BusyUSART()); putrsUSART( "Data Transmission State. \r\n" );

while(BusyUSART()); putrsUSART( "Transmitting Data... \r\n" );

return WaitLongState;}//end int dataTransmission()

void lowPower(){

Page 114: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

114

while(BusyUSART()); putrsUSART( "Low Power State. \r\n" ); //We need more power states. The connecting and disconnecting //of solar panels needs to be finely controlled, instead of //waiting for very low batteries.

//Suggested Battery States: //HIGH HIGH = Overcharged //HIGH = Full Charge //LOW = Weak Charge //LOW LOW = Almost Dead

//Ensure solar panels are connected and charging.

//Then wait for power to become OK. while(!powerOK());}

USART code

// File: Main Function// Purpose: Test USART Functions// Created: 04/11/2008// Tested: 04/13/2008 : Verified

#include <p18f4520.h>#include <stdlib.h>#include <usart.h>#include <delays.h>#include <string.h>

#pragma config OSC = HS /* Sets the oscillator mode to HS */#pragma config WDT = OFF /* Turns the watchdog timer off */#pragma config LVP = OFF /* Turns low voltage programming off */#pragma config DEBUG = OFF /* Compiles without extra debug code */

void InitializeUSART();void InitializePorts();void LightLEDs();void EnableRadio();

void InitializeUSART(){

Page 115: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

115

//Open USART for 1200 BaudOpenUSART ( USART_TX_INT_OFF &

USART_RX_INT_OFF &USART_ASYNCH_MODE &USART_EIGHT_BIT &USART_CONT_RX &USART_BRGH_LOW,129 );

}

void InitializePorts(){ // All PORT D Pins Are Set As Outputs LATD = 0x00;

TRISD = 0x00;

}

void LightLEDs(){

LATDbits.LATD0 = 1;LATDbits.LATD1 = 1;

}

// Enable AND Gate For Multiplexing Radio/GPSvoid EnableRadio(){

LATDbits.LATD6 = 1;

}

void main(void){

InitializePorts();EnableRadio();InitializeUSART();

LightLEDs();

while(1){

while(BusyUSART());

Page 116: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

116

putrsUSART( "Hello World!\r\n" );

Delay10KTCYx( 255 );Delay10KTCYx( 255 );Delay10KTCYx( 255 );Delay10KTCYx( 255 );

}

}

GPS Code

// File: main_gps.c// Purpose: Test GPS Functions// Created: 04/11/2008// Tested: 04/15/2008 Test Passed

// This code should grab $GPGGA strings from the GPS and output those strings// to the USART, which will be connected to Hyperterminal.

/****************************************************************************************// GPS String: $GPGGA,hhmmss.ss,ddmm.mmmm,n,dddmm.mmmm,e,q,ss,y.y,a.a,z,g.g,z,t.t,iii*CC// hhmmss.ss in UTC (coordinated universal time zone). UTC used be known as GMT.// ddmm.mmmm,N latitude of the GPS position fix// dddmm.mmmm,W longitude of the GPS position fix// q quality of the GPS fix (1 = fix, but no differential correction)// ss number of satellites being used// y.y horizontal dillution of precision// a.a,M GPS antenna altitude in meters// g.g,M geoidal separation in meters// t.t age of the deferrential correction data// iiii deferential station's ID// *CC checksum for the sentence****************************************************************************************/

Page 117: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

117

#include <p18f4520.h>#include <stdlib.h>#include <usart.h>#include <delays.h>#include <string.h>

#pragma config OSC = HS /* Sets the oscillator mode to HS */#pragma config WDT = OFF /* Turns the watchdog timer off */#pragma config LVP = OFF /* Turns low voltage programming off */#pragma config DEBUG = OFF /* Compiles without extra debug code */

#define GPS_BUFFER_LENGTH 100

void InitializeUSART_GPS();void InitializeUSART_Radio();void InitializePorts();void LightLEDs();void OffLEDs();void EnableRadio();void EnableGPS();void ReadGPS( char * GPS_buffer );void PrintToUSART(char * buffer);void ParseGPS(char * buffer);void PrintTime(char * buffer);void PrintLocation(char * GPS_str);

void InitializeUSART_GPS(){

//Open USART for 4800 BaudOpenUSART ( USART_TX_INT_OFF &

USART_RX_INT_OFF &USART_ASYNCH_MODE &USART_EIGHT_BIT &USART_CONT_RX &USART_BRGH_LOW,31 );

}

void InitializeUSART_Radio(){

//Open USART for 1200 BaudOpenUSART ( USART_TX_INT_OFF &

USART_RX_INT_OFF &

Page 118: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

118

USART_ASYNCH_MODE &USART_EIGHT_BIT &USART_CONT_RX &USART_BRGH_LOW,129 );

}

void InitializePorts(){

LATD = 0x00;TRISD = 0x00;

}

void LightLEDs(){

LATDbits.LATD0 = 1;LATDbits.LATD1 = 1;

}

void OffLEDs(){

LATDbits.LATD0 = 0;LATDbits.LATD1 = 0;

}

void EnableRadio(){

LATDbits.LATD7 = 0;LATDbits.LATD6 = 1;

}

void EnableGPS(){

LATDbits.LATD6 = 0;LATDbits.LATD7 = 1;

}

void ReadGPS( char * GPS_buffer ){ char compareGGA[] = "$GPGGA"; int stringPosition;

int count;int prefix_is_GGA;

int loop_done;

Page 119: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

119

prefix_is_GGA = 0;loop_done = 0;

// Grab a $GPGGA string. // Only exit do-while once a $GPGGA string is found.

do{while(!DataRdyUSART());GPS_buffer[0] = ReadUSART();

// Is char from USART the beginning of a string?if( GPS_buffer[0] == '$' ){

// Collect the next 5 chars of GPS stringfor(count = 1; count < 6; count++){

while(!DataRdyUSART());GPS_buffer[count] = ReadUSART();

}

// Is this the $GPGGA string? if ( strncmp(GPS_buffer, compareGGA, 6) == 0 ) { loop_done = 1; }

}// end if $

}while(!loop_done);

// Get the rest of the GPS string. // End after the newline character. do{ while(!DataRdyUSART()); GPS_buffer[count] = ReadUSART(); count++; }while( GPS_buffer[count] != '\n' );

count++;

// Terminate string with NULL character. GPS_buffer[count] = 0x00;

}

void ParseGPS(char * buffer){

Page 120: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

120

// Not yet implemented.

}

void PrintToUSART(char * buffer){ putsUSART(buffer);}

void PrintTime(char * GPS_str){ char hours[3]; char minutes[3]; char seconds[3];

hours[0] = GPS_str[7]; hours[1] = GPS_str[8]; hours[2] = 0x00;

minutes[0] = GPS_str[9]; minutes[1] = GPS_str[10]; minutes[2] = 0x00;

seconds[0] = GPS_str[11]; seconds[1] = GPS_str[12]; seconds[2] = 0x00;

putrsUSART("The time is "); PrintToUSART(hours); putrsUSART(" hours, "); PrintToUSART(minutes); putrsUSART(" minutes, and "); PrintToUSART(seconds); putrsUSART(" seconds.\r\n");

}

void PrintLocation(char * GPS_str){ char longitude_degrees[3]; char longitude_minutes[3]; char longitude_direction[2];

char latitude_degrees[3]; char latitude_minutes[3]; char latitude_direction[2];

Page 121: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

121

longitude_degrees[0] = GPS_str[18]; longitude_degress[1] = GPS_str[19]; longitude_degrees[2] = 0x00;

longitude_minutes[0] = GPS_str[20]; longitude_minutes[1] = GPS_str[21]; longitude_minutes[2] = 0x00;

longitude_direction[0] = GPS_str[28]; longitude_direction[1] = 0x00;

latitude_degrees[0] = GPS_str[18]; latitude_degress[1] = GPS_str[19]; latitude_degrees[2] = 0x00;

latitude_minutes[0] = GPS_str[20]; latitude_minutes[1] = GPS_str[21]; latitude_minutes[2] = 0x00;

latitude_direction[0] = GPS_str[28]; latitude_direction[1] = 0x00;

putrsUSART("Coordinates:\r\n"); putrsUSART("Longitude: "); PrintToUSART(longitude_degrees); putrsUSART(" degrees, "); PrintToUSART(longitude_minutes); putrsUSART(" minutes, "); PrintToUSART(longitude_direction);

putrsUSART("\r\nLatitude: "); PrintToUSART(latitude_degrees); putrsUSART(" degrees, "); PrintToUSART(latitude_minutes); putrsUSART(" minutes, "); PrintToUSART(latitude_direction); putrsUSART("\r\n");

}

void main(void){ char GPS_string[GPS_BUFFER_LENGTH];

InitializePorts();

Page 122: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

122

while(1) {

EnableGPS(); InitializeUSART_GPS(); ReadGPS( GPS_string ); CloseUSART();

EnableRadio(); InitializeUSART_Radio(); PrintToUSART( GPS_string ); PrintTime( GPS_string ); PrintLocation( GPS_string);

CloseUSART();

LightLEDs(); Delay10KTCYx( 255 ); Delay10KTCYx( 255 ); Delay10KTCYx( 255 ); Delay10KTCYx( 255 ); OffLEDs();

}}

Page 123: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

123

Sensor Code

// File: Sensor_test.c// Purpose: Test Sensor Functions// Created: 04/18/2008// Tested:

#include <p18f4520.h>#include <stdlib.h>#include <usart.h>#include <adc.h>#include <delays.h>#include <string.h>

#pragma config OSC = HS /* Sets the oscillator mode to HS */#pragma config WDT = OFF /* Turns the watchdog timer off */#pragma config LVP = OFF /* Turns low voltage programming off */#pragma config DEBUG = OFF /* Compiles without extra debug code */

void InitializeUSART();void InitializePorts();void LightLEDs();void EnableRadio();void InitializeSensors();float GetPressure();float GetHumidity();void PrintFloatToUSART(float value);

Page 124: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

124

void InitializeUSART(){

//Open USART for 1200 BaudOpenUSART ( USART_TX_INT_OFF &

USART_RX_INT_OFF &USART_ASYNCH_MODE &USART_EIGHT_BIT &USART_CONT_RX &USART_BRGH_LOW,129 );

}

void InitializePorts(){ // All PORT D Pins Are Set As Outputs LATD = 0x00;

TRISD = 0x00;

}

void LightLEDs(){

LATDbits.LATD0 = 1;LATDbits.LATD1 = 1;

}

// Enable AND Gate For Multiplexing Radio/GPSvoid EnableRadio(){

LATDbits.LATD6 = 1;

}

void InitializeSensors(){ TRISA = 0xFF;

OpenADC( ADC_FOSC_8 & ADC_RIGHT_JUST & ADC_12_TAD, ADC_CH0 & ADC_INT_OFF, 0 );

Delay10TCYx( 5 );

Page 125: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

125

}// Start Pressure Codefloat GetPressure(){

int value;float voltage;float pressure;

SetChanADC( ADC_CH0 );

Delay10TCYx( 5 );

ConvertADC();

while( BusyADC() );

value = ReadADC();

voltage = ( ( ((float)value)/1023 ) * 5 );

pressure = ( (1/.009)( (voltage/5) + .095 ) );

return pressure;} //End Pressure Code

// Start Humidity Codefloat GetHumidity(){ int value; float voltage; float humidity;

SetChanADC( ADC_CH1 );

Delay10TCYx( 5 );

ConvertADC();

while( BusyADC() );

value = ReadADC();

voltage = ( ( ((float)value)/1023 ) * 5 );

humidity = ( (1/.0062)( (voltage/5) - 0.16 ) );

Page 126: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

126

return humidity;} // End Humidity Code

void PrintFloatToUSART(float value){

int integer;integer = (int)value;char value_str[20];

value_str = itoa( integer, value_str );

putsUSART( value_str );

}

// File: main_gps.c// Purpose: Test GPS Functions// Created: 04/11/2008// Tested: 04/15/2008 Test Passed

// This code should grab $GPGGA strings from the GPS and output those strings// to the USART, which will be connected to Hyperterminal.

/****************************************************************************************// GPS String: $GPGGA,hhmmss.ss,ddmm.mmmm,n,dddmm.mmmm,e,q,ss,y.y,a.a,z,g.g,z,t.t,iii*CC// hhmmss.ss in UTC (coordinated universal time zone). UTC used be known as GMT.// ddmm.mmmm,N latitude of the GPS position fix// dddmm.mmmm,W longitude of the GPS position fix// q quality of the GPS fix (1 = fix, but no differential correction)// ss number of satellites being used// y.y horizontal dillution of precision// a.a,M GPS antenna altitude in meters// g.g,M geoidal separation in meters// t.t age of the deferrential correction data// iiii deferential station's ID// *CC checksum for the sentence****************************************************************************************/

#include <p18f4520.h>

Page 127: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

127

#include <stdlib.h>#include <usart.h>#include <delays.h>#include <string.h>

#pragma config OSC = HS /* Sets the oscillator mode to HS */#pragma config WDT = OFF /* Turns the watchdog timer off */#pragma config LVP = OFF /* Turns low voltage programming off */#pragma config DEBUG = OFF /* Compiles without extra debug code */

#define GPS_BUFFER_LENGTH 100

void InitializeUSART_GPS();void InitializeUSART_Radio();void InitializePorts();void LightLEDs();void OffLEDs();void EnableRadio();void EnableGPS();void ReadGPS( char * GPS_buffer );void PrintToUSART(char * buffer);void ParseGPS(char * buffer);void PrintTime(char * buffer);void PrintLocation(char * GPS_str);

void InitializeUSART_GPS(){

//Open USART for 4800 BaudOpenUSART ( USART_TX_INT_OFF &

USART_RX_INT_OFF &USART_ASYNCH_MODE &USART_EIGHT_BIT &USART_CONT_RX &USART_BRGH_LOW,31 );

}

void InitializeUSART_Radio(){

//Open USART for 1200 BaudOpenUSART ( USART_TX_INT_OFF &

USART_RX_INT_OFF &USART_ASYNCH_MODE &USART_EIGHT_BIT &

Page 128: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

128

USART_CONT_RX &USART_BRGH_LOW,129 );

}

void InitializePorts(){

LATD = 0x00;TRISD = 0x00;

}

void LightLEDs(){

LATDbits.LATD0 = 1;LATDbits.LATD1 = 1;

}

void OffLEDs(){

LATDbits.LATD0 = 0;LATDbits.LATD1 = 0;

}

void EnableRadio(){

LATDbits.LATD7 = 0;LATDbits.LATD6 = 1;

}

void EnableGPS(){

LATDbits.LATD6 = 0;LATDbits.LATD7 = 1;

}

void ReadGPS( char * GPS_buffer ){ char compareGGA[] = "$GPGGA"; int stringPosition;

int count;int prefix_is_GGA;

int loop_done;

prefix_is_GGA = 0;loop_done = 0;

Page 129: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

129

// Grab a $GPGGA string. // Only exit do-while once a $GPGGA string is found.

do{while(!DataRdyUSART());GPS_buffer[0] = ReadUSART();

// Is char from USART the beginning of a string?if( GPS_buffer[0] == '$' ){

// Collect the next 5 chars of GPS stringfor(count = 1; count < 6; count++){

while(!DataRdyUSART());GPS_buffer[count] = ReadUSART();

}

// Is this the $GPGGA string? if ( strncmp(GPS_buffer, compareGGA, 6) == 0 ) { loop_done = 1; }

}// end if $

}while(!loop_done);

// Get the rest of the GPS string. // End after the newline character. do{ while(!DataRdyUSART()); GPS_buffer[count] = ReadUSART(); count++; }while( GPS_buffer[count] != '\n' );

count++;

// Terminate string with NULL character. GPS_buffer[count] = 0x00;

}

void ParseGPS(char * buffer){ // Not yet implemented.

Page 130: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

130

}

void PrintToUSART(char * buffer){ putsUSART(buffer);}

void PrintTime(char * GPS_str){ char hours[3]; char minutes[3]; char seconds[3];

hours[0] = GPS_str[7]; hours[1] = GPS_str[8]; hours[2] = 0x00;

minutes[0] = GPS_str[9]; minutes[1] = GPS_str[10]; minutes[2] = 0x00;

seconds[0] = GPS_str[11]; seconds[1] = GPS_str[12]; seconds[2] = 0x00;

putrsUSART("The time is "); PrintToUSART(hours); putrsUSART(" hours, "); PrintToUSART(minutes); putrsUSART(" minutes, and "); PrintToUSART(seconds); putrsUSART(" seconds.\r\n");

}

void PrintLocation(char * GPS_str){ char longitude_degrees[3]; char longitude_minutes[3]; char longitude_direction[2];

char latitude_degrees[3]; char latitude_minutes[3]; char latitude_direction[2];

longitude_degrees[0] = GPS_str[18];

Page 131: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

131

longitude_degrees[1] = GPS_str[19]; longitude_degrees[2] = 0x00;

longitude_minutes[0] = GPS_str[20]; longitude_minutes[1] = GPS_str[21]; longitude_minutes[2] = 0x00;

longitude_direction[0] = GPS_str[28]; longitude_direction[1] = 0x00;

latitude_degrees[0] = GPS_str[18]; latitude_degrees[1] = GPS_str[19]; latitude_degrees[2] = 0x00;

latitude_minutes[0] = GPS_str[20]; latitude_minutes[1] = GPS_str[21]; latitude_minutes[2] = 0x00;

latitude_direction[0] = GPS_str[28]; latitude_direction[1] = 0x00;

putrsUSART("Coordinates:\r\n"); putrsUSART("Longitude: "); PrintToUSART(longitude_degrees); putrsUSART(" degrees, "); PrintToUSART(longitude_minutes); putrsUSART(" minutes, "); PrintToUSART(longitude_direction);

putrsUSART("\r\nLatitude: "); PrintToUSART(latitude_degrees); putrsUSART(" degrees, "); PrintToUSART(latitude_minutes); putrsUSART(" minutes, "); PrintToUSART(latitude_direction); putrsUSART("\r\n");

}

void main(void){ char GPS_string[GPS_BUFFER_LENGTH];

InitializePorts();LightLEDs();

while(1)

Page 132: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

132

{

EnableGPS(); InitializeUSART_GPS(); ReadGPS( GPS_string ); CloseUSART();

EnableRadio(); InitializeUSART_Radio(); PrintToUSART( GPS_string ); PrintTime( GPS_string ); PrintLocation( GPS_string);

CloseUSART();

LightLEDs(); Delay10KTCYx( 255 ); Delay10KTCYx( 255 ); Delay10KTCYx( 255 ); Delay10KTCYx( 255 ); OffLEDs();

}}

Page 133: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

133

// Begin Wind Speed Code

#include <string.h>#include <timers.h>#include <usart.h>#include <stdio.h>#include <stdlib.h>#include <delays.h>#include <capture.h>

void WindSpeed(void);void WindSpeedCalc(int); //WindSpeedCalculationvoid PrintDouble(double);

void main(void){

TRISCbits.TRISC3 = 0; TRISCbits.TRISC4 = 0; TRISCbits.TRISC2 = 1; TRISB = 0xFF; //Timers. Timer3 is not used to detected the period because of its // maximum prescale value(1_8); 1/0.0000032 = 312500. // timer overload occurs when it reaches FFFF = 65535. When an // overload occurs the timer rolls back to 0000. // Note that: 1/0.0001024 = 9765, which is equivalent to 1 second.

Page 134: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

134

// Calling the Timer function, starts the timer. OpenTimer3(TIMER_INT_OFF & // Open Timer 3 for Capture routine

T3_16BIT_RW & T3_SOURCE_INT & T3_PS_1_8 & T3_SYNC_EXT_OFF & T3_SOURCE_CCP); OpenTimer0(TIMER_INT_OFF & // Open Timer T0_16BIT & T0_SOURCE_INT & T0_PS_1_256); OpenCapture1( C1_EVERY_RISE_EDGE & CAPTURE_INT_OFF );

OpenUSART( USART_ASYNCH_MODE & USART_EIGHT_BIT & USART_TX_INT_OFF & USART_RX_INT_OFF & USART_CONT_RX & USART_BRGH_HIGH,64); putrsUSART("Turn On");

WindSpeed();

} void WindSpeed(void){ int count = 0; char str[6]; unsigned int time, timeSix, zeroOrNot, timeEnd; time = zeroOrNot = timeEnd = 0; timeSix = 0; // Restart Timers WriteTimer3(0x0000); WriteTimer0(0x0000); // wait here if Capture flag as not been set // that is, wait here until the wind cup rotates // over hall effect magnet. while(!PIR1bits.CCP1IF) { PIE1bits.CCP1IE = 0; WriteTimer3(0x0000);

Page 135: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

135

timeSix = ReadTimer0(); // if time exceeds 6 seconds and still in loop then // wind speed is equal to 0. 9765 * 6 = 58596 if(timeSix > 58596) //if waited for 6 sec {

zeroOrNot = 1; putrsUSART("The Wind Speed is: "); WindSpeedCalc(0); putsUSART(" meters/second\n\r"); break; } } // flag stays on, so it is necessary to turn it off. PIR1bits.CCP1IF = 0;

// Restart timers WriteTimer3(0x0000); WriteTimer0(0x0000); timeSix = 0; if (zeroOrNot != 1) // if wind speed is not zero meters/second { while(!PIR1bits.CCP1IF) { PIE1bits.CCP1IE = 0; WriteTimer3(0x0000); timeSix = ReadTimer0(); // if waited here for six seconds. Wind speed = 0; if (timeSix > 58596) { putrsUSART("The Wind Speed is: "); WindSpeedCalc(0); putsUSART(" meters/second\n\r"); break; } } } time = ReadTimer0(); putrsUSART("The Wind Speed is: ");

Page 136: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

136

WindSpeedCalc(time); putsUSART(" meters/second\n\r"); WriteTimer3(0x0000); WriteTimer0(0x0000); PIR1bits.CCP1IF = 0; }

void WindSpeedCalc(int time) //WindSpeedCalculation { double period, windSpeed; period = 0; period = time*(double)0.0001024; windSpeed = (2*3.141592654*(1/period))*0.053; //0.053 radius of cups; putrsUSART("The WindSpeed is "); PrintDouble(windSpeed); putrsUSART("\n\r"); }

void PrintDouble(double f){

char str[6];int whole = (int)f;int frac = (f - (int)f) * 10000;putsUSART(itoa(whole, str));putrsUSART(".");putsUSART(itoa(frac, str));

}/////End Wind Speed Code

Page 137: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

137

////Begin DS1621 I2C Temperature Sensor codeinclude <p18f452.h>#include <usart.h>#include <i2c.h> #include <delays.h>#include <stdlib.h>#include <stdio.h>#include <string.h>

#pragma config OSC = HS#pragma config WDT = OFF#pragma config LVP = OFF

char TempMSB ,TempLSB;char tempstring[10];

//temperature conversion variablesdouble FahrenheitTempMSB;int FahrenheitTempMSBInt;char FahrenheitTempMSBDeci; void READTEMP(void);void CelsuisTempPrint(void);void FahrenheitTempPrint(void);void GetTemp(void); void main(void){

Page 138: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

138

FahrenheitTempMSB = 0.00; TempMSB = TempLSB = 0; FahrenheitTempMSBInt = FahrenheitTempMSBDeci = 0.00; TRISC = 0x00; // turn on tri-state register and // make all output pins PORTC = 0x00; // make all output pin LOW OpenUSART( USART_ASYNCH_MODE & USART_EIGHT_BIT & USART_TX_INT_OFF & USART_RX_INT_OFF & USART_CONT_RX & USART_BRGH_LOW,129); OpenI2C(MASTER, SLEW_OFF); SSPADD = 0x3F; // set baud rate

// Setting the configuration for continuous conversion //----------------------------------------------------

StartI2C(); IdleI2C(); //Set I2C idle until an event occurs WriteI2C(0x90); // set slave address 'b1-b3'->'000'. IdleI2C(); WriteI2C(0xAC); //open config register IdleI2C(); WriteI2C(0x02); // set config to continous converstion without // TL and TH and High polarity for byte output IdleI2C();

// Start temperature conversion//-----------------------------

RestartI2C(); IdleI2C(); WriteI2C(0x90); IdleI2C(); WriteI2C(0xEE); IdleI2C(); StopI2C(); //----------------------------- READTEMP();

Page 139: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

139

}

void READTEMP(void){

Delay10KTCYx(200); // This Delay is NECCESSARY to give time for necessary conversions

while(1){

// Read temperature//-----------------

StartI2C(); IdleI2C(); WriteI2C(0x90); IdleI2C(); WriteI2C(0xAA); IdleI2C(); RestartI2C(); IdleI2C(); WriteI2C(0x91);

IdleI2C(); TempMSB = ReadI2C(); //Read Temperature: First Byte IdleI2C(); AckI2C(); //The slaves sends an acknowledge // to the master to indicate that it //has finished reading the temperature. //When an acknowledge is sent, and extra //pulse bit is created IdleI2C(); TempLSB = ReadI2C(); //Read Temperature: Second Byte IdleI2C(); NotAckI2C(); //Indicates that there is no more data // that would be read IdleI2C(); StopI2C(); //-------------------------

CelsuisTempPrint(); FahrenheitTempPrint();

//----------------------------------

Page 140: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

140

// Enter and Start on newline on hyperterminal putcUSART( 0x0A ); //Equivalent to \n while(BusyUSART()); putcUSART( 0x0D ); //Equivalent to \r while(BusyUSART()); //---------------------------------- FahrenheitTempMSB = (9.00/5)*TempMSB + 32;

Delay10KTCYx(200); }

}

void CelsuisTempPrint(void){ //--------------------------------- // TEMPERATURE OUTPUT with Temperature RESOLUTION 1 degree Celsius

btoa(TempMSB, tempstring); putrsUSART("THE TEMPERATURE IS "); while(BusyUSART()); putsUSART( tempstring ); while(BusyUSART()); putrsUSART(" Degree Celsius"); //----------------------------------

}

void FahrenheitTempPrint(void){

//Convert Celsius Temperature to Fahrenheit

putrsUSART("\n\rConverting ... \n\r");while(BusyUSART());

FahrenheitTempMSB = (9.00/5)* TempMSB + 32; // Allow 2 decimal places to print on hyperterminal FahrenheitTempMSBInt = FahrenheitTempMSB; FahrenheitTempMSBDeci = (FahrenheitTempMSB * 100) - (FahrenheitTempMSBInt*100); // Temperature output in Fahrenheit itoa(FahrenheitTempMSB,tempstring); putrsUSART("The temperature is ");

Page 141: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

141

while(BusyUSART()); putsUSART(tempstring); while(BusyUSART()); putrsUSART("."); while(BusyUSART()); itoa(FahrenheitTempMSBDeci, tempstring); putsUSART(tempstring); while(BusyUSART()); putrsUSART(" Degree Fahrenheit \n\r"); while(BusyUSART()); }//End DS1621 I2C Temperature Sensor Code

// File: Sensor_test.c// Purpose: Test Sensor Functions// Created: 04/18/2008// Revised: 10/18/2008 : Changed InitializeSensors();

#include <p18f4520.h>#include <stdlib.h>#include <usart.h>#include <adc.h>#include <delays.h>#include <string.h>

#pragma config OSC = HS /* Sets the oscillator mode to HS */#pragma config WDT = OFF /* Turns the watchdog timer off */#pragma config LVP = OFF /* Turns low voltage programming off */#pragma config DEBUG = OFF /* Compiles without extra debug code */

void InitializeUSART(void);void InitializePorts(void);void LightLEDs(void);void EnableRadio(void);void InitializeSensors(void);float GetPressure(void);float GetHumidity(void);void PrintFloatToUSART(float value);

Page 142: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

142

void main(void){

float humidity;float pressure;

InitializePorts();InitializeSensors();EnableRadio();InitializeUSART();

LightLEDs();

while(1){

while(BusyUSART());

putrsUSART("Sensor Testing!\r\n");

Delay10KTCYx( 255 );Delay10KTCYx( 255 );Delay10KTCYx( 255 );Delay10KTCYx( 255 );

pressure = GetPressure();humidity = GetHumidity();while(BusyUSART());putrsUSART("Pressure: ");while(BusyUSART());PrintFloatToUSART( pressure );while(BusyUSART());putrsUSART(" kPa\r\n");while(BusyUSART());putrsUSART( "Humidity: ");while(BusyUSART());PrintFloatToUSART( humidity );while(BusyUSART());putrsUSART( " %\r\n" );

}//end while(1)}//end main()

void InitializeUSART(){

//Open USART for 1200 BaudOpenUSART ( USART_TX_INT_OFF &

Page 143: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

143

USART_RX_INT_OFF &USART_ASYNCH_MODE &USART_EIGHT_BIT &USART_CONT_RX &USART_BRGH_LOW,129

);}

void InitializePorts(){ // All PORT D Pins Are Set As Outputs LATD = 0x00;

TRISD = 0x00;}

void LightLEDs(){

LATDbits.LATD0 = 1;LATDbits.LATD1 = 1;

}

// Enable AND Gate For Multiplexing Radio/GPSvoid EnableRadio(){

LATDbits.LATD6 = 1;}

void InitializeSensors(){ TRISA = 0xFF;

OpenADC( ADC_FOSC_8 & ADC_RIGHT_JUST & ADC_12_TAD, ADC_CH0 & ADC_INT_OFF, 0

); // Set VREF+ to VDD and VREF- to VSS ADCON1 = 0x00;

Delay10TCYx( 5 );}

float GetPressure()

Page 144: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

144

{int value;float voltage;float pressure;

char buffer[8];

SetChanADC( ADC_CH0 );

Delay10TCYx( 5 );

ConvertADC();

while( BusyADC() );

value = ReadADC();

itoa(value, buffer);

putrsUSART("Pressure raw: "); putsUSART( buffer ); putrsUSART("\r\n");

voltage = ( ( ((float)value)/1023 ) * 5 );

pressure = ( (1/.009)*( (voltage/5) + .095 ) );

return pressure;}

float GetHumidity(){ int value; float voltage; float humidity; char buffer[8];

SetChanADC( ADC_CH1 );

Delay10TCYx( 5 );

ConvertADC();

while( BusyADC() );

value = ReadADC();

Page 145: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

145

itoa(value, buffer); putrsUSART("Humidity raw: "); putsUSART( buffer ); putrsUSART("\r\n");

voltage = ( ( ((float)value)/1023 ) * 5 );

humidity = ( (1/.0062)*( (voltage/5) - 0.16 ) );

return humidity;}

void PrintFloatToUSART(float value){

int integer; char value_str[20];

integer = (int)value;

itoa( integer, value_str );

putsUSART( value_str );}

Page 146: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

146

// File: Main Function// Purpose: Test AX.25 Frames// Created: 11/7/2008

#include <p18f4520.h>#include <stdlib.h>#include <usart.h>#include <delays.h>#include <string.h>

#pragma config OSC = HS /* Sets the oscillator mode to HS */#pragma config WDT = OFF /* Turns the watchdog timer off */#pragma config LVP = OFF /* Turns low voltage programming off */#pragma config DEBUG = OFF /* Compiles without extra debug code */

#define FrameSize 21

void InitializeUSART();void InitializePorts();void LightLEDs();void EnableRadio();

void main(void){ // Destination: CQ // Source: KE5SAC // Control: 0x03 // PID: 0xF0 // Message: Test // Size: 21 Bytes char ax25Frame[] = {0xC0, 0x00, 0x86, 0xA2, 0x40, 0x40, 0x60, 0x96, 0x8A, 0x6A, 0xA6, 0x82, 0x86, 0x61, 0x03, 0xF0, 0x54, 0x65, 0x73, 0x74, 0xC0};

// Loop iteration variable

Page 147: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

147

int i;

InitializePorts();EnableRadio();InitializeUSART();LightLEDs();

while(1){

for(i = 0; i < FrameSize; i++) {

while(BusyUSART()); WriteUSART(ax25Frame[i]); }

Delay10KTCYx( 255 );Delay10KTCYx( 255 );Delay10KTCYx( 255 );Delay10KTCYx( 255 );

}}

void InitializeUSART(){

//Open USART for 1200 BaudOpenUSART ( USART_TX_INT_OFF &

USART_RX_INT_OFF &USART_ASYNCH_MODE &USART_EIGHT_BIT &USART_CONT_RX &USART_BRGH_LOW,129 );

}

void InitializePorts(){

LATD = 0x00;TRISD = 0x00;

}

void LightLEDs(){

LATDbits.LATD0 = 1;

Page 148: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

148

LATDbits.LATD1 = 1;}

void EnableRadio(){

LATDbits.LATD6 = 1;

}

7.3 Data Sheets

TX1H

(Vcc = 3.8V / temperature = 20°C unless stated)

General pin min. typ. max. units notes

 DC supplySupply voltage 5 3.8 - 15 VTX Supply current (at 100mW) 5 - 80 - mA Antenna pin impedance 2 - 50 -

RF centre frequency (100mW) - 151.300 - MHz

Channel spacing - 25 - kHzNumber of channels 1 TransmitterRFRF power output (100mW) 2 +19 +20 +21 dBm 1Spurious emissions (100mW) 2 - -40 - dBmAdja. channel TX power (100mW) - -37 - dBmFrequency accuracy - 2.5 0 +2.

5 kHz 2

FM deviation (peak) ±2.5 ±3.0 ±3.5 kHz 3

 BasebandModulation bandwidth @ -3dB 0 - 5 kHzModulation distortion (THD) TBA %TXD input level (logic low) 7 - 0 - V 4TXD input level (logic high) 7 - 3.0 - V 4 Dynamic timing

Page 149: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

149

TX select to full RF - 5 - ms Notes: 1. Measured into 50 resistive load.2. Total over full supply and temperature range.3. With 0V - 3.0V modulation input.4. To achieve specified FM deviation.

CVR-1

(Vcc = 3V / temperature = 20°C unless stated)

 RF centre frequency 173.225 (other VHF 120-180MHz by special order)Frequency stability +/- 2.5kHzChannel spacing 25Number of channels 1   Supply Voltage 3V (+/- 10% )                                       Current 7mA receive   Operating temperature -10°C to +60°C (Storage -30°C to +70°C)Size 33mm x 23mm x 8mmSpurious radiations Compliant with ETSI EN 300 220-3 and EN 301 489-3Interface  

User  9pin 0.1" pitch molexRF     3pin 0.1" pitch molex

   RF sensitivity @ 12dB SINAD -120dBmRF sensitivity @ 1ppm BER -115dBmRSSI range 60dBBlocking -85dB or betterImage rejection -60dB or betterAdjacent channel rejection -65dBSpurious response rejection -60dB or betterLO re-radiation -65dBm 

Page 150: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

150

BasebandBaseband bandwidth @ -3dB 5kHzAF level 500mVDC offset on AF out 0.8V   Outputs RSSI, Data, AF

TNC-X Parts

Capacitors: C1 10 uf C3 100 pf C2, C4, C5, C6 .1 ufC11, C14, C15, C16 .1 ufC17, C18, C19 .1 ufC20, C21, and C22 .1 ufC7, C8 . 1 uf C9, C10 18 pf C12, C13 22 pf

Resistors:R1, R2, R3 100k ohmR8 24,9 K ohm 1% R9 9.31K ohm 1% R10 18.7K ohmR11, R16 and R18, R20 10k ohm R12, R13 10k ohm potentiometer R14 6.8k ohm R4, R15, R17 and R19 1k ohm

Diodes:D1 green LED D2 1N4001 D4 red LED

Page 151: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

151

D5 yellow LED

Headers, Jumpers:JP1, JP2, JP3 2 Pin HeaderJP4 3 Pin HeaderJP5 8 Pin Header

Other:X1 3.57 MHz Crystal X2 20 MHz Crystal Q1 NPN Transistor U1 CML 614 Modem Chip - 16 pin U2 FM25640 FRAM memory chip - 8 pin U3 PIC16F628A (or PIC16F648A) - 18 pin U4 MPC6023 Op Amp - 8 pin U5 MAX232A, ST232A or similar - 16 pin U6 78L05 Voltage Regulator - 3 pin

Page 152: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

152

7.4 Schematics

Page 153: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

153

Page 154: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

154

Page 155: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

155

Page 156: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

156

Page 157: I - Wikispacesbuoycape.wikispaces.com/file/view/Final_Report_II_Rev_6.doc · Web viewEach packet will correspond to one hour’s worth of data. The data packet will include date,

157