time measurement and transfer
DESCRIPTION
TIME MEASUREMENT AND TRANSFER. Aynur Delibaş - Senem Beken 504051504 504051527 Interconnection Protocols Due to: 20.12.2005. Objectives. - PowerPoint PPT PresentationTRANSCRIPT
TIME MEASUREMENT AND TRANSFER
Aynur Delibaş - Senem Beken504051504 504051527
Interconnection ProtocolsDue to: 20.12.2005
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.
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
System Requirements
Intel Pentium III 600 Mhz microprocessor
128 MB RAM ADUC814 mini kit Motion detectors RS232 cable IRDA module
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
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
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.
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.
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.
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
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:
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.
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)
Standard Serial Communication Interface(UART) SCON register is configured for
controlling serial I/O unitMOV SCON, #52h (0101 0010)
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
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.
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
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
Standard Serial Communication Interface(UART) UART register names and
adresses
Standard Serial Communication Interface(UART) Bits of LCR register
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.
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.
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
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.
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
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
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”
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.
Required IrDA protocols
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)
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
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
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
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
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.
IRCOMM2K architecture
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)
Bluetooth protocol stack
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
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.
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.
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
THANKS FOR YOUR ATTENTION…