Date post: | 06-Apr-2018 |
Category: |
Documents |
Upload: | sumita-santara |
View: | 216 times |
Download: | 0 times |
8/2/2019 Chen Final
http://slidepdf.com/reader/full/chen-final 1/14
Bluetooth Z8 – Yao Chen 1
Bluetooth Z8
Project ReportFor CSci297 Embedded System
April 22, 2008
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 stringdisplayer as well.
Figure 1: Z8 Encore! MCU Connection
8/2/2019 Chen Final
http://slidepdf.com/reader/full/chen-final 2/14
Bluetooth Z8 – Yao Chen 2
2. Components
Generally, there are five basic components for this project:
1) Z8 Encore! Microcontroller Unit;
2) Bluetooth Module;3) Temperature Sensors;
4) Speaker;
5) Java and Bluetooth supported cell phone.
Figure 2: SparkFun Bluetooth Module
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.
8/2/2019 Chen Final
http://slidepdf.com/reader/full/chen-final 3/14
Bluetooth Z8 – Yao Chen 3
3. Project Description
3.1 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) Communicationa) 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)
8/2/2019 Chen Final
http://slidepdf.com/reader/full/chen-final 4/14
Bluetooth Z8 – Yao Chen 4
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. Hardware
4.1 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;
Physical Connection
Wireless Connection
8/2/2019 Chen Final
http://slidepdf.com/reader/full/chen-final 5/14
Bluetooth Z8 – Yao Chen 5
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 +300°F 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
SparkFun
Bluetooth
VDD Power supply VCC (3V)
GND Ground GNDRX Receive register Port D bit 5 (Transmit register)
TX Transmit register Port D bit 4 (Receive register)
RTS Request to send Loop to disable hardware flow
controlCTS Clear to send
ADC
Sensor
VDD Power supply VDD (5V)
VoutOutput of analog
signal
Port B bit 1 (Analog pin 1)
GND Ground GND
I2C
Sensor
VDD Power supply VDD (5V)
SCL Serial clock signal Port A bit 6 (SCL)
SDA Serial data signal Port A bit 7 (SDA)
GND Ground GND
Speaker Pin 1 2 pins for speaker’s
high and low
PC0
Pin 2 PC1
8/2/2019 Chen Final
http://slidepdf.com/reader/full/chen-final 6/14
Bluetooth Z8 – Yao Chen 6
4.3 Hardware Diagram
Figure 6: Hardware Diagram
5. Software5.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.
Zilog Z8
VCC (3V)
VDD (5V)
PB1 (ALG1)
PD5 (TXD1)
PD4 (RXD1)
PA6 (SCL)
PA7 (SDA)
PC0
PC1
Temperature
Sensors
ADC VDD
ADC VOUT
ADC GND
I2C VDD
I2C SCL
I2C SDAI2C GND
VDD GND
RX TX RTS CTS
SparkFun BT
Pin1
Pin2S eaker
8/2/2019 Chen Final
http://slidepdf.com/reader/full/chen-final 7/14
Bluetooth Z8 – Yao Chen 7
Figure 7: Z8 Software Implementation
Startup
Send answer
Countdown
RequestString
Temperature
Request
Read
Temperature
Send
Temperature
Start Timer
and alarm
Send
Instruction
Display
String
Send
Receipt
Help
Send
Instruction
Error
Display
Error
Send Error
Message
Wait for input
Check input
Wait for request
Check request
Initialization
Connection
Established
Not a
Request
Valid Request
NO
Receive
String
8/2/2019 Chen Final
http://slidepdf.com/reader/full/chen-final 8/14
Bluetooth Z8 – Yao Chen 8
5.2 Cell Phone Side
Figure 8: J2ME Software Implementation
5.3 Programming Detail
ZDS Project – BluetoothZ8.zdsproj:
Table 2: Files of ZDS Project
File Description Implementation
ADC.cInitialize and read from ADC
temperature sensor.
ADC_init();
ADC_read();
function.cValidate the type of receiving string;
Send temperature information.
check_string();
send_temp();
float_to_char();
read_num();
char_to_int();
GPIO.c
Initialize the LED array;
Initialize the switch 1;
Initialize the speaker;
Switch 1’s interrupt.
gpio_init();
sio_init();
speaker_init();
isr_sw1();
I2C.cInitialize and read from I2C
temperature sensor.
I2C_init();
I2C_read();
Main Midlet
Startup
Device List
Send Request
User GUI
Debug Form
Debug Form
Debug Form
Send Cmd
Debug Form
Receive Listen
History Log
Destroy
8/2/2019 Chen Final
http://slidepdf.com/reader/full/chen-final 9/14
Bluetooth Z8 – Yao Chen 9
interrupt.cInitialize Timer1 for PWM output on
speaker.
timer1_init();
isr_timer1();
enable_mute();
disable_mute();
LED.c Functions for LED display. led_all_off();etc.
main.c Main file to startup the program. main();
timer.cInitialization and interrupt of timer 0
which is countdown timer.
timer0_init();
isr_timer0;
uart.c
Initialize the UART registers and
receive interrupt;
Functions for sending string.
uart_init();
isr_uart1_rx();
send_string();
send_byte();
etc.
J2ME project – Bluetooth&Z8:Table 3: Files of J2ME Project
File Description
Agent.javaClass for connecting the remote Bluetooth module and
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 user’s 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>
8/2/2019 Chen Final
http://slidepdf.com/reader/full/chen-final 10/14
Bluetooth Z8 – Yao Chen 10
Command Set of Project:
Table 4: Command Set
Cmd DescriptionImplementation
Z8 LED Mobile Device
~Hor ~h
Request help from Z8. “HELP” Display receivedhelp information
on logger form.
~T
or ~t
Request all Temp data and
differential value.
Optional configure:
-A or a: from ADC sensor.
-I or i: from I2C sensor.
Specific Temp
data or differential
Temp value.
Display received
Temp information
on logger form.
~C
or ~c
Set Z8 as countdown
alarm.
Required configure:-A or a: automatically start
timer.
-M or m: manually start
timer by user.
<parameter> should be
greater than 0.
Display integer value of
<parameter>.
When time is up,
speaker sounds to
remind user.
Display operations
required to start or
stop alarm on
logger form.
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.
8/2/2019 Chen Final
http://slidepdf.com/reader/full/chen-final 11/14
Bluetooth Z8 – Yao Chen 11
Appendix - Photo
Figure 9: Overview of Project
Figure 10: Debug Report
8/2/2019 Chen Final
http://slidepdf.com/reader/full/chen-final 12/14
Bluetooth Z8 – Yao Chen 12
Figure 11: Device List
Figure 12: Connection negotiation
8/2/2019 Chen Final
http://slidepdf.com/reader/full/chen-final 13/14
Bluetooth Z8 – Yao Chen 13
Figure 13: Request ADC Temperature Information
Figure 14: Set a Manual Countdown Timer
8/2/2019 Chen Final
http://slidepdf.com/reader/full/chen-final 14/14
Bluetooth Z8 – Yao Chen 14
Figure 15: Instructions of Help