massey university - Engineering and Advanced Technology

Transcription

massey university - Engineering and Advanced Technology
MASSEY UNIVERSITY SCHOOL OF ENGINEERING AND ADVANCED TECHNOLOGY Engineering Project Submitted as part requirement for B.Eng (hons). R/C Longline System Part A Abraham Jadaan 2010 SUPERVISORS Gourab Sen Gupta Subhas Mukhopadhyay Summary This report will explain the research implemented into the design, testing of the R/C Kontiki system. The Kontiki system when complete will be controlled wirelessly using the zigbee wireless protocol suite; this will differentiate it from other kontiki systems as it is controlled wirelessly while the other commercial systems are turned on beforehand, and launched into the sea using a timer device which is set to determine how long the kontiki system motor is on roughly estimating the distance of where the kontiki system will stop. In terms of wireless communication I had chosen to utilize the zigbee protocol as it uses a small amount of power and has the advantage of long range communication. For zigbee configuration and testing, I had used the program XCTU using simple LED circuits and later used JAVA for debugging and finalizing my project. Beginning my project, I made a list of factors which I needed to take into account when building my own Kontiki system. I used different methods for switching the motor on and off before choosing the most suitable method and implementing it within my project. The next stage in this project will be researching and implementing features which would improve the overall performance and design. 1 Table of Contents Summary ............................................................................................................................ 1 1 Introduction ............................................................................................................... 4 2 Background ................................................................................................................ 5 2.1 What is Kontiki fishing ..................................................................................................... 5 2.2 What is a zigbee ................................................................................................................ 6 2.3 2.2 Choosing a zigbee ....................................................................................................... 6 2.4 XBee Explorer .................................................................................................................. 7 2.5 Why I am using zigbee ..................................................................................................... 8 2.5.1 Zigbee protocol advantages ........................................................................................... 8 2.6 What is a protocol suite..................................................................................................... 8 2.7 Labelled parts of a boat ..................................................................................................... 9 3 System Design .......................................................................................................... 10 3.1 System Overview ............................................................................................................ 10 3.1.1 Base Station ................................................................................................................. 11 3.2 Computer......................................................................................................................... 12 3.2.1 Graphical User Interface ............................................................................................. 12 3.2.2 X-CTU Testing ............................................................................................................ 13 3.2.3 Configuration Of Zigbees Using X-CTU .................................................................... 20 3.2.3.1 XBee Coordinator Configuration ............................................................................ 20 3.2.3.2 XBee End Device Configuration ................................................................................... 22 3.2.3.3 Why API mode .............................................................................................................. 23 4 Control Box .............................................................................................................. 24 4.1 Different Methods of Approach of Building Motor Driver Circuit ................................ 24 4.1.1 Method One: Relay Controller .................................................................................... 24 4.1.2 Method Two: Solenoid Switch.................................................................................... 26 4.1.3 Method Three: Simple Relay Circuit .......................................................................... 27 Figure 29 Simple Relay Circuit with Zigbee ............................................................................. 28 Figure 29 Simple Relay Circuit PCB ........................................................................................ 28 4.2 Preferred Method ............................................................................................................ 29 5 Kontiki System ......................................................................................................... 30 5.1 Features taken into account when designing the kontiki system .................................... 30 5.2 Kontiki system designing process................................................................................... 32 5.2.1 Advantages and disadvantages of different hull types ..................................................... 32 5.2.2 Initial CAD design of kontiki system ............................................................................... 33 Figure 30 CAD Kontiki Fishing System Design ....................................................................... 33 5.3 Motor............................................................................................................................... 34 5.3.1 Kontiki Motor.............................................................................................................. 34 Figure 31 Mercury Motor .......................................................................................................... 34 5.3.2 An alternative to launch the kontiki from the shore .................................................... 35 5.3.2.1 Bilge pump .............................................................................................................. 35 5.3.2.2 Sea Scooter .............................................................................................................. 36 5.1.1 Motor On GUI Code .................................................................................................. 37 5.1.2 Motor Off GUI Code .................................................................................................. 37 6 Results ....................................................................................................................... 38 2 7 Future Research and Recommendations ............................................................... 39 8 Conclusion ................................................................................................................ 40 9 Glossary .................................................................................................................... 41 10 Reference .................................................................................................................. 42 11 Appendices ............................................................................................................... 43 Appendix A: Project Proposal ................................................................................................... 44 Appendix B: Datasheet for the zigbee XBee Series 1 ............................................................... 52 Appendix C: Datasheet for the zigbee XBee Series 2 ............................................................... 53 Appendix D: Coordinator Configuration ................................................................................... 54 Appendix E: End Device Configuration .................................................................................... 56 Appendix F: Relay Datasheet .................................................................................................... 58 Appendix G: GUI Code ............................................................................................................. 60 Appendix H: Main Code............................................................................................................ 63 3 1
Introduction The aim of this project is to design and build a remote control kontiki fishing system also known as a long line fishing system. The R/C kontiki system share many similar features to the commercial kontiki system. It is expected that while designing my version of the kontiki system, I had to take into account some of the features required when building my own Kontiki keeping in mind the limited budget of $300 dollars supplied for my project. Kontiki fishing systems usually range from $1500 to 4000 NZD. Purchasing separate parts for my project was difficult seeing it was near impossible to keep within the supplied budget limit; the water proof mercury motor alone cost from $300 to 400 NZD. After doing some research, I came to the conclusion that I could use a seascooter instead which included everything I needed such as a waterproof motor, an airtight chamber, a buoyancy chamber, a battery, and a propeller guard, getting it all for a fraction of the price. For controlling the motor of the kontiki system; I made a Graphical User Interface (GUI) using Java, which enables the user to switch the motor on and off rather than having the standard commercial timer concept. The motor driver circuit is used as a switching device to switch the motor on and off. A GUI called X‐CTU was utilized to configure the zigbees which had to be done before programming in Java. These will be further discussed in this report. This report contains a detailed look at the system design, limitations, problems encountered with the project and ideas on future improvements and design s. 4 2
2.1
Background What is Kontiki fishing Also known as longline fishing; a fishing technique which uses a long, main line (usually 1km to 2km long) with branch lines, or snoods, with baited hooks (sometimes more than a 100). This technique is commonly used to catch tuna, swordfish, marlin, and sailfish. [1] The kontiki can be launched either from the shore or from a boat while at the sea and can be set using one of the two different methods depicted below: Figure 1 Pelagic Longline The first method is pelagic line fishing which is surface set. This comprises a mainline to which are attached branch lines, each fitted with one of more baited hooks or artificial lures. A pelagic longline is set so that mainline, branch lines and hooks are suspended above the seabed by floats at the sea surface. [2] Figure 2 Demersal Longline The second method is demersal line fishing which is bottom set. [2] 5 2.2
What is a zigbee It is a suite of high level communication protocols using small, low‐power digital radios based on WPAN such as Bluetooth, wireless headphones etc.. they are also being deployed in a wide range of markets such as: assisted living, asset tracking, medical etc. Figure 3 Zigbee protocol suite 2.3
2.2 Choosing a zigbee There are two zigbees available; the older zigbee is the XBee series 1 module which only has a point to point and multi‐point networking capability whereas the newer zigbee; the XBee series 2.5 module has a point to point, a multi‐point and a mesh networking capability. Figure 4 Mesh network Figure 5 Star Network “Mesh networking enables to increase the range, reliability (self‐healing) and formation of ad hoc networks where redundant paths are provided” hence is most commonly used these days. (H. Labiod, 2007) 6 Figure 6 XBee Series 1 Figure 7 XBee Series 2.5 The XBee series 2.5 also improves on the power output and data protocol. The XBee series 1 is not as popular nowadays and it cost roughly the same price as the XBee series 2.5 which is why I chose to use the XBee series 2.5 because it has better features that best suite my project. The XBee series 1 is utilized for testing to find out how to get a node‐to‐node communication going using the XBee Explorer USB. 2.4
XBee Explorer The XBee Explorer USB is a simple to use USB to serial base unit for the XBee line. Figure 8 XBee Explorer Interface The XBee Explorer USB is a simple to use, USB to serial base unit for the XBee line. Figure 9 Explorer with zigbee and USB cord 7 This unit works with all XBee modules including the Series 1 and Series 2.5, standard and Pro version. Plug the unit into the XBee Explorer, attach a mini USB cable, and you will have direct access to the serial and programming pins on the XBee unit. 2.5
Why I am using zigbee Referring to Appendix A (my project proposal); I had mentioned in my objectives section, that I chose the zigbee as my wireless data communication protocol suite; this is because the zigbee protocol is developed to address the common need of low‐cost, and low‐power wireless M2M networks. The zigbee protocol suite is mainly intended for low‐cost devices which operate using a battery and it allows these devices to communicate in a variety of network topologies having a battery life lasting several years. 2.5.1 Zigbee protocol advantages The design of the zigbee protocol enables it to communicate through some hostile RF environments which are quite common in commercial and industrial applications. A list of the advantageous zigbee protocol features which differentiates it from other protocol suites are as follows: ¾ Support for multiple network topologies such as point‐to‐point, point‐to‐multipoint and mesh networks ¾ Low duty cycle – provides long battery life ¾ Low latency ¾ Direct Sequence Spread Spectrum (DSSS) ¾ Up to 65,000 nodes per network ¾ 128‐bit AES encryption for secure data connections ¾ Collision avoidance, retries and acknowledgements 2.6
What is a protocol suite A protocol suite is a collection of communications procedures, broken down into small data packets. Each one of those small data packets, contain its own set of rules and message formats, which work together to transmit information electronically across computer networks, via a common communications language. 8 2.7
Labelled parts of a boat In this section, I provide a labeled boat covering all the essential parts that I had to learn while designing the kontiki system. Figure 10 Labeled boat Note that the names of the parts are consistent; even though boats come in different styles and shapes.
Figure 11 Front of boat As this conveyed by this figure, the freeboard is the distance from water to lowest point of the boat where water could come on board; the draft is the depth of water needed to float a vessel, and the 9 beam is the maximum width of a vessel. 3
3.1
System Design System Overview The electric longline I made consists of a computer, control box and a kontiki system (Figure 12) Figure 12 Flow chart of the electric longline A computer is needed to run Java, debugging it loads the graphical user interface. The GUI allows the user to have control of the kontiki system motor. The computer communicates with the control box wirelessly using two zigbee nodes; the GUI is utilized to send a users command from the Zigbee coordinator node which is either connected to the computer via a USB port for power or can connected to a 5V battery supply; to the Zigbee end device node which receives the users selected command completing the motor driver board controlling the switching of the motor driver. Hence, gaining wireless control of the kontiki systems’ motor, via a wireless protocol suite enabling the user to select the desired command of switching it ON or OFF. 10 Figure 13 System Overview The picture above displays the system overview which consists of a laptop, two zigbees; the coordinator which is connected to the laptop via a USB port attached to an XBee explorer board and the end device which is attached to the motor driver board inside the airtight chamber within the sea scooter. And a sea scooter; this is utilized as the main motor which is launched into the sea. 3.1.1 Base Station The base station consists of a Zigbee module programmed as the coordinator which transmits and receives data from the kontiki system (end device) wirelessly. As the coordinator continuously transmits and receives data from the end device, it is normally mains powered. Data is sent from the coordinator node is sent from the computer using the XBee explorer protocol and data is received by the end device switching it on or off using the built GUI on the base station. Figure 14 Block diagram of components in base station 11 3.2
Computer Any computer can be used with the electric kontiki given it has the following. ¾ USB inputs.
¾ Eclipse Classic 3.6.1, if code in the GUI is to be changed for further feature updates.
3.2.1 Graphical User Interface The Graphical User Interface (figure 14) has been written in Eclipse Classic 3.6.1. The GUI has been made as easy and intuitive as possible seeing there will be a variety of people with different levels of computer skills using the GUI. Figure 15 Graphical User Interface The operation of the GUI is explained below ¾ When the user selects the “Turn On” button, the motor of the electric kontiki system will
turn on wirelessly. ¾ When the user selects the “Turn Off” button, the motor of the electric kontiki system will
wirelessly turn off.
12 3.2.2 X‐CTU Testing The software X‐CTU, was downloaded from www.digi.com This software is used to configure and test MaxStream radio modems. Part of testing included having two laptops with zigbees; each zigbee attached to an XBee Explorer board which connects to the laptop through the USB inputs and downloading the X‐CTU software onto both of them; then using the terminal tab to communicate with one another and checking the RSSI with different ranges and placing each laptop in a different room. When X‐CTU is launched there will be four tabs across the top from which you can use for configuration of the zigbee protocol suite etc. Figure 16 PC Settings tab for X‐CTU GUI 13 This consists of the following: PC Setting: The COM port desired can be selected and configured to fit the radios settings. The PC Setting tab includes three options which are listed as follows: ¾ COM port setup: This tab supplies the capability of selecting the desired COM port to configure the selected COM port settings when accessing the port. ¾ The Test/Query button is also supplied to test the selected COM port and PC settings ¾ Host Setup: This tab supplies the capability of configuring how the X‐CTU program is to interface with a radio’s firmware. ¾ User COM ports: This tab supplies the option to select from either adding or deleting a user‐
created COM port. Note that this is only for temporary use while the X‐CTU program is running; once the program is closed, the user‐created COM port will disappear and is no longer be accessible to the program. 14 Figure 17 Range Test tab for X‐CTU GUI Range Test: A range test can be performed between two radios. The range test tab verifies the range of the radio link by sending a user‐specified data packet and also within the specified time verifies that the response packet is the same. This tab could not be utilized because a zigbee development kit was required to run the testing processes the Range Test tab provided. 15 Figure 18 Terminal tab for X‐CTU GUI Terminal: Allows access to the computers COM port with a terminal emulation program. This tab also allows the ability to access the radios’ firmware using AT commands. The Terminal tab consists of three functions which include the following: ¾ A terminal emulator. ¾ Has the capability of sending and receiving predefined data pacts (Assemble packet). ¾ Has the capability of sending and receiving data in Hex and ASCII formats (Show/Hide Hex). 16 Figure 19 Sending Packets using Hex or ASCII Format Most of the communication information sent will occur in the main white portion of this tab while using X‐CTU as a terminal emulator. The blue text is what has been typed in and directed out to the radio’s serial port while the red text is the incoming data from the radio’s serial port as displayed in the figure above. The terminal tab also supplies the “assemble packet” option; this allows assembling a packet and sending it using either HEX or ASCII format. 17 Figure 20 Modem Configuration tab for X‐CTU GUI Modem Configuration: Allows the ability to program the radios’ firmware settings via a graphical user interface. This tab also allows customers the ability to change firmware versions. The Modem Configuration tab consists of four functions which include the following: ¾
¾
¾
¾
To provide a graphical user interface with the radio’s firmware. To Read and Write firmware to the radio’s microcontroller. To download updated firmware from the internet or a compressed file. To save or load a modem profile. 18 Figure 21 Modem Type Confirmation Using the Test/Query Button Another way of finding out and confirming what modem type is being used is via the “Test/Query” option that the PC Settings tab offers. This can also be used to define which COM port the zigbee is on; a COM port is selected using COM port setup and as the “Test/Query” button is launched, one of two zigbees connected to the laptop has LED lights which start flickering which indicates the COM port that the zigbee is connected to. 19 3.2.3 Configuration Of Zigbees Using X‐CTU 3.2.3.1
XBee Coordinator Configuration Figure 22 Coordinator Configuration First restore to factory settings to eliminate the chance of lingering settings * RE Set PAN ID to an arbitrary value. The end device must also use this exact value ID=234 Both radios must have the same Channel and PAN ID to communicate CH=13 Set the node identifier to an arbitrary string. This serves as a convenient way to identify your devices NI=MASTER 20 Set API mode to 2 (escape control bytes) AP=2 Save to settings to survive power cycle WR Reboot the radio. Apply changes "AC" should also suffice FR NOTE: When the Restore command is run, this is generally good as it resets the configuration which existed beforehand; these might cause problems for the user otherwise. A problem I encountered when configuring the zigbees was when I used the X‐CTU software, and was in API mode (AP=2). When I restored the radio, the API mode changed to AP=1 (no escape bytes). And when the “Read” button was clicked, I got an error; this is most likely due to the API mode. To solve this, I unchecked the “Use esc ape characters” checkbox in the “PC Settings” tab and made the configuration changes. I then checked the “Use escape characters” checkbox after changing the API mode to AP=2. 21 3.2.3.2 XBee End Device Configuration Figure 23 End Device Configuration The configuration set for the End Device is the same except for the Identifier. Set to any arbitrary character string that identifies this radio NI=MOTOR 22 3.2.3.3 Why API mode There are two modes of operation which XBees support; API (Packet) mode and AT (Transparent) mode. In API mode, communication is done with the radio by sending and receiving packets. In AT mode, serial data is simply relayed to the receiving XBee by the XBee radio, as identified by the DH+DL address. XBees are required to be configured in API mode using X‐CTU. By setting the AP parameter, the API mode is enabled. X‐CTU requires the AP mode to be set to 2 (escape bytes), as this setting offers the best reliability. Here's a brief overview of the main advantages of API Mode vs. AT (Transparent Mode): API (Packet) Mode ¾
¾
¾
¾
¾
¾
¾
¾
I/O Samples. This feature allows an XBee to receive I/O data from 1 or more remote XBees Acknowledgement (ACK) and Retries. When sending a packet, the transmitting radio receives an ACK, indicating the packet was successfully delivered. The transmitting radio will resend the packet if it does not receive an ACK. Receive packets (RX), contain the source address of transmitting radio Configure a remote radio with the Remote AT feature Easily address multiple radios and send broadcast TX packets Obtain RSSI (signal strength) of an RX packet Packets include a checksum for data integrity ZigBee endpoints, cluster IDs and profile IDs (Series 2 XBee) AT (Transparent) Mode ¾
¾
¾
Simple Compatible with any device that speaks serial Primarily for point to point communication between two XBees. It's possible to communicate with multiple XBees but this requires entering command mode each time to change the destination address. Series 2 radios require a specific firmware for API mode. There are two firmware versions for Series 2 radios; API mode: ZNet and ZB Pro. ZNet is the version I had, and is recommended as it is the easiest to work with. 23 4
Control Box I had several different methods of approach which I spent time researching and testing. In this section will discuss each method in detail and stating the problems I had with each method and then state which method I chose I why. 4.1
Different Methods of Approach of Building Motor Driver Circuit The three different methods which were used to build a motor driver were 1) A Relay controller, 2) A solenoid switch, and 3) and Simple relay circuit. 4.1.1 Method One: Relay Controller A brief outline of the relay controller is as follows. ¾ Has ZB Mesh integrated into it
¾ It requires RS‐232 commands
¾ It receives commands through ZB Mesh and the chip interprets it and turns the relays on and off; having the capability of changing to the desired inputs.
Figure 24 ZB Zigbee Mesh Network The ZB Zigbee Coordinator is plugged into a USB port of a computer and is used to communicate to the wireless ZB Zigbee Mesh Network. The coordinator is mounted as a COM port on the PC, which is opened to begin sending data to the Coordinator. The Coordinator then forwards the data input by a user to all the devices on the ZB Zigbee Mesh Network. 24 A ZB Zigbee Mesh Network consists of up to three components [15]: A Coordinator is Required because it allows your computer to talk to the ZB ZigBee Mesh Network. Use only ONE coordinator in your ZB ZigBee Mesh Network. A Router allows data to hop to another part of the ZB ZigBee Mesh Network. It helps contribute to the network, and it can serve as an Endpoint device. In other words, if a relay controller has the Router firmware installed, you can talk to this device directly, or data can be forwarded from this device to another device that may be too far away for the Coordinator to reach directly. Routers are slower than endpoint devices, so use routers wisely. An Endpoint device can also be a relay controller or many other types of NCD devices. However, endpoint devices cannot forward data to other parts of the ZB ZigBee Mesh Network. Endpoint devices are faster than router devices, so it is always wise to use Endpoint devices when possible, and router devices when required. Both Relay Controller 1 and Relay Controller 2 can be programmed as an End Device or Router. If Relay Controller 1 is programmed as a Router and Relay Controller 2 is programmed as an End Device; in case of point‐ to multipoint communication, the Coordinator cannot send commands directly to Relay Controller 2, so it sends its’ commands to Relay Controller 1 which has a restriction of being within a range of less than three hundred feet away from the Coordinator. Once Relay Controller 1 receives its’ command, it has a router module which decides that the command sent to it by the Coordinator does not belong to it, hence bounces the command to Relay Controller 2 which is programmed to be the End Device; turning the selected relay on or off according to the selected command sent by the user. A typical ZB Zigbee Mesh Network is portrayed below. Figure 25 ZB Zigbee Mesh Network using 8‐Channel Relay Controllers 25 The main problem I had with using this was that the prices were too dear comparing it to the budget I was supplied for my project. A 4‐channel Relay Controller roughly cost $200 NZD excluding freight from the states; the larger the amount of channels, the higher the cost which meant I had to look for an alternative. For further research however, this could be used for implementing the direction control feature of the Kontiki system. This is done by having a main motor for launching the kontiki from shore, and two other motors; having one on each side for direction control, turning on the left motor simultaneously with the main motor to turn right and vice versa. 4.1.2 Method Two: Solenoid Switch The trigger of the sea scooter had a magnet at the end of the arm; as the user pulls the trigger, the magnet would go across a surface which has a magnetic relay switch which is activated turning on the motor. So I decided to make a simple solenoid switching circuit using an inductor in place of the magnet, which would be placed across the magnetic relay. The schematic of the circuit is displayed below. Figure 26 Simple Solenoid Switch Circuit with Zigbee When the command to turn on DIO4 is sent from the Coordinator to the End Device; the inductor turns on, switching the magnetic relay on, completing the circuit and hence, turning the motor on. 26 I could not find a suitable inductor from Jaycar so I went and talked to Mr. Ken Mercer and he supplied me with one from his junkyard. Figure 27 Inductor This idea worked, however some problems I had were the inductor required a minimum of 20 Volts supplied to it in order for the motor to turn on. Another problem I had was that the circuit was going to be placed on the outside of the sea scooter so I had to find an inexpensive way to keep the circuit air‐
tight, water‐tight and easily accessed. I knew that I would not have this problem if I had made a circuit that could be placed inside the sea scooter within the air‐tight and water‐tight chamber, rather than having an external switching circuit which also required a very large voltage supply to turn the motor on. 4.1.3 Method Three: Simple Relay Circuit For this motor driver circuit, a magnet is to be permanently placed near to the magnetic relay switch to keep it on. That way, when a command is sent from the Coordinator to the End Device to switch DIO4 on, the relay switches on, moving the armature to complete the circuit; hence turning the motor on. An SPDT (Single Pole Double Throw) relay was used for my circuit. The relay I got for my circuit is displayed below. Figure 28 SPDT, fully sealed, 10 Amp and 12VDC coil relay 27 A schematic of the simple relay circuit is displayed below. Figure 29 Simple Relay Circuit with Zigbee As portrayed above, the motor and the relay circuit have separate power supplies; the relay needs a minimum of 9 volts supply to switch on, while the motor requires a 24 volts supply. The inductor L1 represents the motor. The PCB for this relay circuit is displayed below. Figure 29 Simple Relay Circuit PCB 28 4.2
Preferred Method I ended up choosing method three; using a simple relay circuit. This is because, in comparison to the relay controller method (method one); the main reason I chose the simple relay circuit method instead was because it cost a fraction of what the relay controller method would have cost me. However, the relay controller method would have definitely enabled me to include more features such as direction control by having a motor on each relay channel; more detail to this approach is covered later on in this report. As for comparing it to the solenoid switch method (method two); the reason I chose the relay circuit method instead is because it is a much more practical method in terms of power efficiency; the power required to supply the relay circuit is roughly half the amount needed for the solenoid switch method; the solenoid required a minimum of 20 volts whereas the relay circuit only requires 9 volts. Another reason is; seeing the solenoid switch method is placed externally, not to mention the extremely big battery I would need for it; I would also have to find an extra air‐tight casing to use for it, where as I can just place the relay circuit within the air‐tight chamber of the sea scooter taking up a fraction of the size seeing I would only need a 9 volt battery supplied to it. 29 5
Kontiki System I began learning about different types of hulls and looked at a variety of boat designs, with the intention of mainly trying to find rugged designs which had features that could withstand waves, also taking into account all the conceivable obstacles a boat could face while out sailing in the sea, hence making a list of features I needed to think about while designing my kontiki system. 5.1
Features taken into account when designing the kontiki system There were a list of factors I had to take into account when was designing my kontiki fishing system. Some of the main factors I took into account were: •
•
•
Rigidness‐ A kontiki that rigid; being shock proof and have a long lifetime. Performance‐ A kontiki which can withstand waves with ease. Cost effectiveness‐ A kontiki which costs. Going into more detail, there are several factors I had consider when designing my kontiki project. Motor: To tow any length and weight of line with the desired distance off shore, the power of the motor must be taken into account. Typically 1000 to 2000 metres of a 100 to 300 lb breaking strain. Usually kontiki motors start at around 200 watts or 28lb thrust. Something really important I took into account was a propeller guard to protect the propeller from seaweed catching onto it, to protect the propeller from damage, and also protects your fingers and toes from the propeller. Battery: It must be taken into account that the batteries used must supply sufficient current to power the motor for the period of time desired. ie a 12v, 200 watt motor draws 17 amps. This means that if the desired run time of the motor is 30 minutes to drag 1500m of line, a battery that can supply 8.5 Amps/hr is needed. Normally in kontikis, sealed lead/acid batteries are used which come in a variety of different sizes. The larger the battery, the more times you can send the kontiki into the sea which means that a timer is used to regulate the battery to save power; making the kontiki fishing boat motor stop after a set time allowing extra power for more sets of line being sent. The main drawback is the weight penalty. Kontiki boat structure and casing: The hull of the kontiki fishing boat must be buoyant enough to support the motor and batteries. The batteries must also be completely airtight, yet allow access to the switch or timer and removal of the batteries for recharging. 30 The kontiki fishing boat must be rugged enough to take on the battering waves and should be highly visible so that both the user and other sea craft can see it at all times. A powerful light should be used for if the user ever desired to go kontiki fishing during night time. In some kontiki fishing boat designs; a keel is used for directional stability making sure the boat keeps going in a forward direction, rather than slipping to the side. Other kontiki fishing boat designs use a rudder so that the kontiki can be steered against the wind or current, and multiple offset towing points which is also for steerage. 31 5.2
Kontiki system designing process I did some research on all the different hull types and compared different types of boat designs deciding which one would fit my kontiki fishing system specifications to optimize the performance and results desired. 5.2.1 Advantages and disadvantages of different hull types Hull
Shapes
Hull Illustrations
Advantages
Disadvantages
Flat
Bottom
Hull
This planing (sailing)
hull has a shallow
Rides roughly in
draft, which is good
choppy waters.
for fishing in small
lakes and rivers.
Deep
“Vee”
Hull
Takes more power to
This planing hull
move at the same
gives a smoother ride
speed as flat bottom
than a flat bottom hull
hulls. May roll or bank
in rough water.
in sharp turns.
Round
Bottom
Hull
This typical
displacement hull
Has a tendency to roll
moves easily through unless it has a deep
the water even at
keel or stabilizers.
slow speeds.
MultiHull
Another example of a
displacement hull, the
Needs a large area
multi-hull has greater
when turning.
stability because of
its wide beam.
The table above provides figures of different boat hull designs; the “multi‐hull” design interested me the most because of the fact that this design would make the kontiki fishing boat much more stable; noting that it has a wider beam. 32 5.2.2 Initial CAD design of kontiki system The Kontiki system design I came up with is portrayed below: Figure 30 CAD Kontiki Fishing System Design Utilizing the research I had done on all the different hull types I came to the conclusion that the best one to suite my kontiki systems was the multi‐hull type. I chose this hull design as it had the advantage of being more stable because of its wide beam and theoretically has a less chance of tipping over (depending on the weather conditions the user decides to go kontiki fishing). For the pontoons on each side, I intended on using PVC tubes but then I came up with the idea of using polystyrene instead having both the advantages of being lighter and cheaper. 33 5.3
Motor I struggled finding a motor seeing all the kontiki motors were expensive and my first alternative was using a bilge pump which was sold at a decent price however was not powerful enough. After a lot of research, I came up with the idea of using a sea scooter which included most of the features I brainstormed earlier and was a perfect alternative to purchasing separate parts saving a vast amount of money. 5.3.1 Kontiki Motor I had trouble finding a kontiki motor with an appropriate price. My plans initially were to build a kontiki fishing boat consisting of three kontiki motors; turning the middle one on for a standard speed, all three motors on for a maximum speed and turning the middle motor and either one of the left or right motors simultaneously for direction control. However, this did not quite work as planned as a standard kontiki motor cost approximately $250‐300 NZD plus, on the internet. A picture of a standard kontiki motor is conveyed below: Figure 31 Mercury Motor The electric kontiki motor displayed above is a 30 lb thrust motor costing at $250NZD including GST. This was simply too expensive for the budget I had planned for this project so I had to go look elsewhere for better prices or alternatives. To begin with, I decided to visit to several places in Palmerston North including, Dick Smith Electronics which told me to go to Jaycar, which then told me to go to Leader and Watt; finally Leader and Watt telling me to go to a model shop which would cost much more than me purchasing it off the internet. 34 5.3.2 An alternative to launch the kontiki from the shore I started to look for alternatives in regards to launching the kontiki from the shore; 5.3.2.1 Bilge pump My first alternative idea was using a bilge pump instead because doing some research on the prices, I found that there were generally decent prices compared to the prices of kontiki motors provided the fact that bilge pumps would also not consume as much power as kontiki motors. The bilge pump I was interested in is conveyed below: Figure 32 Bilge Pump The figure above displays a 12volts, 2.5 amperes, fully submersible bilge pump which also has a capacity of 500 gallons per hour and a maximum lift of 3 metres; it only cost $33NZD. 35 5.3.2.2 Sea Scooter Figure 33 Sea Scooter I ended up using the sea scooter as my main motor to be launched into the sea as it included almost all the features I had brainstormed integrated into one single piece. After spending a lot of time searching a variety of different stores and sites; getting contact with them. Many of the stores I went to visit in Auckland were quite expensive and had sea scooters which reached a price of $4000 NZD. Later, I went on to searching a variety of different sites online and getting in contact with the suppliers. There were good deals; however, freight cost from overseas was expensive so I had to go search local stores. Luckily I found that Jaycar had sea scooters which were Chinese imports, similar to the ones I had been trying to get from overseas suppliers, and only cost me $150 NZD. Obviously it was not to the same quality standards as the sea scooters which were sold at stores in Auckland, but it is perfect for the purpose of this project. It had of the features I had intended on including were the propeller guard, the air tight chamber for the battery, a buoyancy chamber, a 24V‐6Ah battery and a 250W motor; all at $150NZD. The max speed is approximately 7km/h and has a run time of up 1 hour. Some bonus features include a moss tube overheat protection and a low voltage protection. 36 5.1.1 Motor On GUI Code {
onBn = new Button(onOffComp, SWT.PUSH |
SWT.CENTER);
GridData onBnLData = new GridData();
onBnLData.grabExcessHorizontalSpace = true;
onBnLData.horizontalAlignment = GridData.CENTER;
onBn.setLayoutData(onBnLData);
onBn.setText("Turn On");
onBn.addSelectionListener(new
SelectionListener() {
@Override
public void widgetSelected(SelectionEvent
arg0) {
try {
motorController.turnOnMotor();
} catch (XBeeException e) {
// TODO Auto-generated catch
block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch
block
e.printStackTrace(); 5.1.2 Motor Off GUI Code {
offBN = new Button(onOffComp, SWT.PUSH |
SWT.CENTER);
GridData offBNLData = new GridData();
offBNLData.grabExcessHorizontalSpace = true;
offBNLData.horizontalAlignment =
GridData.CENTER;
offBN.setLayoutData(offBNLData);
offBN.setText("Turn Off");
offBN.addSelectionListener(new
SelectionListener() {
@Override
public void widgetSelected(SelectionEvent
arg0) {
motorController.turnOff();
37 6
Results In testing consideration, upon the successful completion of the Java programming and GUI; I regularly ran tests by debugging my code to check that it is in working order. I had tested it with an LED at first and later on tested it with the motor driver circuit. As for wireless communication power efficiency, zigbees are well known for being standardized protocols for Ultra Low Power Wireless Personal Area Networks (WPANs). Low power consumption is an important criterion when deploying it in remote control longline fishing to ensure the ability of operating the kontiki system for long periods of time with a minimum maintenance required. The power consumption is only measured for the end device as the coordinator is practically mains powered at the base station. During the measurement, the end device is configured to be in a timer sleep mode condition. The node is configured to wake up every couple of seconds for a set time interval just to receive data from the base station. For the rest of the time, the end device is in a sleep condition. 38 7
Future Research and Recommendations Sea trials can be done to test the remote control longline fishing systems wireless communication. These trials can be utilized to implement any further changes to the design of the wireless kontiki system. More features which can be researched and implemented are: ¾ Repeaters (i.e. more than one zigbee device along the fishing line to so that if the kontiki system exceeds the maximum coverage range of 1.5km, contact would not be lost). ¾ GPS unit used if the kontiki system gets lost. ¾ Kontiki system direction and speed control. ¾ Ultrasonic device to detect fish around the area of which the kontiki system is in. ¾ Camera to send back images of fish in the same area of the kontiki system. ¾ A zigbee device on top and on the bottom of the boat in case of the kontiki system flipping upside down. ¾ Wheels that come down from the kontiki system once it is winched back onto the shore to make it easier to move and to reduce tension on the fishing line. 39 8
Conclusion The remote control longline fishing project involved a number of problems that had to be overcome with both the design and testing of the kontiki system. I designed my kontiki system based on the research on different hull types and boat designs. I did research on and implemented different methods for the motor driver, choosing the relay circuit because of it being more practical price wise and power wise than the other two methods which were using the relay controller and the solenoid switch. More improvements and modifications can be made to the GUI as the project evolves. In the GUIs’ current state, it allows the user to wirelessly switch the kontiki on and off. DIO4 is currently being used to switch the main motor on and off; there are eight other DIOs which can be utilized for including more features such as a GPS system, used for in case of the kontiki system getting lost when launched out into the sea; a camera, to take snapshots of the fishing line sending data (pictures of the line) back to the base station confirming whether any fish were caught on the fishing line or not; and direction control, by adding motors on each side of the kontiki system and turning on the left motor simultaneously with the main motor to turn right and vice versa, this feature can be used in case of the waves pushing the kontiki system off track while moving towards its targeted area. The current Coordinator to End Device range is 1.5Km; in order to increase this range, repeaters can be inserted along the fishing line in between the Coordinator and End Device nodes making them routers. The remote control longline fishing project is still in its early stages, the work completed on this project has created a good platform for the future, the problems encountered and proposed design solutions will benefit this project as it continues. 40 9
Glossary RSSI‐ Received signal strength indicator DTR‐ Data terminal ready RTS‐ Ready to send COM Port‐ Communication Port DIO‐ Digital Input Output RX‐ Data received TX‐ Data transmitted M2M‐ Machine‐to‐Machine
Bow‐ Is the front end of the boat Stern‐ Is the rear end of the boat Beam‐ Is the width at the widest point of the boat Hull‐ Is the boat itself without masts, spars, or rigging Keel‐ Is the piece of timber running along the centre of the bottom of the hull; it is used to give the boat a hold on the water, so that the boat will not slide sideways 41 10
Reference [1] http://symposia.cbc.amnh.org/archives/seascapes/glossary.html [2] http://www.afma.gov.au/information/publications/corporate/annual/ar99_00/glossary.htm [3] http://www.sparkfun.com/commerce/product_info.php?products_id=8687 [4] http://en.wikipedia.org/wiki/Zigbee [5] H. Labiod, H. A. (2007). Wi‐Fi, Bluetooth, Zigbee and WiMax. Dordrecht, The Netherlands: Springer. [6] http://www.sparkfun.com/commerce/product_info.php?products_id=8664 [7] http://www.sparkfun.com/commerce/product_info.php?products_id=8691 [8] http://www.ZigBee.org [9] http://www.sparkfun.com/datasheets/Wireless/Zigbee/XBee‐2.5‐Datasheet.pdf [10] http://www.sparkfun.com/datasheets/Wireless/Zigbee/XBee‐Datasheet.pdf [11] http://www.maxstream.net/wireless/zigbee.php [12] http://www.ehow.com/about_5849361_protocol‐suite_.html#ixzz11AzkuYaX [13] http://northlandfishing.net.nz/Kontiki.html [14] www.boat‐ed.com/ia/course/p1‐3_boatparts.html [15] http://www.relaycontrollers.com/Relay/Device/ZADR85PROXR_ZBMESH [16] http://www.khalus.com.ua/data/chips/chameleon‐relay/pdf/frs/frs10.pdf [17] http://www.trademe.co.nz/Trade‐Me‐Motors/Boats‐marine/Parts‐accessories/Pumps‐
tanks/auction‐324679053.htm [19] http://www.kentiki.co.nz/products.html [20] Rasin, Z., & Abdullah, M. R. (2009). Water Quality Monitoring System Using Zigbee Based Wireless Sensor Network. International Journal of Engineering & Technology IJET , 9 (10), 1‐5. [21] http://code.google.com/p/xbee‐api/, Xbee‐api, Andrew Rapp (4/5/08) 42 11
Appendices The Appendices included below are:
Appendix A: Project Proposal Appendix B: Datasheet for the zigbee XBee Series 1 Appendix C: Datasheet for the zigbee XBee Series 2 Appendix D: Coordinator Configuration Appendix E: End Device Configuration Appendix F: Relay Datasheet Appendix G: GUI Code Appendix H: Main Code 43 Appendix A: Project Proposal Remote Control Longline fishing Name: Abraham Jadaan 07111983
Supervisor: Dr. Gourab Sen Gupta
Co-supervisor: Dr. Subhas Mukhopadhyay
Industrial Liaison: Sports and Recreation
Background Longline fishing (kontiki) is a commercial technique which promotes fishing using a long line.
The long line used is called the main line, with baited hooks that are attached to the main line
using a clip or swivel, with the hook at the other end. From the shore; the kontiki boat is launched
out into the sea and left there for a few hours varying from 1-3 hours; later winched back onto
shore. Two methods of setting a longline are displayed below:
Fishing has never been made easier and more efficient time wise. Beach longline fishing is an
economic, environment friendly and effective way to regularly catch fresh fish - either single
handed or with family and friends.
Instead of investing in a boat which costs thousands of dollars; people can invest in a much
cheaper option by purchasing the R/C Kontiki which is a beach fishing system launched from the
shore and later winched back onto shore enjoying a catch of multiple fish.
44 The main difficulty to overcome is that the kontiki boat changes its position due to waves
pushing it.
The problem is that commercial electric kontikis are high in cost and may in some cases lack
features one might desire such as a longer range of communication, speed and direction control.
Some of the current problems are that long range remote controls are expensive; it is also hard to
find long range remote controls which go over 1Km without infringing any maritime licenses.
Overall, the current kontiki fishing system is expensive and not easily manufactured.
One solution to this problem is using a zigbee for communication; a zigbee is wireless protocol
suite which has a range of approximately 1.6Km and is now widely used and known for its power
efficiency and capabilities of supplying the user the privilege of a number of different types of
networks the zigbee protocol suite is capable of.
Roughly two zigbees will be used to transmit and receive data for communication and extra
nodes can be added if a longer range is required.
For my project I would like to work on developing an electric kontiki which is controlled using a
zigbee protocol suite.
45 I shall begin by first endeavoring to investigate the zigbee protocol suite by putting it through
various testing procedures and gaining control the kontiki wirelessly; later on looking into other
features which could be added to improve and broaden the capabilities of the kontiki fishing
system performance and design wise.
The existing electric kontiki fishing system does a good job piercing through waves and has a
range of roughly 1.5Km and uses a timer to set how long it will be on for; however, these
features can be improved by making them wireless; improving the launching technique, hence
making it more user friendly and obtaining better results with extra features taking into account
the wireless control factor cost effectiveness, which generally attracts many customers.
46 There are currently three commercial products which are out in the market:
$1495
Longline Hauler
$1595
The Seahorse
$1495
Challenger Marine
Fishing Torpedo
Longline Hauler:
•
•
•
•
30lb thrust Mercury motor.
12V DC rechargeable batteries.
Approx 1000m in 15 min.
The machine will do two sets x 600-800 meters or one set x 1300-1400metres.
The Seahorse:
•
•
•
•
A powerful 2 speed 46lb thrust motor.
22 amp hour SLA (Sealed lead acid) battery pack.
You can run the Seahorse until the low battery cut-out switches it off, or you can set the
timer to 25, 20, 15, 10 or 5 minutes run time.
Night activated Strobe light and flag.
Challenger marine fishing torpedo:
•
•
•
•
•
A 30lb thrust motor.
2 x 12V rechargeable batteries. (Optional 3rd battery if required)
You can set the timer from 0-30 minutes.
A 15 minute setting approximately gives a range of 1 kilometer.
Gross weight is 20 kilograms.
47 The current electric kontiki fishing system provides a good basis to develop new improved
models integrating features which are used to supply the user with an overall more enjoyable and
rewarding experience.
Aim:
The aim of my project is to build an electric kontiki system using the zigbee protocol suite for
wireless control.
Objectives:
-
To Control a kontiki system via a wireless data communication protocol. Preferred is
zigbee.
To use cost effective and power efficient protocol suites to control the kontiki fishing
system wirelessly.
Constraints:
-Not all items needed for building and completing this project are available from the city of
Palmerston North; in Auckland there is much more variety which means I would have to
purchase some of my items online, therefore spending more than what I would normally spend
for the items if I had been in the city of Auckland itself. (Palmerston North does not have as
much variety as Auckland or wellington city)
SWOT Analysis
Strengths:
Product perspective:
The electric kontiki fishing system provides a:
- Time effective
- Cost effective
- Power efficient
- User friendly
Project perspective:
Gaining the experience of producing innovative ideas integrating new features to the existing
product; using new technology improving the product, making it more user friendly therefore
increasing the chance of product sale.
48 Weaknesses:
Product perspective:
-One of the main weaknesses in building and creating an enhanced product is the time constraints
to implement research and development, market study, building the project, getting it ready for
testing etc
-Products viability in the market.
Project perspective:
Facilities to build the project and the feasibility constraints.
Opportunities:
Product perspective:
If the electric kontiki is a success, the public will interested in investing in the product and more
units can be made and sold.
Project perspective:
If the project concept is admired by the clients, a company might offer to invest into the project
doing more R&D and continue on developing and improving the product.
Threats:
Product perspective:
-Other competitors in the market are one of the main threats for the product.
- Product viability in the market.
Project perspective:
The project might not be completed in time within the set time constraints.
49 Resource and skill acquisition
-
-
-
One of the main skills which will take me a bit of time to learn is the C programming
language. Resources I will refer to most often are advanced programming in C text books
and sample codes and tutorials from the internet.
Another thing that may take approximately up to two weeks is surveying students for my
product which I’m making. The surveys that I will make will be resources I could use for
statistics on judging how well my product will do in the market.
The last thing which will approximately take from two weeks up to a month is searching
for suppliers to purchase parts for my project. Resources I will use are different shops in
town and suppliers from the internet.
Cost Estimates
To buy a commercial electric kontiki system, it generally costs from $1500-$4000.
My mission is to build a remote control electric kontiki using an approximate total of $300 to
$500 if needed.
Testing Considerations
My testing will be mainly qualitative. For the testing process, I will be regularly debugging my
code to test whether it works and after my code is done and ready for practice; I plan on using it
for my electric kontiki system to test the performance of using the zigbee protocol suite in my
application in regards to wireless communication power efficiency.
Project Output
A remote controlled electric kontiki system protocol will be built and a debugged software will
be provided in regards to testing consideration.
Project Schedule:
Market survey
March/April
System conceptualization
April/ May
System design and fabrication
May/July
Testing and evaluation
July/August
Modification and finalization
August/September
Final testing
September/November
50 Report writing
March/November
Time Budget:
The above figure displays a Gantt chart which specifies the start date and end date of the project,
setting a time allocation to each of the major stages of the project.
Budget:
I am allowed to spend up to roughly $500 NZD if required to do so; to purchase my items to
build my R/C kontiki fishing system which usually costs from $1600 to $3000.
Communication plan:
I intend on making an appointment with my supervisor at least once a week to update him on
what I have been doing and to consult him on whether I am on track.
51 Appendix B: Datasheet for the zigbee XBee Series 1 52 Appendix C: Datasheet for the zigbee XBee Series 2 53 Appendix D: Coordinator Configuration XB24‐B_ZigBee_1147.mxi 80 0 251 1147 0 [A]ID=234 [A]SC=1FFE [A]SD=3 [A]NJ=FF [A]DH=0 [A]DL=FFFF [A]NI=MASTER [A]BH=0 [A]AR=FF [A]DD=0 [A]NT=3C [A]NO=0 [A]PL=4 [A]PM=1 [A]EE=0 [A]EO=0 [A]BD=7 [A]NB=0 54 [A]D7=1 [A]D6=0 [A]AP=2 [A]AO=1 [A]SP=20 [A]D0=1 [A]D1=0 [A]D2=0 [A]D3=0 [A]D4=0 [A]D5=1 [A]P0=1 [A]P1=0 [A]P2=0 [A]LT=0 [A]RP=28 [A]PR=1FFF [A]IR=0 [A]IC=0 [A]V+=0 55 Appendix E: End Device Configuration XB24‐B_ZigBee_1347.mxi 80 0 251 1347 0 [A]ID=234 [A]SC=1FFE [A]SD=3 [A]NJ=FF [A]JV=1 [A]DH=0 [A]DL=0 [A]NI=MOTOR [A]BH=0 [A]AR=FF [A]DD=20000 [A]NT=3C [A]NO=0 [A]PL=4 [A]PM=1 [A]EE=0 [A]EO=0 [A]BD=7 56 [A]NB=0 [A]D7=1 [A]D6=0 [A]AP=2 [A]AO=0 [A]SM=0 [A]ST=1388 [A]SP=20 [A]SN=1 [A]SO=0 [A]D0=0 [A]D1=0 [A]D2=0 [A]D3=0 [A]D4=4 [A]D5=1 [A]P0=1 [A]P1=0 [A]P2=0 [A]LT=0 [A]RP=28 [A]PR=1FFF [A]IR=0 [A]IC=0 [A]V+=0 57 Appendix F: Relay Datasheet 58 59 Appendix G: GUI Code package ac.nz.massey.AJadaan.gui;
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
org.eclipse.swt.SWT;
org.eclipse.swt.events.SelectionEvent;
org.eclipse.swt.events.SelectionListener;
org.eclipse.swt.graphics.Point;
org.eclipse.swt.graphics.Rectangle;
org.eclipse.swt.layout.FillLayout;
org.eclipse.swt.layout.FormAttachment;
org.eclipse.swt.layout.FormData;
org.eclipse.swt.layout.FormLayout;
org.eclipse.swt.layout.GridData;
org.eclipse.swt.layout.GridLayout;
org.eclipse.swt.layout.RowLayout;
org.eclipse.swt.widgets.Button;
org.eclipse.swt.widgets.Composite;
org.eclipse.swt.widgets.Display;
org.eclipse.swt.widgets.Menu;
org.eclipse.swt.widgets.MenuItem;
org.eclipse.swt.widgets.ProgressBar;
org.eclipse.swt.widgets.Shell;
org.eclipse.swt.widgets.TabFolder;
org.eclipse.swt.widgets.TabItem;
import com.cloudgarden.resource.SWTResourceManager;
import com.rapplogic.xbee.api.XBeeException;
import com.rapplogic.xbee.examples.zigbee.MotorOn;
public class MotorGui extends org.eclipse.swt.widgets.Composite {
private Composite onOffComp;
private Button offBN;
private Button onBn;
private MotorOn motorController = new MotorOn();
{
//Register as a resource user - SWTResourceManager will
//handle the obtaining and disposing of resources
SWTResourceManager.registerResourceUser(this);
}
public MotorGui(Composite parent, int style) {
super(parent, style);
initGUI();
}
/**
* Initializes the GUI.
*/
private void initGUI() {
try {
this.setSize(new org.eclipse.swt.graphics.Point(400,300));
this.setBackground(SWTResourceManager.getColor(192, 192,
192));
60 GridLayout thisLayout = new GridLayout();
thisLayout.makeColumnsEqualWidth = true;
this.setLayout(thisLayout);
{
onOffComp = new Composite(this, SWT.NONE);
GridLayout onOffCompLayout = new GridLayout();
onOffCompLayout.makeColumnsEqualWidth = true;
onOffCompLayout.numColumns =2;
GridData onOffCompLData = new GridData();
onOffCompLData.grabExcessHorizontalSpace = true;
onOffCompLData.horizontalAlignment = GridData.FILL;
onOffCompLData.verticalAlignment = GridData.FILL;
onOffCompLData.grabExcessVerticalSpace = true;
onOffComp.setLayoutData(onOffCompLData);
onOffComp.setLayout(onOffCompLayout);
{
onBn = new Button(onOffComp, SWT.PUSH |
SWT.CENTER);
GridData onBnLData = new GridData();
onBnLData.grabExcessHorizontalSpace = true;
onBnLData.horizontalAlignment = GridData.CENTER;
onBn.setLayoutData(onBnLData);
onBn.setText("Turn On");
onBn.addSelectionListener(new
SelectionListener() {
@Override
public void widgetSelected(SelectionEvent
arg0) {
try {
motorController.turnOnMotor();
} catch (XBeeException e) {
// TODO Auto-generated catch
block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch
block
e.printStackTrace();
}
}
@Override
public void
widgetDefaultSelected(SelectionEvent arg0) {
// TODO Auto-generated method stub
}
});
}
{
offBN = new Button(onOffComp, SWT.PUSH |
SWT.CENTER);
GridData offBNLData = new GridData();
offBNLData.grabExcessHorizontalSpace = true;
61 offBNLData.horizontalAlignment =
GridData.CENTER;
offBN.setLayoutData(offBNLData);
offBN.setText("Turn Off");
offBN.addSelectionListener(new
SelectionListener() {
@Override
public void widgetSelected(SelectionEvent
arg0) {
motorController.turnOff();
}
@Override
public void
widgetDefaultSelected(SelectionEvent arg0) {
// TODO Auto-generated method stub
}
});
}
}
this.layout();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
Display display = Display.getDefault();
Shell shell = new Shell(display);
MotorGui inst = new MotorGui(shell, SWT.NULL);
Point size = inst.getSize();
shell.setLayout(new FillLayout());
shell.layout();
if(size.x == 0 && size.y == 0) {
inst.pack();
shell.pack();
} else {
Rectangle shellBounds = shell.computeTrim(0, 0, size.x,
size.y);
shell.setSize(shellBounds.width, shellBounds.height);
}
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
}
62 Appendix H: Main Code package com.rapplogic.xbee.examples.zigbee;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import com.rapplogic.xbee.api.XBee;
import com.rapplogic.xbee.api.XBeeAddress64;
import com.rapplogic.xbee.api.XBeeException;
import com.rapplogic.xbee.api.XBeeTimeoutException;
import com.rapplogic.xbee.api.zigbee.ZNetRemoteAtRequest;
import com.rapplogic.xbee.api.zigbee.ZNetRemoteAtResponse;
public class MotorOn {
private final static Logger log = Logger.getLogger(MotorOn.class);
XBee xbee = new XBee();
XBeeAddress64 addr64 ;
ZNetRemoteAtRequest request ;
ZNetRemoteAtResponse response;
public MotorOn(){
// place serial high (SH) + serial low (SL) of end device
addr64 = new XBeeAddress64(0, 0x13, 0xa2, 0, 0x40, 0x3e, 0x18,
0xb8);
}
public boolean turnOnMotor()
throws XBeeException, InterruptedException
{
xbee.open("COM6", 115200);
request = new ZNetRemoteAtRequest(addr64, "D4", new int[]
{5});
try {
response = (ZNetRemoteAtResponse)
xbee.sendSynchronous(request, 10000);
} catch (XBeeTimeoutException e) {
e.printStackTrace();
} catch (XBeeException e) {
e.printStackTrace();
}finally{
xbee.close();
}
xbee.close();
return response.isOk(); //log.info("successfully turned on
D4");
}
@SuppressWarnings("finally")
public boolean turnOff (){
try {
xbee.open("COM6", 115200);
} catch (XBeeException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
return false;
63 }
try{
//turn on end device (D4)D0 (Digital Output high =5)
request = new ZNetRemoteAtRequest(addr64, "D4", new int[]
{4});
response = (ZNetRemoteAtResponse) xbee.sendSynchronous(request,
10000);
xbee.close();
if (response.isOk()) {
log.info("successfully turned off D4 ");
return true;
} else {
throw new RuntimeException("failed to turn off pin 20.
status is " + response.getStatus());
}
} catch (XBeeTimeoutException e) {
log.error("request timed out. make sure you remote XBee is
configured and powered on");
} catch (Exception e) {
log.error("unexpected error", e);
} finally {
// close the serial port and associated threads
xbee.close();
return false;
}
}
public static void main(String[] args) throws XBeeException,
InterruptedException {
PropertyConfigurator.configure("log4j.properties");
new MotorOn();
}
}
64