Académique Documents
Professionnel Documents
Culture Documents
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
Page 2
1. Introduction
This document contains all the information we have collected that could help us in
our project.
Page 3
Page 4
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
Page 5
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
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.
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
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.
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
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).
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
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.
Page 10
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
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
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.
Serial connection: Using Xbee usb adapter board & usb cable.
Modem configuration- AT/API , Coordinator/Enddevice/Router
Set the PAN(personal area network) ID
Page 12
All the Xbees in the network must have the same PAN ID
Communication:
Addressing
Error Checking & Acknowledgments
Encapsulation
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);
}
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 :
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/
Page 15