time measurement and transfer

43
TIME MEASUREMENT AND TRANSFER Aynur Delibaş - Senem Beken 504051504 504051527 Interconnection Protocols Due to: 20.12.2005

Upload: mikaia

Post on 12-Jan-2016

32 views

Category:

Documents


0 download

DESCRIPTION

TIME MEASUREMENT AND TRANSFER. Aynur Delibaş - Senem Beken 504051504 504051527 Interconnection Protocols Due to: 20.12.2005. Objectives. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: TIME MEASUREMENT AND                TRANSFER

TIME MEASUREMENT AND TRANSFER

Aynur Delibaş - Senem Beken504051504 504051527

Interconnection ProtocolsDue to: 20.12.2005

Page 2: TIME MEASUREMENT AND                TRANSFER

Objectives

Measurement of time interval of a particle passing between two sensors and transfering the measured time from microcontroller to PC and then from PC to mobile phone.

Page 3: TIME MEASUREMENT AND                TRANSFER

Platforms Used

Microsoft Visual C++ 6.0 Turbo C ADuC software Compile and debug (ASPIRE.exe) Assembler (ASM51.exe) Downloader (WSD.exe) Borland JBuilderX Ircomm2K Nokia Developer’s Suite 3.0

Page 4: TIME MEASUREMENT AND                TRANSFER

System Requirements

Intel Pentium III 600 Mhz microprocessor

128 MB RAM ADUC814 mini kit Motion detectors RS232 cable IRDA module

Page 5: TIME MEASUREMENT AND                TRANSFER

Hardware Components

ADuC814 microcontroller 28 pins, 8 bits 8051 compatible 6 channels ADC & 12 bits DAC 3-5 V power supply No need for an additional program loading

card On-chip program download feature from

serial port RS232 cable For loading assembler code to the

microcontroller For writing data to serial port

Page 6: TIME MEASUREMENT AND                TRANSFER

Motion Detectors

Detects the particles moving Products signal with the changement

of the voltage Working on negative logic The output voltage is 12 V. To

decrease the voltage to the logic 1(5 V), a voltage divisor is used.

Easy installation, portable, low price

Page 7: TIME MEASUREMENT AND                TRANSFER

Assembler Code

Intel 8051 assembler language Using interrupts and timers Main program waits for signal coming

from the first motion detector. After taking the signal from the first

motion detector, time counting starts. When a signal comes from the second

detector, time counting ends. The millisecond and second values of

measured time are written to the serial port via RS232 cable.

Page 8: TIME MEASUREMENT AND                TRANSFER

Assembler Code

DEF.ASM: Code piece which contains the definitions of variables that are used in the program. The variables used for measuring time: ON_MSN, YUZ_MSN, SANIYE

INITIAL.ASM: Code piece which contains the default value assignments for the time variables , configuration of UART for 9600 baud, setting timer so that it produces an interrupt for each 10 ms and enabling all interrupts.

Page 9: TIME MEASUREMENT AND                TRANSFER

Assembler Code

TIMER0.ASM: Code piece which measures the time value by changing the values of ON_MSN, YUZ_MSN, SANIYE variables when an interrupt occurs(from the first sensor)

MAIN.ASM: Waits for interrupt from the first sensor. When interrupt occurs timer starts to count and TIMER0.ASM is called. When an interrupt comes from the second sensor, timer is set to zero. Time value is calculated and written to the serial port.

Page 10: TIME MEASUREMENT AND                TRANSFER

RS232 Serial Communication Communication standart that

provides communication of peripheral devices with computer

Characters are sent bit by bit Advantage: Easy connection Disadvantage: When

communication speed increases, cable length should be decreased to prevent losing data

Page 11: TIME MEASUREMENT AND                TRANSFER

RS232 Serial Communication RS232 defines bits as electrical

signal: Bit “1” : (-3)V – (-25)V Bit “0” : (+3)V – (+25)V Undefined signal: (-3)V – (+3)V 9 pins RS232 connector:

Page 12: TIME MEASUREMENT AND                TRANSFER

RS232 Serial Communication For serial communication Pin 5(GND) of microcontroller

RS232 connector is connected to Pin5(GND) of PC RS232 connector

Pin 3(TxD) of microcontroller RS232 connector is connected to Pin2(RxD) of PC RS232 connector and vice versa

RS232 is a physical layer protocol of OSI model. It provides sending and receiving data on a carrier.

Page 13: TIME MEASUREMENT AND                TRANSFER

Standard Serial Communication Interface(UART) ADuC814 microcontroller has a

serial communication unit UART Timer2 is used to config baud

rate T2CON(Timer/Counter 2 Control

Register) is configuredMOV T2CON, #34h (0011 0100)

Page 14: TIME MEASUREMENT AND                TRANSFER

Standard Serial Communication Interface(UART) SCON register is configured for

controlling serial I/O unitMOV SCON, #52h (0101 0010)

Page 15: TIME MEASUREMENT AND                TRANSFER

Standard Serial Communication Interface(UART) Baud Rate Table

The necessary configuration is done in the assembler code for serial communication by assigning the required values to the related registers for 9600 baud rate

Page 16: TIME MEASUREMENT AND                TRANSFER

Standard Serial Communication Interface(UART) Sending data to serial port SBUF register is used Character that will be sent to the

serial port is written to SBUF register Writing to serial port is done in a time

interval Before a new character is sent, it

should be sure that the previous one is written successfully

This control is done by TI bit of SCON register. If bit is 1, then a new character can be sent.

Page 17: TIME MEASUREMENT AND                TRANSFER

Standard Serial Communication Interface(UART) Sending data to serial port Example: Sending SANIYE variable

to serial portMOV A, SANIYE MOV SBUF, AJNB TI, $ ; if TI = 1 sent operation is

; doneCLR TI ; Clear TI for sending new

; character

Page 18: TIME MEASUREMENT AND                TRANSFER

Standard Serial Communication Interface(UART) Reading data from serial port A C code was written Turbo C compiler was used Two functions of dos.h header are used

int inportb(int portid); void outportb(int portid, unsigned

char value); Definition of COM1 Port base address: #define PORT1 0x3F8

Page 19: TIME MEASUREMENT AND                TRANSFER

Standard Serial Communication Interface(UART) UART register names and

adresses

Page 20: TIME MEASUREMENT AND                TRANSFER

Standard Serial Communication Interface(UART) Bits of LCR register

Page 21: TIME MEASUREMENT AND                TRANSFER

Standard Serial Communication Interface(UART)

Configuration of UART registers for 9600 baud rate//DLAB=1 for baudrate configurationoutportb(PORT1+3,0x80); //baudrate 9600 bpsoutportb(PORT1+0,0x0C);//low byteoutportb(PORT1+1,0x00);//high byte

Control whether the data comes from the serial portinportb(PORT1+5);

If data comes from the serial port, read datainportb(PORT1);

After these operations, data come from serial port is written to a text file to be used for the IRDA module.

Page 22: TIME MEASUREMENT AND                TRANSFER

Results of Hardware Module

Time passing between two motion detectors are measured with the format second and millisecond.

Measured time value is written to the serial port.

With the code compiled with Turbo C, time value is read from the serial port.

Measured time value is written to a file.

Page 23: TIME MEASUREMENT AND                TRANSFER

IrDA: General features

Inexpensive and widely adopted short range wireless technology

Designed to eliminate wires, connectors and their limitations

Replaces wires with a “virtual wire”

Key protocol features for easy operation for: Inexperienced users Devices with little user interface

Page 24: TIME MEASUREMENT AND                TRANSFER

IrDA: General features

Communication in half duplex mode

During transmission, the device’s transceiver is blinded by the light of its own transmitter

Simulation of full duplex communication by the communicating devices.

Page 25: TIME MEASUREMENT AND                TRANSFER

IrDA: General features

Transmission rates: SIR (Serial IrDA): Speeds normally

supported by RS-232 (9600 bps, 19.2 Kbps, 38.4 Kbps, 57.6 Kbps, 115.2 Kbps)

MIR (Medium IrDA): Unofficial term for .576 Mbps and 1.152 Mbps

FIR (Fast IrDA): Communication speed at 4Mbps

VFIR (Very Fast IrDA): Speeds up to 16 Mbps

Page 26: TIME MEASUREMENT AND                TRANSFER

IrDA: General features

IrDA protocols organized in the traditional layered (stacked) architecture

Stack composed of mandatory (required to carry IrDA logo) and optional (for specific use models) layers

Page 27: TIME MEASUREMENT AND                TRANSFER

Typical use model

Two devices: primary and secondary Primary:

Responsible for selecting a device within its visual space (“device discovery”)

Establishes connection

Responsible for maintaining the communication on the virtual wire

Secondary: Responses when “spoken to”

Page 28: TIME MEASUREMENT AND                TRANSFER

Operation Primary device initiates device

discovery.

From the devices that respond, primary selects one and tries to connect to it

During connection establishment, devices negotiate to understand each other’s capabilities.

Once connection established, devices jump to their highest common connection speed and attempt to optimize throughput and reliability of connection.

Page 29: TIME MEASUREMENT AND                TRANSFER

Required IrDA protocols

Page 30: TIME MEASUREMENT AND                TRANSFER

Optional IrDA protocols

IrOBEX (IrDA Object Exchange) IrCOMM IrLPT (IrDA Line Printer Protocol) IrTran-P (IrDA Transfer Picture) IrMC (IrDA Mobile Communications) RTCON (Real time transfer and control

protocol) JetSend (Created and licensed by HP

for digital image transfer)

Page 31: TIME MEASUREMENT AND                TRANSFER

Optional IrDA protocols

Optional IrDA protocols used in the project: IrCOMM, IrOBEX and also IrDA Lite which is not a protocol itself.

IrCOMM: Designed to provide support for

applications that run over COM ports

IrOBEX: Best used in situations where objects

(phone, address, calendar information etc.) are to be moved from one device to another

Page 32: TIME MEASUREMENT AND                TRANSFER

Optional IrDA protocols

IrDA Lite: Not a protocol itself

Renders minimal implementation on embedded devices to

Reduce memory consumption (two to five times reduction in RAM / ROM usage)

Enable devices to still interoperate with full featured IrDA stacks

Result: Reduction in operation speed (9600 bps), throughput and removal of non-essential features from the stack

Page 33: TIME MEASUREMENT AND                TRANSFER

Implementation

Client-server architecture Server side:

Implemented in C++ using Microsoft Platform SDK

Runs on a PC Reads data from a file, opens the IrDA

port and writes to it The IrDA port treated like a “casual”

COM port thanks to the IrCOMM2K virtual COM port driver

Page 34: TIME MEASUREMENT AND                TRANSFER

IrCOMM protocol support in MS OS

Support since Microsoft Windows 2000

Two possible protocol implementations on the OS side:

Providing a virtual COM port which behaves like an actual COM port (existing programs do not have to be rewritten.)

Providing an interface for applications that use IRCOMM protocol

Page 35: TIME MEASUREMENT AND                TRANSFER

IrCOMM protocol support in MS OS

Microsoft’s choice: (2nd approach) All existing programs had to be ported to Windows 2000 using Windows Socket API which supports a simplified version of IRCOMM protocol

IRCOMM2K’s role: A COM port can only be realized as a

driver in kernel space. The Winsock API is designed for user

space applications and cannot be directly used by kernel drivers.

Page 36: TIME MEASUREMENT AND                TRANSFER

IRCOMM2K architecture

Page 37: TIME MEASUREMENT AND                TRANSFER

Implementation (cntd)

Client side: Implemented in J2ME as a MIDlet

application Runs on a mobile phone Waits for a connection, reads data from

the IrDA port and displays the result on the phone’s screen

JSR-82 Java APIs for Bluetooth Wireless

Technology (JABWT) Composed of two independent optional

packages Core Bluetooth API OBEX (Object Exchange)

Page 38: TIME MEASUREMENT AND                TRANSFER

Bluetooth protocol stack

Page 39: TIME MEASUREMENT AND                TRANSFER

Implementation (cntd)

L2CAP (logical link control and adaptation protocol) Packet oriented multiplexing layer

designed for higher leverl protocols (RFCOMM, SDP)

It can be used when the application needs to control bytes in a single packet

RFCOMM: Emulates a serial connection Used for stream oriented connections

Page 40: TIME MEASUREMENT AND                TRANSFER

Implementation (cntd)

OBEX: Originally introduced by Infrared Data

Association High level API and protocol for

exchanging objects

Connections of the types named above are based on GCF (Generic Connection Framework), a hierarchy of interfaces and classes to create connections and perform I/O.

Page 41: TIME MEASUREMENT AND                TRANSFER

Why RFCOMM?

Emulates serial connection

Selected mobile device does not have OBEX support

No need to control bytes in packets

Easy to handle connections and perform operations on them with the help of the GCF.

Page 42: TIME MEASUREMENT AND                TRANSFER

Encountered problems

JABWT has to be compatible with CLDC (connected limited device configuration) Problems with the CLDC 1.0 because of missing floating point support

No standard implementation: Phone manufacturers do not have to implement optional protocols and may omit implementing parts of them

Page 43: TIME MEASUREMENT AND                TRANSFER

THANKS FOR YOUR ATTENTION…