Home

BlueSense Final Report

image

Contents

1. BlueSense Project Final Report l BlueSense Final Report Hypheng Lim hypheng gwu edu CSCI297 2007 04 24 Project Abstract The goal of this project is to establish a wireless bluetooth communications channel between the Zilog Z8 microcontroller and a Sony Ericsson P9101 mobile phone Once connected the P9101 would be able to send commands to the Z8 to request certain data such as readings from a temperature sensor Additionally the P9101 can send data messages to the Z8 to be displayed on a connected LCD device The P9101 supports bluetooth natively as well as the required extensions for java bluetooth support JSR82 The Z8 will be connected to a BlueSMiRF bluetooth modem from Sparkfun The proposed requirements for this project are Establish a wireless bluetooth connection between the P9101 and the Z8 The P9101 must allow the user to enter and send commands data to the Z8 The Z8 will read and parse commands sent from the P9101 The Z8 will send sensor readings when a specific command is sent The P9101 will read and parse responses from the Z8 for display to the user Status Major functions all work as intended Changes to initial design e Used LCD display as opposed to LED array on the Z8 The LCD display does not require scanning to draw various characters In addition it displays more characters at once 16 vs 4 e Software flow modified to support initial setup of bluetooth Specification Description
2. There are two major devices for this project the Sony Ericcson P9101 mobile phone and the Zilog Z8 Encore Evaluation Board The Sony Ericcson P9101 has built in support for bluetooth and does not require any external hardware A J2ME client program will be written for the P9101 The Zilog Z8 has BlueSense Project Final Report 2 several components in addition to the evaluation board It will use the BlueSMiRF from Sparkfun for bluetooth communications In addition an LCD display and temperature sensor will be connected A C server program will be written to drive its various external components as well as handle communications with the P9101 Hardware Modules Sony Ericsson P9101 has the following characteristics related to this project e GSM mobile phone e CLDC1 0 MIDP2 0 J2ME support e JSR 82 bluetooth support within J2ME e Input via touch sensitive screen or attached QWERTY keyboard e 64MB built in storage space Technically any phone that meets the above requirement should work with the client program However only the P9101 has been tested Additionally some phones may require moresetup then was required by the P9101 Zilog Z8 Encore Evaluation Board e Z8F6403 8 bit microprocessor e UART RS232 interface for BlueSMiRF communications e 80 GPIO pins 8 for LCD driver e DC interface for temperature sensor e Part 99C0868 01 AD7414 2 I2C Temperature Sensor e 10 bit temperature to digital converter e Standard 2C serial bu
3. esmirf c program for zilog z8 Use the Zilog Z8 IDE to open the projects file to compile amp install datasheets resources and datasheets for this project e AD7414 7415 pdf temp sensor an0143 pdf LCD driver application note from Zilog LCD 100 pdf lcd display datasheet BlueRadios ATMP Commands Rev 3 5 1 1 0 pdf command set for bluesmirf BlueSMiRF vl pdf bluesmirf user manual BlueSMiRF RPSMA Schematic pdf bluesmirf schematic References Resources J2ME Tutorial Part 1 Creating MIDlets http today java net pub a today 2005 02 09 42me1 html page 1 J2ME Tutorial Part 2 User Interfaces with MIDP 2 0 http today java net pub a today 2005 05 03 midletUI html Wireless Application Programming with J2ME and Bluetooth http developers sun com techtopics mobility midp articles bluetooth1 http developers sun com techtopics mobility midp articles bluetooth2 J2ME and JSR82 APIs http java sun com javame reference apis jsp Serial Port Communications http www tigoe net pcomp resources archives avr 000749 shtml http discussion forum nokia com forum showthread php t 49736
4. for bluetooth communications in addition to various standard J2ME classes When a user has selected a device the program will create a service URL by combining btspp with the selected device s bluetooth address followed by This specifies service channel on that device An example service URL would look like btspp 00A09617A712 1 A connection is established to this device by using the StreamConnection class on the service URL Once this happens an OutputStream and InputStream is created to allow read write to the remote device A protocol was created to allow proper read write termination on the this the client end and to prevent the client from blocking on a read When the client receives a r n in the data stream it signifies that the server will not be sending any more responses for the last request Otherwise the protocol is a simple request response loop Interestingly I did not have to configure baud rate or other serial settings when pairing with the BlueSMiRF Software Zilog Z8 Zilog Z8 server program flow control ge initialize components wait for bluetooth input raw data from bt parser execute_cmd is message icd command read sensor send to LCD display send over bluetooth message to co BlueSense Project Final Report 9 Z8 program files e main c initializes components program startup e common c common h common helper functions such as sleep e ad7414 c ad7414 h tempe
5. he message is displayed Hardware amp Software Tests The Zilog Z8 program was developed first and verified using a PC w bluetooth support It would be paired to the PC to ensure the program and user tested to verify correct input and output Each external component was written and tested separately before combined into one program The temperature sensor was verified by placing my finger against the sensor to increase the temperature reading The LCD was visibly inspected to ensure the correct data was displayed The BlueSMiRF was verified by a small program which sends output through its connection On the other side of this connection was a PC terminal program displaying the output After the Z8 program was confirmed to work correctly the P9101 app was developed While still developing the UI the Sun wireless tool kit emulator was used to verify various forms and menus were displayed correctly Once bluetooth was added to the program this was no longer possible and it was tested against the Z8 itself Again verification was done by user testing visible inspections of input and output responses Milestones 2007 03 20 Established a bluetooth connection between the Z8 amp PC bluetooth 2007 03 23 Loaded sample J2ME apps to P9101 Wrote own simple hello world apps 2007 03 27 Temperature sensor driver written 2007 04 10 LCD driver written Temperature Sensor connected Z8 program complete 2007 04 13 J2ME UI designed Rough implementa
6. ilog Z8 Encore Family IDE version 4 10 06121401 Used to develop and debug the server side program which runs on the Zilog Z8 Implementation amp Construction Hardware Interface Overview Temperature Sensor BlueSMirF BlueSense Project Final Report 4 Hardware Wiring Diagram All external components are directly connected to the Z8F6403 microprocessor BlueSMirF HD44780 16x1 LCD AS Ad7414i2c SDA Gnd Temp sensor Alert Vdd SCL BlueSense Project Final Report Pin Connection Detail Z8 LCD Description Gnd Pin 1 Gnd Ground Vcc Pin 2 Vcc Power J7 Ext VREF 2 Pin 3 Vee Contrast Control PE3 Pin 4 RS Register Select PE1 Pin 5 RW Read Write PE2 Pin 6 E Enable Pin 7 DBO Data Bus Pin 8 DB Pin 9 DB2 Pin 10 DB3 PE4 Pin 11 DB4 DER Pin 12 DB5 PE6 Pin 13 DB6 PE7 Pin 14 DB7 Z8 BlueSMiRF Pin 1 CTS Clear to Send Vcc Pin 2 PWR Power Gnd Pin 3 GND Ground PD4 RXD1 Pin 4 TX O Trasnmit PD5 TXD1 Pin 5 RX l Receive Pin 6 RTS O Ready to Send CTS4 is looped to RTS O to disable hardware flow control Z8 Temp Sensor Description Pin 1 AS Address Select Gnd Pin 2 GND Ground Vdd Pin 3 Vdd Power PA6 SCL Pin 4 SCL Serial Clock Pin 5 ALERT Alert Config PA7 SDA Pin 6 SDA Serial Data BlueSense Project Final Report Software P910i P910i client program flow diagram Start bt device search start No Device Found device found connect to device successful vz wait fo
7. lay responses from the bluetooth connection The Search Form starts the bluetooth device search function When a device is found it is added to the list of choices which is updated dynamically and displayed on the form The first device found is also highlighted as the default choice The user may select another device from the list There are three commands available on this form e RESCAN restart the bluetooth device search Currently the device list is not cleared and duplicates are not checked for so the same device may show up multiple times e CONNECT connect to the highlighted device If no device is selected or found a rescan is performed when this button is pushed e EXIT this command resides in the menu it will exit the program The Main Form has a user input text box and two text fields sent response The text box allows the user to input text using the natively available interface QWERTY keyboard touch screen stylus or T9 input using keypad The sent text field is immutable and echoes what was sent to the bluetooth connection The response field is also immutable and outputs what is read from the bluetooth connection after data command has been sent This form has two commands e SEND sends whatever is in the text box to the bluetooth connection e EXIT resides in the menu exits the program BlueSense Project Final Report P9101 Bluetooth Communications This client program uses the APIs specified by JSR82
8. r bluetooth data wait for user input user input send to over bluetooth P910i Client Program Classes ChoiceGroup ChoiceGroupObject void append String Object Object getAssociatedObj int elementNum CommandListener BlueSense_ DiscoveryListener BlueSense Project Final Report 7 BlueSense Class This is the main class of the client program It extends the javax microedition midlet MIDlet as required by J2ME programs In addition it implements the following Interfaces e CommandListener allows user input to execute certain commands from the UI e DiscoveryListener bluetooth api for device discovery ChoiceGroupObject Class This class extends the ChoiceGroup class This allows the client program to keep track of remote devices or any objects in addition to the display strings It is used by the BlueSense Class to display and keep track of discovered bluetooth devices found during the search P910i files e BlueSense java source file for main program Belongs to hp blue package e ChoiceGroupObject java source file for ChoiceGroup class Belongs to hp blue package e bluesense jad describes the jar file that is loaded onto the P9101 e project properties used by WTK to profile the J2ME program P910i User Interface There are two main forms windows for the client program The first is a search form and 1s loaded at startup The second form is the main program and waits for user input and disp
9. rature sensor driver e i2c c i2c h Ge bus driver e Icd c Icdah cd driver e ui c ui h user machine interface for server reads input from uart and responds Temperature Sensor Driver Using the provided 12c driver provided Professor Dan a simple driver was written for the ad7414 temperature sensor It has only one function ad7414_getTemp which returns the current temperature reading LCD Driver Based on Application Note 143 from Zilog a custom LCD driver was written for the HD44780 display Several functions were written to allow easy printing to the driver such as cd_prints char string which prints a string character array to the LCD In addition 8 custom characters were created and can be accessed via a c command BlueSMiRF The BlueSMiRF has the following default settings from the factory e 9600 8N1 serial port settings e Sparkfun friendly bluetooth name e default pass key if required e Serial Port Profile over Bluetooth If using the default settings no real configuration is necessary All data sent to the UART is pass to the serial port profile over bluetooth and vice versa When needed however the configuration mode can be entered by sending n in a communications terminal program that is connected to either end of the BlueSMiRF physical serial port or serial port profile over bluetooth Once in configuration mode there are several commands to query and configure the device settings A few examples incl
10. s support e 40 to 125 degrees C temperature range MDLS 16166 01 16x1 LCD display device e Standard HD44780 Display e 8x2 matrix arranged as a 16x1 display e 4and 8 bit data interfaces 4 is used BlueSMiRF v1 0 Bluetooth Modem e UART interface full duplex up to 115200bps e Built in bluetooth stack e 200 300ft range e 9600 8 N 1 default port settings BlueSense Project Final Report 3 Software Development Tools Java JDK 1 5 0 11 Sun Java compiler It is used to compile the client program for the P9101 mobile phone Sun Wireless Tool Kit WTK 2 5 This tool kit will compile package and sign applications ready for deployment to mobile devices In addition it has an emulator which helped with debugging the interface Sony Ericcsson PC Suite 3 1 1 optional This program allows the user to install programs to the P9101 via a USB cable Alternatively programs can be loaded via Bluetooth file transfer from PC and then installed by the phone Eclipse 3 2 EclipseME 1 6 6 both optional These two programs are an integrated development environment for Java EclipseME is a plugin for Eclipse to aid in developing J2ME programs They were both used mainly for editing the Java programs The Sun WTK was used to compile and package the application Alternatively any simple text editor will suffice for development Eclipse makes it a bit easier with various features such as code refactor and real time error checking static Z
11. t sensors BlueSense Project Final Report 12 Appendix Photos Sony Ericcson P9101 BlueSense Project Final Report Temperature Sensor LCD and BlueSMiRF on breadboard 13 BlueSense Project Final Report 14 a a ag d za Wiz LCD and BlueSMiRF connections backside ME L kkkdegd P910i Client Screenshots 1 Before application launch 2 App startup device search started z8blue found ee amp 8 Applications Edit bluesense ANS 8 Chess Kb bluesens Solitaire pnie ot tak zb bluesense g blur T RESCAN CONNECT Ri m BlueSense Project Final Report 15 3 Device Discovery Complete 2 devices found 4 Connected to z8blue oo D oo hluest hse buespnmsg bluesemgg F z blue response Iess connerie to a b epnp POG ID S RE SCAN CONHECI a er o aef hlugpspmsg bluesens man main it mae mul response gerni i BSpotrse west Leal D temp fe i annected ta REA it yoni Ar tei i eonnected to bhtsnp MAN bitsy yas fu nee iA BlueSense Project Final Report 16 Notes Description of various folders in the zip file bluesense j2me program for p9101 To compile and run this application place in the x wtk25 apps folder and open within the Sun Wireless ToolKit X wtk25 should be where the wireless toolkit is installed Use either bluetooth or usb to load the resulting jar amp jad file to the mobile phone blu
12. tion complete 2007 04 15 J2ME bluetooth comms completed P9101 client program completed BlueSense Project Final Report 11 Version 2 0 There are many additions that can improve the operation of the client program First is to add service discovery rather than simply connecting to service 1 Service Discovery did not currently work properly on the P9101 phone mostly likely due to my limited knowledge of the J2ME bluetooth API The user interface could be cleaned up as well Instead of a simple response text a log of messages could be kept so that the user can see the previous messages Additionally buttons could be added to the main form to allow easier methods of sending repeated commands such as retrieving sensor readings Auto device discovery and connection could be added When devices get near each other they could auto pair up and begin communications The client program would have to run in the background of the phone The communications protocol could be improved to be more generic allowing other devices such as GPS coordinates to be read in via the client program Additionally sensors could be added Support for self contained bluetooth sensors could be added The client could be program to talk to multiple bluetooth devices simultaneously A system to automate what messages go to what devices would have to be designed but this would allow the client program to associate and communicate with many devices housing differen
13. ude e ATSI 2 lt cr gt read the friendly device name e ATSN z amp blue lt cr gt change friendly device name e ATSW20 236 0 0 1 lt cr gt changes default settings to 57600 8 n 1 e ATMD lt cr gt go back into data mode The last command is required to resume data communications All commands with a few exceptions will reply with the a message and an OK For all the commands and full descriptions consult the datasheet BlueSense Project Final Report 10 User Machine Interface The user interface is a simple command line request response design It reads and waits for input from the UART 1 port until a carriage return n is read and then processes what was received If the data is a certain set of characters then it is processed as a command Currently the following commands are supported e t read the temperature and reply with the temperature value in Fahrenheit degrees Additionally it also sends the temperature to the LCD e c print custom character There are 0 7 valid values for Replies with the custom character number that was printed The reply gets sent to the UART e s shift cursor to position This value is in hex and is valid for 0 F Replies with the position that was sent to the UART e p print all custom characters to the LCD Sends the text done to the UART If the data received does not match a command it is displayed to the LCD A done message is sent to the UART when t

Download Pdf Manuals

image

Related Search

Related Contents

Índice del Manual de usuario SIIEI Reportes_de_Incidencias  Anleitung LE-EH 2440 SPK 7  Visualization Environment for Rich Data Interpretation  Bedienungsanleitung    取扱説明書 1  カタログPDF  T5 Operator`s Guide - Franklin Fueling Systems  Dictionnaire encyclopédique de français  Metra 70-5514 power cable  

Copyright © All rights reserved.
Failed to retrieve file