Bluetooth Z8 Project Report
Bluetooth Z8 Project Report
Bluetooth Z8 Project Report
1.
Introduction
This project intends to implement an information transaction between Zilog Z8 Encore! Microcontroller Unit and a cell phone via Bluetooth connection. Once the communication is established, user is allowed to send a command from cell phone to the Z8 to request some information, e.g the temperature. The Z8 MCU is supposed to be used as a countdown alarm and string displayer as well.
2.
1) 2) 3) 4) 5)
Components
Z8 Encore! Microcontroller Unit; Bluetooth Module; Temperature Sensors; Speaker; Java and Bluetooth supported cell phone.
Figure 3: Temperature Sensors The Bluetooth module used in this project is manufactured by SparkFun Electronics and the Bluetooth component is Philips BGB203. The temperature sensors used here are ADC and I2C sensors.
3.
3.1
Project Description
Functionality: 1) Z8 Side a) Z8 has physical connections with Bluetooth module, temperature sensors and speaker; b) Z8 reads temperature data from both two sensors; c) Z8 is implemented as a countdown timer. When the time is up, the speaker sounds as an alarm; d) Z8 displays string with LED arrays; 2) Cell Phone Side a) Cell phone runs J2ME application to discover the devices in the certain range with Bluetooth; b) Cell phone connects to the target device; 3) Communication a) Cell phone detects the Bluetooth module that links to Z8 MCU and asks for connection by sending a passkey 0000; b) Z8 receives the passkey and reminds user there is a connection request which is supposed to be answered by pressing switch 1 (sending answer key Z8BT); c) When connection is established, cell phone is supposed to send a string or a command to Z8; d) Z8 displays strings with LED arrays or answers the requests from cell phone.
Figure 4: Connection Negotiation 3.2 Developing Technologies 1) Z8 Encore! Family IDE version 4.10 (06121401)
Used to develop and debug the program on Z8. 2) Java JDK 1.6 Sun Java compiler, used to compile the program on cell phone. 3) Sun Wireless Tool Kit (WTK) 2.5 Emulator, used to compile and debug the J2ME application for mobile devices. 4) Sun Netbeans IDE 6 Developing tool for J2ME application.
4.
4.1
Hardware
Overview
Figure 5: Overview of implementation Nokia N93i: GSM mobile phone; CLDC 1.0/MIDP 2.0 J2ME support; Bluetooth support; Typically, all Java runtime environment supported mobile devices meet the requirement of this project. Zilog Z8 Encore: Z8F6403 8 bit microprocessor; UART interface for Bluetooth communications;
GPIO pins; ADC and I2C interfaces for temperature sensors; SparkFun Bluetooth Module: Philips BGB203 Bluetooth Component; UART interface, baud rate at 9600; Plug-and-play Bluetooth class 1 System-in-a-Package (SiP); Peripheral pins 1.8 and 3.3 V; LM34 Temperature Sensor: Analog data output; Calibrated directly in degrees Fahrenheit; Linear +10.0 mV/F scale factor; Rated for full 50 to +300F range; Operates from 5 to 30 volts; TMP175 Temperature Sensor: 27 Address ; Digital Output: Two-Wire Serial Interface; Resolution: 9- to 12-Bits, User-Selectable; Wide Supply Range: 2.7V to 5.5V. 4.2 Pin Connection Detail Table 1: Pin Connection Detail Module Zilog Z8 VDD Power supply VCC (3V) GND Ground GND RX Receive register Port D bit 5 (Transmit register) SparkFun Bluetooth TX Transmit register Port D bit 4 (Receive register) RTS Request to send Loop to disable hardware flow control CTS Clear to send VDD Power supply VDD (5V) ADC Output of analog Port B bit 1 (Analog pin 1) Vout Sensor signal GND Ground GND VDD Power supply VDD (5V) SCL Serial clock signal Port A bit 6 (SCL) I2C Sensor SDA Serial data signal Port A bit 7 (SDA) GND Ground GND Pin 1 2 pins for speakers PC0 Speaker high and low Pin 2 PC1
4.3
Hardware Diagram
VCC (3V) VDD SparkFun BT RX TX RTS CTS PB1 (ALG1) GND VDD (5V)
PD5 (TXD1) PD4 (RXD1) ADC VDD ADC VOUT ADC GND Temperature Sensors I2C VDD I2C SCL I2C SDA I2C GND Pin1 Pin2 PA6 (SCL) PA7 (SDA)
Zilog Z8
Speaker
PC0 PC1
5.
Software
5.1 Z8 Side The program starts with waiting for connection request. When there is a request being received, the program verifies the request string. If the string is correspondent to the default, Z8 sends an answer to cell phone to establish the connection. Then receiver of UART1 keeps waiting for the data. When the string is received, program checks the string whether a command or a string received. If the data starts with command mark ~, validate the following bytes to find out if it is a valid command or not. If it is a string, display it on the LED.
Startup Initialization Connection Established NO Not a Request Wait for request Receive String Check request Valid Request Send answer
Check input
String
Help
Error
5.2
Figure 8: J2ME Software Implementation 5.3 Programming Detail ZDS Project BluetoothZ8.zdsproj: Table 2: Files of ZDS Project File Description Implementation Initialize and read from ADC ADC_init(); ADC.c temperature sensor. ADC_read(); check_string(); send_temp(); Validate the type of receiving string; function.c float_to_char(); Send temperature information. read_num(); char_to_int(); Initialize the LED array; gpio_init(); Initialize the switch 1; sio_init(); GPIO.c Initialize the speaker; speaker_init(); Switch 1s interrupt. isr_sw1(); Initialize and read from I2C I2C_init(); I2C.c temperature sensor. I2C_read();
interrupt.c
Initialize Timer1 for PWM output on speaker. Functions for LED display. Main file to startup the program. Initialization and interrupt of timer 0 which is countdown timer. Initialize the UART registers and receive interrupt; Functions for sending string.
uart.c
timer1_init(); isr_timer1(); enable_mute(); disable_mute(); led_all_off(); etc. main(); timer0_init(); isr_timer0; uart_init(); isr_uart1_rx(); send_string(); send_byte(); etc.
J2ME project Bluetooth&Z8: Table 3: Files of J2ME Project File Description Class for connecting the remote Bluetooth module and Agent.java sending or receiving data. Conn.java Class for establishing connection. Debug.java Form of debugging report. DeviceList.java List of found devices. Logger.java Form for displaying receiving data and history operations. MainUI.java Form of users GUI. Z8BT.java Main Midlet of project. 5.4 Implementation Detail
Command Syntax: ~<command><configuration><parameter> <command>: required; <configuration>: required when set Z8 as a countdown timer; <parameter>: optional. Mobile Device Logger: Previous command is: ~<command><configuration><parameter> Response: <response>
10
Command Set of Project: Cmd ~H or ~h Table 4: Command Set Implementation Description Z8 LED Mobile Device Display received Request help from Z8. HELP help information on logger form. Request all Temp data and differential value. Specific Temp Display received Optional configure: data or differential Temp information -A or a: from ADC sensor. Temp value. on logger form. -I or i: from I2C sensor. Set Z8 as countdown alarm. Display integer Required configure: Display operations value of -A or a: automatically start required to start or <parameter>. timer. stop alarm on When time is up, -M or m: manually start speaker sounds to logger form. timer by user. remind user. <parameter> should be greater than 0.
~T or ~t
~C or ~c
6.
Summary
This project is a highly practical example for integrating the software and hardware technologies. The concept of this project is not only focusing on the temperature capturing, but also many utilities in the regular life. I really hope it can be helpful for the public services in the future.
11
Appendix - Photo
12
13
14