Design Project



Homework 9: Software Design Considerations

Due: Friday, March 21, at NOON

Team Code Name: ___Bluetooth Mass Storage __________________ Group No. __2___

Team Member Completing This Homework: _Yucel Parsak__________________________

e-mail Address of Team Member: ____yparsak___ @ purdue.edu

[pic]

Evaluation:

|SCORE |DESCRIPTION |

|10 |Excellent – among the best papers submitted for this assignment. Very few corrections needed for version submitted in |

| |Final Report. |

|9 |Very good – all requirements aptly met. Minor additions/corrections needed for version submitted in Final Report. |

|8 |Good – all requirements considered and addressed. Several noteworthy additions/corrections needed for version |

| |submitted in Final Report. |

|7 |Average – all requirements basically met, but some revisions in content should be made for the version submitted in the|

| |Final Report. |

|6 |Marginal – all requirements met at a nominal level. Significant revisions in content should be made for the version |

| |submitted in the Final Report. |

|* |Below the passing threshold – major revisions required to meet report requirements at a nominal level. Revise and |

| |resubmit. |

* Resubmissions are due within one week of the date of return, and will be awarded a score of “6” provided all report requirements have been met at a nominal level.

Comments:

1. Introduction

The “Bluetooth Mass Storage” design project uses software to communicate with a PC through Bluetooth RF or USB signal to provide file transfer and storage on an external flash memory. The project consists of two main software implementations: the PC software and CYPRESS EZ-HOST microcontroller software. In order to facilitate our embedded development, Cypress has provided third-party software under NDA that provides us higher level access to USB communication and access of FAT formatted memory. The PC software written in Python scripting language runs on Linux based UBUNTU operating system which initiates a communication and file transfer with the Bluetooth Mass Storage design project. The Bluetooth Mass Storage Device responds to the requests made by PC over Bluetooth RF. It does not initiate any transfer protocol with another device. The second part of the software implementation is written for the microcontroller CYPRESS EZ-HOST. The microcontroller determines the appropriate transfer protocol, and changes in between modes of operation. The first mode of operation uses USB protocol which has higher priority because it has fast data rate and also the circuit battery is charged through USB lines. In USB mode the microcontroller acts as a transparent layer; meaning only passes the signal from USB header to USB signal and sends it to the Flash Controller through USB pins. However it is responsible of making necessary changes on Bluetooth communication if it is already established. The second mode is Bluetooth communication. The Bluetooth module sends RF signal through UART lines so it is microcontroller’s responsibility to convert the signal to USB pins on the Flash Controller. In times of switching between modes, the microcontroller determines the priority of each communication, and makes necessary changes. The goal here is to make the transition as smooth as possible without any loss of data in between mode changes.

2. Software Design Considerations

The Bluetooth Mass Storage Device will communicate with a PC through either USB or Bluetooth RF signal. The user will be able to change directory and file system in the flash memory, and also receive and send files using the PC software. In terms of implementation, there are two main applications: “The PC Software” and “EZ-Host Microcontroller Software”. They will be explained in the following sections.

2.1 The PC Software:

The PC Software enables user to access the Bluetooth Mass Storage Device. It supports Bluetooth handshaking protocol and OBEX (object exchange) FTP protocol. After some research, Python scripting language and Linux based Ubuntu OS were chosen to build the application. After considering “Python”, “Microsoft Visual Studio” and “Java J2R”; we observed that J2R and Python have very good support on Bluetooth communication, and having more experience in Python we chose Python and PyBluez API. Using Bluetooth dongle, a sample code [1] was tested to communicate with a Bluetooth development kit. This sample code is given in “Appendix A: A1 Sample Software Code for PC Software”.

When the program is executed, the user will be able to search devices. After available devices displayed, user will be able to select the device and type passkey in order to establish connection with the device. The passkey may have up to 16 digits and encrypted within Bluetooth communication protocol. The block diagram is given in “A.2. PC Software Block Diagram”. The screenshot image of a sample program running on UBUNTU OS was given in Appendix C.

2.2 EZ-Host Programmable Microcontroller Software:

The Cypress CY7C6700 EZ-Host Programmable Embedded USB Host/Peripheral Controller communicates with PC software through Bluetooth module via asynchronous UART pins, and converts this signal into FAT file system. This signal is passed onto the Flash Controller through microcontroller’s USB pins. The microcontroller contains 8K x 16 internal SRAM and 8 K on-chip EEPROM. However the EEPROM is reserved for BIOS; therefore 128K SRAM and 32K EEPROM external memory have been used. The program code will be stored into 32K EEPROM, and 128K SRAM will be used as a buffer if needed. A large 128K SRAM was chosen to hold large USB chunks in memory because of the data rate difference between the Bluetooth module and the Flash Controller; 3Mbits/sec and 12Mbits/sec respectively.

The Bluetooth module is connected to the microcontroller via asynchronous UART pins. The microcontroller sends AT commands to program the Bluetooth module to change its settings, and the data transfer will be done on the same UART pins as well after handshaking is established. In terms of the peripherals, interrupt-driven timer module is used. In order to use the TIMER module, Interrupt enable register will be used. Depending on the time that the push button is pressed different functionalities will be implemented. For example; if the button is pressed for a long time, then the device will turn off. In USB mode, the microcontroller becomes a transparent layer between the USB header and the Flash Controller. The microcontroller’s OTG (USB On-the-go) pins are connected to the USB pins of the Flash controller. The microcontroller will be polling this line, and if activity is detected, necessary changes will be made. This block diagram is given in Appendix B “Hierarchical Block Diagram of Code Organization”

The microcontroller’s internal mapping [2] is given in Firgure 2.2.1.

Figure 2.2.1 Memory Map (Internal Memory)

| |HW INT’s |

|0x0000 – 0x00FF | |

| |SW INT’s |

|0x0100 - 0x011F |Primary Registers |

|0x0120 - 0x013F |Swap Registers |

|0x0140 - 0x0148 |HPI Int / Mailbox |

|0x014A - 0x01FF |LCP Variables |

|0x0200 - 0x02FF |USB Registers |

|0x0300 - 0x030F |Slave Setup Packet |

|0x0310 - 0x03FF |BIOS stack |

|0x0400 - 0x04A2 |USB Slave & OTG |

|0x04A4 - 0x3FFF |USER SPACE |

| |~15K |

| | |

|0xC000 - 0xC0FF |Control Registers |

| | |

|0xE000 - 0xFFFF |BIOS |

In terms of initial debugging we used the Bluetooth Dev Kit. Initially PIC microcontroller was used, and some testing had been done before design change. This test and debugging includes blinking of LED for timer module, and communicating with the Bluetooth module via UART pins in order to change its settings.

3. Software Design Narrative

The Cypress microcontroller software provides the USB and FAT file system interpreting capability. In order to use their software NDA had to be agreed upon. The company also provided us some GNU tools that have been ported over to our microcontroller’s architecture. The second implementation includes the PC software written in Python using PyBluez API.

3.1 Cypress microcontroller software implementation

The block diagram of this implementation is given in Appendix B “Hierarchical Block Diagram of Code Organization”. The Software code polls the USB pins, and if some activity is detected, the checks if Bluetooth protocol status. Since it gives higher priority to USB protocol, it tries to terminate the Bluetooth communication smoothly. If Bluetooth communication is idle, it disconnects the communication, so that the PC side will not initiate another file transfer. If USB connection is idle, then the microcontroller sends the passkey to the Bluetooth module and makes the device visible to other devices. This is done via UART pins, and the microcontroller sends AT commands to the Bluetooth Module in order to change its status. Once the Bluetooth communication is established, it again checks for USB connection. In Bluetooth mode, it converts the data on UART pins into USB protocol and sends it to the Flash Controller.

1 The PC Software:

The PC software is written in Python, and uses mainly Tkinter GUI and PyBluez API. The block diagram for is given in “Appendix A2. PC Software Block Diagram”. Once the program is called on the command prompt, it brings up the main frame that gives the search option. If this option is chosen by clicking on the button, then it calls a function called “Search_devices()”. Using PyBluez API, the Bluetooth devices are recognized and displayed in window frame. Upto this point this software has been implemented and tested, and a screenshot image is given in Appendix C PC Software Screenshot. After one device is selected, the event handler On_Device_Selected() makes the connection to that particular device if the correct passkey is entered. Upon successful connection, the menu is displayed on the command prompt of this software. If the user types shell commands, then the PC software will execute those commands that are supported by our software. These commands will include “DIR”, “MV”, “CP”, “RM”, “RMDIR” etc.

4. Summary

The Bluetooth Mass Storage Device communicates with a PC software and serves the requests made by PC software user. Using this software one may connect to the design project and do file transfer. The USB connection provides much faster connection and also used to recharge the battery. In order to demonstrate this design project, the PC software is also being implemented, using Python along with Tkinter GUI and PyBluez API that enables Bluetooth protocol connection. The microcontroller in this design orchestrates each communication and allows smooth data transfer, giving higher priority to the USB. Parts of the software implementation have been done successfully, and the remaining part is mainly on file system.

List of References

1] RobertPrice.co.uk; Programming with Bluetooth using Python; [INTERNET]



2] Cypress Semiconductor Corporation; Cypress CY7C67300 Datasheet; [INTERNET]



Appendix A: Flowchart/Pseudo-code for Main Program

A.1 Sample Software Code for PC Software

| |

|#!/usr/bin/env Python |

| |

|# This code is provided at the following URL, and only used for testing |

|# purposes: |

|# |

|# Programming_Bluetooth_Using_Python.shtml |

|# |

| |

|import bluetooth |

| |

|print "looking for nearby devices..." |

| |

|nearby_devices = bluetooth.discover_devices(lookup_names = True, flush_cache = True, duration = 20) |

| |

|print "found %d devices" % len(nearby_devices) |

| |

|for addr, name in nearby_devices: |

|print " %s - %s" % (addr, name) |

|for services in bluetooth.find_service(address = addr): |

|print " Name: %s" % (services["name"]) |

|print " Description: %s" % (services["description"]) |

|print " Protocol: %s" % (services["protocol"]) |

|print " Provider: %s" % (services["provider"]) |

|print " Port: %s" % (services["port"]) |

|print " Service id: %s" % (services["service-id"]) |

|print "" |

|print "" |

A.2 PC Software Block Diagram

Appendix B: Hierarchical Block Diagram of Code Organization

Appendix C: PC Software Screenshot

[pic]

Appendix D: Overall Block Diagram

-----------------------

START

NOTE: This is the last in a series of four “design component” homework assignments, each of which is to be completed by one team member. The completed homework will count for 20% of the individual component of the team member’s grade. The body of the report should be 3-5 pages, not including this cover sheet, references, attachments or appendices.

START

SEARCH

DEVICES

Is Device Selected

NO

YES

CONNECT

On_Device_Selected()

Search_devices()

* File Transfer

* Change Passkey

* Disconnect

DISCONNECT

Disconnect()

Change Directory System

Transfer File

Read_file()

Write_file()

get_dir()

change_dir()

On_change_passkey()

Change passkey

SRAM

Microcontroller

GO TO START

Bluetooth Connection

Enable

Bluetooth

NO

USB Connection

Disable

Bluetooth

NO

Wait

YES

Is Bluetooth

Active

YES

USB Signal

Detected

EEPROM

Bluetooth

Module

Flash Controller & Memory

UART

USB

USB

RF

PC

................
................

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

Google Online Preview   Download