Vous êtes sur la page 1sur 15

Development of a Wireless Gateway Node

A Research document made by Group 01


Ganesh Ramesh
Mohammed Imran
Niveditha Bhat

Wireless Gateway Node

Page 1

Table of Contents

1. Introduction.....................................................................................3
2. Basic communication terms.............................................................3
3. Selection of a protocol.....................................................................3
4. Programming Xbee and Arduino.....................................................10
5.
6.
7.
8.
9.

Setting up a database......................................................................12
Visualization of the data on the Computer......................................12
Transferring the data from the Arduino to MATLAB........................13
Conclusion........................................................................................13
References........................................................................................13

Wireless Gateway Node

Page 2

1. Introduction
This document contains all the information we have collected that could help us in
our project.

2. Basic communication terms:


OSI (Open Systems Interconnection) Model

Wireless Gateway Node

Page 3

Figure 1. OSI Model

OSI was developed in 1984 by the International Organization for


Standardization (ISO), a global federation of national standards organizations
representing approximately 130 countries. The core of this standard is the OSI
Reference Model, a set of seven layers that define the different stages that data must
go through to travel from one device to another over a network. The term open in
OSI was used because the intent of the model was to provide a way for networks to
be interconnected without regard to the underlying hardware, as long as the
communications software adhered to the standards.
1. Application Layer: Provides network services to user applications. It is
responsible for exchanging information between programs running on the
machine, such as an e-mail program, and other services running on a network,
such as a print server or another computers' application.
2. Presentation Layer: Concerned with how data is converted and formatted for
data transfer. Examples of format conversions include ASCII text for documents
and .gif and JPG for images. This layer performs code conversion, data translation,
compression and encryption.
3. Session Layer: Determines how two devices establish, maintain and manage a
connection - how they talk to each other. These connections are called sessions.
4. Transport Layer: Responsible for breaking the data into segments, establishing
an end-to-end logical connection between machines, and providing for error
handling.

Wireless Gateway Node

Page 4

5. Network Layer: Responsible for determining addressing on the network,


determining the routes that information will take on its journey, and managing
network traffic congestion. Data at this level is packaged into packets.
6. Data Link Layer: Provides the link for how data, packaged into frames is
communicated through hardware to be transported across a medium. It
communicates with network cards, manages physical layer communications
between connecting systems and handles error notification.
7. Physical Layer: Specifies how data is processed into bits and physically
transferred over medium, such as cables. It's responsible for activating and
maintaining the physical link between systems.

Data Transmission:
Data transmission, digital transmission, or digital communications is the physical
transfer of data (a digital bit stream) over a point-to-point or point-to-multipoint
communication channel.

Examples

of

such

channels

are copper

wires, optical

fibres, wireless communication channels, storage media and computer buses. The
data

are

represented

as

an electromagnetic signal,

such

as

an electrical

voltage, radio wave, microwave, or infrared signal.

Serial and parallel data transmission

Figure 2. Serial and Parallel Transmission

In telecommunications, serial transmission is the sequential transmission of signal


elements of a group representing a character or other entity of data. Digital serial
transmissions are bits sent over a single wire, frequency or optical path sequentially.
Because it requires less signal processing and less chances for error than parallel
transmission, the transfer rate of each individual path may be faster. This can be used
over longer distances as a check digit or parity bit can be sent along it easily.

Wireless Gateway Node

Page 5

In telecommunications, parallel transmission is the simultaneous transmission of


the signal elements of a character or other entity of data. In digital communications,
parallel transmission is the simultaneous transmission of related signal elements over
two or more separate paths. Multiple electrical wires are used which can transmit
multiple bits simultaneously, which allows for higher data transfer rates than can be
achieved with serial transmission. This method is used internally within the computer,
for example the internal buses, and sometimes externally for such things as printers,
The major issue with this is "skewing" because the wires in parallel data transmission
have slightly different properties (not intentionally) so some bits may arrive before
others, which may corrupt the message. A parity bit can help to reduce this. However,
electrical wire parallel data transmission is therefore less reliable for long distances
because corrupt transmissions are far more likely.

Asynchronous and Synchronous Transmission

Figure 3. Asynchronoun and synchronous transmission

Asynchronous transmission uses start and stop bits to signify the beginning bit
ASCII character would actually be transmitted using 10 bits. For example, "0100
0001" would become "1 0100 0001 0". The extra one (or zero, depending on parity
bit) at the start and end of the transmission tells the receiver first that a character is
coming and secondly that the character has ended. This method of transmission is
used when data are sent intermittently as opposed to in a solid stream. In the
previous example the start and stop bits are in bold. The start and stop bits must be
of opposite polarity. This allows the receiver to recognize when the second packet of
information is being sent.
Synchronous transmission uses no start and stop bits, but instead synchronizes
transmission speeds at both the receiving and sending end of the transmission
using clock signal(s) built into each component. A continual stream of data is then
sent between the two nodes. Due to there being no start and stop bits the data
transfer rate is quicker although more errors will occur, as the clocks will eventually
get out of sync, and the receiving device would have the wrong time that had been
agreed in the protocol for sending/receiving data, so some bytes could become

Wireless Gateway Node

Page 6

corrupted (by losing bits).Ways to get around this problem include re-synchronization
of the clocks and use of check digits to ensure the byte is correctly interpreted and
received.

Half Duplex and Full Duplex Communication

Figure 4. Half duplex and full duplex communication

A duplex communication

system is

a point-to-point system

composed

of

two

connected parties or devices that can communicate with one another in both
directions, simultaneously. An example of a duplex device is a telephone. The people
at both ends of a telephone call can speak at the same time and simultaneously each
be heard by the other at the same time. The earphone reproduces the speech of the
other person as the microphone transmits the speech of the local person, because
there is a two-way communication channel between them.
A half-duplex (HDX) system provides communication in both directions, but only one
direction at a time (not simultaneously). Typically, once a party begins receiving a
signal, it must wait for the transmitter to stop transmitting, before replying (antennas
are of trans-receiver type in these devices, so as to transmit and receive the signal as
well).
An example of a half-duplex system is a two-party system such as a walkie-talkie,
wherein one must use "Over" or another previously designated command to indicate
the end of transmission, and ensure that only one party transmits at a time, because
both parties transmit and receive on the same frequency.
A full-duplex (FDX)

system,

or

sometimes

called double-duplex,

allows

communication in both directions, and, unlike half-duplex, allows this to happen


simultaneously. Land-line telephone networks are full-duplex, since they allow both
callers to speak and be heard at the same time, with the transition from four to two
wires being achieved by a hybrid coil in a telephone hybrid.

Wireless Gateway Node

Page 7

A good analogy for a full-duplex system would be a two-lane road with one lane for
each direction. In full-duplex mode, transmitted data does not appear to be sent until
it has been actually received and an acknowledgment was sent back by the other
party.
Two-way radios can be designed as full-duplex systems, transmitting on one
frequency and receiving on another. This is also called frequency-division duplex.
Frequency-division duplex systems can be extended to farther distances using pairs
of simple repeater stations, because the communications transmitted on any one
frequency always travel in the same direction.
There are several benefits to using full-duplex over half-duplex. Firstly, time is not
wasted, since no frames need to be retransmitted, as there are no collisions.
Secondly, the full data capacity is available in both directions because the send and
receive functions are separated. Thirdly, stations (or nodes) do not have to wait until
others complete their transmission, since there is only one transmitter for each
twisted pair.

Bit rate and Baud rate


Bits per second is straightforward. It is exactly what it sounds like. If I have 1000 bits
and am sending them at 1000 bps, it will take exactly one second for them to
transfer.
Baud is symbols per second. If your data encoding uses something other than bits,
the baud rate will be lower than the bit rate by the factor of bits per symbol. That is, if
there are 4 bits per symbol, the baud rate will be that of the bit rate.

UART/ USART
UART- Universal Asynchronous Receiver Transmitter.
USART - Universal Synchronous Asynchronous Receiver Transmitter.
UART, for Universal Asynchronous Receiver Transmitter, is one of the most used
serial protocols. Most controllers have a hardware UART on board. It uses a single
data line for transmitting and one for receiving data. Most often 8-bit data is
transferred, as follows: 1 start bit, low level, 8 data bits, 1 stop bit, high level. The low
level start bit and high level stop bit mean that there's always a high to low transition
to start the communication.
The timing dependency is one of the big drawbacks of UART, and the solution
is USART, for Universal Synchronous/Asynchronous Receiver Transmitter. This can do

Wireless Gateway Node

Page 8

UART, but also a synchronous protocol. In synchronous there's not only data, but also
a clock transmitted. With each bit a clock pulse tells the receiver it should latch that
bit. Synchronous protocols either need a higher bandwidth, like in the case of
Manchester encoding, or an extra wire for the clock, like SPI and I2C.

Serial Interfaces:
For long distance communication (that doesn't have to be hundreds of meters) the 5
V UART is not very reliable, that's why it's converted to a higher voltage, typically
+12 V for a "0" and -12 V for a "1". The data format remains the same. Then you
have RS-232 (which you actually should call EIA-232, but nobody does.) RS-232 is a
very simple serial protocol that was originally used for modems and teletypes. It is
what

is

commonly

called

serial

port

(or

COM

port

in

MS-Windows).

In telecommunications, RS-232 is a standard for serial communication transmission of


data. It formally defines the signals connecting between a DTE (data terminal
equipment) such as a computer terminal, and a DCE (data circuit-terminating
equipment, originally defined as data communication equipment[1]), such as
a modem.
Also defined by the EIA/TIA standard, RS-485 interface is now called TIA-485. It
defines not only a single device-to-device interface but also a communications bus
that can be used to form simple networks of multiple devices. Its configuration and
specifications also extend the range and data rate beyond the RS-232 interface
capabilities. The TIA-232 standard is currently deployed in a wide range of low-datarate short-range applications. It is particularly effective in equipment used in noisy
environments such as factories, process control plants and utilities sites. Cable
lengths are typically less than 50 feet. Common equipment includes low-speed
modems, industrial control equipment like programmable logic controllers (PLCs),
computer numerically controlled (CNC) machine tools, robots, embedded control
computers,

medical

instruments

and

equipment,

and

embedded

controller

development systems
The RS-232 is best for short-distance low-speed requirements. It is simple and low
cost, and plenty of components like line drivers and receivers, UARTs, and connectors
are available to build the interface. Some drivers permit data rates to 2 or 3 Mbits/s
for short lines. Most interface chips include a charge pump dc-dc converter that
supplies the positive and negative supply voltages allowing the IC to operate from a
single 3.3- or 5-V supply.
The RS-485 is for higher speeds over longer ranges or if duplex networking capability
is required. Again, many standard parts are available to create the interface. ICs have
drivers and receivers that can permit more than 32 drops, and data rates can be as

Wireless Gateway Node

Page 9

high as 40 Mbits/s. Some ICs also include dc-dc converters to furnish dual supply
voltages (see the table).
SPI (Serial Peripheral Interface) is another very simple serial protocol. A master sends
a clock signal, and upon each clock pulse it shifts one bit out to the slave, and one bit
in, coming from the slave. Signal names are therefore SCK for clock, MOSI for Master
Out Slave In, and MISO for Master In Slave Out. By using SS (Slave Select) signals the
master can control more than 1 slave on the bus. There are two ways to connect
multiple slave devices to one master, one is mentioned above i.e. using slave select,
and other is daisy chaining, it uses less hardware pins(select lines), but software gets
complicated.
I2C (Inter-Integrated Circuit, pronounced "I squared C") is also a synchronous
protocol, and it's the first we see which has some "intelligence" in it; the other ones
dumbly shifted bits in and out, and that was that. I2C uses only 2 wires, one for the
clock (SCL) and one for the data (SDA). That means that master and slave send data
over the same wire, again controlled by the master who creates the clock signal. I2C
doesn't use separate Slave Selects to select a particular device, but has addressing.
The first byte sent by the master holds a 7 bit address (so that you can use 127
devices on the bus) and a read/write bit, indicating whether the next byte(s) will also
come from the master of should come from the slave. After each byte receiver must
send a "0" to acknowledge the reception of the byte, which the master latches with a
9th clock pulse. If the master wants to write a byte the same process repeats: the
master puts bit after bit on the bus and each time gives a clock pulse to signal that
the data is ready to be read. If the master wants to receive data it only generates the
clock pulses. The slave has to take care that the next bit is ready when the clock
pulse is given. This protocol is patented by NXP(formerly Phillips), to save licensing
cost, Atmel using the word TWI(2-wire interface) which exactly same as I2C, so any
AVR device will not have I2C but it will have TWI.
The CAN Bus is an automotive bus developed by Robert Bosch, which has quickly
gained acceptance into the automotive and aerospace industries. CAN is a serial bus
protocol to connect individual systems and sensors as an alternative to conventional
multi-wire looms. It allows automotive components to communicate on a single or
dual-wire networked data bus up to 1Mbps. As technology progressed, the vehicles
became more complex as electronic components replaced mechanical systems and
provided additional comforts, convenience, and safety features. Up until the release
of CAN Bus, vehicles contained enormous amounts of wiring which was necessary to
interconnect all of the various electronic components.

Wireless Gateway Node

Page 10

Comparative Study of Wireless Protocols

Bluetooth

Wifi

ZigBee

Frequency

2.4 GHz

2.4 to 5GHz

915MHz to 2.4GHZ

Data Rate

1 to 24 Mbps

10 Mbps to 100
Gbps

250 Kbps

Channel Bandwidth

1MHz

22MHz

0.6 to 2MHz

Operating range

10-100m

100m

40-120m

Data Protection

16-bit CRC

32-bit CRC

16-bit CRC

Table 1. Comparision between various protocols.

EnOcean
The EnOcean technology is an energy harvesting wireless technology used
primarily in building automation systems; but is also applied to other applications
in industry, transportation, logistics and smart homes. Modules based on EnOcean
technology combine micro energy converters with ultralow power electronics and
enable wireless communications between batteryless wireless sensors, switches,
controllers and gateways. In March 2012, the EnOcean wireless standard was
ratified as the international standard ISO/IEC 14543-3-10.[1] The standard covers
the OSI (Open Systems Interconnection) layers 1-3 which are the physical, data
link and networking layers. The energy harvesting wireless modules are
manufactured and marketed by the company EnOcean which is based
in Oberhaching, Germany. EnOcean offers its technology and licenses for the
patented features within the EnOcean Alliance framework.
EnOcean technology is based on the energetically efficient exploitation of slight
mechanical motion and other potentials from the environment, such as indoor
light and temperature differences, using the principles of energy harvesting. In
order to transform such energy fluctuations into usable electrical energy,
electromagnetic, solar, and thermoelectric energy converters are used.
EnOcean-based products (such as sensors and light switches) perform without
batteries and are engineered to operate maintenance-free. The radio signals from
these sensors and switches can be transmitted wirelessly over a distance of up to
300 meters in the open and up to 30 meters inside buildings. Early designs from
the company used piezo generators, but were later replaced with electromagnetic
energy sources to reduce the operating force (3.5 newtons), and increase the
service life to 100 operations a day for more than 25 years.

Wireless HART
Wireless Gateway Node

Page 11

WirelessHART is a wireless sensor networking technology based on the Highway


Addressable Remote Transducer Protocol (HART). Developed as a multivendor, interoperable wireless standard, WirelessHART was defined for the
requirements of process field device networks.
The primary uses are 1. Access to diagnostics data available in HART-enabled
instruments, which are installed in legacy systems that do not speak HART. 2)
Condition and performance monitoring of critical equipment, which is not part of
the control loop due to excessive wiring cost.

3. Selection of Protocol
Zigbee is a low-cost and low-power wireless sensor Network. The low duty cycle,
which is lower than 0.15%, makes Zigbee to a low power communication, as the
node can be in a sleep mode most of the time. The maximum number of nodes in
the network is 1024 with a range up to 200 meter.

Table 2. Maximum of devices and range of different wireless protocols

4. Programming Xbee and Arduino


X-bee
The Xbee has 2 communication modes namely AT & API
AT is used for communication through xbee.
API is used to Interact within Xbee.
In a mesh network, devices have one of three different duties:

Coordinator: Establishes and maintains the network by assigning


addresses to joining(associated) devices and assisting with route building.
Routers: move data between nodes that cannot communicate directly due
to distances.
Endpoints: The node that collects data and controls devices on the network
and is typically connected to our controllers, sensors and other devices for
network interfacing.

Digi XCTU software is required to communicate from PC- Xbee

Serial connection: Using Xbee usb adapter board & usb cable.
Modem configuration- AT/API , Coordinator/Enddevice/Router
Set the PAN(personal area network) ID

Wireless Gateway Node

Page 12

All the Xbees in the network must have the same PAN ID

Communication:

Addressing
Error Checking & Acknowledgments
Encapsulation

Figure 5. Packing Data for Delivery

Arduino
Arduino Software is required to program the arduino. It can be used to write the
code and to upload it on to the microcontroller.
The code shall be written with C++ as we are most comfortable with it.
Example code:
void setup()
{
Serial.begin(9600);
}
void loop()

{
Serial.print('H');
delay(1000);
Serial.print('L');
delay(1000);
}

Wireless Gateway Node

Page 13

When you upload this code, you can check that it's working with the Arduino serial
monitor. You should see H's and L's arriving one a second.

5. Setting up a database
The values that are transferred to the Co-ordinator Xbee need to be saved so that
they can be used later. For this purpose we need to set up a database.
We have the following options for setting up the databasea. In the PC
b. In the EEPROM of the Arduino
c. In an SD card
Having the database in a PC is not practical because the data would be lost when
we turn off the machine. In addition, software like SQLServer and MSAccess
cannot interact directly with the serial port of the computer. Hence, we would
have to write an intermediate program to transfer the data.
The Arduino has a database library that makes use of the Arduino's EEPROM
memory to store records in a table. It is very simple to keep the memory footprint
small. However, this has a few issues like :

Tables are limited to a maximum of 255 records

Tables are limited to the amount of EEPROM on your Arduino

Maximum number of records: (EEPROM size / record size = max records)

To solve these issues, a re-implementation of the Arduino database library has


been made. This version increases the maximum number of records allowed in a
database from 256 records (byte) to a theoretical maximum of 4,294,967,295
records (unsigned long). The maximum record size was also increased from 256
bytes (byte) to 65,534 bytes (unsigned int).
With these changes, it is now possible to use this library in conjunction with any
other platform that supports byte level reading and writing such as an SD card.

6. Visualization of the data on the Computer


We have chosen to use MATLAB because it has a Support Package for Arduino that
helps to use MATLAB or Simulink to communicate with the Arduino board
over a USB cable. This package is based on a server program running on the
board, which listens to commands arriving via serial port, executes the
commands, and, if needed, returns a result. Also, MATLAB can read/send the data
from/to the serial port of the computer and process it.

7. Transferring the data from the Arduino to


MATLAB
We can use GoBetwino to transfer the saved data from the microcontroller to an
Excel file on the computer. GoBetwino is a program running on a PC (Windows

Wireless Gateway Node

Page 14

only), that will act on behalf of Arduino and do some of the things that Arduino
cannot do on its own.
GoBetwino is free, comes with a detailed user manual, and sample Arduino
sketches to show how it can be used. One out of its many functions enables us to
log data directly to a CSV file on the PC, so the data can be used in spreadsheets
or databases.
Matlab has in-built functions such as xlsread that can be used to extract the
information from Excel files.

8. Conclusion
For the implementation of a wireless gateway node, we have decided on the
following
1. We will use the existing Zigbee protocol for achieving communication between
the Xbees
2. The programming in Arduino as well as the program for serial communication
will be done using C++.
3. The database will be set up in Arduino EEPROM using the extended database
library provided by Arduino.
4. For visualization, we will use MATLAB and feed it data by means of Excel file.

9. References
1. Arduino Cookbook
2. http://geodes.ict.tuwien.ac.at/PowerSavingHandbook/WUPS/WUPS
%202011/WUPS_7.pdf

3. https://www.youtube.com/watch?v=odekkumB3WQ
4. http://examples.digi.com/get-started/configuring-xbee-radios-with-xctu/
5. Getting Started with XBee RF Modules
(http://www.makershed.com/v/vspfiles/assets/images/122-32450xbeetutorial-v1.0.1.pdf)
6. http://arduino.cc/en/Guide/ArduinoXbeeShield
7. http://cs.smith.edu/dftwiki/index.php/Tutorial:_Arduino_and_XBee_Com
munication
8. http://playground.arduino.cc

9. http://www.mathworks.de/hardware-support/arduino-matlab.html
10.http://blog.brauingenieur.de/2014/01/20/extended-database-libraryusing-an-sd-card/

Wireless Gateway Node

Page 15

Vous aimerez peut-être aussi